4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * Copyright (c) 1997,1998 Mark Brinicombe.
40 * Copyright (c) 1997,1998 Causality Limited.
41 * All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by Mark Brinicombe
54 * for the NetBSD Project.
55 * 4. The name of the company nor the name of the author may be used to
56 * endorse or promote products derived from this software without specific
57 * prior written permission.
59 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
60 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
61 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
63 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
64 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
65 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 * Machine dependant functions for kernel setup for the ADI Engineering
72 * BRH i80200 evaluation platform.
75 #include <sys/cdefs.h>
76 __KERNEL_RCSID(0, "$NetBSD$");
79 #include "opt_pmap_debug.h"
81 #include <sys/param.h>
82 #include <sys/device.h>
83 #include <sys/systm.h>
84 #include <sys/kernel.h>
87 #include <sys/msgbuf.h>
88 #include <sys/reboot.h>
89 #include <sys/termios.h>
90 #include <sys/ksyms.h>
92 #include <uvm/uvm_extern.h>
96 #include <machine/db_machdep.h>
97 #include <ddb/db_sym.h>
98 #include <ddb/db_extern.h>
100 #include <machine/bootconfig.h>
101 #include <machine/bus.h>
102 #include <machine/cpu.h>
103 #include <machine/frame.h>
104 #include <arm/undefined.h>
106 #include <arm/arm32/machdep.h>
108 #include <arm/xscale/i80200reg.h>
109 #include <arm/xscale/i80200var.h>
111 #include <dev/pci/ppbreg.h>
113 #include <arm/xscale/beccreg.h>
114 #include <arm/xscale/beccvar.h>
116 #include <evbarm/adi_brh/brhreg.h>
117 #include <evbarm/adi_brh/brhvar.h>
118 #include <evbarm/adi_brh/obiovar.h>
122 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
123 #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
124 #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
127 * The range 0xc1000000 - 0xccffffff is available for kernel VM space
128 * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
130 #define KERNEL_VM_SIZE 0x0C000000
133 * Address to call from cpu_reset() to reset the machine.
134 * This is machine architecture dependant as it varies depending
135 * on where the ROM appears when you turn the MMU off.
138 u_int cpu_reset_address
= 0x00000000;
140 /* Define various stack sizes in pages */
141 #define IRQ_STACK_SIZE 1
142 #define ABT_STACK_SIZE 1
143 #define UND_STACK_SIZE 1
145 BootConfig bootconfig
; /* Boot config storage */
146 char *boot_args
= NULL
;
147 char *boot_file
= NULL
;
149 vm_offset_t physical_start
;
150 vm_offset_t physical_freestart
;
151 vm_offset_t physical_freeend
;
152 vm_offset_t physical_end
;
156 #ifndef PMAP_STATIC_L1S
157 int max_processes
= 64; /* Default number */
158 #endif /* !PMAP_STATIC_L1S */
160 /* Physical and virtual addresses for some global pages */
164 pv_addr_t kernelstack
;
165 pv_addr_t minidataclean
;
167 vm_offset_t msgbufphys
;
169 extern u_int data_abort_handler_address
;
170 extern u_int prefetch_abort_handler_address
;
171 extern u_int undefined_handler_address
;
174 extern int pmap_debug_level
;
177 #define KERNEL_PT_SYS 0 /* L2 table for mapping zero page */
179 #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
180 #define KERNEL_PT_KERNEL_NUM 2
182 /* L2 tables for mapping kernel VM */
183 #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
184 #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
185 #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
187 pv_addr_t kernel_pt_table
[NUM_KERNEL_PTS
];
195 #include <dev/ic/comreg.h>
196 #include <dev/ic/comvar.h>
200 * Define the default console speed for the board. This is generally
201 * what the firmware provided with the board defaults to.
204 #define CONSPEED B57600
205 #endif /* ! CONSPEED */
212 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
215 int comcnspeed
= CONSPEED
;
216 int comcnmode
= CONMODE
;
217 int comcnunit
= CONUNIT
;
220 * void cpu_reboot(int howto, char *bootstr)
224 * Deal with any syncing, unmounting, dumping and shutdown hooks,
225 * then reset the CPU.
228 cpu_reboot(int howto
, char *bootstr
)
232 * If we are still cold then hit the air brakes
233 * and crash to earth fast
237 pmf_system_shutdown(boothowto
);
238 printf("The operating system has halted.\n");
239 printf("Please press any key to reboot.\n\n");
241 printf("rebooting...\n");
245 /* Disable console buffering */
248 * If RB_NOSYNC was not specified sync the discs.
249 * Note: Unless cold is set to 1 here, syslogd will die during the
250 * unmount. It looks like syslogd is getting woken up only to find
251 * that it cannot page part of the binary in as the filesystem has
254 if (!(howto
& RB_NOSYNC
))
257 /* Say NO to interrupts */
260 /* Do a dump if requested. */
261 if ((howto
& (RB_DUMP
| RB_HALT
)) == RB_DUMP
)
264 /* Run any shutdown hooks */
267 pmf_system_shutdown(boothowto
);
269 /* Make sure IRQ's are disabled */
272 if (howto
& RB_HALT
) {
274 printf("The operating system has halted.\n");
275 printf("Please press any key to reboot.\n\n");
279 printf("rebooting...\n\r");
284 /* Static device mappings. */
285 static const struct pmap_devmap brh_devmap
[] = {
290 VM_PROT_READ
|VM_PROT_WRITE
,
297 VM_PROT_READ
|VM_PROT_WRITE
,
304 VM_PROT_READ
|VM_PROT_WRITE
,
311 VM_PROT_READ
|VM_PROT_WRITE
,
318 VM_PROT_READ
|VM_PROT_WRITE
,
325 VM_PROT_READ
|VM_PROT_WRITE
,
332 VM_PROT_READ
|VM_PROT_WRITE
,
339 VM_PROT_READ
|VM_PROT_WRITE
,
352 brh_hardclock_hook(void)
354 static int snakefreq
;
356 if ((snakefreq
++ & 15) == 0)
363 * Initial entry point on startup. This gets called before main() is
365 * It should be responsible for setting up everything that must be
366 * in place when main is called.
368 * Taking a copy of the boot configuration structure.
369 * Initialising the physical console so characters can be printed.
370 * Setting up page tables for the kernel
371 * Relocating the kernel to the bottom of physical memory
376 extern vaddr_t xscale_cache_clean_addr
;
378 extern vsize_t xscale_minidata_clean_size
;
387 * Clear out the 7-segment display. Whee, the first visual
388 * indication that we're running kernel code.
393 * Since we have mapped the on-board devices at their permanent
394 * locations already, it is possible for us to initialize
399 #ifdef VERBOSE_INIT_ARM
400 /* Talk to the user */
401 printf("\nNetBSD/evbarm (ADI BRH) booting ...\n");
404 /* Calibrate the delay loop. */
405 becc_hardclock_hook
= brh_hardclock_hook
;
408 * Heads up ... Setup the CPU / MMU / TLB functions
411 panic("CPU not recognized!");
414 * We are currently running with the MMU enabled and the
415 * entire address space mapped VA==PA. Memory conveniently
416 * starts at 0xc0000000, which is where we want it. Certain
417 * on-board devices have already been mapped where we want
418 * them to be. There is an L1 page table at 0xc0004000.
424 * Memory always starts at 0xc0000000 on a BRH, and the
425 * memory size is always 128M.
427 memstart
= 0xc0000000UL
;
428 memsize
= (128UL * 1024 * 1024);
430 #ifdef VERBOSE_INIT_ARM
431 printf("initarm: Configuring system ...\n");
434 /* Fake bootconfig structure for the benefit of pmap.c */
435 /* XXX must make the memory description h/w independent */
436 bootconfig
.dramblocks
= 1;
437 bootconfig
.dram
[0].address
= memstart
;
438 bootconfig
.dram
[0].pages
= memsize
/ PAGE_SIZE
;
441 * Set up the variables that define the availablilty of
442 * physical memory. For now, we're going to set
443 * physical_freestart to 0xc0200000 (where the kernel
444 * was loaded), and allocate the memory we need downwards.
445 * If we get too close to the L1 table that we set up, we
446 * will panic. We will update physical_freestart and
447 * physical_freeend later to reflect what pmap_bootstrap()
450 * XXX pmap_bootstrap() needs an enema.
452 physical_start
= bootconfig
.dram
[0].address
;
453 physical_end
= physical_start
+ (bootconfig
.dram
[0].pages
* PAGE_SIZE
);
455 physical_freestart
= 0xc0009000UL
;
456 physical_freeend
= 0xc0200000UL
;
458 #ifdef VERBOSE_INIT_ARM
459 /* Tell the user about the memory */
460 printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem
,
461 physical_start
, physical_end
- 1);
465 * Okay, the kernel starts 2MB in from the bottom of physical
466 * memory. We are going to allocate our bootstrap pages downwards
469 * We need to allocate some fixed page tables to get the kernel
470 * going. We allocate one page directory and a number of page
471 * tables and store the physical addresses in the kernel_pt_table
474 * The kernel page directory must be on a 16K boundary. The page
475 * tables must be on 4K boundaries. What we do is allocate the
476 * page directory on the first 16K boundary that we encounter, and
477 * the page tables on 4K boundaries otherwise. Since we allocate
478 * at least 3 L2 page tables, we are guaranteed to encounter at
479 * least one 16K aligned region.
482 #ifdef VERBOSE_INIT_ARM
483 printf("Allocating page tables\n");
486 free_pages
= (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
488 #ifdef VERBOSE_INIT_ARM
489 printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
490 physical_freestart
, free_pages
, free_pages
);
493 /* Define a macro to simplify memory allocation */
494 #define valloc_pages(var, np) \
495 alloc_pages((var).pv_pa, (np)); \
496 (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
498 #define alloc_pages(var, np) \
499 physical_freeend -= ((np) * PAGE_SIZE); \
500 if (physical_freeend < physical_freestart) \
501 panic("initarm: out of memory"); \
502 (var) = physical_freeend; \
503 free_pages -= (np); \
504 memset((char *)(var), 0, ((np) * PAGE_SIZE));
507 for (loop
= 0; loop
<= NUM_KERNEL_PTS
; ++loop
) {
508 /* Are we 16KB aligned for an L1 ? */
509 if (((physical_freeend
- L1_TABLE_SIZE
) & (L1_TABLE_SIZE
- 1)) == 0
510 && kernel_l1pt
.pv_pa
== 0) {
511 valloc_pages(kernel_l1pt
, L1_TABLE_SIZE
/ PAGE_SIZE
);
513 valloc_pages(kernel_pt_table
[loop1
],
514 L2_TABLE_SIZE
/ PAGE_SIZE
);
519 /* This should never be able to happen but better confirm that. */
520 if (!kernel_l1pt
.pv_pa
|| (kernel_l1pt
.pv_pa
& (L1_TABLE_SIZE
-1)) != 0)
521 panic("initarm: Failed to align the kernel page directory\n");
524 * Allocate a page for the system page mapped to V0x00000000
525 * This page will just contain the system vectors and can be
526 * shared by all processes.
528 alloc_pages(systempage
.pv_pa
, 1);
530 /* Allocate stacks for all modes */
531 valloc_pages(irqstack
, IRQ_STACK_SIZE
);
532 valloc_pages(abtstack
, ABT_STACK_SIZE
);
533 valloc_pages(undstack
, UND_STACK_SIZE
);
534 valloc_pages(kernelstack
, UPAGES
);
536 /* Allocate enough pages for cleaning the Mini-Data cache. */
537 KASSERT(xscale_minidata_clean_size
<= PAGE_SIZE
);
538 valloc_pages(minidataclean
, 1);
540 #ifdef VERBOSE_INIT_ARM
541 printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack
.pv_pa
,
543 printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack
.pv_pa
,
545 printf("UND stack: p0x%08lx v0x%08lx\n", undstack
.pv_pa
,
547 printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack
.pv_pa
,
552 * XXX Defer this to later so that we can reclaim the memory
553 * XXX used by the RedBoot page tables.
555 alloc_pages(msgbufphys
, round_page(MSGBUFSIZE
) / PAGE_SIZE
);
558 * Ok we have allocated physical pages for the primary kernel
562 #ifdef VERBOSE_INIT_ARM
563 printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt
.pv_pa
);
567 * Now we start construction of the L1 page table
568 * We start by mapping the L2 page tables into the L1.
569 * This means that we can replace L1 mappings later on if necessary
571 l1pagetable
= kernel_l1pt
.pv_pa
;
573 /* Map the L2 pages tables in the L1 page table */
574 pmap_link_l2pt(l1pagetable
, ARM_VECTORS_HIGH
& ~(0x00400000 - 1),
575 &kernel_pt_table
[KERNEL_PT_SYS
]);
576 for (loop
= 0; loop
< KERNEL_PT_KERNEL_NUM
; loop
++)
577 pmap_link_l2pt(l1pagetable
, KERNEL_BASE
+ loop
* 0x00400000,
578 &kernel_pt_table
[KERNEL_PT_KERNEL
+ loop
]);
579 for (loop
= 0; loop
< KERNEL_PT_VMDATA_NUM
; loop
++)
580 pmap_link_l2pt(l1pagetable
, KERNEL_VM_BASE
+ loop
* 0x00400000,
581 &kernel_pt_table
[KERNEL_PT_VMDATA
+ loop
]);
583 /* update the top of the kernel VM */
585 KERNEL_VM_BASE
+ (KERNEL_PT_VMDATA_NUM
* 0x00400000);
587 #ifdef VERBOSE_INIT_ARM
588 printf("Mapping kernel\n");
591 /* Now we fill in the L2 pagetable for the kernel static code/data */
593 extern char etext
[], _end
[];
594 size_t textsize
= (uintptr_t) etext
- KERNEL_TEXT_BASE
;
595 size_t totalsize
= (uintptr_t) _end
- KERNEL_TEXT_BASE
;
598 textsize
= (textsize
+ PGOFSET
) & ~PGOFSET
;
599 totalsize
= (totalsize
+ PGOFSET
) & ~PGOFSET
;
601 logical
= 0x00200000; /* offset of kernel in RAM */
603 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
604 physical_start
+ logical
, textsize
,
605 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
606 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
607 physical_start
+ logical
, totalsize
- textsize
,
608 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
611 #ifdef VERBOSE_INIT_ARM
612 printf("Constructing L2 page tables\n");
615 /* Map the stack pages */
616 pmap_map_chunk(l1pagetable
, irqstack
.pv_va
, irqstack
.pv_pa
,
617 IRQ_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
618 pmap_map_chunk(l1pagetable
, abtstack
.pv_va
, abtstack
.pv_pa
,
619 ABT_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
620 pmap_map_chunk(l1pagetable
, undstack
.pv_va
, undstack
.pv_pa
,
621 UND_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
622 pmap_map_chunk(l1pagetable
, kernelstack
.pv_va
, kernelstack
.pv_pa
,
623 UPAGES
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
625 pmap_map_chunk(l1pagetable
, kernel_l1pt
.pv_va
, kernel_l1pt
.pv_pa
,
626 L1_TABLE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
628 for (loop
= 0; loop
< NUM_KERNEL_PTS
; ++loop
) {
629 pmap_map_chunk(l1pagetable
, kernel_pt_table
[loop
].pv_va
,
630 kernel_pt_table
[loop
].pv_pa
, L2_TABLE_SIZE
,
631 VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
634 /* Map the Mini-Data cache clean area. */
635 xscale_setup_minidata(l1pagetable
, minidataclean
.pv_va
,
636 minidataclean
.pv_pa
);
638 /* Map the vector page. */
639 pmap_map_entry(l1pagetable
, ARM_VECTORS_HIGH
, systempage
.pv_pa
,
640 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
642 /* Map the statically mapped devices. */
643 pmap_devmap_bootstrap(l1pagetable
, brh_devmap
);
646 * Give the XScale global cache clean code an appropriately
647 * sized chunk of unmapped VA space starting at 0xff500000
648 * (our device mappings end before this address).
650 xscale_cache_clean_addr
= 0xff500000U
;
653 * Now we have the real page tables in place so we can switch to them.
654 * Once this is done we will be running with the REAL kernel page
659 #ifdef VERBOSE_INIT_ARM
660 printf("switching to new L1 page table @%#lx...", kernel_l1pt
.pv_pa
);
662 cpu_domains((DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2)) | DOMAIN_CLIENT
);
663 cpu_setttb(kernel_l1pt
.pv_pa
);
665 cpu_domains(DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2));
668 * Move from cpu_startup() as data_abort_handler() references
669 * this during uvm init
671 uvm_lwp_setuarea(&lwp0
, kernelstack
.pv_va
);
673 #ifdef VERBOSE_INIT_ARM
677 #ifdef VERBOSE_INIT_ARM
678 printf("bootstrap done.\n");
682 * Inform the BECC code where the BECC is mapped.
684 becc_vaddr
= BRH_BECC_VBASE
;
687 * Now that we have becc_vaddr set, calibrate delay.
689 becc_calibrate_delay();
692 * BECC <= Rev7 can only address 64M through the inbound
693 * PCI windows. Limit memory to 64M on those revs. (This
694 * problem was fixed in Rev8 of the BECC; get an FPGA upgrade.)
697 vaddr_t va
= BRH_PCI_CONF_VBASE
| (1U << BECC_IDSEL_BIT
) |
701 reg
= *(volatile uint32_t *) va
;
702 becc_rev
= PCI_REVISION(reg
);
703 if (becc_rev
<= BECC_REV_V7
&&
704 memsize
> (64UL * 1024 * 1024)) {
705 memsize
= (64UL * 1024 * 1024);
706 bootconfig
.dram
[0].pages
= memsize
/ PAGE_SIZE
;
707 physical_end
= physical_start
+
708 (bootconfig
.dram
[0].pages
* PAGE_SIZE
);
709 printf("BECC <= Rev7: memory truncated to 64M\n");
714 * Update the physical_freestart/physical_freeend/free_pages
720 physical_freestart
= physical_start
+
721 (((((uintptr_t) _end
) + PGOFSET
) & ~PGOFSET
) -
723 physical_freeend
= physical_end
;
725 (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
727 #ifdef VERBOSE_INIT_ARM
728 printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
729 physical_freestart
, free_pages
, free_pages
);
732 physmem
= (physical_end
- physical_start
) / PAGE_SIZE
;
734 arm32_vector_init(ARM_VECTORS_HIGH
, ARM_VEC_ALL
);
737 * Pages were allocated during the secondary bootstrap for the
738 * stacks for different CPU modes.
739 * We must now set the r13 registers in the different CPU modes to
740 * point to these stacks.
741 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
742 * of the stack memory.
744 #ifdef VERBOSE_INIT_ARM
745 printf("init subsystems: stacks ");
748 set_stackptr(PSR_IRQ32_MODE
,
749 irqstack
.pv_va
+ IRQ_STACK_SIZE
* PAGE_SIZE
);
750 set_stackptr(PSR_ABT32_MODE
,
751 abtstack
.pv_va
+ ABT_STACK_SIZE
* PAGE_SIZE
);
752 set_stackptr(PSR_UND32_MODE
,
753 undstack
.pv_va
+ UND_STACK_SIZE
* PAGE_SIZE
);
756 * Well we should set a data abort handler.
757 * Once things get going this will change as we will need a proper
759 * Until then we will use a handler that just panics but tells us
761 * Initialisation of the vectors will just panic on a data abort.
762 * This just fills in a slightly better one.
764 #ifdef VERBOSE_INIT_ARM
767 data_abort_handler_address
= (u_int
)data_abort_handler
;
768 prefetch_abort_handler_address
= (u_int
)prefetch_abort_handler
;
769 undefined_handler_address
= (u_int
)undefinedinstruction_bounce
;
771 /* Initialise the undefined instruction handlers */
772 #ifdef VERBOSE_INIT_ARM
773 printf("undefined ");
777 /* Load memory into UVM. */
778 #ifdef VERBOSE_INIT_ARM
781 uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
782 uvm_page_physload(atop(physical_freestart
), atop(physical_freeend
),
783 atop(physical_freestart
), atop(physical_freeend
),
784 VM_FREELIST_DEFAULT
);
786 /* Boot strap pmap telling it where the kernel page table is */
787 #ifdef VERBOSE_INIT_ARM
790 pmap_bootstrap(KERNEL_VM_BASE
, KERNEL_VM_BASE
+ KERNEL_VM_SIZE
);
792 /* Setup the IRQ system */
793 #ifdef VERBOSE_INIT_ARM
797 #ifdef VERBOSE_INIT_ARM
803 if (boothowto
& RB_KDB
)
807 /* We return the new stack pointer address */
808 return(kernelstack
.pv_va
+ USPACE_SVC_STACK_TOP
);
814 static const bus_addr_t comcnaddrs
[] = {
815 BRH_UART1_BASE
, /* com0 */
816 BRH_UART2_BASE
, /* com1 */
818 static int consinit_called
;
820 if (consinit_called
!= 0)
826 * brh_start() has mapped the console devices for us per
827 * the devmap, so register it now so drivers can map the
830 pmap_devmap_register(brh_devmap
);
833 if (comcnattach(&obio_bs_tag
, comcnaddrs
[comcnunit
], comcnspeed
,
834 BECC_PERIPH_CLOCK
, COM_TYPE_NORMAL
, comcnmode
))
835 panic("can't init serial console @%lx", comcnaddrs
[comcnunit
]);
837 panic("serial console @%lx not configured", comcnaddrs
[comcnunit
]);