mini2440_machdep.c revision 1.2.4.4 1 1.2.4.2 yamt /*-
2 1.2.4.2 yamt * Copyright (c) 2012 The NetBSD Foundation, Inc.
3 1.2.4.2 yamt * All rights reserved.
4 1.2.4.2 yamt *
5 1.2.4.2 yamt * This code is derived from software contributed to The NetBSD Foundation
6 1.2.4.2 yamt * by Paul Fleischer <paul (at) xpg.dk>
7 1.2.4.2 yamt *
8 1.2.4.2 yamt * Redistribution and use in source and binary forms, with or without
9 1.2.4.2 yamt * modification, are permitted provided that the following conditions
10 1.2.4.2 yamt * are met:
11 1.2.4.2 yamt * 1. Redistributions of source code must retain the above copyright
12 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer.
13 1.2.4.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
14 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer in the
15 1.2.4.2 yamt * documentation and/or other materials provided with the distribution.
16 1.2.4.2 yamt *
17 1.2.4.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.2.4.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.2.4.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.2.4.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.2.4.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.2.4.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.2.4.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.2.4.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.2.4.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.2.4.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.2.4.2 yamt * POSSIBILITY OF SUCH DAMAGE.
28 1.2.4.2 yamt */
29 1.2.4.2 yamt /* This file is based on arch/evbarm/smdk2xx0/smdk2410_machdep.c */
30 1.2.4.2 yamt /*
31 1.2.4.2 yamt * Copyright (c) 2002, 2003 Fujitsu Component Limited
32 1.2.4.2 yamt * Copyright (c) 2002, 2003, 2005 Genetec Corporation
33 1.2.4.2 yamt * All rights reserved.
34 1.2.4.2 yamt *
35 1.2.4.2 yamt * Redistribution and use in source and binary forms, with or without
36 1.2.4.2 yamt * modification, are permitted provided that the following conditions
37 1.2.4.2 yamt * are met:
38 1.2.4.2 yamt * 1. Redistributions of source code must retain the above copyright
39 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer.
40 1.2.4.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
41 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer in the
42 1.2.4.2 yamt * documentation and/or other materials provided with the distribution.
43 1.2.4.2 yamt * 3. Neither the name of The Fujitsu Component Limited nor the name of
44 1.2.4.2 yamt * Genetec corporation may not be used to endorse or promote products
45 1.2.4.2 yamt * derived from this software without specific prior written permission.
46 1.2.4.2 yamt *
47 1.2.4.2 yamt * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
48 1.2.4.2 yamt * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
49 1.2.4.2 yamt * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
50 1.2.4.2 yamt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51 1.2.4.2 yamt * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
52 1.2.4.2 yamt * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53 1.2.4.2 yamt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
54 1.2.4.2 yamt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
55 1.2.4.2 yamt * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
56 1.2.4.2 yamt * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
57 1.2.4.2 yamt * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
58 1.2.4.2 yamt * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 1.2.4.2 yamt * SUCH DAMAGE.
60 1.2.4.2 yamt */
61 1.2.4.2 yamt /*
62 1.2.4.2 yamt * Copyright (c) 2001,2002 ARM Ltd
63 1.2.4.2 yamt * All rights reserved.
64 1.2.4.2 yamt *
65 1.2.4.2 yamt * Redistribution and use in source and binary forms, with or without
66 1.2.4.2 yamt * modification, are permitted provided that the following conditions
67 1.2.4.2 yamt * are met:
68 1.2.4.2 yamt * 1. Redistributions of source code must retain the above copyright
69 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer.
70 1.2.4.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
71 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer in the
72 1.2.4.2 yamt * documentation and/or other materials provided with the distribution.
73 1.2.4.2 yamt * 3. The name of the company may not be used to endorse or promote
74 1.2.4.2 yamt * products derived from this software without specific prior written
75 1.2.4.2 yamt * permission.
76 1.2.4.2 yamt *
77 1.2.4.2 yamt * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
78 1.2.4.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
79 1.2.4.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
80 1.2.4.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD
81 1.2.4.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
82 1.2.4.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
83 1.2.4.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
84 1.2.4.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
85 1.2.4.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
86 1.2.4.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
87 1.2.4.2 yamt * POSSIBILITY OF SUCH DAMAGE.
88 1.2.4.2 yamt *
89 1.2.4.2 yamt */
90 1.2.4.2 yamt
91 1.2.4.2 yamt /*
92 1.2.4.2 yamt * Copyright (c) 1997,1998 Mark Brinicombe.
93 1.2.4.2 yamt * Copyright (c) 1997,1998 Causality Limited.
94 1.2.4.2 yamt * All rights reserved.
95 1.2.4.2 yamt *
96 1.2.4.2 yamt * Redistribution and use in source and binary forms, with or without
97 1.2.4.2 yamt * modification, are permitted provided that the following conditions
98 1.2.4.2 yamt * are met:
99 1.2.4.2 yamt * 1. Redistributions of source code must retain the above copyright
100 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer.
101 1.2.4.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
102 1.2.4.2 yamt * notice, this list of conditions and the following disclaimer in the
103 1.2.4.2 yamt * documentation and/or other materials provided with the distribution.
104 1.2.4.2 yamt * 3. All advertising materials mentioning features or use of this software
105 1.2.4.2 yamt * must display the following acknowledgement:
106 1.2.4.2 yamt * This product includes software developed by Mark Brinicombe
107 1.2.4.2 yamt * for the NetBSD Project.
108 1.2.4.2 yamt * 4. The name of the company nor the name of the author may be used to
109 1.2.4.2 yamt * endorse or promote products derived from this software without specific
110 1.2.4.2 yamt * prior written permission.
111 1.2.4.2 yamt *
112 1.2.4.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
113 1.2.4.2 yamt * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
114 1.2.4.2 yamt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
115 1.2.4.2 yamt * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
116 1.2.4.2 yamt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
117 1.2.4.2 yamt * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
118 1.2.4.2 yamt * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
119 1.2.4.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
120 1.2.4.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
121 1.2.4.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
122 1.2.4.2 yamt * SUCH DAMAGE.
123 1.2.4.2 yamt *
124 1.2.4.2 yamt * Machine dependant functions for kernel setup for integrator board
125 1.2.4.2 yamt *
126 1.2.4.2 yamt * Created : 24/11/97
127 1.2.4.2 yamt */
128 1.2.4.2 yamt
129 1.2.4.2 yamt /*
130 1.2.4.2 yamt * Machine dependant functions for kernel setup for FriendlyARM MINI2440
131 1.2.4.2 yamt */
132 1.2.4.2 yamt
133 1.2.4.2 yamt #include <sys/cdefs.h>
134 1.2.4.4 yamt __KERNEL_RCSID(0, "$NetBSD: mini2440_machdep.c,v 1.2.4.4 2014/05/22 11:39:42 yamt Exp $");
135 1.2.4.2 yamt
136 1.2.4.2 yamt #include "opt_ddb.h"
137 1.2.4.2 yamt #include "opt_kgdb.h"
138 1.2.4.2 yamt #include "opt_pmap_debug.h"
139 1.2.4.2 yamt #include "opt_md.h"
140 1.2.4.2 yamt
141 1.2.4.2 yamt #include <sys/param.h>
142 1.2.4.2 yamt #include <sys/device.h>
143 1.2.4.2 yamt #include <sys/systm.h>
144 1.2.4.2 yamt #include <sys/kernel.h>
145 1.2.4.2 yamt #include <sys/exec.h>
146 1.2.4.2 yamt #include <sys/proc.h>
147 1.2.4.2 yamt #include <sys/msgbuf.h>
148 1.2.4.2 yamt #include <sys/reboot.h>
149 1.2.4.2 yamt #include <sys/termios.h>
150 1.2.4.2 yamt #include <sys/ksyms.h>
151 1.2.4.2 yamt #include <sys/mount.h>
152 1.2.4.2 yamt
153 1.2.4.2 yamt #include <net/if.h>
154 1.2.4.2 yamt #include <net/if_ether.h>
155 1.2.4.2 yamt #include <net/if_media.h>
156 1.2.4.2 yamt
157 1.2.4.2 yamt #include <uvm/uvm_extern.h>
158 1.2.4.2 yamt
159 1.2.4.2 yamt #include <dev/cons.h>
160 1.2.4.2 yamt #include <dev/md.h>
161 1.2.4.2 yamt
162 1.2.4.2 yamt #include <machine/db_machdep.h>
163 1.2.4.2 yamt #include <ddb/db_sym.h>
164 1.2.4.2 yamt #include <ddb/db_extern.h>
165 1.2.4.2 yamt #ifdef KGDB
166 1.2.4.2 yamt #include <sys/kgdb.h>
167 1.2.4.2 yamt #endif
168 1.2.4.2 yamt
169 1.2.4.2 yamt #include <sys/exec_elf.h>
170 1.2.4.2 yamt
171 1.2.4.2 yamt #include <sys/bus.h>
172 1.2.4.2 yamt #include <machine/cpu.h>
173 1.2.4.2 yamt #include <machine/frame.h>
174 1.2.4.2 yamt #include <machine/intr.h>
175 1.2.4.2 yamt #include <arm/undefined.h>
176 1.2.4.2 yamt
177 1.2.4.2 yamt #include <machine/autoconf.h>
178 1.2.4.2 yamt
179 1.2.4.4 yamt #include <arm/locore.h>
180 1.2.4.2 yamt #include <arm/arm32/machdep.h>
181 1.2.4.2 yamt
182 1.2.4.2 yamt #include <arm/s3c2xx0/s3c2440reg.h>
183 1.2.4.2 yamt #include <arm/s3c2xx0/s3c2440var.h>
184 1.2.4.2 yamt
185 1.2.4.2 yamt #include <arch/evbarm/mini2440/mini2440_bootinfo.h>
186 1.2.4.2 yamt
187 1.2.4.2 yamt #include "ksyms.h"
188 1.2.4.2 yamt
189 1.2.4.2 yamt #ifndef SDRAM_START
190 1.2.4.2 yamt #define SDRAM_START S3C2440_SDRAM_START
191 1.2.4.2 yamt #endif
192 1.2.4.2 yamt #ifndef SDRAM_SIZE
193 1.2.4.2 yamt #define SDRAM_SIZE (64*1024*1024) /* 64 Mb */
194 1.2.4.2 yamt #endif
195 1.2.4.2 yamt
196 1.2.4.2 yamt /*
197 1.2.4.2 yamt * Address to map I/O registers in early initialize stage.
198 1.2.4.2 yamt */
199 1.2.4.2 yamt #define MINI2440_IO_VBASE 0xfd000000
200 1.2.4.2 yamt
201 1.2.4.2 yamt /* Kernel text starts 2MB in from the bottom of the kernel address space. */
202 1.2.4.2 yamt #define KERNEL_OFFSET 0x00200000
203 1.2.4.2 yamt #define KERNEL_TEXT_BASE (KERNEL_BASE + KERNEL_OFFSET)
204 1.2.4.2 yamt #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
205 1.2.4.2 yamt
206 1.2.4.2 yamt /*
207 1.2.4.2 yamt * The range 0xc1000000 - 0xccffffff is available for kernel VM space
208 1.2.4.2 yamt * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
209 1.2.4.2 yamt */
210 1.2.4.2 yamt #define KERNEL_VM_SIZE 0x0C000000
211 1.2.4.2 yamt
212 1.2.4.2 yamt /* Declared extern elsewhere in the kernel */
213 1.2.4.2 yamt BootConfig bootconfig; /* Boot config storage */
214 1.2.4.2 yamt char *boot_args = NULL;
215 1.2.4.2 yamt //char *boot_file = NULL;
216 1.2.4.2 yamt
217 1.2.4.2 yamt char bootinfo[BOOTINFO_MAXSIZE];
218 1.2.4.2 yamt struct btinfo_rootdevice *bi_rdev;
219 1.2.4.2 yamt struct btinfo_net *bi_net;
220 1.2.4.2 yamt struct btinfo_bootpath *bi_path;
221 1.2.4.2 yamt
222 1.2.4.2 yamt vm_offset_t physical_start;
223 1.2.4.2 yamt vm_offset_t physical_freestart;
224 1.2.4.2 yamt vm_offset_t physical_freeend;
225 1.2.4.2 yamt vm_offset_t physical_freeend_low;
226 1.2.4.2 yamt vm_offset_t physical_end;
227 1.2.4.2 yamt u_int free_pages;
228 1.2.4.2 yamt vm_offset_t pagetables_start;
229 1.2.4.2 yamt
230 1.2.4.2 yamt /*int debug_flags;*/
231 1.2.4.2 yamt #ifndef PMAP_STATIC_L1S
232 1.2.4.2 yamt int max_processes = 64; /* Default number */
233 1.2.4.2 yamt #endif /* !PMAP_STATIC_L1S */
234 1.2.4.2 yamt
235 1.2.4.2 yamt vm_offset_t msgbufphys;
236 1.2.4.2 yamt
237 1.2.4.2 yamt #ifdef PMAP_DEBUG
238 1.2.4.2 yamt extern int pmap_debug_level;
239 1.2.4.2 yamt #endif
240 1.2.4.2 yamt
241 1.2.4.2 yamt #define KERNEL_PT_SYS 0 /* L2 table for mapping zero page */
242 1.2.4.2 yamt #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
243 1.2.4.2 yamt #define KERNEL_PT_KERNEL_NUM 3 /* L2 tables for mapping kernel VM */
244 1.2.4.2 yamt
245 1.2.4.2 yamt #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
246 1.2.4.2 yamt
247 1.2.4.2 yamt #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
248 1.2.4.2 yamt #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
249 1.2.4.2 yamt
250 1.2.4.2 yamt pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
251 1.2.4.2 yamt
252 1.2.4.2 yamt /* Prototypes */
253 1.2.4.2 yamt
254 1.2.4.2 yamt void consinit(void);
255 1.2.4.2 yamt void kgdb_port_init(void);
256 1.2.4.2 yamt static void mini2440_ksyms(struct btinfo_symtab *bi_symtab);
257 1.2.4.2 yamt static void *lookup_bootinfo(int type);
258 1.2.4.2 yamt static void mini2440_device_register(device_t dev, void *aux);
259 1.2.4.2 yamt
260 1.2.4.2 yamt
261 1.2.4.2 yamt #include "com.h"
262 1.2.4.2 yamt #if NCOM > 0
263 1.2.4.2 yamt #include <dev/ic/comreg.h>
264 1.2.4.2 yamt #include <dev/ic/comvar.h>
265 1.2.4.2 yamt #endif
266 1.2.4.2 yamt
267 1.2.4.2 yamt #include "sscom.h"
268 1.2.4.2 yamt #if NSSCOM > 0
269 1.2.4.2 yamt #include "opt_sscom.h"
270 1.2.4.2 yamt #include <arm/s3c2xx0/sscom_var.h>
271 1.2.4.2 yamt #endif
272 1.2.4.2 yamt
273 1.2.4.2 yamt /*
274 1.2.4.2 yamt * Define the default console speed for the board. This is generally
275 1.2.4.2 yamt * what the firmware provided with the board defaults to.
276 1.2.4.2 yamt */
277 1.2.4.2 yamt #ifndef CONSPEED
278 1.2.4.2 yamt #define CONSPEED B115200 /* TTYDEF_SPEED */
279 1.2.4.2 yamt #endif
280 1.2.4.2 yamt #ifndef CONMODE
281 1.2.4.2 yamt #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
282 1.2.4.2 yamt #endif
283 1.2.4.2 yamt
284 1.2.4.2 yamt int comcnspeed = CONSPEED;
285 1.2.4.2 yamt int comcnmode = CONMODE;
286 1.2.4.2 yamt
287 1.2.4.2 yamt /*
288 1.2.4.2 yamt * void cpu_reboot(int howto, char *bootstr)
289 1.2.4.2 yamt *
290 1.2.4.2 yamt * Reboots the system
291 1.2.4.2 yamt *
292 1.2.4.2 yamt * Deal with any syncing, unmounting, dumping and shutdown hooks,
293 1.2.4.2 yamt * then reset the CPU.
294 1.2.4.2 yamt */
295 1.2.4.2 yamt void
296 1.2.4.2 yamt cpu_reboot(int howto, char *bootstr)
297 1.2.4.2 yamt {
298 1.2.4.2 yamt #ifdef DIAGNOSTIC
299 1.2.4.2 yamt /* info */
300 1.2.4.2 yamt printf("boot: howto=%08x curproc=%p\n", howto, curproc);
301 1.2.4.2 yamt #endif
302 1.2.4.2 yamt
303 1.2.4.3 yamt cpu_reset_address_paddr = vtophys((uintptr_t)s3c2440_softreset);
304 1.2.4.2 yamt
305 1.2.4.2 yamt /*
306 1.2.4.2 yamt * If we are still cold then hit the air brakes
307 1.2.4.2 yamt * and crash to earth fast
308 1.2.4.2 yamt */
309 1.2.4.2 yamt if (cold) {
310 1.2.4.2 yamt doshutdownhooks();
311 1.2.4.2 yamt printf("The operating system has halted.\n");
312 1.2.4.2 yamt printf("Please press any key to reboot.\n\n");
313 1.2.4.2 yamt cngetc();
314 1.2.4.2 yamt printf("rebooting...\n");
315 1.2.4.2 yamt cpu_reset();
316 1.2.4.2 yamt /* NOTREACHED */
317 1.2.4.2 yamt }
318 1.2.4.2 yamt /* Disable console buffering */
319 1.2.4.2 yamt
320 1.2.4.2 yamt /*
321 1.2.4.2 yamt * If RB_NOSYNC was not specified sync the discs.
322 1.2.4.2 yamt * Note: Unless cold is set to 1 here, syslogd will die during the
323 1.2.4.2 yamt * unmount. It looks like syslogd is getting woken up only to find
324 1.2.4.2 yamt * that it cannot page part of the binary in as the filesystem has
325 1.2.4.2 yamt * been unmounted.
326 1.2.4.2 yamt */
327 1.2.4.2 yamt if (!(howto & RB_NOSYNC))
328 1.2.4.2 yamt bootsync();
329 1.2.4.2 yamt
330 1.2.4.2 yamt /* Say NO to interrupts */
331 1.2.4.2 yamt splhigh();
332 1.2.4.2 yamt
333 1.2.4.2 yamt /* Do a dump if requested. */
334 1.2.4.2 yamt if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
335 1.2.4.2 yamt dumpsys();
336 1.2.4.2 yamt
337 1.2.4.2 yamt /* Run any shutdown hooks */
338 1.2.4.2 yamt doshutdownhooks();
339 1.2.4.2 yamt
340 1.2.4.2 yamt /* Make sure IRQ's are disabled */
341 1.2.4.2 yamt IRQdisable;
342 1.2.4.2 yamt
343 1.2.4.2 yamt if (howto & RB_HALT) {
344 1.2.4.2 yamt printf("The operating system has halted.\n");
345 1.2.4.2 yamt printf("Please press any key to reboot.\n\n");
346 1.2.4.2 yamt cngetc();
347 1.2.4.2 yamt }
348 1.2.4.2 yamt printf("rebooting...\n");
349 1.2.4.2 yamt cpu_reset();
350 1.2.4.2 yamt /* NOTREACHED */
351 1.2.4.2 yamt }
352 1.2.4.2 yamt
353 1.2.4.2 yamt /*
354 1.2.4.2 yamt * Static device mappings. These peripheral registers are mapped at
355 1.2.4.2 yamt * fixed virtual addresses very early in initarm() so that we can use
356 1.2.4.2 yamt * them while booting the kernel , and stay at the same address
357 1.2.4.2 yamt * throughout whole kernel's life time.
358 1.2.4.2 yamt *
359 1.2.4.2 yamt * We use this table twice; once with bootstrap page table, and once
360 1.2.4.2 yamt * with kernel's page table which we build up in initarm().
361 1.2.4.2 yamt *
362 1.2.4.2 yamt * Since we map these registers into the bootstrap page table using
363 1.2.4.2 yamt * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
364 1.2.4.2 yamt * registers segment-aligned and segment-rounded in order to avoid
365 1.2.4.2 yamt * using the 2nd page tables.
366 1.2.4.2 yamt */
367 1.2.4.2 yamt
368 1.2.4.2 yamt #define _A(a) ((a) & ~L1_S_OFFSET)
369 1.2.4.2 yamt #define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
370 1.2.4.2 yamt
371 1.2.4.2 yamt #define _V(n) (MINI2440_IO_VBASE + (n) * L1_S_SIZE)
372 1.2.4.2 yamt
373 1.2.4.2 yamt #define GPIO_VBASE _V(0)
374 1.2.4.2 yamt #define INTCTL_VBASE _V(1)
375 1.2.4.2 yamt #define CLKMAN_VBASE _V(2)
376 1.2.4.2 yamt #define UART_VBASE _V(3)
377 1.2.4.2 yamt
378 1.2.4.2 yamt static const struct pmap_devmap mini2440_devmap[] = {
379 1.2.4.2 yamt /* GPIO registers */
380 1.2.4.2 yamt {
381 1.2.4.2 yamt GPIO_VBASE,
382 1.2.4.2 yamt _A(S3C2440_GPIO_BASE),
383 1.2.4.2 yamt _S(S3C2440_GPIO_SIZE),
384 1.2.4.2 yamt VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
385 1.2.4.2 yamt },
386 1.2.4.2 yamt {
387 1.2.4.2 yamt INTCTL_VBASE,
388 1.2.4.2 yamt _A(S3C2440_INTCTL_BASE),
389 1.2.4.2 yamt _S(S3C2440_INTCTL_SIZE),
390 1.2.4.2 yamt VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
391 1.2.4.2 yamt },
392 1.2.4.2 yamt {
393 1.2.4.2 yamt CLKMAN_VBASE,
394 1.2.4.2 yamt _A(S3C2440_CLKMAN_BASE),
395 1.2.4.2 yamt _S(S3C24X0_CLKMAN_SIZE),
396 1.2.4.2 yamt VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
397 1.2.4.2 yamt },
398 1.2.4.2 yamt { /* UART registers for UART0, 1, 2. */
399 1.2.4.2 yamt UART_VBASE,
400 1.2.4.2 yamt _A(S3C2440_UART0_BASE),
401 1.2.4.2 yamt _S(S3C2440_UART_BASE(3) - S3C2440_UART0_BASE),
402 1.2.4.2 yamt VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
403 1.2.4.2 yamt },
404 1.2.4.2 yamt
405 1.2.4.2 yamt { 0, 0, 0, 0 }
406 1.2.4.2 yamt };
407 1.2.4.2 yamt
408 1.2.4.2 yamt #undef _A
409 1.2.4.2 yamt #undef _S
410 1.2.4.2 yamt
411 1.2.4.2 yamt static inline pd_entry_t *
412 1.2.4.2 yamt read_ttb(void)
413 1.2.4.2 yamt {
414 1.2.4.2 yamt long ttb;
415 1.2.4.2 yamt
416 1.2.4.2 yamt __asm volatile("mrc p15, 0, %0, c2, c0, 0" : "=r"(ttb));
417 1.2.4.2 yamt
418 1.2.4.2 yamt
419 1.2.4.2 yamt return (pd_entry_t *)(ttb & ~((1 << 14) - 1));
420 1.2.4.2 yamt }
421 1.2.4.2 yamt
422 1.2.4.2 yamt
423 1.2.4.2 yamt #define ioreg_write32(a,v) (*(volatile uint32_t *)(a)=(v))
424 1.2.4.2 yamt
425 1.2.4.2 yamt /*
426 1.2.4.2 yamt * u_int initarm(...)
427 1.2.4.2 yamt *
428 1.2.4.2 yamt * Initial entry point on startup. This gets called before main() is
429 1.2.4.2 yamt * entered.
430 1.2.4.2 yamt * It should be responsible for setting up everything that must be
431 1.2.4.2 yamt * in place when main is called.
432 1.2.4.2 yamt * This includes
433 1.2.4.2 yamt * Taking a copy of the boot configuration structure.
434 1.2.4.2 yamt * Initialising the physical console so characters can be printed.
435 1.2.4.2 yamt * Setting up page tables for the kernel
436 1.2.4.2 yamt * Relocating the kernel to the bottom of physical memory
437 1.2.4.2 yamt */
438 1.2.4.2 yamt
439 1.2.4.2 yamt u_int
440 1.2.4.2 yamt initarm(void *arg)
441 1.2.4.2 yamt {
442 1.2.4.2 yamt int loop;
443 1.2.4.2 yamt int loop1;
444 1.2.4.2 yamt u_int l1pagetable;
445 1.2.4.2 yamt extern int etext __asm("_etext");
446 1.2.4.2 yamt extern int end __asm("_end");
447 1.2.4.2 yamt uint32_t kerneldatasize;
448 1.2.4.2 yamt struct btinfo_magic *bi_magic = arg;
449 1.2.4.2 yamt struct btinfo_bootstring *bi_bootstring;
450 1.2.4.2 yamt struct btinfo_symtab *bi_symtab;
451 1.2.4.2 yamt
452 1.2.4.2 yamt boothowto = 0;
453 1.2.4.2 yamt
454 1.2.4.2 yamt /* Copy bootinfo from boot loader into kernel memory where it remains.
455 1.2.4.2 yamt */
456 1.2.4.2 yamt if (bi_magic != 0x0 && bi_magic->magic == BOOTINFO_MAGIC) {
457 1.2.4.2 yamt memcpy(bootinfo, bi_magic, sizeof(bootinfo));
458 1.2.4.2 yamt } else {
459 1.2.4.2 yamt memset(bootinfo, 0, sizeof(bootinfo));
460 1.2.4.2 yamt }
461 1.2.4.2 yamt
462 1.2.4.2 yamt /* Extract boot_args from bootinfo */
463 1.2.4.2 yamt bi_bootstring = lookup_bootinfo(BTINFO_BOOTSTRING);
464 1.2.4.2 yamt if (bi_bootstring ) {
465 1.2.4.2 yamt printf("Bootloader args are %s\n", bi_bootstring->bootstring);
466 1.2.4.2 yamt boot_args = bi_bootstring->bootstring;
467 1.2.4.2 yamt parse_mi_bootargs(boot_args);
468 1.2.4.2 yamt }
469 1.2.4.2 yamt
470 1.2.4.2 yamt #define pdatb (*(volatile uint8_t *)(S3C2440_GPIO_BASE+GPIO_PBDAT))
471 1.2.4.2 yamt
472 1.2.4.2 yamt // 0x1E0 is the mask for GPB5, GPB6, GPB7, and GPB8
473 1.2.4.2 yamt #define __LED(x) (pdatb = (pdatb & ~0x1e0) | (~(1<<(x+5)) & 0x1e0))
474 1.2.4.2 yamt
475 1.2.4.2 yamt __LED(0);
476 1.2.4.2 yamt
477 1.2.4.2 yamt /*
478 1.2.4.2 yamt * Heads up ... Setup the CPU / MMU / TLB functions
479 1.2.4.2 yamt */
480 1.2.4.2 yamt if (set_cpufuncs())
481 1.2.4.2 yamt panic("cpu not recognized!");
482 1.2.4.2 yamt
483 1.2.4.2 yamt /*
484 1.2.4.2 yamt * Map I/O registers that are used in startup. Now we are
485 1.2.4.2 yamt * still using page table prepared by bootloader. Later we'll
486 1.2.4.2 yamt * map those registers at the same address in the kernel page
487 1.2.4.2 yamt * table.
488 1.2.4.2 yamt */
489 1.2.4.2 yamt pmap_devmap_bootstrap((vaddr_t)read_ttb(), mini2440_devmap);
490 1.2.4.2 yamt
491 1.2.4.2 yamt #undef pdatb
492 1.2.4.2 yamt #define pdatb (*(volatile uint8_t *)(GPIO_VBASE+GPIO_PBDAT))
493 1.2.4.2 yamt
494 1.2.4.2 yamt /* Disable all peripheral interrupts */
495 1.2.4.2 yamt ioreg_write32(INTCTL_VBASE + INTCTL_INTMSK, ~0);
496 1.2.4.2 yamt
497 1.2.4.2 yamt __LED(1);
498 1.2.4.2 yamt
499 1.2.4.2 yamt /* initialize some variables so that splfoo() doesn't
500 1.2.4.2 yamt touch illegal address. */
501 1.2.4.2 yamt s3c2xx0_intr_bootstrap(INTCTL_VBASE);
502 1.2.4.2 yamt
503 1.2.4.2 yamt __LED(2);
504 1.2.4.2 yamt consinit();
505 1.2.4.2 yamt __LED(3);
506 1.2.4.2 yamt
507 1.2.4.2 yamt /* Extract information from the bootloader configuration */
508 1.2.4.2 yamt bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE);
509 1.2.4.2 yamt bi_net = lookup_bootinfo(BTINFO_NET);
510 1.2.4.2 yamt bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
511 1.2.4.2 yamt
512 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
513 1.2.4.2 yamt printf("consinit done\n");
514 1.2.4.2 yamt #endif
515 1.2.4.2 yamt
516 1.2.4.2 yamt #ifdef KGDB
517 1.2.4.2 yamt kgdb_port_init();
518 1.2.4.2 yamt #endif
519 1.2.4.2 yamt
520 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
521 1.2.4.2 yamt /* Talk to the user */
522 1.2.4.2 yamt printf("\nNetBSD/evbarm (MINI2440) booting ...\n");
523 1.2.4.2 yamt #endif
524 1.2.4.2 yamt /*
525 1.2.4.2 yamt * Ok we have the following memory map
526 1.2.4.2 yamt *
527 1.2.4.2 yamt * Physical Address Range Description
528 1.2.4.2 yamt * ----------------------- ----------------------------------
529 1.2.4.2 yamt * 0x30000000 - 0x33ffffff SDRAM (64MB)
530 1.2.4.2 yamt *
531 1.2.4.2 yamt * Kernel is loaded by bootloader at 0x30200000
532 1.2.4.2 yamt *
533 1.2.4.2 yamt * The initarm() has the responsibility for creating the kernel
534 1.2.4.2 yamt * page tables.
535 1.2.4.2 yamt * It must also set up various memory pointers that are used
536 1.2.4.2 yamt * by pmap etc.
537 1.2.4.2 yamt */
538 1.2.4.2 yamt
539 1.2.4.2 yamt /* Fake bootconfig structure for the benefit of pmap.c */
540 1.2.4.2 yamt /* XXX must make the memory description h/w independent */
541 1.2.4.2 yamt bootconfig.dramblocks = 1;
542 1.2.4.2 yamt bootconfig.dram[0].address = SDRAM_START;
543 1.2.4.2 yamt bootconfig.dram[0].pages = SDRAM_SIZE / PAGE_SIZE;
544 1.2.4.2 yamt
545 1.2.4.2 yamt /*
546 1.2.4.2 yamt * Set up the variables that define the availablilty of
547 1.2.4.2 yamt * physical memory.
548 1.2.4.2 yamt * We use the 2MB between the physical start and the kernel to
549 1.2.4.2 yamt * begin with. Allocating from 0x30200000 and downwards
550 1.2.4.2 yamt * If we get too close to the bottom of SDRAM, we
551 1.2.4.2 yamt * will panic. We will update physical_freestart and
552 1.2.4.2 yamt * physical_freeend later to reflect what pmap_bootstrap()
553 1.2.4.2 yamt * wants to see.
554 1.2.4.2 yamt *
555 1.2.4.2 yamt * XXX pmap_bootstrap() needs an enema.
556 1.2.4.2 yamt */
557 1.2.4.2 yamt physical_start = bootconfig.dram[0].address;
558 1.2.4.2 yamt physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE);
559 1.2.4.2 yamt
560 1.2.4.2 yamt physical_freestart = SDRAM_START; /* XXX */
561 1.2.4.2 yamt physical_freeend = SDRAM_START + KERNEL_OFFSET;
562 1.2.4.2 yamt
563 1.2.4.2 yamt physmem = (physical_end - physical_start) / PAGE_SIZE;
564 1.2.4.2 yamt
565 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
566 1.2.4.2 yamt /* Tell the user about the memory */
567 1.2.4.2 yamt printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
568 1.2.4.2 yamt physical_start, physical_end - 1);
569 1.2.4.2 yamt printf("phys_end: 0x%08lx\n", physical_end);
570 1.2.4.2 yamt #endif
571 1.2.4.2 yamt
572 1.2.4.2 yamt /*
573 1.2.4.2 yamt * XXX
574 1.2.4.2 yamt * Okay, the kernel starts 2MB in from the bottom of physical
575 1.2.4.2 yamt * memory. We are going to allocate our bootstrap pages downwards
576 1.2.4.2 yamt * from there.
577 1.2.4.2 yamt *
578 1.2.4.2 yamt * We need to allocate some fixed page tables to get the kernel
579 1.2.4.2 yamt * going. We allocate one page directory and a number of page
580 1.2.4.2 yamt * tables and store the physical addresses in the kernel_pt_table
581 1.2.4.2 yamt * array.
582 1.2.4.2 yamt *
583 1.2.4.2 yamt * The kernel page directory must be on a 16K boundary. The page
584 1.2.4.2 yamt * tables must be on 4K boundaries. What we do is allocate the
585 1.2.4.2 yamt * page directory on the first 16K boundary that we encounter, and
586 1.2.4.2 yamt * the page tables on 4K boundaries otherwise. Since we allocate
587 1.2.4.2 yamt * at least 3 L2 page tables, we are guaranteed to encounter at
588 1.2.4.2 yamt * least one 16K aligned region.
589 1.2.4.2 yamt */
590 1.2.4.2 yamt
591 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
592 1.2.4.2 yamt printf("Allocating page tables\n");
593 1.2.4.2 yamt #endif
594 1.2.4.2 yamt
595 1.2.4.2 yamt free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
596 1.2.4.2 yamt
597 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
598 1.2.4.2 yamt printf("freestart = 0x%08lx, free_pages = %d (0x%08x), freeend = 0x%08lx\n",
599 1.2.4.2 yamt physical_freestart, free_pages, free_pages, physical_freeend);
600 1.2.4.2 yamt #endif
601 1.2.4.2 yamt
602 1.2.4.2 yamt /* Define a macro to simplify memory allocation */
603 1.2.4.2 yamt #define valloc_pages(var, np) \
604 1.2.4.2 yamt alloc_pages((var).pv_pa, (np)); \
605 1.2.4.2 yamt (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
606 1.2.4.2 yamt
607 1.2.4.2 yamt #define alloc_pages(var, np) \
608 1.2.4.2 yamt physical_freeend -= ((np) * PAGE_SIZE); \
609 1.2.4.2 yamt if (physical_freeend < physical_freestart) \
610 1.2.4.2 yamt panic("initarm: out of memory"); \
611 1.2.4.2 yamt (var) = physical_freeend; \
612 1.2.4.2 yamt free_pages -= (np); \
613 1.2.4.2 yamt memset((char *)(var), 0, ((np) * PAGE_SIZE));
614 1.2.4.2 yamt
615 1.2.4.2 yamt loop1 = 0;
616 1.2.4.2 yamt for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
617 1.2.4.2 yamt /* Are we 16KB aligned for an L1 ? */
618 1.2.4.2 yamt if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
619 1.2.4.2 yamt && kernel_l1pt.pv_pa == 0) {
620 1.2.4.2 yamt valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
621 1.2.4.2 yamt } else {
622 1.2.4.2 yamt valloc_pages(kernel_pt_table[loop1],
623 1.2.4.2 yamt L2_TABLE_SIZE / PAGE_SIZE);
624 1.2.4.2 yamt ++loop1;
625 1.2.4.2 yamt }
626 1.2.4.2 yamt }
627 1.2.4.2 yamt
628 1.2.4.2 yamt /* This should never be able to happen but better confirm that. */
629 1.2.4.2 yamt if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0)
630 1.2.4.2 yamt panic("initarm: Failed to align the kernel page directory\n");
631 1.2.4.2 yamt
632 1.2.4.2 yamt /*
633 1.2.4.2 yamt * Allocate a page for the system page mapped to V0x00000000
634 1.2.4.2 yamt * This page will just contain the system vectors and can be
635 1.2.4.2 yamt * shared by all processes.
636 1.2.4.2 yamt */
637 1.2.4.2 yamt alloc_pages(systempage.pv_pa, 1);
638 1.2.4.2 yamt
639 1.2.4.2 yamt /* Allocate stacks for all modes */
640 1.2.4.2 yamt valloc_pages(irqstack, IRQ_STACK_SIZE);
641 1.2.4.2 yamt valloc_pages(abtstack, ABT_STACK_SIZE);
642 1.2.4.2 yamt valloc_pages(undstack, UND_STACK_SIZE);
643 1.2.4.2 yamt valloc_pages(kernelstack, UPAGES);
644 1.2.4.2 yamt
645 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
646 1.2.4.2 yamt printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
647 1.2.4.2 yamt irqstack.pv_va);
648 1.2.4.2 yamt printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
649 1.2.4.2 yamt abtstack.pv_va);
650 1.2.4.2 yamt printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
651 1.2.4.2 yamt undstack.pv_va);
652 1.2.4.2 yamt printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
653 1.2.4.2 yamt kernelstack.pv_va);
654 1.2.4.2 yamt printf("Free memory in bootstrap region: %ld bytes\n", physical_freeend - physical_freestart);
655 1.2.4.2 yamt #endif
656 1.2.4.2 yamt
657 1.2.4.2 yamt alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
658 1.2.4.2 yamt
659 1.2.4.2 yamt physical_freeend_low = physical_freeend;
660 1.2.4.2 yamt
661 1.2.4.2 yamt /*
662 1.2.4.2 yamt * Ok we have allocated physical pages for the primary kernel
663 1.2.4.2 yamt * page tables
664 1.2.4.2 yamt */
665 1.2.4.2 yamt
666 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
667 1.2.4.2 yamt printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
668 1.2.4.2 yamt #endif
669 1.2.4.2 yamt
670 1.2.4.2 yamt /*
671 1.2.4.2 yamt * Now we start construction of the L1 page table
672 1.2.4.2 yamt * We start by mapping the L2 page tables into the L1.
673 1.2.4.2 yamt * This means that we can replace L1 mappings later on if necessary
674 1.2.4.2 yamt */
675 1.2.4.2 yamt l1pagetable = kernel_l1pt.pv_pa;
676 1.2.4.2 yamt
677 1.2.4.2 yamt /* Map the L2 pages tables in the L1 page table */
678 1.2.4.2 yamt pmap_link_l2pt(l1pagetable, 0x00000000,
679 1.2.4.2 yamt &kernel_pt_table[KERNEL_PT_SYS]);
680 1.2.4.2 yamt for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
681 1.2.4.2 yamt pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
682 1.2.4.2 yamt &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
683 1.2.4.2 yamt for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
684 1.2.4.2 yamt pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
685 1.2.4.2 yamt &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
686 1.2.4.2 yamt
687 1.2.4.2 yamt /* update the top of the kernel VM */
688 1.2.4.2 yamt pmap_curmaxkvaddr =
689 1.2.4.2 yamt KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
690 1.2.4.2 yamt
691 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
692 1.2.4.2 yamt printf("Mapping kernel\n");
693 1.2.4.2 yamt #endif
694 1.2.4.2 yamt
695 1.2.4.2 yamt /* Now we fill in the L2 pagetable for the kernel static code/data */
696 1.2.4.2 yamt {
697 1.2.4.2 yamt /* Total size must include symbol table, if it exists.
698 1.2.4.2 yamt The size of the symbol table can be acquired from the ELF
699 1.2.4.2 yamt header, to which a pointer is passed in the boot info (ssym).
700 1.2.4.2 yamt */
701 1.2.4.2 yamt size_t textsize = (uintptr_t)&etext - KERNEL_TEXT_BASE;
702 1.2.4.2 yamt kerneldatasize = (uintptr_t)&end - KERNEL_TEXT_BASE;
703 1.2.4.2 yamt u_int logical;
704 1.2.4.2 yamt
705 1.2.4.2 yamt bi_symtab = lookup_bootinfo(BTINFO_SYMTAB);
706 1.2.4.2 yamt
707 1.2.4.2 yamt if (bi_symtab) {
708 1.2.4.2 yamt Elf_Ehdr *elfHeader;
709 1.2.4.2 yamt Elf_Shdr *sectionHeader;
710 1.2.4.2 yamt int nsection;
711 1.2.4.2 yamt int sz = 0;
712 1.2.4.2 yamt
713 1.2.4.2 yamt elfHeader = bi_symtab->ssym;
714 1.2.4.2 yamt
715 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
716 1.2.4.2 yamt printf("Symbol table information provided by bootloader\n");
717 1.2.4.2 yamt printf("ELF header is at %p\n", elfHeader);
718 1.2.4.2 yamt #endif
719 1.2.4.2 yamt sectionHeader = (Elf_Shdr*)((char*)(bi_symtab->ssym) +
720 1.2.4.2 yamt (elfHeader->e_shoff));
721 1.2.4.2 yamt nsection = elfHeader->e_shnum;
722 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
723 1.2.4.2 yamt printf("Number of sections: %d\n", nsection);
724 1.2.4.2 yamt #endif
725 1.2.4.2 yamt for(; nsection > 0; nsection--, sectionHeader++) {
726 1.2.4.2 yamt if (sectionHeader->sh_offset > 0 &&
727 1.2.4.2 yamt (sectionHeader->sh_offset + sectionHeader->sh_size) > sz)
728 1.2.4.2 yamt sz = sectionHeader->sh_offset + sectionHeader->sh_size;
729 1.2.4.2 yamt }
730 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
731 1.2.4.2 yamt printf("Max size of sections: %d\n", sz);
732 1.2.4.2 yamt #endif
733 1.2.4.2 yamt kerneldatasize += sz;
734 1.2.4.2 yamt }
735 1.2.4.2 yamt
736 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
737 1.2.4.2 yamt printf("Textsize: %u, kerneldatasize: %u\n", (uint)textsize,
738 1.2.4.2 yamt (uint)kerneldatasize);
739 1.2.4.2 yamt printf("&etext: 0x%x\n", (uint)&etext);
740 1.2.4.2 yamt printf("&end: 0x%x\n", (uint)&end);
741 1.2.4.2 yamt printf("KERNEL_TEXT_BASE: 0x%x\n", KERNEL_TEXT_BASE);
742 1.2.4.2 yamt #endif
743 1.2.4.2 yamt
744 1.2.4.2 yamt textsize = (textsize + PGOFSET) & ~PGOFSET;
745 1.2.4.2 yamt kerneldatasize = (kerneldatasize + PGOFSET) & ~PGOFSET;
746 1.2.4.2 yamt
747 1.2.4.2 yamt logical = KERNEL_OFFSET; /* offset of kernel in RAM */
748 1.2.4.2 yamt
749 1.2.4.2 yamt logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
750 1.2.4.2 yamt physical_start + logical, textsize,
751 1.2.4.2 yamt VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
752 1.2.4.2 yamt logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
753 1.2.4.2 yamt physical_start + logical, kerneldatasize - textsize,
754 1.2.4.2 yamt VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
755 1.2.4.2 yamt }
756 1.2.4.2 yamt
757 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
758 1.2.4.2 yamt printf("Constructing L2 page tables\n");
759 1.2.4.2 yamt #endif
760 1.2.4.2 yamt
761 1.2.4.2 yamt /* Map the stack pages */
762 1.2.4.2 yamt pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
763 1.2.4.2 yamt IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
764 1.2.4.2 yamt PTE_CACHE);
765 1.2.4.2 yamt pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
766 1.2.4.2 yamt ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
767 1.2.4.2 yamt PTE_CACHE);
768 1.2.4.2 yamt pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
769 1.2.4.2 yamt UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
770 1.2.4.2 yamt PTE_CACHE);
771 1.2.4.2 yamt pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
772 1.2.4.2 yamt UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
773 1.2.4.2 yamt
774 1.2.4.2 yamt pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
775 1.2.4.2 yamt L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
776 1.2.4.2 yamt
777 1.2.4.2 yamt for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
778 1.2.4.2 yamt pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
779 1.2.4.2 yamt kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
780 1.2.4.2 yamt VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
781 1.2.4.2 yamt }
782 1.2.4.2 yamt
783 1.2.4.2 yamt /* Map the vector page. */
784 1.2.4.2 yamt #if 0
785 1.2.4.2 yamt /* MULTI-ICE requires that page 0 is NC/NB so that it can download the
786 1.2.4.2 yamt * cache-clean code there. */
787 1.2.4.2 yamt pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
788 1.2.4.2 yamt VM_PROT_READ | VM_PROT_WRITE, PTE_NOCACHE);
789 1.2.4.2 yamt #else
790 1.2.4.2 yamt pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
791 1.2.4.2 yamt VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
792 1.2.4.2 yamt #endif
793 1.2.4.2 yamt
794 1.2.4.2 yamt /*
795 1.2.4.2 yamt * map integrated peripherals at same address in l1pagetable
796 1.2.4.2 yamt * so that we can continue to use console.
797 1.2.4.2 yamt */
798 1.2.4.2 yamt pmap_devmap_bootstrap(l1pagetable, mini2440_devmap);
799 1.2.4.2 yamt
800 1.2.4.2 yamt /*
801 1.2.4.2 yamt * Now we have the real page tables in place so we can switch to them.
802 1.2.4.2 yamt * Once this is done we will be running with the REAL kernel page
803 1.2.4.2 yamt * tables.
804 1.2.4.2 yamt */
805 1.2.4.2 yamt /*
806 1.2.4.2 yamt * Update the physical_freestart/physical_freeend/free_pages
807 1.2.4.2 yamt * variables.
808 1.2.4.2 yamt */
809 1.2.4.2 yamt physical_freestart = physical_start +
810 1.2.4.2 yamt (KERNEL_TEXT_BASE - KERNEL_BASE) + kerneldatasize;
811 1.2.4.2 yamt physical_freeend = physical_end;
812 1.2.4.2 yamt free_pages =
813 1.2.4.2 yamt (physical_freeend - physical_freestart) / PAGE_SIZE;
814 1.2.4.2 yamt
815 1.2.4.2 yamt /* Switch tables */
816 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
817 1.2.4.2 yamt printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
818 1.2.4.2 yamt physical_freestart, free_pages, free_pages);
819 1.2.4.2 yamt printf("switching to new L1 page table @%#lx...", kernel_l1pt.pv_pa);
820 1.2.4.2 yamt #endif
821 1.2.4.2 yamt cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
822 1.2.4.3 yamt cpu_setttb(kernel_l1pt.pv_pa, true);
823 1.2.4.2 yamt cpu_tlb_flushID();
824 1.2.4.2 yamt cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
825 1.2.4.2 yamt
826 1.2.4.2 yamt /*
827 1.2.4.2 yamt * Moved from cpu_startup() as data_abort_handler() references
828 1.2.4.2 yamt * this during uvm init
829 1.2.4.2 yamt */
830 1.2.4.2 yamt uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
831 1.2.4.2 yamt
832 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
833 1.2.4.2 yamt printf("done!\n");
834 1.2.4.2 yamt #endif
835 1.2.4.2 yamt
836 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
837 1.2.4.2 yamt printf("bootstrap done.\n");
838 1.2.4.2 yamt #endif
839 1.2.4.2 yamt
840 1.2.4.2 yamt arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL);
841 1.2.4.2 yamt
842 1.2.4.2 yamt /*
843 1.2.4.2 yamt * Pages were allocated during the secondary bootstrap for the
844 1.2.4.2 yamt * stacks for different CPU modes.
845 1.2.4.2 yamt * We must now set the r13 registers in the different CPU modes to
846 1.2.4.2 yamt * point to these stacks.
847 1.2.4.2 yamt * Since the ARM stacks use STMFD etc. we must set r13 to the top end
848 1.2.4.2 yamt * of the stack memory.
849 1.2.4.2 yamt */
850 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
851 1.2.4.2 yamt printf("init subsystems: stacks ");
852 1.2.4.2 yamt #endif
853 1.2.4.2 yamt
854 1.2.4.2 yamt set_stackptr(PSR_IRQ32_MODE,
855 1.2.4.2 yamt irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
856 1.2.4.2 yamt set_stackptr(PSR_ABT32_MODE,
857 1.2.4.2 yamt abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
858 1.2.4.2 yamt set_stackptr(PSR_UND32_MODE,
859 1.2.4.2 yamt undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
860 1.2.4.2 yamt
861 1.2.4.2 yamt cpu_idcache_wbinv_all();
862 1.2.4.2 yamt
863 1.2.4.2 yamt /*
864 1.2.4.2 yamt * Well we should set a data abort handler.
865 1.2.4.2 yamt * Once things get going this will change as we will need a proper
866 1.2.4.2 yamt * handler.
867 1.2.4.2 yamt * Until then we will use a handler that just panics but tells us
868 1.2.4.2 yamt * why.
869 1.2.4.2 yamt * Initialisation of the vectors will just panic on a data abort.
870 1.2.4.2 yamt * This just fills in a slightly better one.
871 1.2.4.2 yamt */
872 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
873 1.2.4.2 yamt printf("vectors ");
874 1.2.4.2 yamt #endif
875 1.2.4.2 yamt data_abort_handler_address = (u_int)data_abort_handler;
876 1.2.4.2 yamt prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
877 1.2.4.2 yamt undefined_handler_address = (u_int)undefinedinstruction_bounce;
878 1.2.4.2 yamt
879 1.2.4.2 yamt /* Initialise the undefined instruction handlers */
880 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
881 1.2.4.2 yamt printf("undefined ");
882 1.2.4.2 yamt #endif
883 1.2.4.2 yamt undefined_init();
884 1.2.4.2 yamt
885 1.2.4.2 yamt /* Load memory into UVM. */
886 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
887 1.2.4.2 yamt printf("page ");
888 1.2.4.2 yamt #endif
889 1.2.4.2 yamt uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
890 1.2.4.2 yamt uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
891 1.2.4.2 yamt atop(physical_freestart), atop(physical_freeend),
892 1.2.4.2 yamt VM_FREELIST_DEFAULT);
893 1.2.4.2 yamt uvm_page_physload(atop(SDRAM_START), atop(physical_freeend_low),
894 1.2.4.2 yamt atop(SDRAM_START), atop(physical_freeend_low),
895 1.2.4.2 yamt VM_FREELIST_DEFAULT);
896 1.2.4.2 yamt
897 1.2.4.2 yamt
898 1.2.4.2 yamt /* Boot strap pmap telling it where the kernel page table is */
899 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
900 1.2.4.2 yamt printf("pmap ");
901 1.2.4.2 yamt #endif
902 1.2.4.2 yamt pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
903 1.2.4.2 yamt
904 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
905 1.2.4.2 yamt printf("done.\n");
906 1.2.4.2 yamt #endif
907 1.2.4.2 yamt
908 1.2.4.2 yamt #ifdef BOOTHOWTO
909 1.2.4.2 yamt boothowto |= BOOTHOWTO;
910 1.2.4.2 yamt #endif
911 1.2.4.2 yamt
912 1.2.4.2 yamt #ifdef KGDB
913 1.2.4.2 yamt if (boothowto & RB_KDB) {
914 1.2.4.2 yamt kgdb_debug_init = 1;
915 1.2.4.2 yamt kgdb_connect(1);
916 1.2.4.2 yamt }
917 1.2.4.2 yamt #endif
918 1.2.4.2 yamt
919 1.2.4.2 yamt mini2440_ksyms(bi_symtab);
920 1.2.4.2 yamt
921 1.2.4.2 yamt #ifdef DDB
922 1.2.4.2 yamt /*db_machine_init();*/
923 1.2.4.2 yamt if (boothowto & RB_KDB)
924 1.2.4.2 yamt Debugger();
925 1.2.4.2 yamt #endif
926 1.2.4.2 yamt
927 1.2.4.2 yamt evbarm_device_register = mini2440_device_register;
928 1.2.4.2 yamt
929 1.2.4.2 yamt /* We return the new stack pointer address */
930 1.2.4.2 yamt return (kernelstack.pv_va + USPACE_SVC_STACK_TOP);
931 1.2.4.2 yamt }
932 1.2.4.2 yamt
933 1.2.4.2 yamt void
934 1.2.4.2 yamt consinit(void)
935 1.2.4.2 yamt {
936 1.2.4.2 yamt static int consinit_done = 0;
937 1.2.4.2 yamt #if defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE)
938 1.2.4.2 yamt bus_space_tag_t iot = &s3c2xx0_bs_tag;
939 1.2.4.2 yamt #endif
940 1.2.4.2 yamt int pclk;
941 1.2.4.2 yamt
942 1.2.4.2 yamt if (consinit_done != 0)
943 1.2.4.2 yamt return;
944 1.2.4.2 yamt
945 1.2.4.2 yamt consinit_done = 1;
946 1.2.4.2 yamt
947 1.2.4.2 yamt s3c24x0_clock_freq2(CLKMAN_VBASE, NULL, NULL, &pclk);
948 1.2.4.2 yamt
949 1.2.4.2 yamt #if NSSCOM > 0
950 1.2.4.2 yamt #ifdef SSCOM0CONSOLE
951 1.2.4.2 yamt if (0 == s3c2440_sscom_cnattach(iot, 0, comcnspeed,
952 1.2.4.2 yamt pclk, comcnmode))
953 1.2.4.2 yamt return;
954 1.2.4.2 yamt #endif
955 1.2.4.2 yamt #ifdef SSCOM1CONSOLE
956 1.2.4.2 yamt if (0 == s3c2440_sscom_cnattach(iot, 1, comcnspeed,
957 1.2.4.2 yamt pclk, comcnmode))
958 1.2.4.2 yamt return;
959 1.2.4.2 yamt #endif
960 1.2.4.2 yamt #endif /* NSSCOM */
961 1.2.4.2 yamt #if NCOM>0 && defined(CONCOMADDR)
962 1.2.4.2 yamt if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed,
963 1.2.4.2 yamt COM_FREQ, COM_TYPE_NORMAL, comcnmode))
964 1.2.4.2 yamt panic("can't init serial console @%x", CONCOMADDR);
965 1.2.4.2 yamt return;
966 1.2.4.2 yamt #endif
967 1.2.4.2 yamt
968 1.2.4.2 yamt consinit_done = 0;
969 1.2.4.2 yamt }
970 1.2.4.2 yamt
971 1.2.4.2 yamt
972 1.2.4.2 yamt #ifdef KGDB
973 1.2.4.2 yamt
974 1.2.4.2 yamt #if (NSSCOM > 0)
975 1.2.4.2 yamt
976 1.2.4.2 yamt #ifdef KGDB_DEVNAME
977 1.2.4.2 yamt const char kgdb_devname[] = KGDB_DEVNAME;
978 1.2.4.2 yamt #else
979 1.2.4.2 yamt const char kgdb_devname[] = "";
980 1.2.4.2 yamt #endif
981 1.2.4.2 yamt
982 1.2.4.2 yamt #ifndef KGDB_DEVMODE
983 1.2.4.2 yamt #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */
984 1.2.4.2 yamt #endif
985 1.2.4.2 yamt int kgdb_sscom_mode = KGDB_DEVMODE;
986 1.2.4.2 yamt
987 1.2.4.2 yamt #endif /* NSSCOM */
988 1.2.4.2 yamt
989 1.2.4.2 yamt void
990 1.2.4.2 yamt kgdb_port_init(void)
991 1.2.4.2 yamt {
992 1.2.4.2 yamt #if (NSSCOM > 0)
993 1.2.4.2 yamt int unit = -1;
994 1.2.4.2 yamt int pclk;
995 1.2.4.2 yamt
996 1.2.4.2 yamt if (strcmp(kgdb_devname, "sscom0") == 0)
997 1.2.4.2 yamt unit = 0;
998 1.2.4.2 yamt else if (strcmp(kgdb_devname, "sscom1") == 0)
999 1.2.4.2 yamt unit = 1;
1000 1.2.4.2 yamt
1001 1.2.4.2 yamt if (unit >= 0) {
1002 1.2.4.2 yamt s3c24x0_clock_freq2(CLKMAN_VBASE, NULL, NULL, &pclk);
1003 1.2.4.2 yamt
1004 1.2.4.2 yamt s3c2440_sscom_kgdb_attach(&s3c2xx0_bs_tag,
1005 1.2.4.2 yamt unit, kgdb_rate, pclk, kgdb_sscom_mode);
1006 1.2.4.2 yamt }
1007 1.2.4.2 yamt #endif
1008 1.2.4.2 yamt }
1009 1.2.4.2 yamt #endif
1010 1.2.4.2 yamt
1011 1.2.4.2 yamt
1012 1.2.4.2 yamt static struct arm32_dma_range mini2440_dma_ranges[1];
1013 1.2.4.2 yamt
1014 1.2.4.2 yamt bus_dma_tag_t
1015 1.2.4.2 yamt s3c2xx0_bus_dma_init(struct arm32_bus_dma_tag *dma_tag_template)
1016 1.2.4.2 yamt {
1017 1.2.4.2 yamt extern paddr_t physical_start, physical_end;
1018 1.2.4.2 yamt struct arm32_bus_dma_tag *dmat;
1019 1.2.4.2 yamt
1020 1.2.4.2 yamt mini2440_dma_ranges[0].dr_sysbase = physical_start;
1021 1.2.4.2 yamt mini2440_dma_ranges[0].dr_busbase = physical_start;
1022 1.2.4.2 yamt mini2440_dma_ranges[0].dr_len = physical_end - physical_start;
1023 1.2.4.2 yamt
1024 1.2.4.2 yamt #if 1
1025 1.2.4.2 yamt dmat = dma_tag_template;
1026 1.2.4.2 yamt #else
1027 1.2.4.2 yamt dmat = malloc(sizeof *dmat, M_DEVBUF, M_NOWAIT);
1028 1.2.4.2 yamt if (dmat == NULL)
1029 1.2.4.2 yamt return NULL;
1030 1.2.4.2 yamt *dmat = *dma_tag_template;
1031 1.2.4.2 yamt #endif
1032 1.2.4.2 yamt
1033 1.2.4.2 yamt dmat->_ranges = mini2440_dma_ranges;
1034 1.2.4.2 yamt dmat->_nranges = 1;
1035 1.2.4.2 yamt
1036 1.2.4.2 yamt return dmat;
1037 1.2.4.2 yamt }
1038 1.2.4.2 yamt
1039 1.2.4.2 yamt void
1040 1.2.4.2 yamt mini2440_ksyms(struct btinfo_symtab *bi_symtab)
1041 1.2.4.2 yamt {
1042 1.2.4.2 yamt #if NKSYMS || defined(DDB) || defined(LKM)
1043 1.2.4.2 yamt extern int end;
1044 1.2.4.2 yamt
1045 1.2.4.2 yamt #ifdef DDB
1046 1.2.4.2 yamt db_machine_init();
1047 1.2.4.2 yamt #endif
1048 1.2.4.2 yamt if (bi_symtab == NULL) {
1049 1.2.4.2 yamt return;
1050 1.2.4.2 yamt }
1051 1.2.4.2 yamt #ifdef VERBOSE_INIT_ARM
1052 1.2.4.2 yamt printf("Got symbol table. nsym=%d, ssym=%p, esym=%p\n",
1053 1.2.4.2 yamt bi_symtab->nsym,
1054 1.2.4.2 yamt bi_symtab->ssym,
1055 1.2.4.2 yamt bi_symtab->esym);
1056 1.2.4.2 yamt #endif
1057 1.2.4.2 yamt
1058 1.2.4.2 yamt ksyms_addsyms_elf(bi_symtab->nsym,
1059 1.2.4.2 yamt (int*)bi_symtab->ssym,
1060 1.2.4.2 yamt (int*)bi_symtab->esym);
1061 1.2.4.2 yamt #endif
1062 1.2.4.2 yamt }
1063 1.2.4.2 yamt
1064 1.2.4.2 yamt void *
1065 1.2.4.2 yamt lookup_bootinfo(int type)
1066 1.2.4.2 yamt {
1067 1.2.4.2 yamt struct btinfo_common *bt;
1068 1.2.4.2 yamt struct btinfo_common *help = (struct btinfo_common *)bootinfo;
1069 1.2.4.2 yamt
1070 1.2.4.2 yamt if (help->next == 0)
1071 1.2.4.2 yamt return (NULL); /* bootinfo[] was not made */
1072 1.2.4.2 yamt do {
1073 1.2.4.2 yamt bt = help;
1074 1.2.4.2 yamt if (bt->type == type)
1075 1.2.4.2 yamt return (help);
1076 1.2.4.2 yamt help = (struct btinfo_common *)((char*)help + bt->next);
1077 1.2.4.2 yamt } while (bt->next &&
1078 1.2.4.2 yamt (size_t)help < (size_t)bootinfo + BOOTINFO_MAXSIZE);
1079 1.2.4.2 yamt
1080 1.2.4.2 yamt return (NULL);
1081 1.2.4.2 yamt }
1082 1.2.4.2 yamt
1083 1.2.4.2 yamt
1084 1.2.4.2 yamt extern char *booted_kernel;
1085 1.2.4.2 yamt
1086 1.2.4.2 yamt static void
1087 1.2.4.2 yamt mini2440_device_register(device_t dev, void *aux) {
1088 1.2.4.2 yamt if (device_class(dev) == DV_IFNET) {
1089 1.2.4.2 yamt #ifndef MEMORY_DISK_IS_ROOT
1090 1.2.4.2 yamt if (bi_rdev != NULL && device_is_a(dev, bi_rdev->devname) ) {
1091 1.2.4.2 yamt booted_device = dev;
1092 1.2.4.2 yamt rootfstype = MOUNT_NFS;
1093 1.2.4.2 yamt if( bi_path != NULL ) {
1094 1.2.4.2 yamt booted_kernel = bi_path->bootpath;
1095 1.2.4.2 yamt }
1096 1.2.4.2 yamt }
1097 1.2.4.2 yamt #endif
1098 1.2.4.2 yamt if (bi_net != NULL && device_is_a(dev, bi_net->devname)) {
1099 1.2.4.2 yamt prop_data_t pd;
1100 1.2.4.2 yamt pd = prop_data_create_data_nocopy(bi_net->mac_address, ETHER_ADDR_LEN);
1101 1.2.4.2 yamt KASSERT(pd != NULL);
1102 1.2.4.2 yamt if (prop_dictionary_set(device_properties(dev), "mac-address", pd) == false) {
1103 1.2.4.2 yamt printf("WARNING: Unable to set mac-address property for %s\n", device_xname(dev));
1104 1.2.4.2 yamt }
1105 1.2.4.2 yamt prop_object_release(pd);
1106 1.2.4.2 yamt bi_net = NULL;
1107 1.2.4.2 yamt }
1108 1.2.4.2 yamt }
1109 1.2.4.2 yamt #ifndef MEMORY_DISK_IS_ROOT
1110 1.2.4.2 yamt if (bi_rdev != NULL && device_class(dev) == DV_DISK
1111 1.2.4.2 yamt && device_is_a(dev, bi_rdev->devname)
1112 1.2.4.2 yamt && device_unit(dev) == bi_rdev->cookie) {
1113 1.2.4.2 yamt booted_device = dev;
1114 1.2.4.2 yamt booted_partition = bi_rdev->partition;
1115 1.2.4.2 yamt rootfstype = ROOT_FSTYPE_ANY;
1116 1.2.4.2 yamt if( bi_path != NULL ) {
1117 1.2.4.2 yamt booted_kernel = bi_path->bootpath;
1118 1.2.4.2 yamt }
1119 1.2.4.2 yamt }
1120 1.2.4.2 yamt #endif
1121 1.2.4.2 yamt }
1122