4 * Copyright (c) 2002, 2003
5 * Ichiro FUKUHARA <ichiro@ichiro.org>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Copyright (c) 1997,1998 Mark Brinicombe.
31 * Copyright (c) 1997,1998 Causality Limited.
32 * All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by Mark Brinicombe
45 * for the NetBSD Project.
46 * 4. The name of the company nor the name of the author may be used to
47 * endorse or promote products derived from this software without specific
48 * prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
51 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
52 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
54 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
55 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
56 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD$");
67 #include "opt_modular.h"
68 #include "opt_pmap_debug.h"
70 #include <sys/param.h>
71 #include <sys/device.h>
72 #include <sys/systm.h>
73 #include <sys/kernel.h>
76 #include <sys/msgbuf.h>
77 #include <sys/reboot.h>
78 #include <sys/termios.h>
79 #include <sys/ksyms.h>
81 #include <uvm/uvm_extern.h>
87 #if NKSYMS || defined(DDB) || defined(MODULAR)
88 #include <machine/db_machdep.h>
89 #include <ddb/db_sym.h>
90 #include <ddb/db_extern.h>
92 #error Must define DB_ELFSIZE!
94 #define ELFSIZE DB_ELFSIZE
95 #include <sys/exec_elf.h>
98 #include <machine/bootconfig.h>
99 #include <machine/bus.h>
100 #include <machine/cpu.h>
101 #include <machine/frame.h>
102 #include <arm/undefined.h>
104 #include <arm/arm32/machdep.h>
106 #include <arm/ixp12x0/ixp12x0reg.h>
107 #include <arm/ixp12x0/ixp12x0var.h>
108 #include <arm/ixp12x0/ixp12x0_comreg.h>
109 #include <arm/ixp12x0/ixp12x0_comvar.h>
110 #include <arm/ixp12x0/ixp12x0_pcireg.h>
112 #include <evbarm/ixm1200/ixm1200reg.h>
113 #include <evbarm/ixm1200/ixm1200var.h>
115 /* XXX for consinit related hacks */
116 #include <sys/conf.h>
118 void ixp12x0_reset(void) __attribute__((noreturn
));
120 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
121 #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
122 #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
125 * The range 0xc1000000 - 0xccffffff is available for kernel VM space
126 * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
128 #define KERNEL_VM_SIZE 0x0C000000
131 * Address to call from cpu_reset() to reset the machine.
132 * This is machine architecture dependant as it varies depending
133 * on where the ROM appears when you turn the MMU off.
136 u_int cpu_reset_address
= (u_int
) ixp12x0_reset
;
139 * Define the default console speed for the board.
142 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB)) | CS8) /* 8N1 */
145 #define CONSPEED B38400
148 #define CONADDR IXPCOM_UART_BASE
151 /* Define various stack sizes in pages */
152 #define IRQ_STACK_SIZE 1
153 #define ABT_STACK_SIZE 1
154 #define UND_STACK_SIZE 1
156 BootConfig bootconfig
; /* Boot config storage */
157 char *boot_args
= NULL
;
158 char *boot_file
= NULL
;
160 vm_offset_t physical_start
;
161 vm_offset_t physical_freestart
;
162 vm_offset_t physical_freeend
;
163 vm_offset_t physical_end
;
167 #ifndef PMAP_STATIC_L1S
168 int max_processes
= 64; /* Default number */
169 #endif /* !PMAP_STATIC_L1S */
171 /* Physical and virtual addresses for some global pages */
175 pv_addr_t kernelstack
;
177 vm_offset_t msgbufphys
;
179 extern u_int data_abort_handler_address
;
180 extern u_int prefetch_abort_handler_address
;
181 extern u_int undefined_handler_address
;
185 extern int pmap_debug_level
;
186 #endif /* PMAP_DEBUG */
188 #define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */
189 #define KERNEL_PT_KERNEL 1 /* Page table for mapping kernel */
190 #define KERNEL_PT_KERNEL_NUM 2
191 #define KERNEL_PT_IO (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
192 /* Page table for mapping IO */
193 #define KERNEL_PT_VMDATA (KERNEL_PT_IO + 1)
194 /* Page tables for mapping kernel VM */
195 #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
196 #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
198 pv_addr_t kernel_pt_table
[NUM_KERNEL_PTS
];
201 #define CPU_IXP12X0_CACHE_CLEAN_SIZE (0x4000 * 2)
202 extern unsigned int ixp12x0_cache_clean_addr
;
203 extern unsigned int ixp12x0_cache_clean_size
;
204 static vaddr_t ixp12x0_cc_base
;
205 #endif /* CPU_IXP12X0 */
210 u_int
cpu_get_control(void);
212 void ixdp_ixp12x0_cc_setup(void);
215 * void cpu_reboot(int howto, char *bootstr)
219 * Deal with any syncing, unmounting, dumping and shutdown hooks,
220 * then reset the CPU.
224 cpu_reboot(int howto
, char *bootstr
)
227 * If we are still cold then hit the air brakes
228 * and crash to earth fast
232 pmf_system_shutdown(boothowto
);
233 printf("Halted while still in the ICE age.\n");
234 printf("The operating system has halted.\n");
235 printf("Please press any key to reboot.\n\n");
237 printf("rebooting...\n");
241 /* Disable console buffering */
245 * If RB_NOSYNC was not specified sync the discs.
246 * Note: Unless cold is set to 1 here, syslogd will die during the unmount.
247 * It looks like syslogd is getting woken up only to find that it cannot
248 * page part of the binary in as the filesystem has been unmounted.
250 if (!(howto
& RB_NOSYNC
))
253 /* Say NO to interrupts */
256 /* Do a dump if requested. */
257 if ((howto
& (RB_DUMP
| RB_HALT
)) == RB_DUMP
)
260 /* Run any shutdown hooks */
263 pmf_system_shutdown(boothowto
);
265 /* Make sure IRQ's are disabled */
268 if (howto
& RB_HALT
) {
269 printf("The operating system has halted.\n");
270 printf("Please press any key to reboot.\n\n");
274 printf("rebooting...\n");
276 /* all interrupts are disabled */
277 disable_interrupts(I32_bit
);
281 /* ...and if that didn't work, just croak. */
282 printf("RESET FAILED!\n");
286 /* Static device mappings. */
287 static const struct pmap_devmap ixm1200_devmap
[] = {
288 /* StrongARM System and Peripheral Registers */
293 VM_PROT_READ
|VM_PROT_WRITE
,
296 /* PCI Registers Accessible Through StrongARM Core */
298 IXP12X0_PCI_VBASE
, IXP12X0_PCI_HWBASE
,
300 VM_PROT_READ
|VM_PROT_WRITE
,
303 /* PCI Registers Accessible Through I/O Cycle Access */
305 IXP12X0_PCI_IO_VBASE
, IXP12X0_PCI_IO_HWBASE
,
307 VM_PROT_READ
|VM_PROT_WRITE
,
310 /* PCI Type0 Configuration Space */
312 IXP12X0_PCI_TYPE0_VBASE
, IXP12X0_PCI_TYPE0_HWBASE
,
313 IXP12X0_PCI_TYPE0_SIZE
,
314 VM_PROT_READ
|VM_PROT_WRITE
,
317 /* PCI Type1 Configuration Space */
319 IXP12X0_PCI_TYPE1_VBASE
, IXP12X0_PCI_TYPE1_HWBASE
,
320 IXP12X0_PCI_TYPE1_SIZE
,
321 VM_PROT_READ
|VM_PROT_WRITE
,
334 * Initial entry point on startup. This gets called before main() is
336 * It should be responsible for setting up everything that must be
337 * in place when main is called.
339 * Taking a copy of the boot configuration structure.
340 * Initialising the physical console so characters can be printed.
341 * Setting up page tables for the kernel
342 * Relocating the kernel to the bottom of physical memory
349 u_int kerneldatasize
, symbolsize
;
352 #if NKSYMS || defined(DDB) || defined(MODULAR)
357 * Since we map v0xf0000000 == p0x90000000, it's possible for
358 * us to initialize the console now.
362 #ifdef VERBOSE_INIT_ARM
363 /* Talk to the user */
364 printf("\nNetBSD/evbarm (IXM1200) booting ...\n");
368 * Heads up ... Setup the CPU / MMU / TLB functions
371 panic("CPU not recognized!");
373 /* XXX overwrite bootconfig to hardcoded values */
374 bootconfig
.dram
[0].address
= 0xc0000000;
375 bootconfig
.dram
[0].pages
= 0x10000000 / PAGE_SIZE
; /* SDRAM 256MB */
376 bootconfig
.dramblocks
= 1;
378 kerneldatasize
= (u_int32_t
)&end
- (u_int32_t
)KERNEL_TEXT_BASE
;
386 #if NKSYMS || defined(DDB) || defined(MODULAR)
387 if (! memcmp(&end
, "\177ELF", 4)) {
388 sh
= (Elf_Shdr
*)((char *)&end
+ ((Elf_Ehdr
*)&end
)->e_shoff
);
389 loop
= ((Elf_Ehdr
*)&end
)->e_shnum
;
390 for(; loop
; loop
--, sh
++)
391 if (sh
->sh_offset
> 0 &&
392 (sh
->sh_offset
+ sh
->sh_size
) > symbolsize
)
393 symbolsize
= sh
->sh_offset
+ sh
->sh_size
;
396 #ifdef VERBOSE_INIT_ARM
397 printf("kernsize=0x%x\n", kerneldatasize
);
399 kerneldatasize
+= symbolsize
;
400 kerneldatasize
= ((kerneldatasize
- 1) & ~(PAGE_SIZE
* 4 - 1)) + PAGE_SIZE
* 8;
403 * Set up the variables that define the availablilty of physcial
406 physical_start
= bootconfig
.dram
[0].address
;
407 physical_end
= physical_start
+ (bootconfig
.dram
[0].pages
* PAGE_SIZE
);
409 physical_freestart
= physical_start
410 + (KERNEL_TEXT_BASE
- KERNEL_BASE
) + kerneldatasize
;
411 physical_freeend
= physical_end
;
413 physmem
= (physical_end
- physical_start
) / PAGE_SIZE
;
415 freemempos
= 0xc0000000;
417 #ifdef VERBOSE_INIT_ARM
418 printf("Allocating page tables\n");
420 free_pages
= (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
422 #ifdef VERBOSE_INIT_ARM
423 printf("CP15 Register1 = 0x%08x\n", cpu_get_control());
424 printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
425 physical_freestart
, free_pages
, free_pages
);
426 printf("physical_start = 0x%08lx, physical_end = 0x%08lx\n",
427 physical_start
, physical_end
);
430 /* Define a macro to simplify memory allocation */
431 #define valloc_pages(var, np) \
432 alloc_pages((var).pv_pa, (np)); \
433 (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
434 #define alloc_pages(var, np) \
435 (var) = freemempos; \
436 memset((char *)(var), 0, ((np) * PAGE_SIZE)); \
437 freemempos += (np) * PAGE_SIZE;
440 for (loop
= 0; loop
<= NUM_KERNEL_PTS
; ++loop
) {
441 /* Are we 16KB aligned for an L1 ? */
442 if (((physical_freeend
- L1_TABLE_SIZE
) & (L1_TABLE_SIZE
- 1)) == 0
443 && kernel_l1pt
.pv_pa
== 0) {
444 valloc_pages(kernel_l1pt
, L1_TABLE_SIZE
/ PAGE_SIZE
);
446 valloc_pages(kernel_pt_table
[loop1
],
447 L2_TABLE_SIZE
/ PAGE_SIZE
);
453 /* This should never be able to happen but better confirm that. */
454 if (!kernel_l1pt
.pv_pa
|| (kernel_l1pt
.pv_pa
& (L1_TABLE_SIZE
-1)) != 0)
455 panic("initarm: Failed to align the kernel page directory");
459 * Allocate a page for the system page mapped to V0x00000000
460 * This page will just contain the system vectors and can be
461 * shared by all processes.
463 alloc_pages(systempage
.pv_pa
, 1);
465 /* Allocate stacks for all modes */
466 valloc_pages(irqstack
, IRQ_STACK_SIZE
);
467 valloc_pages(abtstack
, ABT_STACK_SIZE
);
468 valloc_pages(undstack
, UND_STACK_SIZE
);
469 valloc_pages(kernelstack
, UPAGES
);
471 #ifdef VERBOSE_INIT_ARM
472 printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack
.pv_pa
, irqstack
.pv_va
);
473 printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack
.pv_pa
, abtstack
.pv_va
);
474 printf("UND stack: p0x%08lx v0x%08lx\n", undstack
.pv_pa
, undstack
.pv_va
);
475 printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack
.pv_pa
, kernelstack
.pv_va
);
478 alloc_pages(msgbufphys
, round_page(MSGBUFSIZE
) / PAGE_SIZE
);
482 * XXX totally stuffed hack to work round problems introduced
483 * in recent versions of the pmap code. Due to the calls used there
484 * we cannot allocate virtual memory during bootstrap.
487 alloc_pages(ixp12x0_cc_base
, 1);
488 if (! (ixp12x0_cc_base
& (CPU_IXP12X0_CACHE_CLEAN_SIZE
- 1)))
493 alloc_pages(dummy
, CPU_IXP12X0_CACHE_CLEAN_SIZE
/ PAGE_SIZE
- 1);
495 ixp12x0_cache_clean_addr
= ixp12x0_cc_base
;
496 ixp12x0_cache_clean_size
= CPU_IXP12X0_CACHE_CLEAN_SIZE
/ 2;
497 #endif /* CPU_IXP12X0 */
499 #ifdef VERBOSE_INIT_ARM
500 printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt
.pv_pa
);
504 * Now we start construction of the L1 page table
505 * We start by mapping the L2 page tables into the L1.
506 * This means that we can replace L1 mappings later on if necessary
508 l1pagetable
= kernel_l1pt
.pv_pa
;
510 /* Map the L2 pages tables in the L1 page table */
511 pmap_link_l2pt(l1pagetable
, ARM_VECTORS_HIGH
& ~(0x00400000 - 1),
512 &kernel_pt_table
[KERNEL_PT_SYS
]);
514 for (loop
= 0; loop
< KERNEL_PT_KERNEL_NUM
; loop
++)
515 pmap_link_l2pt(l1pagetable
, KERNEL_BASE
+ loop
* 0x00400000,
516 &kernel_pt_table
[KERNEL_PT_KERNEL
+ loop
]);
518 for (loop
= 0; loop
< KERNEL_PT_VMDATA_NUM
; loop
++)
519 pmap_link_l2pt(l1pagetable
, KERNEL_VM_BASE
+ loop
* 0x00400000,
520 &kernel_pt_table
[KERNEL_PT_VMDATA
+ loop
]);
522 /* update the top of the kernel VM */
524 KERNEL_VM_BASE
+ (KERNEL_PT_VMDATA_NUM
* 0x00400000);
526 pmap_link_l2pt(l1pagetable
, IXP12X0_IO_VBASE
,
527 &kernel_pt_table
[KERNEL_PT_IO
]);
529 #ifdef VERBOSE_INIT_ARM
530 printf("Mapping kernel\n");
534 /* Now we fill in the L2 pagetable for the kernel code/data */
536 extern char etext
[], _end
[];
537 size_t textsize
= (uintptr_t) etext
- KERNEL_TEXT_BASE
;
538 size_t totalsize
= (uintptr_t) _end
- KERNEL_TEXT_BASE
;
541 textsize
= (textsize
+ PGOFSET
) & ~PGOFSET
;
542 totalsize
= (totalsize
+ PGOFSET
) & ~PGOFSET
;
544 logical
= 0x00200000; /* offset of kernel in RAM */
546 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
547 physical_start
+ logical
, textsize
,
548 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
549 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
550 physical_start
+ logical
, totalsize
- textsize
,
551 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
555 pmap_map_chunk(l1pagetable
, KERNEL_TEXT_BASE
,
556 KERNEL_TEXT_BASE
, kerneldatasize
,
557 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
561 #ifdef VERBOSE_INIT_ARM
562 printf("Constructing L2 page tables\n");
565 /* Map the stack pages */
566 pmap_map_chunk(l1pagetable
, irqstack
.pv_va
, irqstack
.pv_pa
,
567 IRQ_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
568 pmap_map_chunk(l1pagetable
, abtstack
.pv_va
, abtstack
.pv_pa
,
569 ABT_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
570 pmap_map_chunk(l1pagetable
, undstack
.pv_va
, undstack
.pv_pa
,
571 UND_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
572 pmap_map_chunk(l1pagetable
, kernelstack
.pv_va
, kernelstack
.pv_pa
,
573 UPAGES
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
575 pmap_map_chunk(l1pagetable
, kernel_l1pt
.pv_va
, kernel_l1pt
.pv_pa
,
576 L1_TABLE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
578 for (loop
= 0; loop
< NUM_KERNEL_PTS
; ++loop
) {
579 pmap_map_chunk(l1pagetable
, kernel_pt_table
[loop
].pv_va
,
580 kernel_pt_table
[loop
].pv_pa
, L2_TABLE_SIZE
,
581 VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
584 /* Map the vector page. */
585 pmap_map_entry(l1pagetable
, ARM_VECTORS_HIGH
, systempage
.pv_pa
,
586 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
588 #ifdef VERBOSE_INIT_ARM
589 printf("systempage (vector page): p0x%08lx v0x%08lx\n",
590 systempage
.pv_pa
, vector_page
);
593 /* Map the statically mapped devices. */
594 pmap_devmap_bootstrap(l1pagetable
, ixm1200_devmap
);
596 #ifdef VERBOSE_INIT_ARM
601 * Map the Dcache Flush page.
602 * Hw Ref Manual 3.2.4.5 Software Dcache Flush
604 pmap_map_chunk(l1pagetable
, ixp12x0_cache_clean_addr
, 0xe0000000,
605 CPU_IXP12X0_CACHE_CLEAN_SIZE
, VM_PROT_READ
, PTE_CACHE
);
608 * Now we have the real page tables in place so we can switch to them.
609 * Once this is done we will be running with the REAL kernel page
614 cpu_domains((DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2)) | DOMAIN_CLIENT
);
615 cpu_setttb(kernel_l1pt
.pv_pa
);
617 cpu_domains(DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2));
620 * Moved here from cpu_startup() as data_abort_handler() references
623 uvm_lwp_setuarea(&lwp0
, kernelstack
.pv_va
);
626 * We must now clean the cache again....
627 * Cleaning may be done by reading new data to displace any
628 * dirty data in the cache. This will have happened in cpu_setttb()
629 * but since we are boot strapping the addresses used for the read
630 * may have just been remapped and thus the cache could be out
631 * of sync. A re-clean after the switch will cure this.
632 * After booting there are no gross reloations of the kernel thus
633 * this problem will not occur after initarm().
635 cpu_idcache_wbinv_all();
637 arm32_vector_init(ARM_VECTORS_HIGH
, ARM_VEC_ALL
);
640 * Pages were allocated during the secondary bootstrap for the
641 * stacks for different CPU modes.
642 * We must now set the r13 registers in the different CPU modes to
643 * point to these stacks.
644 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
645 * of the stack memory.
647 #ifdef VERBOSE_INIT_ARM
648 printf("init subsystems: stacks ");
651 set_stackptr(PSR_IRQ32_MODE
,
652 irqstack
.pv_va
+ IRQ_STACK_SIZE
* PAGE_SIZE
);
653 set_stackptr(PSR_ABT32_MODE
,
654 abtstack
.pv_va
+ ABT_STACK_SIZE
* PAGE_SIZE
);
655 set_stackptr(PSR_UND32_MODE
,
656 undstack
.pv_va
+ UND_STACK_SIZE
* PAGE_SIZE
);
658 if (pmap_debug_level
>= 0)
659 printf("kstack V%08lx P%08lx\n", kernelstack
.pv_va
,
661 #endif /* PMAP_DEBUG */
664 * Well we should set a data abort handler.
665 * Once things get going this will change as we will need a proper
666 * handler. Until then we will use a handler that just panics but
668 * Initialisation of the vetcors will just panic on a data abort.
669 * This just fills in a slightly better one.
671 #ifdef VERBOSE_INIT_ARM
674 data_abort_handler_address
= (u_int
)data_abort_handler
;
675 prefetch_abort_handler_address
= (u_int
)prefetch_abort_handler
;
676 undefined_handler_address
= (u_int
)undefinedinstruction_bounce
;
677 #ifdef VERBOSE_INIT_ARM
678 printf("\ndata_abort_handler_address = %08x\n", data_abort_handler_address
);
679 printf("prefetch_abort_handler_address = %08x\n", prefetch_abort_handler_address
);
680 printf("undefined_handler_address = %08x\n", undefined_handler_address
);
683 /* Initialise the undefined instruction handlers */
684 #ifdef VERBOSE_INIT_ARM
685 printf("undefined ");
689 /* Load memory into UVM. */
690 #ifdef VERBOSE_INIT_ARM
693 uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
694 uvm_page_physload(atop(physical_freestart
), atop(physical_freeend
),
695 atop(physical_freestart
), atop(physical_freeend
),
696 VM_FREELIST_DEFAULT
);
698 /* Boot strap pmap telling it where the kernel page table is */
699 #ifdef VERBOSE_INIT_ARM
702 pmap_bootstrap(KERNEL_VM_BASE
, KERNEL_VM_BASE
+ KERNEL_VM_SIZE
);
704 /* Setup the IRQ system */
705 #ifdef VERBOSE_INIT_ARM
710 #ifdef VERBOSE_INIT_ARM
714 #ifdef VERBOSE_INIT_ARM
715 printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
716 physical_freestart
, free_pages
, free_pages
);
717 printf("freemempos=%08lx\n", freemempos
);
718 printf("switching to new L1 page table @%#lx... \n", kernel_l1pt
.pv_pa
);
722 #ifdef VERBOSE_INIT_ARM
723 printf("consinit \n");
726 ixdp_ixp12x0_cc_setup();
728 #ifdef VERBOSE_INIT_ARM
729 printf("bootstrap done.\n");
732 #if NKSYMS || defined(DDB) || defined(MODULAR)
733 ksyms_addsyms_elf(symbolsize
, ((int *)&end
), ((char *)&end
) + symbolsize
);
738 if (boothowto
& RB_KDB
)
742 /* We return the new stack pointer address */
743 return(kernelstack
.pv_va
+ USPACE_SVC_STACK_TOP
);
749 static int consinit_called
= 0;
751 if (consinit_called
!= 0)
756 pmap_devmap_register(ixm1200_devmap
);
758 if (ixpcomcnattach(&ixp12x0_bs_tag
,
759 IXPCOM_UART_HWBASE
, IXPCOM_UART_VBASE
,
761 panic("can't init serial console @%lx", IXPCOM_UART_HWBASE
);
765 * For optimal cache cleaning we need two 16K banks of
766 * virtual address space that NOTHING else will access
767 * and then we alternate the cache cleaning between the
769 * The cache cleaning code requires requires 2 banks aligned
770 * on total size boundry so the banks can be alternated by
771 * eorring the size bit (assumes the bank size is a power of 2)
774 ixdp_ixp12x0_cc_setup(void)
780 (void) pmap_extract(pmap_kernel(), KERNEL_TEXT_BASE
, &kaddr
);
781 for (loop
= 0; loop
< CPU_IXP12X0_CACHE_CLEAN_SIZE
; loop
+= PAGE_SIZE
) {
782 pte
= vtopte(ixp12x0_cc_base
+ loop
);
783 *pte
= L2_S_PROTO
| kaddr
|
784 L2_S_PROT(PTE_KERNEL
, VM_PROT_READ
) | pte_l2_s_cache_mode
;
787 ixp12x0_cache_clean_addr
= ixp12x0_cc_base
;
788 ixp12x0_cache_clean_size
= CPU_IXP12X0_CACHE_CLEAN_SIZE
/ 2;