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