| @@ -1,337 +1,337 @@ | | | @@ -1,337 +1,337 @@ |
1 | /* $NetBSD: machdep.c,v 1.19 2009/11/27 03:23:09 rmind Exp $ */ | | 1 | /* $NetBSD: machdep.c,v 1.20 2009/12/01 23:14:02 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2009/11/27 03:23:09 rmind Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.20 2009/12/01 23:14:02 skrll Exp $"); |
31 | | | 31 | |
32 | #include "opt_ddb.h" | | 32 | #include "opt_ddb.h" |
33 | | | 33 | |
34 | #include <sys/param.h> | | 34 | #include <sys/param.h> |
35 | #include <sys/systm.h> | | 35 | #include <sys/systm.h> |
36 | #include <sys/kernel.h> | | 36 | #include <sys/kernel.h> |
37 | #include <sys/proc.h> | | 37 | #include <sys/proc.h> |
38 | #include <sys/buf.h> | | 38 | #include <sys/buf.h> |
39 | #include <sys/reboot.h> | | 39 | #include <sys/reboot.h> |
40 | #include <sys/mount.h> | | 40 | #include <sys/mount.h> |
41 | #include <sys/kcore.h> | | 41 | #include <sys/kcore.h> |
42 | #include <sys/boot_flag.h> | | 42 | #include <sys/boot_flag.h> |
43 | #include <sys/device.h> | | 43 | #include <sys/device.h> |
44 | | | 44 | |
45 | #include <uvm/uvm_extern.h> | | 45 | #include <uvm/uvm_extern.h> |
46 | | | 46 | |
47 | #include <machine/bootinfo.h> | | 47 | #include <machine/bootinfo.h> |
48 | #include <machine/locore.h> | | 48 | #include <machine/locore.h> |
49 | #include <machine/sbdvar.h> /* System board */ | | 49 | #include <machine/sbdvar.h> /* System board */ |
50 | #include <machine/wired_map.h> | | 50 | #include <machine/wired_map.h> |
51 | | | 51 | |
52 | #include <mips/cache.h> | | 52 | #include <mips/cache.h> |
53 | | | 53 | |
54 | #ifdef DDB | | 54 | #ifdef DDB |
55 | #include <machine/db_machdep.h> | | 55 | #include <machine/db_machdep.h> |
56 | #include <ddb/db_sym.h> | | 56 | #include <ddb/db_sym.h> |
57 | #include <ddb/db_extern.h> | | 57 | #include <ddb/db_extern.h> |
58 | #include <ddb/db_output.h> | | 58 | #include <ddb/db_output.h> |
59 | #ifndef DB_ELFSIZE | | 59 | #ifndef DB_ELFSIZE |
60 | #error Must define DB_ELFSIZE! | | 60 | #error Must define DB_ELFSIZE! |
61 | #endif | | 61 | #endif |
62 | #define ELFSIZE DB_ELFSIZE | | 62 | #define ELFSIZE DB_ELFSIZE |
63 | #include <sys/exec_elf.h> | | 63 | #include <sys/exec_elf.h> |
64 | #endif | | 64 | #endif |
65 | | | 65 | |
66 | #include <dev/cons.h> | | 66 | #include <dev/cons.h> |
67 | | | 67 | |
68 | #include <ews4800mips/ews4800mips/cons_machdep.h> | | 68 | #include <ews4800mips/ews4800mips/cons_machdep.h> |
69 | | | 69 | |
70 | vsize_t kseg2iobufsize; /* to reserve PTEs for KSEG2 I/O space */ | | 70 | vsize_t kseg2iobufsize; /* to reserve PTEs for KSEG2 I/O space */ |
71 | | | 71 | |
72 | /* our exported CPU info */ | | 72 | /* our exported CPU info */ |
73 | struct cpu_info cpu_info_store; | | 73 | struct cpu_info cpu_info_store; |
74 | | | 74 | |
75 | /* maps for VM objects */ | | 75 | /* maps for VM objects */ |
76 | struct vm_map *mb_map; | | 76 | struct vm_map *mb_map; |
77 | struct vm_map *phys_map; | | 77 | struct vm_map *phys_map; |
78 | | | 78 | |
79 | /* referenced by mips_machdep.c:cpu_dump() */ | | 79 | /* referenced by mips_machdep.c:cpu_dump() */ |
80 | int mem_cluster_cnt; | | 80 | int mem_cluster_cnt; |
81 | phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX]; | | 81 | phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX]; |
82 | | | 82 | |
83 | void mach_init(int, char *[], struct bootinfo *); | | 83 | void mach_init(int, char *[], struct bootinfo *); |
84 | void option(int, char *[], struct bootinfo *); | | 84 | void option(int, char *[], struct bootinfo *); |
85 | /* NMI */ | | 85 | /* NMI */ |
86 | void nmi_exception(void); | | 86 | void nmi_exception(void); |
87 | | | 87 | |
88 | void | | 88 | void |
89 | mach_init(int argc, char *argv[], struct bootinfo *bi) | | 89 | mach_init(int argc, char *argv[], struct bootinfo *bi) |
90 | { | | 90 | { |
91 | extern char kernel_text[], edata[], end[]; | | 91 | extern char kernel_text[], edata[], end[]; |
92 | struct pcb *pcb0; | | 92 | struct pcb *pcb0; |
93 | vaddr_t v; | | 93 | vaddr_t v; |
94 | int i; | | 94 | int i; |
95 | | | 95 | |
96 | /* Clear BSS */ | | 96 | /* Clear BSS */ |
97 | if (bi == NULL || bi->bi_size != sizeof(struct bootinfo)) { | | 97 | if (bi == NULL || bi->bi_size != sizeof(struct bootinfo)) { |
98 | /* | | 98 | /* |
99 | * No bootinfo, so assume we are loaded by | | 99 | * No bootinfo, so assume we are loaded by |
100 | * the firmware directly and have to clear BSS here. | | 100 | * the firmware directly and have to clear BSS here. |
101 | */ | | 101 | */ |
102 | memset(edata, 0, end - edata); | | 102 | memset(edata, 0, end - edata); |
103 | /* | | 103 | /* |
104 | * XXX | | 104 | * XXX |
105 | * lwp0 and cpu_info_store are allocated in BSS | | 105 | * lwp0 and cpu_info_store are allocated in BSS |
106 | * and initialized before mach_init() is called, | | 106 | * and initialized before mach_init() is called, |
107 | * so restore them again. | | 107 | * so restore them again. |
108 | */ | | 108 | */ |
109 | lwp0.l_cpu = &cpu_info_store; | | 109 | lwp0.l_cpu = &cpu_info_store; |
110 | cpu_info_store.ci_curlwp = &lwp0; | | 110 | cpu_info_store.ci_curlwp = &lwp0; |
111 | } | | 111 | } |
112 | | | 112 | |
113 | /* Setup early-console with BIOS ROM routines */ | | 113 | /* Setup early-console with BIOS ROM routines */ |
114 | rom_cons_init(); | | 114 | rom_cons_init(); |
115 | | | 115 | |
116 | /* Initialize machine dependent System-Board ops. */ | | 116 | /* Initialize machine dependent System-Board ops. */ |
117 | sbd_init(); | | 117 | sbd_init(); |
118 | | | 118 | |
119 | __asm volatile("move %0, $29" : "=r"(v)); | | 119 | __asm volatile("move %0, $29" : "=r"(v)); |
120 | printf("kernel_text=%p edata=%p end=%p sp=%p\n", kernel_text, edata, | | 120 | printf("kernel_text=%p edata=%p end=%p sp=%lx\n", kernel_text, edata, |
121 | end, v); | | 121 | end, v); |
122 | | | 122 | |
123 | option(argc, argv, bi); | | 123 | option(argc, argv, bi); |
124 | | | 124 | |
125 | uvm_setpagesize(); | | 125 | uvm_setpagesize(); |
126 | | | 126 | |
127 | /* Fill mem_clusters and mem_cluster_cnt */ | | 127 | /* Fill mem_clusters and mem_cluster_cnt */ |
128 | (*platform.mem_init)(kernel_text, | | 128 | (*platform.mem_init)(kernel_text, |
129 | (bi && bi->bi_nsym) ? (void *)bi->bi_esym : end); | | 129 | (bi && bi->bi_nsym) ? (void *)bi->bi_esym : end); |
130 | | | 130 | |
131 | /* | | 131 | /* |
132 | * make sure that we don't call BIOS console from now | | 132 | * make sure that we don't call BIOS console from now |
133 | * because wired mappings set up by BIOS will be discarded | | 133 | * because wired mappings set up by BIOS will be discarded |
134 | * in mips_vector_init(). | | 134 | * in mips_vector_init(). |
135 | */ | | 135 | */ |
136 | cn_tab = NULL; | | 136 | cn_tab = NULL; |
137 | | | 137 | |
138 | mips_vector_init(); | | 138 | mips_vector_init(); |
139 | | | 139 | |
140 | memcpy((void *)0x80000200, ews4800mips_nmi_vec, 32); /* NMI */ | | 140 | memcpy((void *)0x80000200, ews4800mips_nmi_vec, 32); /* NMI */ |
141 | mips_dcache_wbinv_all(); | | 141 | mips_dcache_wbinv_all(); |
142 | mips_icache_sync_all(); | | 142 | mips_icache_sync_all(); |
143 | | | 143 | |
144 | /* setup cpu_info */ | | 144 | /* setup cpu_info */ |
145 | curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz; | | 145 | curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz; |
146 | curcpu()->ci_divisor_delay = | | 146 | curcpu()->ci_divisor_delay = |
147 | ((curcpu()->ci_cpu_freq + 500000) / 1000000); | | 147 | ((curcpu()->ci_cpu_freq + 500000) / 1000000); |
148 | if (mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT) { | | 148 | if (mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT) { |
149 | curcpu()->ci_cycles_per_hz /= 2; | | 149 | curcpu()->ci_cycles_per_hz /= 2; |
150 | curcpu()->ci_divisor_delay /= 2; | | 150 | curcpu()->ci_divisor_delay /= 2; |
151 | } | | 151 | } |
152 | | | 152 | |
153 | /* Load memory to UVM */ | | 153 | /* Load memory to UVM */ |
154 | for (i = 1; i < mem_cluster_cnt; i++) { | | 154 | for (i = 1; i < mem_cluster_cnt; i++) { |
155 | phys_ram_seg_t *p; | | 155 | phys_ram_seg_t *p; |
156 | paddr_t start; | | 156 | paddr_t start; |
157 | size_t size; | | 157 | size_t size; |
158 | p = &mem_clusters[i]; | | 158 | p = &mem_clusters[i]; |
159 | start = p->start; | | 159 | start = p->start; |
160 | size = p->size; | | 160 | size = p->size; |
161 | uvm_page_physload(atop(start), atop(start + size), | | 161 | uvm_page_physload(atop(start), atop(start + size), |
162 | atop(start), atop(start + size), VM_FREELIST_DEFAULT); | | 162 | atop(start), atop(start + size), VM_FREELIST_DEFAULT); |
163 | } | | 163 | } |
164 | | | 164 | |
165 | sprintf(cpu_model, "NEC %s", platform.name); | | 165 | sprintf(cpu_model, "NEC %s", platform.name); |
166 | | | 166 | |
167 | mips_init_msgbuf(); | | 167 | mips_init_msgbuf(); |
168 | | | 168 | |
169 | pmap_bootstrap(); | | 169 | pmap_bootstrap(); |
170 | | | 170 | |
171 | v = uvm_pageboot_alloc(USPACE); | | 171 | v = uvm_pageboot_alloc(USPACE); |
172 | uvm_lwp_setuarea(&lwp0, v); | | 172 | uvm_lwp_setuarea(&lwp0, v); |
173 | | | 173 | |
174 | pcb0 = lwp_getpcb(&lwp0); | | 174 | pcb0 = lwp_getpcb(&lwp0); |
175 | pcb0->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */ | | 175 | pcb0->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */ |
176 | | | 176 | |
177 | lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1; | | 177 | lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1; |
178 | } | | 178 | } |
179 | | | 179 | |
180 | void | | 180 | void |
181 | option(int argc, char *argv[], struct bootinfo *bi) | | 181 | option(int argc, char *argv[], struct bootinfo *bi) |
182 | { | | 182 | { |
183 | extern char __boot_kernel_name[]; | | 183 | extern char __boot_kernel_name[]; |
184 | bool boot_device_set; | | 184 | bool boot_device_set; |
185 | char *p; | | 185 | char *p; |
186 | int i; | | 186 | int i; |
187 | | | 187 | |
188 | printf("argc=%d argv=%p syminfo=%p\n", argc, argv, bi); | | 188 | printf("argc=%d argv=%p syminfo=%p\n", argc, argv, bi); |
189 | printf("version=%d size=%d nsym=%d ssym=%p esym=%p\n", | | 189 | printf("version=%d size=%d nsym=%d ssym=%p esym=%p\n", |
190 | bi->bi_version, bi->bi_size, bi->bi_nsym, bi->bi_ssym, bi->bi_esym); | | 190 | bi->bi_version, bi->bi_size, bi->bi_nsym, bi->bi_ssym, bi->bi_esym); |
191 | | | 191 | |
192 | for (i = 0; i < argc; i++) | | 192 | for (i = 0; i < argc; i++) |
193 | printf("[%d] %s\n", i, argv[i]); | | 193 | printf("[%d] %s\n", i, argv[i]); |
194 | | | 194 | |
195 | #ifdef DDB | | 195 | #ifdef DDB |
196 | /* Load symbol table */ | | 196 | /* Load symbol table */ |
197 | if (bi->bi_nsym) | | 197 | if (bi->bi_nsym) |
198 | ksyms_addsyms_elf(bi->bi_esym - bi->bi_ssym, | | 198 | ksyms_addsyms_elf(bi->bi_esym - bi->bi_ssym, |
199 | (void *)bi->bi_ssym, (void *)bi->bi_esym); | | 199 | (void *)bi->bi_ssym, (void *)bi->bi_esym); |
200 | #endif | | 200 | #endif |
201 | /* Parse option */ | | 201 | /* Parse option */ |
202 | boot_device_set = false; | | 202 | boot_device_set = false; |
203 | for (i = 2; i < argc; i++) { | | 203 | for (i = 2; i < argc; i++) { |
204 | p = argv[i]; | | 204 | p = argv[i]; |
205 | /* prompt for root device */ | | 205 | /* prompt for root device */ |
206 | if (p[0] == '-' && p[1] == 'a') | | 206 | if (p[0] == '-' && p[1] == 'a') |
207 | boot_device_set = true; | | 207 | boot_device_set = true; |
208 | | | 208 | |
209 | /* root device option. ex) -b=net:netbsd, -b=sd0k:netbsd */ | | 209 | /* root device option. ex) -b=net:netbsd, -b=sd0k:netbsd */ |
210 | if (p[0] == '-' && p[1] == 'b') { | | 210 | if (p[0] == '-' && p[1] == 'b') { |
211 | boot_device_set = true; | | 211 | boot_device_set = true; |
212 | strcpy(__boot_kernel_name, p + 3); | | 212 | strcpy(__boot_kernel_name, p + 3); |
213 | } | | 213 | } |
214 | } | | 214 | } |
215 | | | 215 | |
216 | if (!boot_device_set) | | 216 | if (!boot_device_set) |
217 | strcpy(__boot_kernel_name, argv[1]); | | 217 | strcpy(__boot_kernel_name, argv[1]); |
218 | | | 218 | |
219 | /* Memory address information from IPL */ | | 219 | /* Memory address information from IPL */ |
220 | sbd_memcluster_init(bi->bi_mainfo); | | 220 | sbd_memcluster_init(bi->bi_mainfo); |
221 | } | | 221 | } |
222 | | | 222 | |
223 | void | | 223 | void |
224 | mips_machdep_cache_config(void) | | 224 | mips_machdep_cache_config(void) |
225 | { | | 225 | { |
226 | | | 226 | |
227 | /* Set L2-cache size */ | | 227 | /* Set L2-cache size */ |
228 | if (platform.cache_config) | | 228 | if (platform.cache_config) |
229 | (*platform.cache_config)(); | | 229 | (*platform.cache_config)(); |
230 | } | | 230 | } |
231 | | | 231 | |
232 | void | | 232 | void |
233 | cpu_startup(void) | | 233 | cpu_startup(void) |
234 | { | | 234 | { |
235 | vaddr_t minaddr, maxaddr; | | 235 | vaddr_t minaddr, maxaddr; |
236 | char pbuf[9]; | | 236 | char pbuf[9]; |
237 | | | 237 | |
238 | printf("%s%s", copyright, version); | | 238 | printf("%s%s", copyright, version); |
239 | printf("%s %dMHz\n", cpu_model, platform.cpu_clock / 1000000); | | 239 | printf("%s %dMHz\n", cpu_model, platform.cpu_clock / 1000000); |
240 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); | | 240 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); |
241 | printf("total memory = %s\n", pbuf); | | 241 | printf("total memory = %s\n", pbuf); |
242 | | | 242 | |
243 | minaddr = 0; | | 243 | minaddr = 0; |
244 | /* | | 244 | /* |
245 | * Allocate a submap for physio. | | 245 | * Allocate a submap for physio. |
246 | */ | | 246 | */ |
247 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, | | 247 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, |
248 | VM_PHYS_SIZE, 0, false, NULL); | | 248 | VM_PHYS_SIZE, 0, false, NULL); |
249 | | | 249 | |
250 | /* | | 250 | /* |
251 | * (No need to allocate an mbuf cluster submap. Mbuf clusters | | 251 | * (No need to allocate an mbuf cluster submap. Mbuf clusters |
252 | * are allocated via the pool allocator, and we use KSEG to | | 252 | * are allocated via the pool allocator, and we use KSEG to |
253 | * map those pages.) | | 253 | * map those pages.) |
254 | */ | | 254 | */ |
255 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); | | 255 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); |
256 | printf("avail memory = %s\n", pbuf); | | 256 | printf("avail memory = %s\n", pbuf); |
257 | } | | 257 | } |
258 | | | 258 | |
259 | void | | 259 | void |
260 | cpu_reboot(int howto, char *bootstr) | | 260 | cpu_reboot(int howto, char *bootstr) |
261 | { | | 261 | { |
262 | static int waittime = -1; | | 262 | static int waittime = -1; |
263 | | | 263 | |
264 | /* Take a snapshot before clobbering any registers. */ | | 264 | /* Take a snapshot before clobbering any registers. */ |
265 | if (curlwp) | | 265 | if (curlwp) |
266 | savectx(curpcb); | | 266 | savectx(curpcb); |
267 | | | 267 | |
268 | if (cold) { | | 268 | if (cold) { |
269 | howto |= RB_HALT; | | 269 | howto |= RB_HALT; |
270 | goto haltsys; | | 270 | goto haltsys; |
271 | } | | 271 | } |
272 | | | 272 | |
273 | /* If "always halt" was specified as a boot flag, obey. */ | | 273 | /* If "always halt" was specified as a boot flag, obey. */ |
274 | if (boothowto & RB_HALT) | | 274 | if (boothowto & RB_HALT) |
275 | howto |= RB_HALT; | | 275 | howto |= RB_HALT; |
276 | | | 276 | |
277 | boothowto = howto; | | 277 | boothowto = howto; |
278 | if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) { | | 278 | if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) { |
279 | waittime = 0; | | 279 | waittime = 0; |
280 | vfs_shutdown(); | | 280 | vfs_shutdown(); |
281 | | | 281 | |
282 | /* | | 282 | /* |
283 | * If we've been adjusting the clock, the todr | | 283 | * If we've been adjusting the clock, the todr |
284 | * will be out of synch; adjust it now. | | 284 | * will be out of synch; adjust it now. |
285 | */ | | 285 | */ |
286 | resettodr(); | | 286 | resettodr(); |
287 | } | | 287 | } |
288 | | | 288 | |
289 | splhigh(); | | 289 | splhigh(); |
290 | | | 290 | |
291 | if (howto & RB_DUMP) | | 291 | if (howto & RB_DUMP) |
292 | dumpsys(); | | 292 | dumpsys(); |
293 | | | 293 | |
294 | haltsys: | | 294 | haltsys: |
295 | doshutdownhooks(); | | 295 | doshutdownhooks(); |
296 | | | 296 | |
297 | pmf_system_shutdown(boothowto); | | 297 | pmf_system_shutdown(boothowto); |
298 | | | 298 | |
299 | if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { | | 299 | if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { |
300 | if (platform.poweroff) { | | 300 | if (platform.poweroff) { |
301 | DELAY(1000000); | | 301 | DELAY(1000000); |
302 | (*platform.poweroff)(); | | 302 | (*platform.poweroff)(); |
303 | } | | 303 | } |
304 | } | | 304 | } |
305 | | | 305 | |
306 | if (howto & RB_HALT) { | | 306 | if (howto & RB_HALT) { |
307 | printf("System halted. Hit any key to reboot.\n\n"); | | 307 | printf("System halted. Hit any key to reboot.\n\n"); |
308 | (void)cngetc(); | | 308 | (void)cngetc(); |
309 | } | | 309 | } |
310 | | | 310 | |
311 | printf("rebooting...\n"); | | 311 | printf("rebooting...\n"); |
312 | DELAY(1000000); | | 312 | DELAY(1000000); |
313 | if (platform.reboot) | | 313 | if (platform.reboot) |
314 | (*platform.reboot)(); | | 314 | (*platform.reboot)(); |
315 | | | 315 | |
316 | printf("reboot faild.\n"); | | 316 | printf("reboot faild.\n"); |
317 | for (;;) | | 317 | for (;;) |
318 | ; | | 318 | ; |
319 | /* NOTREACHED */ | | 319 | /* NOTREACHED */ |
320 | } | | 320 | } |
321 | | | 321 | |
322 | #ifdef DDB | | 322 | #ifdef DDB |
323 | void | | 323 | void |
324 | __db_print_symbol(db_expr_t value) | | 324 | __db_print_symbol(db_expr_t value) |
325 | { | | 325 | { |
326 | const char *name; | | 326 | const char *name; |
327 | db_expr_t offset; | | 327 | db_expr_t offset; |
328 | | | 328 | |
329 | db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset); | | 329 | db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset); |
330 | | | 330 | |
331 | if (name != NULL && offset <= db_maxoff && offset != value) | | 331 | if (name != NULL && offset <= db_maxoff && offset != value) |
332 | db_print_loc_and_inst(value); | | 332 | db_print_loc_and_inst(value); |
333 | else | | 333 | else |
334 | db_printf("\n"); | | 334 | db_printf("\n"); |
335 | | | 335 | |
336 | } | | 336 | } |
337 | #endif | | 337 | #endif |