| @@ -1,208 +1,212 @@ | | | @@ -1,208 +1,212 @@ |
1 | /* $NetBSD: cpuvar.h,v 1.20 2019/04/07 05:25:55 thorpej Exp $ */ | | 1 | /* $NetBSD: cpuvar.h,v 1.21 2020/07/06 10:54:56 rin Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. | | 3 | * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to The NetBSD Foundation | | 6 | * This code is derived from software contributed to The NetBSD Foundation |
7 | * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects | | 7 | * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects |
8 | * Agency and which was developed by Matt Thomas of 3am Software Foundry. | | 8 | * Agency and which was developed by Matt Thomas of 3am Software Foundry. |
9 | * | | 9 | * |
10 | * This material is based upon work supported by the Defense Advanced Research | | 10 | * This material is based upon work supported by the Defense Advanced Research |
11 | * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under | | 11 | * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under |
12 | * Contract No. N66001-09-C-2073. | | 12 | * Contract No. N66001-09-C-2073. |
13 | * Approved for Public Release, Distribution Unlimited | | 13 | * Approved for Public Release, Distribution Unlimited |
14 | * | | 14 | * |
15 | * Redistribution and use in source and binary forms, with or without | | 15 | * Redistribution and use in source and binary forms, with or without |
16 | * modification, are permitted provided that the following conditions | | 16 | * modification, are permitted provided that the following conditions |
17 | * are met: | | 17 | * are met: |
18 | * 1. Redistributions of source code must retain the above copyright | | 18 | * 1. Redistributions of source code must retain the above copyright |
19 | * notice, this list of conditions and the following disclaimer. | | 19 | * notice, this list of conditions and the following disclaimer. |
20 | * 2. Redistributions in binary form must reproduce the above copyright | | 20 | * 2. Redistributions in binary form must reproduce the above copyright |
21 | * notice, this list of conditions and the following disclaimer in the | | 21 | * notice, this list of conditions and the following disclaimer in the |
22 | * documentation and/or other materials provided with the distribution. | | 22 | * documentation and/or other materials provided with the distribution. |
23 | * | | 23 | * |
24 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 24 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
25 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 25 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
26 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 26 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
27 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 27 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
28 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 28 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34 | * POSSIBILITY OF SUCH DAMAGE. | | 34 | * POSSIBILITY OF SUCH DAMAGE. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #ifndef _POWERPC_BOOKE_CPUVAR_H_ | | 37 | #ifndef _POWERPC_BOOKE_CPUVAR_H_ |
38 | #define _POWERPC_BOOKE_CPUVAR_H_ | | 38 | #define _POWERPC_BOOKE_CPUVAR_H_ |
39 | | | 39 | |
| | | 40 | #ifdef _KERNEL_OPT |
| | | 41 | #include "opt_multiprocessor.h" |
| | | 42 | #endif |
| | | 43 | |
40 | #include <sys/bus.h> | | 44 | #include <sys/bus.h> |
41 | #include <prop/proplib.h> | | 45 | #include <prop/proplib.h> |
42 | #include <powerpc/psl.h> | | 46 | #include <powerpc/psl.h> |
43 | | | 47 | |
44 | struct cpunode_softc { | | 48 | struct cpunode_softc { |
45 | device_t sc_dev; | | 49 | device_t sc_dev; |
46 | u_int sc_children; | | 50 | u_int sc_children; |
47 | }; | | 51 | }; |
48 | | | 52 | |
49 | struct cpu_softc { | | 53 | struct cpu_softc { |
50 | struct cpu_info *cpu_ci; | | 54 | struct cpu_info *cpu_ci; |
51 | struct evcnt *cpu_evcnt_intrs; | | 55 | struct evcnt *cpu_evcnt_intrs; |
52 | bus_space_tag_t cpu_bst; | | 56 | bus_space_tag_t cpu_bst; |
53 | bus_space_tag_t cpu_le_bst; | | 57 | bus_space_tag_t cpu_le_bst; |
54 | bus_space_handle_t cpu_bsh; | | 58 | bus_space_handle_t cpu_bsh; |
55 | bus_addr_t cpu_clock_gtbcr; | | 59 | bus_addr_t cpu_clock_gtbcr; |
56 | | | 60 | |
57 | paddr_t cpu_highmem; | | 61 | paddr_t cpu_highmem; |
58 | | | 62 | |
59 | u_int cpu_pcpls[5]; | | 63 | u_int cpu_pcpls[5]; |
60 | struct evcnt cpu_evcnt_spurious_intr; | | 64 | struct evcnt cpu_evcnt_spurious_intr; |
61 | | | 65 | |
62 | struct evcnt cpu_ev_late_clock; | | 66 | struct evcnt cpu_ev_late_clock; |
63 | u_long cpu_ticks_per_clock_intr; | | 67 | u_long cpu_ticks_per_clock_intr; |
64 | struct evcnt cpu_ev_exec_trap_sync; | | 68 | struct evcnt cpu_ev_exec_trap_sync; |
65 | | | 69 | |
66 | uint64_t cpu_spl_tb[NIPL][NIPL]; | | 70 | uint64_t cpu_spl_tb[NIPL][NIPL]; |
67 | }; | | 71 | }; |
68 | | | 72 | |
69 | struct cpunode_locators { | | 73 | struct cpunode_locators { |
70 | const char *cnl_name; | | 74 | const char *cnl_name; |
71 | bus_addr_t cnl_addr; | | 75 | bus_addr_t cnl_addr; |
72 | bus_size_t cnl_size; | | 76 | bus_size_t cnl_size; |
73 | uint8_t cnl_instance; | | 77 | uint8_t cnl_instance; |
74 | uint8_t cnl_nintr; | | 78 | uint8_t cnl_nintr; |
75 | uint8_t cnl_intrs[4]; | | 79 | uint8_t cnl_intrs[4]; |
76 | uint32_t cnl_flags; | | 80 | uint32_t cnl_flags; |
77 | uint16_t cnl_ids[6]; | | 81 | uint16_t cnl_ids[6]; |
78 | }; | | 82 | }; |
79 | | | 83 | |
80 | struct cpunode_attach_args { | | 84 | struct cpunode_attach_args { |
81 | const char *cna_busname; | | 85 | const char *cna_busname; |
82 | bus_space_tag_t cna_memt; | | 86 | bus_space_tag_t cna_memt; |
83 | bus_space_tag_t cna_le_memt; | | 87 | bus_space_tag_t cna_le_memt; |
84 | bus_dma_tag_t cna_dmat; | | 88 | bus_dma_tag_t cna_dmat; |
85 | struct cpunode_locators cna_locs; | | 89 | struct cpunode_locators cna_locs; |
86 | u_int cna_childmask; | | 90 | u_int cna_childmask; |
87 | }; | | 91 | }; |
88 | | | 92 | |
89 | struct mainbus_attach_args { | | 93 | struct mainbus_attach_args { |
90 | const char *ma_name; | | 94 | const char *ma_name; |
91 | bus_space_tag_t ma_memt; | | 95 | bus_space_tag_t ma_memt; |
92 | bus_space_tag_t ma_le_memt; | | 96 | bus_space_tag_t ma_le_memt; |
93 | bus_dma_tag_t ma_dmat; | | 97 | bus_dma_tag_t ma_dmat; |
94 | int ma_node; | | 98 | int ma_node; |
95 | }; | | 99 | }; |
96 | | | 100 | |
97 | struct generic_attach_args { | | 101 | struct generic_attach_args { |
98 | const char *ga_name; | | 102 | const char *ga_name; |
99 | bus_space_tag_t ga_bst; | | 103 | bus_space_tag_t ga_bst; |
100 | bus_dma_tag_t ga_dmat; | | 104 | bus_dma_tag_t ga_dmat; |
101 | bus_addr_t ga_addr; | | 105 | bus_addr_t ga_addr; |
102 | bus_size_t ga_size; | | 106 | bus_size_t ga_size; |
103 | int ga_cs; | | 107 | int ga_cs; |
104 | int ga_irq; | | 108 | int ga_irq; |
105 | }; | | 109 | }; |
106 | | | 110 | |
107 | #ifndef __BSD_PT_ENTRY_T | | 111 | #ifndef __BSD_PT_ENTRY_T |
108 | #define __BSD_PT_ENTRY_T __uint32_t | | 112 | #define __BSD_PT_ENTRY_T __uint32_t |
109 | typedef __BSD_PT_ENTRY_T pt_entry_t; | | 113 | typedef __BSD_PT_ENTRY_T pt_entry_t; |
110 | #define PRIxPTE PRIx32 | | 114 | #define PRIxPTE PRIx32 |
111 | #endif | | 115 | #endif |
112 | | | 116 | |
113 | #include <uvm/pmap/tlb.h> | | 117 | #include <uvm/pmap/tlb.h> |
114 | | | 118 | |
115 | struct tlb_md_io_ops { | | 119 | struct tlb_md_io_ops { |
116 | /* | | 120 | /* |
117 | * We need mapiodev to be first so we can easily override it in | | 121 | * We need mapiodev to be first so we can easily override it in |
118 | * early boot by doing cpu_md_ops.tlb_md_ops = (const struct | | 122 | * early boot by doing cpu_md_ops.tlb_md_ops = (const struct |
119 | * tlb_md_ops *) &<variable containing mapiodev pointer>. | | 123 | * tlb_md_ops *) &<variable containing mapiodev pointer>. |
120 | */ | | 124 | */ |
121 | void *(*md_tlb_mapiodev)(paddr_t, psize_t, bool); | | 125 | void *(*md_tlb_mapiodev)(paddr_t, psize_t, bool); |
122 | void (*md_tlb_unmapiodev)(vaddr_t, vsize_t); | | 126 | void (*md_tlb_unmapiodev)(vaddr_t, vsize_t); |
123 | int (*md_tlb_ioreserve)(vaddr_t, vsize_t, uint32_t); | | 127 | int (*md_tlb_ioreserve)(vaddr_t, vsize_t, uint32_t); |
124 | int (*md_tlb_iorelease)(vaddr_t); | | 128 | int (*md_tlb_iorelease)(vaddr_t); |
125 | }; | | 129 | }; |
126 | | | 130 | |
127 | struct cpu_md_ops { | | 131 | struct cpu_md_ops { |
128 | const struct cpunode_locators *md_cpunode_locs; | | 132 | const struct cpunode_locators *md_cpunode_locs; |
129 | void (*md_cpu_attach)(device_t, u_int); | | 133 | void (*md_cpu_attach)(device_t, u_int); |
130 | | | 134 | |
131 | void (*md_device_register)(device_t, void *); | | 135 | void (*md_device_register)(device_t, void *); |
132 | void (*md_cpu_startup)(void); | | 136 | void (*md_cpu_startup)(void); |
133 | void (*md_cpu_reset)(void); | | 137 | void (*md_cpu_reset)(void); |
134 | void (*md_cpunode_attach)(device_t, device_t, void *); | | 138 | void (*md_cpunode_attach)(device_t, device_t, void *); |
135 | | | 139 | |
136 | const struct tlb_md_ops *md_tlb_ops; | | 140 | const struct tlb_md_ops *md_tlb_ops; |
137 | const struct tlb_md_io_ops *md_tlb_io_ops; | | 141 | const struct tlb_md_io_ops *md_tlb_io_ops; |
138 | }; | | 142 | }; |
139 | | | 143 | |
140 | | | 144 | |
141 | #ifdef _KERNEL | | 145 | #ifdef _KERNEL |
142 | | | 146 | |
143 | static __inline register_t | | 147 | static __inline register_t |
144 | wrtee(register_t msr) | | 148 | wrtee(register_t msr) |
145 | { | | 149 | { |
146 | register_t old_msr; | | 150 | register_t old_msr; |
147 | __asm("mfmsr\t%0" : "=r"(old_msr)); | | 151 | __asm("mfmsr\t%0" : "=r"(old_msr)); |
148 | | | 152 | |
149 | if (__builtin_constant_p(msr)) { | | 153 | if (__builtin_constant_p(msr)) { |
150 | __asm __volatile("wrteei\t%0" :: "n"((msr & PSL_EE) ? 1 : 0)); | | 154 | __asm __volatile("wrteei\t%0" :: "n"((msr & PSL_EE) ? 1 : 0)); |
151 | } else { | | 155 | } else { |
152 | __asm __volatile("wrtee\t%0" :: "r"(msr)); | | 156 | __asm __volatile("wrtee\t%0" :: "r"(msr)); |
153 | } | | 157 | } |
154 | return old_msr; | | 158 | return old_msr; |
155 | } | | 159 | } |
156 | | | 160 | |
157 | struct trapframe; | | 161 | struct trapframe; |
158 | void booke_sstep(struct trapframe *); | | 162 | void booke_sstep(struct trapframe *); |
159 | | | 163 | |
160 | void booke_cpu_startup(const char *); /* model name */ | | 164 | void booke_cpu_startup(const char *); /* model name */ |
161 | extern struct powerpc_bus_dma_tag booke_bus_dma_tag; | | 165 | extern struct powerpc_bus_dma_tag booke_bus_dma_tag; |
162 | | | 166 | |
163 | extern struct cpu_info cpu_info[]; | | 167 | extern struct cpu_info cpu_info[]; |
164 | #ifdef MULTIPROCESSOR | | 168 | #ifdef MULTIPROCESSOR |
165 | extern volatile struct cpu_hatch_data cpu_hatch_data; | | 169 | extern volatile struct cpu_hatch_data cpu_hatch_data; |
166 | #endif | | 170 | #endif |
167 | | | 171 | |
168 | void cpu_evcnt_attach(struct cpu_info *); | | 172 | void cpu_evcnt_attach(struct cpu_info *); |
169 | uint32_t cpu_read_4(bus_size_t); | | 173 | uint32_t cpu_read_4(bus_size_t); |
170 | uint8_t cpu_read_1(bus_size_t); | | 174 | uint8_t cpu_read_1(bus_size_t); |
171 | void cpu_write_4(bus_size_t, uint32_t); | | 175 | void cpu_write_4(bus_size_t, uint32_t); |
172 | void cpu_write_1(bus_size_t, uint8_t); | | 176 | void cpu_write_1(bus_size_t, uint8_t); |
173 | | | 177 | |
174 | void dump_splhist(struct cpu_info *, void (*)(const char *, ...)); | | 178 | void dump_splhist(struct cpu_info *, void (*)(const char *, ...)); |
175 | void calc_delayconst(void); | | 179 | void calc_delayconst(void); |
176 | | | 180 | |
177 | struct intrsw; | | 181 | struct intrsw; |
178 | void exception_init(const struct intrsw *); | | 182 | void exception_init(const struct intrsw *); |
179 | | | 183 | |
180 | void *tlb_mapiodev(paddr_t, psize_t, bool); | | 184 | void *tlb_mapiodev(paddr_t, psize_t, bool); |
181 | void tlb_unmapiodev(vaddr_t, vsize_t); | | 185 | void tlb_unmapiodev(vaddr_t, vsize_t); |
182 | int tlb_ioreserve(vaddr_t, vsize_t, pt_entry_t); | | 186 | int tlb_ioreserve(vaddr_t, vsize_t, pt_entry_t); |
183 | int tlb_iorelease(vaddr_t); | | 187 | int tlb_iorelease(vaddr_t); |
184 | | | 188 | |
185 | extern struct cpu_md_ops cpu_md_ops; | | 189 | extern struct cpu_md_ops cpu_md_ops; |
186 | | | 190 | |
187 | void board_info_init(void); | | 191 | void board_info_init(void); |
188 | void board_info_add_number(const char *, uint64_t); | | 192 | void board_info_add_number(const char *, uint64_t); |
189 | void board_info_add_data(const char *, const void *, size_t); | | 193 | void board_info_add_data(const char *, const void *, size_t); |
190 | void board_info_add_string(const char *, const char *); | | 194 | void board_info_add_string(const char *, const char *); |
191 | void board_info_add_bool(const char *); | | 195 | void board_info_add_bool(const char *); |
192 | void board_info_add_object(const char *, void *); | | 196 | void board_info_add_object(const char *, void *); |
193 | uint64_t board_info_get_number(const char *); | | 197 | uint64_t board_info_get_number(const char *); |
194 | bool board_info_get_bool(const char *); | | 198 | bool board_info_get_bool(const char *); |
195 | void *board_info_get_object(const char *); | | 199 | void *board_info_get_object(const char *); |
196 | const void * | | 200 | const void * |
197 | board_info_get_data(const char *, size_t *); | | 201 | board_info_get_data(const char *, size_t *); |
198 | | | 202 | |
199 | /* trap.c */ | | 203 | /* trap.c */ |
200 | void dump_trapframe(const struct trapframe *, void (*)(const char *, ...)); | | 204 | void dump_trapframe(const struct trapframe *, void (*)(const char *, ...)); |
201 | | | 205 | |
202 | extern char root_string[]; | | 206 | extern char root_string[]; |
203 | extern paddr_t msgbuf_paddr; | | 207 | extern paddr_t msgbuf_paddr; |
204 | extern prop_dictionary_t board_properties; | | 208 | extern prop_dictionary_t board_properties; |
205 | extern psize_t pmemsize; | | 209 | extern psize_t pmemsize; |
206 | #endif | | 210 | #endif |
207 | | | 211 | |
208 | #endif /* !_POWERPC_BOOKE_CPUVAR_H_ */ | | 212 | #endif /* !_POWERPC_BOOKE_CPUVAR_H_ */ |