4 * Copyright (c) 2001,2002 ARM Ltd
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the company may not be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1997,1998 Mark Brinicombe.
34 * Copyright (c) 1997,1998 Causality Limited.
35 * All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by Mark Brinicombe
48 * for the NetBSD Project.
49 * 4. The name of the company nor the name of the author may be used to
50 * endorse or promote products derived from this software without specific
51 * prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
54 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
55 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
57 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * Machine dependant functions for kernel setup for integrator board
70 #include <sys/cdefs.h>
71 __KERNEL_RCSID(0, "$NetBSD$");
74 #include "opt_pmap_debug.h"
76 #include <sys/param.h>
77 #include <sys/device.h>
78 #include <sys/systm.h>
79 #include <sys/kernel.h>
82 #include <sys/msgbuf.h>
83 #include <sys/reboot.h>
84 #include <sys/termios.h>
85 #include <sys/ksyms.h>
87 #include <uvm/uvm_extern.h>
91 #include <machine/db_machdep.h>
92 #include <ddb/db_sym.h>
93 #include <ddb/db_extern.h>
95 #include <machine/bootconfig.h>
96 #include <machine/bus.h>
97 #include <machine/cpu.h>
98 #include <machine/frame.h>
99 #include <machine/intr.h>
100 #include <arm/undefined.h>
102 #include <arm/arm32/machdep.h>
104 #include <evbarm/integrator/integrator_boot.h>
109 void ifpga_reset(void) __attribute__((noreturn
));
111 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
112 #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
113 #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
116 * The range 0xc1000000 - 0xccffffff is available for kernel VM space
117 * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
119 #define KERNEL_VM_SIZE 0x0C000000
122 * Address to call from cpu_reset() to reset the machine.
123 * This is machine architecture dependant as it varies depending
124 * on where the ROM appears when you turn the MMU off.
127 u_int cpu_reset_address
= (u_int
) ifpga_reset
;
129 /* Define various stack sizes in pages */
130 #define IRQ_STACK_SIZE 1
131 #define ABT_STACK_SIZE 1
132 #define UND_STACK_SIZE 1
134 BootConfig bootconfig
; /* Boot config storage */
135 char *boot_args
= NULL
;
136 char *boot_file
= NULL
;
138 vm_offset_t physical_start
;
139 vm_offset_t physical_end
;
142 #ifndef PMAP_STATIC_L1S
143 int max_processes
= 64; /* Default number */
144 #endif /* !PMAP_STATIC_L1S */
146 /* Physical and virtual addresses for some global pages */
150 pv_addr_t kernelstack
;
152 vm_offset_t msgbufphys
;
154 extern u_int data_abort_handler_address
;
155 extern u_int prefetch_abort_handler_address
;
156 extern u_int undefined_handler_address
;
159 extern int pmap_debug_level
;
162 #define KERNEL_PT_SYS 0 /* L2 table for mapping zero page */
164 #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
165 #define KERNEL_PT_KERNEL_NUM 2
166 /* L2 tables for mapping kernel VM */
167 #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
168 #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
169 #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
171 pv_addr_t kernel_pt_table
[NUM_KERNEL_PTS
];
175 static void integrator_sdram_bounds (paddr_t
*, psize_t
*);
179 /* A load of console goo. */
182 #include <dev/ic/mc6845reg.h>
183 #include <dev/ic/pcdisplayvar.h>
184 #include <dev/ic/vgareg.h>
185 #include <dev/ic/vgavar.h>
190 #include <dev/ic/i8042reg.h>
191 #include <dev/ic/pckbcvar.h>
196 #include <dev/ic/comreg.h>
197 #include <dev/ic/comvar.h>
199 #define CONCOMADDR 0x3f8
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
211 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
214 int comcnspeed
= CONSPEED
;
215 int comcnmode
= CONMODE
;
219 #include <evbarm/dev/plcomreg.h>
220 #include <evbarm/dev/plcomvar.h>
222 #include <evbarm/ifpga/ifpgamem.h>
223 #include <evbarm/ifpga/ifpgareg.h>
224 #include <evbarm/ifpga/ifpgavar.h>
228 #define CONSDEVNAME "plcom"
232 #define PLCONSPEED B38400
235 #define PLCONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
238 #define PLCOMCNUNIT -1
241 int plcomcnspeed
= PLCONSPEED
;
242 int plcomcnmode
= PLCONMODE
;
245 extern struct consdev kcomcons
;
246 static void kcomcnputc(dev_t
, int);
250 * void cpu_reboot(int howto, char *bootstr)
254 * Deal with any syncing, unmounting, dumping and shutdown hooks,
255 * then reset the CPU.
258 cpu_reboot(int howto
, char *bootstr
)
262 * If we are still cold then hit the air brakes
263 * and crash to earth fast
267 pmf_system_shutdown(boothowto
);
268 printf("The operating system has halted.\n");
269 printf("Please press any key to reboot.\n\n");
271 printf("rebooting...\n");
276 /* Disable console buffering */
279 * If RB_NOSYNC was not specified sync the discs.
280 * Note: Unless cold is set to 1 here, syslogd will die during the
281 * unmount. It looks like syslogd is getting woken up only to find
282 * that it cannot page part of the binary in as the filesystem has
285 if (!(howto
& RB_NOSYNC
))
288 /* Say NO to interrupts */
291 /* Do a dump if requested. */
292 if ((howto
& (RB_DUMP
| RB_HALT
)) == RB_DUMP
)
295 /* Run any shutdown hooks */
298 pmf_system_shutdown(boothowto
);
300 /* Make sure IRQ's are disabled */
303 if (howto
& RB_HALT
) {
304 printf("The operating system has halted.\n");
305 printf("Please press any key to reboot.\n\n");
309 printf("rebooting...\n");
314 /* Statically mapped devices. */
315 static const struct pmap_devmap integrator_devmap
[] = {
316 #if NPLCOM > 0 && defined(PLCONSOLE)
319 IFPGA_IO_BASE
+ IFPGA_UART0
,
321 VM_PROT_READ
|VM_PROT_WRITE
,
327 IFPGA_IO_BASE
+ IFPGA_UART1
,
329 VM_PROT_READ
|VM_PROT_WRITE
,
338 VM_PROT_READ
|VM_PROT_WRITE
,
343 IFPGA_PCI_CONF_VBASE
,
345 IFPGA_PCI_CONF_VSIZE
,
346 VM_PROT_READ
|VM_PROT_WRITE
,
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
380 extern char etext
__asm ("_etext");
381 extern char end
__asm ("_end");
384 vm_offset_t physical_freestart
;
385 vm_offset_t physical_freeend
;
386 #if NPLCOM > 0 && defined(PLCONSOLE)
387 static struct bus_space plcom_bus_space
;
391 * Heads up ... Setup the CPU / MMU / TLB functions
394 panic("CPU not recognized!");
396 #if NPLCOM > 0 && defined(PLCONSOLE)
398 * Initialise the diagnostic serial console
399 * This allows a means of generating output during initarm().
400 * Once all the memory map changes are complete we can call consinit()
401 * and not have to worry about things moving.
404 if (PLCOMCNUNIT
== 0) {
405 ifpga_create_io_bs_tag(&plcom_bus_space
, (void*)0xfd600000);
406 plcomcnattach(&plcom_bus_space
, 0, plcomcnspeed
,
407 IFPGA_UART_CLK
, plcomcnmode
, PLCOMCNUNIT
);
408 } else if (PLCOMCNUNIT
== 1) {
409 ifpga_create_io_bs_tag(&plcom_bus_space
, (void*)0xfd700000);
410 plcomcnattach(&plcom_bus_space
, 0, plcomcnspeed
,
411 IFPGA_UART_CLK
, plcomcnmode
, PLCOMCNUNIT
);
415 #ifdef VERBOSE_INIT_ARM
416 /* Talk to the user */
417 printf("\nNetBSD/evbarm (Integrator) booting ...\n");
421 * Fetch the SDRAM start/size from the CM configuration registers.
423 integrator_sdram_bounds(&memstart
, &memsize
);
425 #ifdef VERBOSE_INIT_ARM
426 printf("initarm: Configuring system ...\n");
429 /* Fake bootconfig structure for the benefit of pmap.c */
430 /* XXX must make the memory description h/w independent */
431 bootconfig
.dramblocks
= 1;
432 bootconfig
.dram
[0].address
= memstart
;
433 bootconfig
.dram
[0].pages
= memsize
/ PAGE_SIZE
;
434 bootconfig
.dram
[0].flags
= BOOT_DRAM_CAN_DMA
| BOOT_DRAM_PREFER
;
437 * Set up the variables that define the availablilty of
438 * physical memory. For now, we're going to set
439 * physical_freestart to 0x00200000 (where the kernel
440 * was loaded), and allocate the memory we need downwards.
441 * If we get too close to the L1 table that we set up, we
442 * will panic. We will update physical_freestart and
443 * physical_freeend later to reflect what pmap_bootstrap()
446 * We assume that the kernel is loaded into bank[0].
448 * XXX pmap_bootstrap() needs an enema.
450 physical_start
= bootconfig
.dram
[0].address
;
453 /* Update the address of the first free 16KB chunk of physical memory */
454 physical_freestart
= ((uintptr_t) &end
- KERNEL_BASE
+ PGOFSET
)
456 if (physical_freestart
< bootconfig
.dram
[0].address
)
457 physical_freestart
= bootconfig
.dram
[0].address
;
458 physical_freeend
= bootconfig
.dram
[0].address
+
459 bootconfig
.dram
[0].pages
* PAGE_SIZE
;
461 for (loop
= 0, physmem
= 0; loop
< bootconfig
.dramblocks
; loop
++) {
462 paddr_t memoryblock_end
;
464 memoryblock_end
= bootconfig
.dram
[loop
].address
+
465 bootconfig
.dram
[loop
].pages
* PAGE_SIZE
;
466 if (memoryblock_end
> physical_end
)
467 physical_end
= memoryblock_end
;
468 if (bootconfig
.dram
[loop
].address
< physical_start
)
469 physical_start
= bootconfig
.dram
[loop
].address
;
471 physmem
+= bootconfig
.dram
[loop
].pages
;
474 #ifdef VERBOSE_INIT_ARM
475 /* Tell the user about the memory */
476 printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem
,
477 physical_start
, physical_end
- 1);
481 * Okay, the kernel starts 2MB in from the bottom of physical
482 * memory. We are going to allocate our bootstrap pages downwards
485 * We need to allocate some fixed page tables to get the kernel
486 * going. We allocate one page directory and a number of page
487 * tables and store the physical addresses in the kernel_pt_table
490 * The kernel page directory must be on a 16K boundary. The page
491 * tables must be on 4K boundaries. What we do is allocate the
492 * page directory on the first 16K boundary that we encounter, and
493 * the page tables on 4K boundaries otherwise. Since we allocate
494 * at least 3 L2 page tables, we are guaranteed to encounter at
495 * least one 16K aligned region.
498 #ifdef VERBOSE_INIT_ARM
499 printf("Allocating page tables\n");
502 #ifdef VERBOSE_INIT_ARM
503 printf("freestart = 0x%08lx, free pages = %d (0x%08x)\n",
504 physical_freestart
, physmem
, physmem
);
507 /* Define a macro to simplify memory allocation */
508 #define valloc_pages(var, np) \
509 alloc_pages((var).pv_pa, (np)); \
510 (var).pv_va = KERNEL_BASE + (var).pv_pa;
512 #define alloc_pages(var, np) \
513 (var) = physical_freestart; \
514 physical_freestart += ((np) * PAGE_SIZE); \
515 if (physical_freeend < physical_freestart) \
516 panic("initarm: out of memory"); \
517 memset((char *)(var), 0, ((np) * PAGE_SIZE));
520 for (loop
= 0; loop
<= NUM_KERNEL_PTS
; ++loop
) {
521 /* Are we 16KB aligned for an L1 ? */
522 if ((physical_freestart
& (L1_TABLE_SIZE
- 1)) == 0
523 && kernel_l1pt
.pv_pa
== 0) {
524 valloc_pages(kernel_l1pt
, L1_TABLE_SIZE
/ PAGE_SIZE
);
526 valloc_pages(kernel_pt_table
[loop1
],
527 L2_TABLE_SIZE
/ PAGE_SIZE
);
532 /* This should never be able to happen but better confirm that. */
533 if (!kernel_l1pt
.pv_pa
|| (kernel_l1pt
.pv_pa
& (L1_TABLE_SIZE
-1)) != 0)
534 panic("initarm: Failed to align the kernel page directory");
537 * Allocate a page for the system page mapped to V0x00000000
538 * This page will just contain the system vectors and can be
539 * shared by all processes.
541 alloc_pages(systempage
.pv_pa
, 1);
543 /* Allocate stacks for all modes */
544 valloc_pages(irqstack
, IRQ_STACK_SIZE
);
545 valloc_pages(abtstack
, ABT_STACK_SIZE
);
546 valloc_pages(undstack
, UND_STACK_SIZE
);
547 valloc_pages(kernelstack
, UPAGES
);
549 #ifdef VERBOSE_INIT_ARM
550 printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack
.pv_pa
,
552 printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack
.pv_pa
,
554 printf("UND stack: p0x%08lx v0x%08lx\n", undstack
.pv_pa
,
556 printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack
.pv_pa
,
560 alloc_pages(msgbufphys
, round_page(MSGBUFSIZE
) / PAGE_SIZE
);
563 * Ok we have allocated physical pages for the primary kernel
567 #ifdef VERBOSE_INIT_ARM
568 printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt
.pv_pa
);
572 * Now we start construction of the L1 page table
573 * We start by mapping the L2 page tables into the L1.
574 * This means that we can replace L1 mappings later on if necessary
576 l1pagetable
= kernel_l1pt
.pv_pa
;
578 /* Map the L2 pages tables in the L1 page table */
579 pmap_link_l2pt(l1pagetable
, 0x00000000,
580 &kernel_pt_table
[KERNEL_PT_SYS
]);
581 for (loop
= 0; loop
< KERNEL_PT_KERNEL_NUM
; loop
++)
582 pmap_link_l2pt(l1pagetable
, KERNEL_BASE
+ loop
* 0x00400000,
583 &kernel_pt_table
[KERNEL_PT_KERNEL
+ loop
]);
584 for (loop
= 0; loop
< KERNEL_PT_VMDATA_NUM
; loop
++)
585 pmap_link_l2pt(l1pagetable
, KERNEL_VM_BASE
+ loop
* 0x00400000,
586 &kernel_pt_table
[KERNEL_PT_VMDATA
+ loop
]);
588 /* update the top of the kernel VM */
590 KERNEL_VM_BASE
+ (KERNEL_PT_VMDATA_NUM
* 0x00400000);
592 #ifdef VERBOSE_INIT_ARM
593 printf("Mapping kernel\n");
596 /* Now we fill in the L2 pagetable for the kernel static code/data */
598 size_t textsize
= (uintptr_t) &etext
- KERNEL_TEXT_BASE
;
599 size_t totalsize
= (uintptr_t) &end
- KERNEL_TEXT_BASE
;
602 textsize
= (textsize
+ PGOFSET
) & ~PGOFSET
;
603 totalsize
= (totalsize
+ PGOFSET
) & ~PGOFSET
;
605 logical
= 0x00200000; /* offset of kernel in RAM */
607 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
608 logical
, textsize
, VM_PROT_READ
| VM_PROT_WRITE
,
610 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
611 logical
, totalsize
- textsize
,
612 VM_PROT_READ
| VM_PROT_WRITE
, PTE_CACHE
);
615 #ifdef VERBOSE_INIT_ARM
616 printf("Constructing L2 page tables\n");
619 /* Map the stack pages */
620 pmap_map_chunk(l1pagetable
, irqstack
.pv_va
, irqstack
.pv_pa
,
621 IRQ_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
622 pmap_map_chunk(l1pagetable
, abtstack
.pv_va
, abtstack
.pv_pa
,
623 ABT_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
624 pmap_map_chunk(l1pagetable
, undstack
.pv_va
, undstack
.pv_pa
,
625 UND_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
626 pmap_map_chunk(l1pagetable
, kernelstack
.pv_va
, kernelstack
.pv_pa
,
627 UPAGES
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
629 pmap_map_chunk(l1pagetable
, kernel_l1pt
.pv_va
, kernel_l1pt
.pv_pa
,
630 L1_TABLE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
632 for (loop
= 0; loop
< NUM_KERNEL_PTS
; ++loop
) {
633 pmap_map_chunk(l1pagetable
, kernel_pt_table
[loop
].pv_va
,
634 kernel_pt_table
[loop
].pv_pa
, L2_TABLE_SIZE
,
635 VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
638 /* Map the vector page. */
640 /* MULTI-ICE requires that page 0 is NC/NB so that it can download
641 the cache-clean code there. */
642 pmap_map_entry(l1pagetable
, ARM_VECTORS_LOW
, systempage
.pv_pa
,
643 VM_PROT_READ
|VM_PROT_WRITE
, PTE_NOCACHE
);
645 pmap_map_entry(l1pagetable
, ARM_VECTORS_LOW
, systempage
.pv_pa
,
646 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
649 /* Map the statically mapped devices. */
650 pmap_devmap_bootstrap(l1pagetable
, integrator_devmap
);
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 * Moved from cpu_startup() as data_abort_handler() references
669 * this during uvm init
671 uvm_lwp_setuarea(&lwp0
, kernelstack
.pv_va
);
675 * The IFPGA registers have just moved.
676 * Detach the diagnostic serial port and reattach at the new address.
682 * XXX this should only be done in main() but it useful to
683 * have output earlier ...
687 #ifdef VERBOSE_INIT_ARM
688 printf("bootstrap done.\n");
691 arm32_vector_init(ARM_VECTORS_LOW
, ARM_VEC_ALL
);
694 * Pages were allocated during the secondary bootstrap for the
695 * stacks for different CPU modes.
696 * We must now set the r13 registers in the different CPU modes to
697 * point to these stacks.
698 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
699 * of the stack memory.
701 #ifdef VERBOSE_INIT_ARM
702 printf("init subsystems: stacks ");
705 set_stackptr(PSR_IRQ32_MODE
,
706 irqstack
.pv_va
+ IRQ_STACK_SIZE
* PAGE_SIZE
);
707 set_stackptr(PSR_ABT32_MODE
,
708 abtstack
.pv_va
+ ABT_STACK_SIZE
* PAGE_SIZE
);
709 set_stackptr(PSR_UND32_MODE
,
710 undstack
.pv_va
+ UND_STACK_SIZE
* PAGE_SIZE
);
713 * Well we should set a data abort handler.
714 * Once things get going this will change as we will need a proper
716 * Until then we will use a handler that just panics but tells us
718 * Initialisation of the vectors will just panic on a data abort.
719 * This just fills in a slightly better one.
721 #ifdef VERBOSE_INIT_ARM
724 data_abort_handler_address
= (u_int
)data_abort_handler
;
725 prefetch_abort_handler_address
= (u_int
)prefetch_abort_handler
;
726 undefined_handler_address
= (u_int
)undefinedinstruction_bounce
;
728 /* Initialise the undefined instruction handlers */
729 #ifdef VERBOSE_INIT_ARM
730 printf("undefined ");
734 /* Load memory into UVM. */
735 #ifdef VERBOSE_INIT_ARM
738 uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
740 /* Round the start up and the end down to a page. */
741 physical_freestart
= (physical_freestart
+ PGOFSET
) & ~PGOFSET
;
742 physical_freeend
&= ~PGOFSET
;
744 for (loop
= 0; loop
< bootconfig
.dramblocks
; loop
++) {
745 paddr_t block_start
= (paddr_t
) bootconfig
.dram
[loop
].address
;
746 paddr_t block_end
= block_start
+
747 (bootconfig
.dram
[loop
].pages
* PAGE_SIZE
);
750 block_start
= physical_freestart
;
751 block_end
= physical_freeend
;
755 uvm_page_physload(atop(block_start
), atop(block_end
),
756 atop(block_start
), atop(block_end
),
757 (bootconfig
.dram
[loop
].flags
& BOOT_DRAM_PREFER
) ?
758 VM_FREELIST_DEFAULT
: VM_FREELIST_DEFAULT
+ 1);
761 /* Boot strap pmap telling it where the kernel page table is */
762 #ifdef VERBOSE_INIT_ARM
765 pmap_bootstrap(KERNEL_VM_BASE
, KERNEL_VM_BASE
+ KERNEL_VM_SIZE
);
767 /* Setup the IRQ system */
768 #ifdef VERBOSE_INIT_ARM
773 #ifdef VERBOSE_INIT_ARM
779 if (boothowto
& RB_KDB
)
783 /* We return the new stack pointer address */
784 return(kernelstack
.pv_va
+ USPACE_SVC_STACK_TOP
);
790 static int consinit_called
= 0;
791 #if NPLCOM > 0 && defined(PLCONSOLE)
792 static struct bus_space plcom_bus_space
;
795 char *console
= CONSDEVNAME
;
798 if (consinit_called
!= 0)
803 #if NPLCOM > 0 && defined(PLCONSOLE)
804 if (PLCOMCNUNIT
== 0) {
805 ifpga_create_io_bs_tag(&plcom_bus_space
,
806 (void*)UART0_BOOT_BASE
);
807 if (plcomcnattach(&plcom_bus_space
, 0, plcomcnspeed
,
808 IFPGA_UART_CLK
, plcomcnmode
, PLCOMCNUNIT
))
809 panic("can't init serial console");
811 } else if (PLCOMCNUNIT
== 1) {
812 ifpga_create_io_bs_tag(&plcom_bus_space
,
813 (void*)UART0_BOOT_BASE
);
814 if (plcomcnattach(&plcom_bus_space
, 0, plcomcnspeed
,
815 IFPGA_UART_CLK
, plcomcnmode
, PLCOMCNUNIT
))
816 panic("can't init serial console");
821 if (comcnattach(&isa_io_bs_tag
, CONCOMADDR
, comcnspeed
,
822 COM_FREQ
, COM_TYPE_NORMAL
, comcnmode
))
823 panic("can't init serial console @%x", CONCOMADDR
);
826 panic("No serial console configured");
830 integrator_sdram_bounds(paddr_t
*memstart
, psize_t
*memsize
)
832 volatile unsigned long *cm_sdram
833 = (volatile unsigned long *)0x10000020;
834 volatile unsigned long *cm_stat
835 = (volatile unsigned long *)0x10000010;
837 *memstart
= *cm_stat
& 0x00ff0000;
840 * Although the SSRAM overlaps the SDRAM, we can use the wrap-around
841 * to access the entire bank.
843 switch ((*cm_sdram
>> 2) & 0x7)
846 *memsize
= 16 * 1024 * 1024;
849 *memsize
= 32 * 1024 * 1024;
852 *memsize
= 64 * 1024 * 1024;
855 *memsize
= 128 * 1024 * 1024;
858 /* With 256M of memory there is no wrap-around. */
859 *memsize
= 256 * 1024 * 1024 - *memstart
;
862 printf("CM_SDRAM retuns unknown value, using 16M\n");
863 *memsize
= 16 * 1024 * 1024;