4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe and Steve C. Woodford 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 Intel IQ80321 evaluation
72 * boards using RedBoot firmware.
75 #include <sys/cdefs.h>
76 __KERNEL_RCSID(0, "$NetBSD$");
80 #include "opt_pmap_debug.h"
82 #include <sys/param.h>
83 #include <sys/device.h>
84 #include <sys/systm.h>
85 #include <sys/kernel.h>
88 #include <sys/msgbuf.h>
89 #include <sys/reboot.h>
90 #include <sys/termios.h>
91 #include <sys/ksyms.h>
93 #include <uvm/uvm_extern.h>
97 #include <machine/db_machdep.h>
98 #include <ddb/db_sym.h>
99 #include <ddb/db_extern.h>
101 #include <machine/bootconfig.h>
102 #include <machine/bus.h>
103 #include <machine/cpu.h>
104 #include <machine/frame.h>
105 #include <arm/undefined.h>
107 #include <arm/arm32/machdep.h>
109 #include <arm/xscale/i80321reg.h>
110 #include <arm/xscale/i80321var.h>
112 #include <dev/pci/ppbreg.h>
114 #include <evbarm/iq80321/iq80321reg.h>
115 #include <evbarm/iq80321/iq80321var.h>
116 #include <evbarm/iq80321/obiovar.h>
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.
135 * XXX Not actally used on IQ80321 -- clean up the generic
139 u_int cpu_reset_address
= 0x00000000;
141 /* Define various stack sizes in pages */
142 #define IRQ_STACK_SIZE 1
143 #define ABT_STACK_SIZE 1
144 #define UND_STACK_SIZE 1
146 BootConfig bootconfig
; /* Boot config storage */
147 char *boot_args
= NULL
;
148 char *boot_file
= NULL
;
150 vm_offset_t physical_start
;
151 vm_offset_t physical_freestart
;
152 vm_offset_t physical_freeend
;
153 vm_offset_t physical_end
;
157 #ifndef PMAP_STATIC_L1S
158 int max_processes
= 64; /* Default number */
159 #endif /* !PMAP_STATIC_L1S */
161 /* Physical and virtual addresses for some global pages */
165 pv_addr_t kernelstack
;
166 pv_addr_t minidataclean
;
168 vm_offset_t msgbufphys
;
170 extern u_int data_abort_handler_address
;
171 extern u_int prefetch_abort_handler_address
;
172 extern u_int undefined_handler_address
;
175 extern int pmap_debug_level
;
178 #define KERNEL_PT_SYS 0 /* L2 table for mapping zero page */
180 #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
181 #define KERNEL_PT_KERNEL_NUM 4
183 /* L2 table for mapping i80321 */
184 #define KERNEL_PT_IOPXS (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
186 /* L2 tables for mapping kernel VM */
187 #define KERNEL_PT_VMDATA (KERNEL_PT_IOPXS + 1)
188 #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
189 #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
191 pv_addr_t kernel_pt_table
[NUM_KERNEL_PTS
];
199 #include <dev/ic/comreg.h>
200 #include <dev/ic/comvar.h>
204 * Define the default console speed for the board. This is generally
205 * what the firmware provided with the board defaults to.
208 #define CONSPEED B115200
209 #endif /* ! CONSPEED */
216 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
219 int comcnspeed
= CONSPEED
;
220 int comcnmode
= CONMODE
;
221 int comcnunit
= CONUNIT
;
225 #error Must define KGDB_DEVNAME
227 const char kgdb_devname
[] = KGDB_DEVNAME
;
230 #error Must define KGDB_DEVADDR
232 unsigned long kgdb_devaddr
= KGDB_DEVADDR
;
235 #define KGDB_DEVRATE CONSPEED
237 int kgdb_devrate
= KGDB_DEVRATE
;
240 #define KGDB_DEVMODE CONMODE
242 int kgdb_devmode
= KGDB_DEVMODE
;
246 * void cpu_reboot(int howto, char *bootstr)
250 * Deal with any syncing, unmounting, dumping and shutdown hooks,
251 * then reset the CPU.
254 cpu_reboot(int howto
, char *bootstr
)
258 * If we are still cold then hit the air brakes
259 * and crash to earth fast
263 pmf_system_shutdown(boothowto
);
264 printf("The operating system has halted.\n");
265 printf("Please press any key to reboot.\n\n");
267 printf("rebooting...\n");
271 /* Disable console buffering */
274 * If RB_NOSYNC was not specified sync the discs.
275 * Note: Unless cold is set to 1 here, syslogd will die during the
276 * unmount. It looks like syslogd is getting woken up only to find
277 * that it cannot page part of the binary in as the filesystem has
280 if (!(howto
& RB_NOSYNC
))
283 /* Say NO to interrupts */
286 /* Do a dump if requested. */
287 if ((howto
& (RB_DUMP
| RB_HALT
)) == RB_DUMP
)
290 /* Run any shutdown hooks */
293 pmf_system_shutdown(boothowto
);
295 /* Make sure IRQ's are disabled */
298 if (howto
& RB_HALT
) {
299 printf("The operating system has halted.\n");
300 printf("Please press any key to reboot.\n\n");
304 printf("rebooting...\n\r");
307 * Make really really sure that all interrupts are disabled,
308 * and poke the Internal Bus and Peripheral Bus reset lines.
310 (void) disable_interrupts(I32_bit
|F32_bit
);
311 *(volatile uint32_t *)(IQ80321_80321_VBASE
+ VERDE_ATU_BASE
+
312 ATU_PCSR
) = PCSR_RIB
| PCSR_RPB
;
314 /* ...and if that didn't work, just croak. */
315 printf("RESET FAILED!\n");
319 /* Static device mappings. */
320 static const struct pmap_devmap iq80321_devmap
[] = {
322 * Map the on-board devices VA == PA so that we can access them
323 * with the MMU on or off.
329 VM_PROT_READ
|VM_PROT_WRITE
,
335 VERDE_OUT_XLATE_IO_WIN0_BASE
,
336 VERDE_OUT_XLATE_IO_WIN_SIZE
,
337 VM_PROT_READ
|VM_PROT_WRITE
,
345 VM_PROT_READ
|VM_PROT_WRITE
,
361 * Initial entry point on startup. This gets called before main() is
363 * It should be responsible for setting up everything that must be
364 * in place when main is called.
366 * Taking a copy of the boot configuration structure.
367 * Initialising the physical console so characters can be printed.
368 * Setting up page tables for the kernel
369 * Relocating the kernel to the bottom of physical memory
374 extern vaddr_t xscale_cache_clean_addr
;
376 extern vsize_t xscale_minidata_clean_size
;
384 /* Calibrate the delay loop. */
385 i80321_calibrate_delay();
386 i80321_hardclock_hook
= NULL
;
389 * Since we map the on-board devices VA==PA, and the kernel
390 * is running VA==PA, it's possible for us to initialize
395 #ifdef VERBOSE_INIT_ARM
396 /* Talk to the user */
397 printf("\nNetBSD/evbarm (NPWR_FC) booting ...\n");
401 * Heads up ... Setup the CPU / MMU / TLB functions
404 panic("cpu not recognized!");
407 * We are currently running with the MMU enabled and the
408 * entire address space mapped VA==PA, except for the
409 * first 64M of RAM is also double-mapped at 0xc0000000.
410 * There is an L1 page table at 0xa0004000.
414 * Fetch the SDRAM start/size from the i80321 SDRAM configration
417 i80321_sdram_bounds(&obio_bs_tag
, VERDE_PMMR_BASE
+ VERDE_MCU_BASE
,
418 &memstart
, &memsize
);
420 #ifdef VERBOSE_INIT_ARM
421 printf("initarm: Configuring system ...\n");
424 /* Fake bootconfig structure for the benefit of pmap.c */
425 /* XXX must make the memory description h/w independent */
426 bootconfig
.dramblocks
= 1;
427 bootconfig
.dram
[0].address
= memstart
;
428 bootconfig
.dram
[0].pages
= memsize
/ PAGE_SIZE
;
431 * Set up the variables that define the availablilty of
432 * physical memory. For now, we're going to set
433 * physical_freestart to 0xa0200000 (where the kernel
434 * was loaded), and allocate the memory we need downwards.
435 * If we get too close to the L1 table that we set up, we
436 * will panic. We will update physical_freestart and
437 * physical_freeend later to reflect what pmap_bootstrap()
440 * XXX pmap_bootstrap() needs an enema.
442 physical_start
= bootconfig
.dram
[0].address
;
443 physical_end
= physical_start
+ (bootconfig
.dram
[0].pages
* PAGE_SIZE
);
445 physical_freestart
= 0xa0009000UL
;
446 physical_freeend
= 0xa0200000UL
;
448 physmem
= (physical_end
- physical_start
) / PAGE_SIZE
;
450 #ifdef VERBOSE_INIT_ARM
451 /* Tell the user about the memory */
452 printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem
,
453 physical_start
, physical_end
- 1);
457 * Okay, the kernel starts 2MB in from the bottom of physical
458 * memory. We are going to allocate our bootstrap pages downwards
461 * We need to allocate some fixed page tables to get the kernel
462 * going. We allocate one page directory and a number of page
463 * tables and store the physical addresses in the kernel_pt_table
466 * The kernel page directory must be on a 16K boundary. The page
467 * tables must be on 4K bounaries. What we do is allocate the
468 * page directory on the first 16K boundary that we encounter, and
469 * the page tables on 4K boundaries otherwise. Since we allocate
470 * at least 3 L2 page tables, we are guaranteed to encounter at
471 * least one 16K aligned region.
474 #ifdef VERBOSE_INIT_ARM
475 printf("Allocating page tables\n");
478 free_pages
= (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
480 #ifdef VERBOSE_INIT_ARM
481 printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
482 physical_freestart
, free_pages
, free_pages
);
485 /* Define a macro to simplify memory allocation */
486 #define valloc_pages(var, np) \
487 alloc_pages((var).pv_pa, (np)); \
488 (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
490 #define alloc_pages(var, np) \
491 physical_freeend -= ((np) * PAGE_SIZE); \
492 if (physical_freeend < physical_freestart) \
493 panic("initarm: out of memory"); \
494 (var) = physical_freeend; \
495 free_pages -= (np); \
496 memset((char *)(var), 0, ((np) * PAGE_SIZE));
499 for (loop
= 0; loop
<= NUM_KERNEL_PTS
; ++loop
) {
500 /* Are we 16KB aligned for an L1 ? */
501 if (((physical_freeend
- L1_TABLE_SIZE
) & (L1_TABLE_SIZE
- 1)) == 0
502 && kernel_l1pt
.pv_pa
== 0) {
503 valloc_pages(kernel_l1pt
, L1_TABLE_SIZE
/ PAGE_SIZE
);
505 valloc_pages(kernel_pt_table
[loop1
],
506 L2_TABLE_SIZE
/ PAGE_SIZE
);
511 /* This should never be able to happen but better confirm that. */
512 if (!kernel_l1pt
.pv_pa
|| (kernel_l1pt
.pv_pa
& (L1_TABLE_SIZE
-1)) != 0)
513 panic("initarm: Failed to align the kernel page directory");
516 * Allocate a page for the system page mapped to V0x00000000
517 * This page will just contain the system vectors and can be
518 * shared by all processes.
520 alloc_pages(systempage
.pv_pa
, 1);
522 /* Allocate stacks for all modes */
523 valloc_pages(irqstack
, IRQ_STACK_SIZE
);
524 valloc_pages(abtstack
, ABT_STACK_SIZE
);
525 valloc_pages(undstack
, UND_STACK_SIZE
);
526 valloc_pages(kernelstack
, UPAGES
);
528 /* Allocate enough pages for cleaning the Mini-Data cache. */
529 KASSERT(xscale_minidata_clean_size
<= PAGE_SIZE
);
530 valloc_pages(minidataclean
, 1);
532 #ifdef VERBOSE_INIT_ARM
533 printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack
.pv_pa
,
535 printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack
.pv_pa
,
537 printf("UND stack: p0x%08lx v0x%08lx\n", undstack
.pv_pa
,
539 printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack
.pv_pa
,
544 * XXX Defer this to later so that we can reclaim the memory
545 * XXX used by the RedBoot page tables.
547 alloc_pages(msgbufphys
, round_page(MSGBUFSIZE
) / PAGE_SIZE
);
550 * Ok we have allocated physical pages for the primary kernel
554 #ifdef VERBOSE_INIT_ARM
555 printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt
.pv_pa
);
559 * Now we start construction of the L1 page table
560 * We start by mapping the L2 page tables into the L1.
561 * This means that we can replace L1 mappings later on if necessary
563 l1pagetable
= kernel_l1pt
.pv_pa
;
565 /* Map the L2 pages tables in the L1 page table */
566 pmap_link_l2pt(l1pagetable
, ARM_VECTORS_HIGH
& ~(0x00400000 - 1),
567 &kernel_pt_table
[KERNEL_PT_SYS
]);
568 for (loop
= 0; loop
< KERNEL_PT_KERNEL_NUM
; loop
++)
569 pmap_link_l2pt(l1pagetable
, KERNEL_BASE
+ loop
* 0x00400000,
570 &kernel_pt_table
[KERNEL_PT_KERNEL
+ loop
]);
571 pmap_link_l2pt(l1pagetable
, IQ80321_IOPXS_VBASE
,
572 &kernel_pt_table
[KERNEL_PT_IOPXS
]);
573 for (loop
= 0; loop
< KERNEL_PT_VMDATA_NUM
; loop
++)
574 pmap_link_l2pt(l1pagetable
, KERNEL_VM_BASE
+ loop
* 0x00400000,
575 &kernel_pt_table
[KERNEL_PT_VMDATA
+ loop
]);
577 /* update the top of the kernel VM */
579 KERNEL_VM_BASE
+ (KERNEL_PT_VMDATA_NUM
* 0x00400000);
581 #ifdef VERBOSE_INIT_ARM
582 printf("Mapping kernel\n");
585 /* Now we fill in the L2 pagetable for the kernel static code/data */
587 extern char etext
[], _end
[];
588 size_t textsize
= (uintptr_t) etext
- KERNEL_TEXT_BASE
;
589 size_t totalsize
= (uintptr_t) _end
- KERNEL_TEXT_BASE
;
592 textsize
= (textsize
+ PGOFSET
) & ~PGOFSET
;
593 totalsize
= (totalsize
+ PGOFSET
) & ~PGOFSET
;
595 logical
= 0x00200000; /* offset of kernel in RAM */
597 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
598 physical_start
+ logical
, textsize
,
599 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
600 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
601 physical_start
+ logical
, totalsize
- textsize
,
602 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
605 #ifdef VERBOSE_INIT_ARM
606 printf("Constructing L2 page tables\n");
609 /* Map the stack pages */
610 pmap_map_chunk(l1pagetable
, irqstack
.pv_va
, irqstack
.pv_pa
,
611 IRQ_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
612 pmap_map_chunk(l1pagetable
, abtstack
.pv_va
, abtstack
.pv_pa
,
613 ABT_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
614 pmap_map_chunk(l1pagetable
, undstack
.pv_va
, undstack
.pv_pa
,
615 UND_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
616 pmap_map_chunk(l1pagetable
, kernelstack
.pv_va
, kernelstack
.pv_pa
,
617 UPAGES
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
619 pmap_map_chunk(l1pagetable
, kernel_l1pt
.pv_va
, kernel_l1pt
.pv_pa
,
620 L1_TABLE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
622 for (loop
= 0; loop
< NUM_KERNEL_PTS
; ++loop
) {
623 pmap_map_chunk(l1pagetable
, kernel_pt_table
[loop
].pv_va
,
624 kernel_pt_table
[loop
].pv_pa
, L2_TABLE_SIZE
,
625 VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
628 /* Map the Mini-Data cache clean area. */
629 xscale_setup_minidata(l1pagetable
, minidataclean
.pv_va
,
630 minidataclean
.pv_pa
);
632 /* Map the vector page. */
633 pmap_map_entry(l1pagetable
, ARM_VECTORS_HIGH
, systempage
.pv_pa
,
634 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
636 /* Map the statically mapped devices. */
637 pmap_devmap_bootstrap(l1pagetable
, iq80321_devmap
);
640 * Give the XScale global cache clean code an appropriately
641 * sized chunk of unmapped VA space starting at 0xff000000
642 * (our device mappings end before this address).
644 xscale_cache_clean_addr
= 0xff000000U
;
647 * Now we have the real page tables in place so we can switch to them.
648 * Once this is done we will be running with the REAL kernel page
653 * Update the physical_freestart/physical_freeend/free_pages
659 physical_freestart
= physical_start
+
660 (((((uintptr_t) _end
) + PGOFSET
) & ~PGOFSET
) -
662 physical_freeend
= physical_end
;
664 (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
668 #ifdef VERBOSE_INIT_ARM
669 printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
670 physical_freestart
, free_pages
, free_pages
);
671 printf("switching to new L1 page table @%#lx...", kernel_l1pt
.pv_pa
);
673 cpu_domains((DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2)) | DOMAIN_CLIENT
);
674 cpu_setttb(kernel_l1pt
.pv_pa
);
676 cpu_domains(DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2));
679 * Moved from cpu_startup() as data_abort_handler() references
680 * this during uvm init
682 uvm_lwp_setuarea(&lwp0
, kernelstack
.pv_va
);
684 #ifdef VERBOSE_INIT_ARM
688 #ifdef VERBOSE_INIT_ARM
689 printf("bootstrap done.\n");
692 arm32_vector_init(ARM_VECTORS_HIGH
, ARM_VEC_ALL
);
695 * Pages were allocated during the secondary bootstrap for the
696 * stacks for different CPU modes.
697 * We must now set the r13 registers in the different CPU modes to
698 * point to these stacks.
699 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
700 * of the stack memory.
702 #ifdef VERBOSE_INIT_ARM
703 printf("init subsystems: stacks ");
706 set_stackptr(PSR_IRQ32_MODE
,
707 irqstack
.pv_va
+ IRQ_STACK_SIZE
* PAGE_SIZE
);
708 set_stackptr(PSR_ABT32_MODE
,
709 abtstack
.pv_va
+ ABT_STACK_SIZE
* PAGE_SIZE
);
710 set_stackptr(PSR_UND32_MODE
,
711 undstack
.pv_va
+ UND_STACK_SIZE
* PAGE_SIZE
);
714 * Well we should set a data abort handler.
715 * Once things get going this will change as we will need a proper
717 * Until then we will use a handler that just panics but tells us
719 * Initialisation of the vectors will just panic on a data abort.
720 * This just fills in a slighly better one.
722 #ifdef VERBOSE_INIT_ARM
725 data_abort_handler_address
= (u_int
)data_abort_handler
;
726 prefetch_abort_handler_address
= (u_int
)prefetch_abort_handler
;
727 undefined_handler_address
= (u_int
)undefinedinstruction_bounce
;
729 /* Initialise the undefined instruction handlers */
730 #ifdef VERBOSE_INIT_ARM
731 printf("undefined ");
735 /* Load memory into UVM. */
736 #ifdef VERBOSE_INIT_ARM
739 uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
740 uvm_page_physload(atop(physical_freestart
), atop(physical_freeend
),
741 atop(physical_freestart
), atop(physical_freeend
),
742 VM_FREELIST_DEFAULT
);
744 /* Boot strap pmap telling it where the kernel page table is */
745 #ifdef VERBOSE_INIT_ARM
748 pmap_bootstrap(KERNEL_VM_BASE
, KERNEL_VM_BASE
+ KERNEL_VM_SIZE
);
750 /* Setup the IRQ system */
751 #ifdef VERBOSE_INIT_ARM
756 #ifdef VERBOSE_INIT_ARM
761 boothowto
= BOOTHOWTO
;
766 if (boothowto
& RB_KDB
)
770 /* We return the new stack pointer address */
771 return(kernelstack
.pv_va
+ USPACE_SVC_STACK_TOP
);
777 static const bus_addr_t comcnaddrs
[] = {
778 IQ80321_UART1
, /* com0 */
780 static int consinit_called
;
782 if (consinit_called
!= 0)
788 * Console devices are mapped VA==PA. Our devmap reflects
789 * this, so register it now so drivers can map the console
792 pmap_devmap_register(iq80321_devmap
);
795 if (comcnattach(&obio_bs_tag
, comcnaddrs
[comcnunit
], comcnspeed
,
796 COM_FREQ
, COM_TYPE_NORMAL
, comcnmode
))
797 panic("can't init serial console @%lx", comcnaddrs
[comcnunit
]);
799 panic("serial console @%lx not configured", comcnaddrs
[comcnunit
]);
803 if (strcmp(kgdb_devname
, "com") == 0) {
804 com_kgdb_attach(&obio_bs_tag
, kgdb_devaddr
, kgdb_devrate
,
805 COM_FREQ
, COM_TYPE_NORMAL
, kgdb_devmode
);
807 #endif /* NCOM > 0 */