4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
7 * Based on code written by Jason R. Thorpe and Steve C. Woodford for
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed for the NetBSD Project by
21 * Wasabi Systems, Inc.
22 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
23 * or promote products derived from this software without specific prior
26 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
40 * Copyright (c) 1997,1998 Mark Brinicombe.
41 * Copyright (c) 1997,1998 Causality Limited.
42 * All rights reserved.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by Mark Brinicombe
55 * for the NetBSD Project.
56 * 4. The name of the company nor the name of the author may be used to
57 * endorse or promote products derived from this software without specific
58 * prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
61 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
62 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
63 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
64 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
65 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
66 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * Machine dependant functions for kernel setup for Iyonix.
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 <acorn32/include/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/ep93xx/ep93xxreg.h>
110 #include <arm/ep93xx/ep93xxvar.h>
112 #include <dev/ic/comreg.h>
113 #include <dev/ic/comvar.h>
117 #include <arm/ep93xx/epcomvar.h>
122 #include <dev/isa/isareg.h>
123 #include <dev/isa/isavar.h>
126 #include <machine/isa_machdep.h>
128 #include <evbarm/tsarm/tsarmreg.h>
132 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
133 #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
134 #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
137 * The range 0xc1000000 - 0xccffffff is available for kernel VM space
138 * Core-logic registers and I/O mappings occupy 0xf0000000 - 0xffffffff
140 #define KERNEL_VM_SIZE 0x0C000000
143 * Address to call from cpu_reset() to reset the machine.
144 * This is machine architecture dependant as it varies depending
145 * on where the ROM appears when you turn the MMU off.
148 u_int cpu_reset_address
= 0x00000000;
150 /* Define various stack sizes in pages */
151 #define IRQ_STACK_SIZE 8
152 #define ABT_STACK_SIZE 8
153 #define UND_STACK_SIZE 8
155 struct bootconfig bootconfig
; /* Boot config storage */
156 char *boot_args
= NULL
;
157 char *boot_file
= NULL
;
159 vm_offset_t physical_start
;
160 vm_offset_t physical_freestart
;
161 vm_offset_t physical_freeend
;
162 vm_offset_t physical_freeend_low
;
163 vm_offset_t physical_end
;
166 /* Physical and virtual addresses for some global pages */
170 pv_addr_t kernelstack
;
172 vm_offset_t msgbufphys
;
174 static struct arm32_dma_range tsarm_dma_ranges
[4];
177 extern void isa_tsarm_init(u_int
, u_int
);
180 extern u_int data_abort_handler_address
;
181 extern u_int prefetch_abort_handler_address
;
182 extern u_int undefined_handler_address
;
185 extern int pmap_debug_level
;
188 #define KERNEL_PT_SYS 0 /* L2 table for mapping vectors page */
190 #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
191 #define KERNEL_PT_KERNEL_NUM 4
192 /* L2 tables for mapping kernel VM */
193 #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
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
];
204 * Define the default console speed for the machine.
207 #define CONSPEED B115200
208 #endif /* ! CONSPEED */
211 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
214 int comcnspeed
= CONSPEED
;
215 int comcnmode
= CONMODE
;
219 #error Must define KGDB_DEVNAME
221 const char kgdb_devname
[] = KGDB_DEVNAME
;
224 #error Must define KGDB_DEVADDR
226 unsigned long kgdb_devaddr
= KGDB_DEVADDR
;
229 #define KGDB_DEVRATE CONSPEED
231 int kgdb_devrate
= KGDB_DEVRATE
;
234 #define KGDB_DEVMODE CONMODE
236 int kgdb_devmode
= KGDB_DEVMODE
;
240 * void cpu_reboot(int howto, char *bootstr)
244 * Deal with any syncing, unmounting, dumping and shutdown hooks,
245 * then reset the CPU.
248 cpu_reboot(int howto
, char *bootstr
)
252 * If we are still cold then hit the air brakes
253 * and crash to earth fast
257 pmf_system_shutdown(boothowto
);
259 printf("The operating system has halted.\r\n");
260 printf("Please press any key to reboot.\r\n");
262 printf("\r\nrebooting...\r\n");
266 /* Disable console buffering */
269 * If RB_NOSYNC was not specified sync the discs.
270 * Note: Unless cold is set to 1 here, syslogd will die during the
271 * unmount. It looks like syslogd is getting woken up only to find
272 * that it cannot page part of the binary in as the filesystem has
275 if (!(howto
& RB_NOSYNC
))
278 /* Say NO to interrupts */
281 /* Do a dump if requested. */
282 if ((howto
& (RB_DUMP
| RB_HALT
)) == RB_DUMP
)
285 /* Run any shutdown hooks */
288 pmf_system_shutdown(boothowto
);
290 /* Make sure IRQ's are disabled */
293 if (howto
& RB_HALT
) {
295 printf("The operating system has halted.\r\n");
296 printf("Please press any key to reboot.\r\n");
300 printf("\r\nrebooting...\r\n");
303 * Make really really sure that all interrupts are disabled,
304 * and poke the Internal Bus and Peripheral Bus reset lines.
306 (void) disable_interrupts(I32_bit
|F32_bit
);
309 u_int32_t feed
, ctrl
;
311 feed
= TS7XXX_IO16_VBASE
+ TS7XXX_WDOGFEED
;
312 ctrl
= TS7XXX_IO16_VBASE
+ TS7XXX_WDOGCTRL
;
320 : "r" (feed
), "r" (ctrl
)
328 /* Static device mappings. */
329 static const struct pmap_devmap tsarm_devmap
[] = {
334 VM_PROT_READ
|VM_PROT_WRITE
,
342 VM_PROT_READ
|VM_PROT_WRITE
,
347 * IO8 and IO16 space *must* be mapped contiguously with
348 * IO8_VA == IO16_VA - 64 Mbytes. ISA busmap driver depends
355 VM_PROT_READ
|VM_PROT_WRITE
,
363 VM_PROT_READ
|VM_PROT_WRITE
,
379 * Initial entry point on startup. This gets called before main() is
381 * It should be responsible for setting up everything that must be
382 * in place when main is called.
384 * Taking a copy of the boot configuration structure.
385 * Initialising the physical console so characters can be printed.
386 * Setting up page tables for the kernel
387 * Initialising interrupt controllers to a sane default state
393 struct bootconfig
*passed_bootconfig
= arg
;
403 /* Calibrate the delay loop. */
404 i80321_calibrate_delay();
408 * Since we map the on-board devices VA==PA, and the kernel
409 * is running VA==PA, it's possible for us to initialize
414 #ifdef VERBOSE_INIT_ARM
415 /* Talk to the user */
416 printf("\nNetBSD/tsarm booting ...\n");
420 * Heads up ... Setup the CPU / MMU / TLB functions
423 panic("cpu not recognized!");
426 * We are currently running with the MMU enabled
431 * Fetch the SDRAM start/size from the i80321 SDRAM configuration
434 i80321_sdram_bounds(&obio_bs_tag
, VERDE_PMMR_BASE
+ VERDE_MCU_BASE
,
435 &memstart
, &memsize
);
441 #ifdef VERBOSE_INIT_ARM
442 printf("initarm: Configuring system ...\n");
445 /* Fake bootconfig structure for the benefit of pmap.c */
446 /* XXX must make the memory description h/w independent */
447 bootconfig
.dramblocks
= 4;
448 bootconfig
.dram
[0].address
= 0x0UL
;
449 bootconfig
.dram
[0].pages
= 0x800000UL
/ PAGE_SIZE
;
450 bootconfig
.dram
[1].address
= 0x1000000UL
;
451 bootconfig
.dram
[1].pages
= 0x800000UL
/ PAGE_SIZE
;
452 bootconfig
.dram
[2].address
= 0x4000000UL
;
453 bootconfig
.dram
[2].pages
= 0x800000UL
/ PAGE_SIZE
;
454 bootconfig
.dram
[3].address
= 0x5000000UL
;
455 bootconfig
.dram
[3].pages
= 0x800000UL
/ PAGE_SIZE
;
458 * Set up the variables that define the availablilty of
459 * physical memory. For now, we're going to set
460 * physical_freestart to 0x00200000 (where the kernel
461 * was loaded), and allocate the memory we need downwards.
462 * If we get too close to the L1 table that we set up, we
463 * will panic. We will update physical_freestart and
464 * physical_freeend later to reflect what pmap_bootstrap()
467 * XXX pmap_bootstrap() needs an enema.
469 physical_start
= bootconfig
.dram
[0].address
;
470 physical_end
= bootconfig
.dram
[0].address
+
471 (bootconfig
.dram
[0].pages
* PAGE_SIZE
);
473 physical_freestart
= 0x00009000UL
;
474 physical_freeend
= 0x00200000UL
;
476 physmem
= (physical_end
- physical_start
) / PAGE_SIZE
;
478 #ifdef VERBOSE_INIT_ARM
479 /* Tell the user about the memory */
480 printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem
,
481 physical_start
, physical_end
- 1);
485 * Okay, the kernel starts 2MB in from the bottom of physical
486 * memory. We are going to allocate our bootstrap pages downwards
489 * We need to allocate some fixed page tables to get the kernel
490 * going. We allocate one page directory and a number of page
491 * tables and store the physical addresses in the kernel_pt_table
494 * The kernel page directory must be on a 16K boundary. The page
495 * tables must be on 4K bounaries. What we do is allocate the
496 * page directory on the first 16K boundary that we encounter, and
497 * the page tables on 4K boundaries otherwise. Since we allocate
498 * at least 3 L2 page tables, we are guaranteed to encounter at
499 * least one 16K aligned region.
502 #ifdef VERBOSE_INIT_ARM
503 printf("Allocating page tables\n");
506 free_pages
= (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
508 #ifdef VERBOSE_INIT_ARM
509 printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
510 physical_freestart
, free_pages
, free_pages
);
513 /* Define a macro to simplify memory allocation */
514 #define valloc_pages(var, np) \
515 alloc_pages((var).pv_pa, (np)); \
516 (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
518 #define alloc_pages(var, np) \
519 physical_freeend -= ((np) * PAGE_SIZE); \
520 if (physical_freeend < physical_freestart) \
521 panic("initarm: out of memory"); \
522 (var) = physical_freeend; \
523 free_pages -= (np); \
524 memset((char *)(var), 0, ((np) * PAGE_SIZE));
527 for (loop
= 0; loop
<= NUM_KERNEL_PTS
; ++loop
) {
528 /* Are we 16KB aligned for an L1 ? */
529 if (((physical_freeend
- L1_TABLE_SIZE
) & (L1_TABLE_SIZE
- 1)) == 0
530 && kernel_l1pt
.pv_pa
== 0) {
531 valloc_pages(kernel_l1pt
, L1_TABLE_SIZE
/ PAGE_SIZE
);
533 valloc_pages(kernel_pt_table
[loop1
],
534 L2_TABLE_SIZE
/ PAGE_SIZE
);
539 /* This should never be able to happen but better confirm that. */
540 if (!kernel_l1pt
.pv_pa
|| (kernel_l1pt
.pv_pa
& (L1_TABLE_SIZE
-1)) != 0)
541 panic("initarm: Failed to align the kernel page directory");
544 * Allocate a page for the system vectors page
546 alloc_pages(systempage
.pv_pa
, 1);
548 /* Allocate stacks for all modes */
549 valloc_pages(irqstack
, IRQ_STACK_SIZE
);
550 valloc_pages(abtstack
, ABT_STACK_SIZE
);
551 valloc_pages(undstack
, UND_STACK_SIZE
);
552 valloc_pages(kernelstack
, UPAGES
);
554 #ifdef VERBOSE_INIT_ARM
555 printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack
.pv_pa
,
557 printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack
.pv_pa
,
559 printf("UND stack: p0x%08lx v0x%08lx\n", undstack
.pv_pa
,
561 printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack
.pv_pa
,
565 alloc_pages(msgbufphys
, round_page(MSGBUFSIZE
) / PAGE_SIZE
);
568 * Ok we have allocated physical pages for the primary kernel
569 * page tables. Save physical_freeend for when we give whats left
570 * of memory below 2Mbyte to UVM.
573 physical_freeend_low
= physical_freeend
;
575 #ifdef VERBOSE_INIT_ARM
576 printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt
.pv_pa
);
580 * Now we start construction of the L1 page table
581 * We start by mapping the L2 page tables into the L1.
582 * This means that we can replace L1 mappings later on if necessary
584 l1pagetable
= kernel_l1pt
.pv_pa
;
586 /* Map the L2 pages tables in the L1 page table */
587 pmap_link_l2pt(l1pagetable
, ARM_VECTORS_HIGH
& ~(0x00400000 - 1),
588 &kernel_pt_table
[KERNEL_PT_SYS
]);
589 for (loop
= 0; loop
< KERNEL_PT_KERNEL_NUM
; loop
++)
590 pmap_link_l2pt(l1pagetable
, KERNEL_BASE
+ loop
* 0x00400000,
591 &kernel_pt_table
[KERNEL_PT_KERNEL
+ loop
]);
592 for (loop
= 0; loop
< KERNEL_PT_VMDATA_NUM
; loop
++)
593 pmap_link_l2pt(l1pagetable
, KERNEL_VM_BASE
+ loop
* 0x00400000,
594 &kernel_pt_table
[KERNEL_PT_VMDATA
+ loop
]);
596 /* update the top of the kernel VM */
598 KERNEL_VM_BASE
+ (KERNEL_PT_VMDATA_NUM
* 0x00400000);
600 #ifdef VERBOSE_INIT_ARM
601 printf("Mapping kernel\n");
604 /* Now we fill in the L2 pagetable for the kernel static code/data */
606 extern char etext
[], _end
[];
607 size_t textsize
= (uintptr_t) etext
- KERNEL_TEXT_BASE
;
608 size_t totalsize
= (uintptr_t) _end
- KERNEL_TEXT_BASE
;
611 textsize
= (textsize
+ PGOFSET
) & ~PGOFSET
;
612 totalsize
= (totalsize
+ PGOFSET
) & ~PGOFSET
;
614 logical
= 0x00200000; /* offset of kernel in RAM */
615 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
616 physical_start
+ logical
, textsize
,
617 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
618 logical
+= pmap_map_chunk(l1pagetable
, KERNEL_BASE
+ logical
,
619 physical_start
+ logical
, totalsize
- textsize
,
620 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
623 #ifdef VERBOSE_INIT_ARM
624 printf("Constructing L2 page tables\n");
627 /* Map the stack pages */
628 pmap_map_chunk(l1pagetable
, irqstack
.pv_va
, irqstack
.pv_pa
,
629 IRQ_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
630 pmap_map_chunk(l1pagetable
, abtstack
.pv_va
, abtstack
.pv_pa
,
631 ABT_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
632 pmap_map_chunk(l1pagetable
, undstack
.pv_va
, undstack
.pv_pa
,
633 UND_STACK_SIZE
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
634 pmap_map_chunk(l1pagetable
, kernelstack
.pv_va
, kernelstack
.pv_pa
,
635 UPAGES
* PAGE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
637 pmap_map_chunk(l1pagetable
, kernel_l1pt
.pv_va
, kernel_l1pt
.pv_pa
,
638 L1_TABLE_SIZE
, VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
640 for (loop
= 0; loop
< NUM_KERNEL_PTS
; ++loop
) {
641 pmap_map_chunk(l1pagetable
, kernel_pt_table
[loop
].pv_va
,
642 kernel_pt_table
[loop
].pv_pa
, L2_TABLE_SIZE
,
643 VM_PROT_READ
|VM_PROT_WRITE
, PTE_PAGETABLE
);
646 /* Map the vector page. */
647 pmap_map_entry(l1pagetable
, ARM_VECTORS_HIGH
, systempage
.pv_pa
,
648 VM_PROT_READ
|VM_PROT_WRITE
, PTE_CACHE
);
650 /* Map the statically mapped devices. */
651 pmap_devmap_bootstrap(l1pagetable
, tsarm_devmap
);
654 * Update the physical_freestart/physical_freeend/free_pages
660 physical_freestart
= physical_start
+
661 (((((uintptr_t) _end
) + PGOFSET
) & ~PGOFSET
) -
663 physical_freeend
= physical_end
;
665 (physical_freeend
- physical_freestart
) / PAGE_SIZE
;
669 * Now we have the real page tables in place so we can switch to them.
670 * Once this is done we will be running with the REAL kernel page
675 #ifdef VERBOSE_INIT_ARM
676 printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
677 physical_freestart
, free_pages
, free_pages
);
678 printf("switching to new L1 page table @%#lx...", kernel_l1pt
.pv_pa
);
680 cpu_domains((DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2)) | DOMAIN_CLIENT
);
681 cpu_setttb(kernel_l1pt
.pv_pa
);
683 cpu_domains(DOMAIN_CLIENT
<< (PMAP_DOMAIN_KERNEL
*2));
686 * Moved from cpu_startup() as data_abort_handler() references
687 * this during uvm init
689 uvm_lwp_setuarea(&lwp0
, kernelstack
.pv_va
);
691 #ifdef VERBOSE_INIT_ARM
695 #ifdef VERBOSE_INIT_ARM
696 printf("bootstrap done.\n");
699 arm32_vector_init(ARM_VECTORS_HIGH
, ARM_VEC_ALL
);
702 * Pages were allocated during the secondary bootstrap for the
703 * stacks for different CPU modes.
704 * We must now set the r13 registers in the different CPU modes to
705 * point to these stacks.
706 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
707 * of the stack memory.
709 #ifdef VERBOSE_INIT_ARM
710 printf("init subsystems: stacks ");
713 set_stackptr(PSR_IRQ32_MODE
,
714 irqstack
.pv_va
+ IRQ_STACK_SIZE
* PAGE_SIZE
);
715 set_stackptr(PSR_ABT32_MODE
,
716 abtstack
.pv_va
+ ABT_STACK_SIZE
* PAGE_SIZE
);
717 set_stackptr(PSR_UND32_MODE
,
718 undstack
.pv_va
+ UND_STACK_SIZE
* PAGE_SIZE
);
721 * Well we should set a data abort handler.
722 * Once things get going this will change as we will need a proper
724 * Until then we will use a handler that just panics but tells us
726 * Initialisation of the vectors will just panic on a data abort.
727 * This just fills in a slightly better one.
729 #ifdef VERBOSE_INIT_ARM
732 data_abort_handler_address
= (u_int
)data_abort_handler
;
733 prefetch_abort_handler_address
= (u_int
)prefetch_abort_handler
;
734 undefined_handler_address
= (u_int
)undefinedinstruction_bounce
;
736 /* Initialise the undefined instruction handlers */
737 #ifdef VERBOSE_INIT_ARM
738 printf("undefined ");
742 /* Load memory into UVM. */
743 #ifdef VERBOSE_INIT_ARM
746 uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
747 uvm_page_physload(atop(physical_freestart
), atop(physical_freeend
),
748 atop(physical_freestart
), atop(physical_freeend
),
749 VM_FREELIST_DEFAULT
);
750 uvm_page_physload(0, atop(physical_freeend_low
),
751 0, atop(physical_freeend_low
),
752 VM_FREELIST_DEFAULT
);
754 * There is 32 Mb of memory on the TS-7200 in 4 8Mb chunks, so far
755 * we've only been working with the first one mapped at 0x0. Tell
756 * UVM about the others.
758 uvm_page_physload(atop(0x1000000), atop(0x1800000),
759 atop(0x1000000), atop(0x1800000),
760 VM_FREELIST_DEFAULT
);
761 uvm_page_physload(atop(0x4000000), atop(0x4800000),
762 atop(0x4000000), atop(0x4800000),
763 VM_FREELIST_DEFAULT
);
764 uvm_page_physload(atop(0x5000000), atop(0x5800000),
765 atop(0x5000000), atop(0x5800000),
766 VM_FREELIST_DEFAULT
);
768 physmem
= 0x2000000 / PAGE_SIZE
;
771 /* Boot strap pmap telling it where the kernel page table is */
772 #ifdef VERBOSE_INIT_ARM
775 pmap_bootstrap(KERNEL_VM_BASE
, KERNEL_VM_BASE
+ KERNEL_VM_SIZE
);
777 /* Setup the IRQ system */
778 #ifdef VERBOSE_INIT_ARM
785 #ifdef VERBOSE_INIT_ARM
788 isa_tsarm_init(TS7XXX_IO16_VBASE
+ TS7XXX_ISAIO
,
789 TS7XXX_IO16_VBASE
+ TS7XXX_ISAMEM
);
792 #ifdef VERBOSE_INIT_ARM
797 boothowto
= BOOTHOWTO
;
802 if (boothowto
& RB_KDB
)
806 /* We return the new stack pointer address */
807 return(kernelstack
.pv_va
+ USPACE_SVC_STACK_TOP
);
813 static int consinit_called
;
814 bus_space_handle_t ioh
;
816 if (consinit_called
!= 0)
822 * Console devices are already mapped in VA. Our devmap reflects
823 * this, so register it now so drivers can map the console
826 pmap_devmap_register(tsarm_devmap
);
828 isa_tsarm_init(TS7XXX_IO16_VBASE
+ TS7XXX_ISAIO
,
829 TS7XXX_IO16_VBASE
+ TS7XXX_ISAMEM
);
831 if (comcnattach(&isa_io_bs_tag
, 0x3e8, comcnspeed
,
832 COM_FREQ
, COM_TYPE_NORMAL
, comcnmode
))
834 panic("can't init serial console");
839 bus_space_map(&ep93xx_bs_tag
, EP93XX_APB_HWBASE
+ EP93XX_APB_UART1
,
840 EP93XX_APB_UART_SIZE
, 0, &ioh
);
841 if (epcomcnattach(&ep93xx_bs_tag
, EP93XX_APB_HWBASE
+ EP93XX_APB_UART1
,
842 ioh
, comcnspeed
, comcnmode
))
844 panic("can't init serial console");
847 panic("serial console not configured");
851 if (strcmp(kgdb_devname
, "epcom") == 0) {
852 com_kgdb_attach(&ep93xx_bs_tag
, kgdb_devaddr
, kgdb_devrate
,
855 #endif /* NEPCOM > 0 */
861 ep93xx_bus_dma_init(struct arm32_bus_dma_tag
*dma_tag_template
)
864 struct arm32_bus_dma_tag
*dmat
;
866 for (i
= 0; i
< bootconfig
.dramblocks
; i
++) {
867 tsarm_dma_ranges
[i
].dr_sysbase
= bootconfig
.dram
[i
].address
;
868 tsarm_dma_ranges
[i
].dr_busbase
= bootconfig
.dram
[i
].address
;
869 tsarm_dma_ranges
[i
].dr_len
= bootconfig
.dram
[i
].pages
*
873 dmat
= dma_tag_template
;
875 dmat
->_ranges
= tsarm_dma_ranges
;
876 dmat
->_nranges
= bootconfig
.dramblocks
;