Kernel load address can be changed now.diff -r1.3 -r1.4 src/sys/arch/zaurus/conf/Makefile.zaurus.inc
(nonaka)
--- src/sys/arch/zaurus/conf/Makefile.zaurus.inc 2011/05/05 09:07:59 1.3
+++ src/sys/arch/zaurus/conf/Makefile.zaurus.inc 2012/01/20 15:00:27 1.4
@@ -1,22 +1,32 @@ | @@ -1,22 +1,32 @@ | |||
1 | # $NetBSD: Makefile.zaurus.inc,v 1.3 2011/05/05 09:07:59 nonaka Exp $ | 1 | # $NetBSD: Makefile.zaurus.inc,v 1.4 2012/01/20 15:00:27 nonaka Exp $ | |
2 | 2 | |||
3 | MACHINE_ARCH= arm | 3 | MACHINE_ARCH= arm | |
4 | CPPFLAGS+= -D${MACHINE} | 4 | CPPFLAGS+= -D${MACHINE} | |
5 | 5 | |||
6 | SYSTEM_FIRST_OBJ= zaurus_start.o | 6 | SYSTEM_FIRST_OBJ= zaurus_start.o | |
7 | SYSTEM_FIRST_SFILE= ${THISARM}/zaurus/zaurus_start.S | 7 | SYSTEM_FIRST_SFILE= ${THISARM}/zaurus/zaurus_start.S | |
8 | 8 | |||
9 | LINKFLAGS= -T ${THISARM}/conf/ldscript | |||
10 | ||||
11 | EXTRA_CLEAN+= netbsd.map assym.d | |||
12 | ||||
13 | SYSTEM_LD_TAIL_EXTRA+=; \ | 9 | SYSTEM_LD_TAIL_EXTRA+=; \ | |
14 | echo "Checking kernel size..."; \ | 10 | echo "Checking kernel size..."; \ | |
15 | size=`wc -c "$@" | ${TOOL_AWK} '{ print $$1 }'`; \ | 11 | size=`wc -c "$@" | ${TOOL_AWK} '{ print $$1 }'`; \ | |
16 | maxsize=5242880; \ | 12 | maxsize=5242880; \ | |
17 | if [ $$size -gt $$maxsize ]; \ | 13 | if [ $$size -gt $$maxsize ]; \ | |
18 | then \ | 14 | then \ | |
19 | echo "Fatal: kernel size must be less than 5MB."; \ | 15 | echo "Fatal: kernel size must be less than 5MB."; \ | |
20 | echo "Fatal: kernel size: $$size, max kernel size: $$maxsize"; \ | 16 | echo "Fatal: kernel size: $$size, max kernel size: $$maxsize"; \ | |
21 | false; \ | 17 | false; \ | |
22 | fi | 18 | fi | |
19 | ||||
20 | KERNEL_BASE_VIRT= $(LOADADDRESS) | |||
21 | ||||
22 | LINKFLAGS= -T ldscript | |||
23 | ||||
24 | EXTRA_CLEAN+= netbsd.map assym.d ldscript tmp | |||
25 | ||||
26 | netbsd: ldscript # XXX | |||
27 | ||||
28 | # generate ldscript from common template | |||
29 | ldscript: ${THISARM}/conf/ldscript.zaurus ${THISARM}/conf/Makefile.zaurus.inc Makefile | |||
30 | ${TOOL_SED} -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \ | |||
31 | -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' \ | |||
32 | ${THISARM}/conf/ldscript.zaurus > tmp && mv tmp $@ |
--- src/sys/arch/zaurus/conf/std.zaurus 2008/01/27 12:37:12 1.3
+++ src/sys/arch/zaurus/conf/std.zaurus 2012/01/20 15:00:27 1.4
@@ -1,21 +1,22 @@ | @@ -1,21 +1,22 @@ | |||
1 | # $NetBSD: std.zaurus,v 1.3 2008/01/27 12:37:12 chris Exp $ | 1 | # $NetBSD: std.zaurus,v 1.4 2012/01/20 15:00:27 nonaka Exp $ | |
2 | # | 2 | # | |
3 | # standard NetBSD/zaurus options | 3 | # standard NetBSD/zaurus options | |
4 | 4 | |||
5 | machine zaurus arm | 5 | machine zaurus arm | |
6 | include "conf/std" # MI standard options | 6 | include "conf/std" # MI standard options | |
7 | include "arch/arm/conf/std.arm" # arch standard options | 7 | include "arch/arm/conf/std.arm" # arch standard options | |
8 | 8 | |||
9 | options EXEC_AOUT | 9 | options EXEC_AOUT | |
10 | options EXEC_ELF32 | 10 | options EXEC_ELF32 | |
11 | options EXEC_SCRIPT | 11 | options EXEC_SCRIPT | |
12 | 12 | |||
13 | # To support easy transit to ../arch/arm/arm32 | 13 | # To support easy transit to ../arch/arm/arm32 | |
14 | options ARM32 | 14 | options ARM32 | |
15 | 15 | |||
16 | #options ARM32_NEW_VM_LAYOUT # Not yet ready for prime-time | 16 | makeoptions KERNEL_BASE_PHYS="0xa0200000" | |
17 | makeoptions LOADADDRESS="0xc0200000" | |||
17 | 18 | |||
18 | options ARM_INTR_IMPL="<arch/arm/xscale/pxa2x0_intr.h>" | 19 | options ARM_INTR_IMPL="<arch/arm/xscale/pxa2x0_intr.h>" | |
19 | 20 | |||
20 | # OS Timer | 21 | # OS Timer | |
21 | saost* at pxaip? addr 0x40a00000 size 0x20 | 22 | saost* at pxaip? addr 0x40a00000 size 0x20 |
/* $NetBSD: ldscript.zaurus,v 1.3 2012/01/20 15:00:27 nonaka Exp $ */
OUTPUT_ARCH(arm)
ENTRY(KERNEL_BASE_phys)
SECTIONS
{
KERNEL_BASE_phys = @KERNEL_BASE_PHYS@;
KERNEL_BASE_virt = @KERNEL_BASE_VIRT@;
/* Kernel start: */
.start (KERNEL_BASE_phys) :
{
*(.start)
} =0
/* Read-only sections, merged into text segment: */
.text (KERNEL_BASE_virt + SIZEOF(.start)) :
AT (LOADADDR(.start) + SIZEOF(.start))
{
*(.text)
*(.text.*)
*(.stub)
*(.glue_7t) *(.glue_7)
*(.rodata) *(.rodata.*)
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
/* Adjust the address for the data segment to start on the next page
boundary. */
. = ALIGN(0x8000);
.data :
AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
{
__data_start = . ;
*(.data)
*(.data.*)
}
.sdata :
AT (LOADADDR(.data) + (ADDR(.sdata) - ADDR(.data)))
{
*(.sdata)
*(.sdata.*)
}
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
__bss_start__ = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss)
*(.sbss.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.bss :
{
*(.dynbss)
*(.bss)
*(.bss.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
_bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
PROVIDE (end = .);
.note.netbsd.ident :
{
KEEP(*(.note.netbsd.ident));
}
}
--- src/sys/arch/zaurus/zaurus/kloader_machdep.c 2011/11/20 04:07:50 1.4
+++ src/sys/arch/zaurus/zaurus/kloader_machdep.c 2012/01/20 15:00:27 1.5
@@ -1,62 +1,60 @@ | @@ -1,62 +1,60 @@ | |||
1 | /* $NetBSD: kloader_machdep.c,v 1.4 2011/11/20 04:07:50 nonaka Exp $ */ | 1 | /* $NetBSD: kloader_machdep.c,v 1.5 2012/01/20 15:00:27 nonaka Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2009 NONAKA Kimihiro <nonaka@netbsd.org> | 4 | * Copyright (c) 2009-2012 NONAKA Kimihiro <nonaka@netbsd.org> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
15 | * | 15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 16 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: kloader_machdep.c,v 1.4 2011/11/20 04:07:50 nonaka Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: kloader_machdep.c,v 1.5 2012/01/20 15:00:27 nonaka Exp $"); | |
31 | 31 | |||
32 | #include "debug_kloader.h" | 32 | #include "debug_kloader.h" | |
33 | 33 | |||
34 | #include <sys/param.h> | 34 | #include <sys/param.h> | |
35 | #include <sys/systm.h> | 35 | #include <sys/systm.h> | |
36 | #include <sys/device.h> | 36 | #include <sys/device.h> | |
37 | #include <sys/disklabel.h> | 37 | #include <sys/disklabel.h> | |
38 | 38 | |||
39 | #include <machine/kloader.h> | 39 | #include <machine/kloader.h> | |
40 | #include <machine/pmap.h> | 40 | #include <machine/pmap.h> | |
41 | 41 | |||
42 | #include <arm/cpufunc.h> | 42 | #include <arm/cpufunc.h> | |
43 | #include <arm/xscale/pxa2x0reg.h> | 43 | #include <arm/xscale/pxa2x0reg.h> | |
44 | 44 | |||
45 | #include <zaurus/zaurus/zaurus_var.h> | 45 | #include <zaurus/zaurus/zaurus_var.h> | |
46 | 46 | |||
47 | #ifndef KERNEL_BASE | 47 | #define KERNEL_TEXT_BASE ((vaddr_t)&KERNEL_BASE_virt) | |
48 | #define KERNEL_BASE 0xc0000000 | |||
49 | #endif | |||
50 | 48 | |||
51 | kloader_jumpfunc_t kloader_zaurus_jump __attribute__((__noreturn__)); | 49 | kloader_jumpfunc_t kloader_zaurus_jump __attribute__((__noreturn__)); | |
52 | kloader_bootfunc_t kloader_zaurus_boot __attribute__((__noreturn__)); | 50 | kloader_bootfunc_t kloader_zaurus_boot __attribute__((__noreturn__)); | |
53 | void kloader_zaurus_reset(void); | 51 | void kloader_zaurus_reset(void); | |
54 | 52 | |||
55 | struct kloader_ops kloader_zaurus_ops = { | 53 | struct kloader_ops kloader_zaurus_ops = { | |
56 | .jump = kloader_zaurus_jump, | 54 | .jump = kloader_zaurus_jump, | |
57 | .boot = kloader_zaurus_boot, | 55 | .boot = kloader_zaurus_boot, | |
58 | .reset = kloader_zaurus_reset, | 56 | .reset = kloader_zaurus_reset, | |
59 | }; | 57 | }; | |
60 | 58 | |||
61 | void | 59 | void | |
62 | kloader_reboot_setup(const char *filename) | 60 | kloader_reboot_setup(const char *filename) | |
@@ -68,83 +66,85 @@ kloader_reboot_setup(const char *filenam | @@ -68,83 +66,85 @@ kloader_reboot_setup(const char *filenam | |||
68 | void | 66 | void | |
69 | kloader_zaurus_reset(void) | 67 | kloader_zaurus_reset(void) | |
70 | { | 68 | { | |
71 | 69 | |||
72 | zaurus_restart(); | 70 | zaurus_restart(); | |
73 | /*NOTREACHED*/ | 71 | /*NOTREACHED*/ | |
74 | } | 72 | } | |
75 | 73 | |||
76 | void | 74 | void | |
77 | kloader_zaurus_jump(kloader_bootfunc_t func, vaddr_t sp, | 75 | kloader_zaurus_jump(kloader_bootfunc_t func, vaddr_t sp, | |
78 | struct kloader_bootinfo *kbi, struct kloader_page_tag *tag) | 76 | struct kloader_bootinfo *kbi, struct kloader_page_tag *tag) | |
79 | { | 77 | { | |
80 | extern int kloader_howto; | 78 | extern int kloader_howto; | |
81 | void (*bootinfop)(void *, void *) = (void *)(0xc0200000 - PAGE_SIZE); | 79 | extern char KERNEL_BASE_virt[]; | |
82 | uint32_t *bootmagicp = (uint32_t *)(0xc0200000 - BOOTARGS_BUFSIZ); | 80 | void (*bootinfop)(void *, void *); | |
81 | uint32_t *bootmagicp; | |||
83 | vaddr_t top, ptr; | 82 | vaddr_t top, ptr; | |
84 | struct bootinfo *bootinfo; | 83 | struct bootinfo *bootinfo; | |
85 | struct btinfo_howto *bi_howto; | 84 | struct btinfo_howto *bi_howto; | |
86 | struct btinfo_rootdevice *bi_rootdv; | 85 | struct btinfo_rootdevice *bi_rootdv; | |
87 | 86 | |||
88 | disable_interrupts(I32_bit|F32_bit); | 87 | disable_interrupts(I32_bit|F32_bit); | |
89 | 88 | |||
90 | /* copy 2nd boot-loader to va=pa page */ | 89 | /* copy 2nd boot-loader to va=pa page */ | |
90 | bootinfop = (void *)(KERNEL_TEXT_BASE - PAGE_SIZE); | |||
91 | memmove(bootinfop, func, PAGE_SIZE); | 91 | memmove(bootinfop, func, PAGE_SIZE); | |
92 | 92 | |||
93 | /* | 93 | /* | |
94 | * make bootinfo | 94 | * make bootinfo | |
95 | */ | 95 | */ | |
96 | bootmagicp = (uint32_t *)(KERNEL_TEXT_BASE - BOOTARGS_BUFSIZ); | |||
96 | memset(bootmagicp, 0, BOOTARGS_BUFSIZ); | 97 | memset(bootmagicp, 0, BOOTARGS_BUFSIZ); | |
97 | bootinfo = (struct bootinfo *)(bootmagicp + 1); | 98 | bootinfo = (struct bootinfo *)(bootmagicp + 1); | |
98 | bootinfo->nentries = 0; | 99 | bootinfo->nentries = 0; | |
99 | top = ptr = (vaddr_t)bootinfo->info; | 100 | top = ptr = (vaddr_t)bootinfo->info; | |
100 | 101 | |||
101 | /* pass to howto for new kernel */ | 102 | /* pass to howto for new kernel */ | |
102 | bi_howto = (struct btinfo_howto *)ptr; | 103 | bi_howto = (struct btinfo_howto *)ptr; | |
103 | bi_howto->common.len = sizeof(struct btinfo_howto); | 104 | bi_howto->common.len = sizeof(struct btinfo_howto); | |
104 | bi_howto->common.type = BTINFO_HOWTO; | 105 | bi_howto->common.type = BTINFO_HOWTO; | |
105 | bi_howto->howto = kloader_howto; | 106 | bi_howto->howto = kloader_howto; | |
106 | bootinfo->nentries++; | 107 | bootinfo->nentries++; | |
107 | ptr += bi_howto->common.len; | 108 | ptr += bi_howto->common.len; | |
108 | 109 | |||
109 | /* set previous root device for new boot device */ | 110 | /* set previous root device for new boot device */ | |
110 | if (root_device != NULL | 111 | if (root_device != NULL | |
111 | && device_class(root_device) == DV_DISK | 112 | && device_class(root_device) == DV_DISK | |
112 | && !device_is_a(root_device, "dk")) { | 113 | && !device_is_a(root_device, "dk")) { | |
113 | bi_rootdv = (struct btinfo_rootdevice *)ptr; | 114 | bi_rootdv = (struct btinfo_rootdevice *)ptr; | |
114 | bi_rootdv->common.len = sizeof(struct btinfo_rootdevice); | 115 | bi_rootdv->common.len = sizeof(struct btinfo_rootdevice); | |
115 | bi_rootdv->common.type = BTINFO_ROOTDEVICE; | 116 | bi_rootdv->common.type = BTINFO_ROOTDEVICE; | |
116 | snprintf(bi_rootdv->devname, sizeof(bi_rootdv->devname), "%s%c", | 117 | snprintf(bi_rootdv->devname, sizeof(bi_rootdv->devname), "%s%c", | |
117 | device_xname(root_device), (int)DISKPART(rootdev) + 'a'); | 118 | device_xname(root_device), (int)DISKPART(rootdev) + 'a'); | |
118 | bootinfo->nentries++; | 119 | bootinfo->nentries++; | |
119 | ptr += bi_rootdv->common.len; | 120 | ptr += bi_rootdv->common.len; | |
120 | } | 121 | } | |
121 | 122 | |||
122 | if (bootinfo->nentries > 0) | 123 | *bootmagicp = BOOTARGS_MAGIC; | |
123 | *bootmagicp = BOOTARGS_MAGIC; | |||
124 | cpu_idcache_wbinv_all(); | 124 | cpu_idcache_wbinv_all(); | |
125 | 125 | |||
126 | /* jump to 2nd boot-loader */ | 126 | /* jump to 2nd boot-loader */ | |
127 | (*bootinfop)(kbi, tag); | 127 | (*bootinfop)(kbi, tag); | |
128 | 128 | |||
129 | /*NOTREACHED*/ | 129 | /*NOTREACHED*/ | |
130 | for (;;) | 130 | for (;;) | |
131 | continue; | 131 | continue; | |
132 | } | 132 | } | |
133 | 133 | |||
134 | /* | 134 | /* | |
135 | * Physcal address to virtual address | 135 | * Physcal address to virtual address | |
136 | */ | 136 | */ | |
137 | vaddr_t | 137 | vaddr_t | |
138 | kloader_phystov(paddr_t pa) | 138 | kloader_phystov(paddr_t pa) | |
139 | { | 139 | { | |
140 | vaddr_t va; | 140 | vaddr_t va; | |
141 | int error; | 141 | int error; | |
142 | 142 | |||
143 | va = KERNEL_BASE + pa - 0xa0000000UL; | 143 | va = KERNEL_BASE + pa - PXA2X0_SDRAM0_START; | |
144 | error = pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL, 0); | 144 | error = pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL, 0); | |
145 | if (error) { | 145 | if (error) { | |
146 | printf("%s: map failed: pa=0x%lx, va=0x%lx, error=%d\n", | 146 | printf("%s: map failed: pa=0x%lx, va=0x%lx, error=%d\n", | |
147 | __func__, pa, va, error); | 147 | __func__, pa, va, error); | |
148 | } | 148 | } | |
149 | return va; | 149 | return va; | |
150 | } | 150 | } |
--- src/sys/arch/zaurus/zaurus/machdep.c 2011/11/12 04:39:19 1.27
+++ src/sys/arch/zaurus/zaurus/machdep.c 2012/01/20 15:00:27 1.28
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.c,v 1.27 2011/11/12 04:39:19 nonaka Exp $ */ | 1 | /* $NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $ */ | |
2 | /* $OpenBSD: zaurus_machdep.c,v 1.25 2006/06/20 18:24:04 todd Exp $ */ | 2 | /* $OpenBSD: zaurus_machdep.c,v 1.25 2006/06/20 18:24:04 todd Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. | 5 | * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. | |
6 | * Written by Hiroyuki Bessho for Genetec Corporation. | 6 | * Written by Hiroyuki Bessho for Genetec Corporation. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -97,27 +97,27 @@ | @@ -97,27 +97,27 @@ | |||
97 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 97 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
98 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 98 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
99 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 99 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
101 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 101 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
102 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 102 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
103 | * SUCH DAMAGE. | 103 | * SUCH DAMAGE. | |
104 | * | 104 | * | |
105 | * Machine dependent functions for kernel setup for Intel IQ80310 evaluation | 105 | * Machine dependent functions for kernel setup for Intel IQ80310 evaluation | |
106 | * boards using RedBoot firmware. | 106 | * boards using RedBoot firmware. | |
107 | */ | 107 | */ | |
108 | 108 | |||
109 | #include <sys/cdefs.h> | 109 | #include <sys/cdefs.h> | |
110 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.27 2011/11/12 04:39:19 nonaka Exp $"); | 110 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $"); | |
111 | 111 | |||
112 | #include "opt_ddb.h" | 112 | #include "opt_ddb.h" | |
113 | #include "opt_kgdb.h" | 113 | #include "opt_kgdb.h" | |
114 | #include "opt_modular.h" | 114 | #include "opt_modular.h" | |
115 | #include "opt_pmap_debug.h" | 115 | #include "opt_pmap_debug.h" | |
116 | #include "opt_md.h" | 116 | #include "opt_md.h" | |
117 | #include "opt_com.h" | 117 | #include "opt_com.h" | |
118 | #include "ksyms.h" | 118 | #include "ksyms.h" | |
119 | 119 | |||
120 | #include "opt_kloader.h" | 120 | #include "opt_kloader.h" | |
121 | #ifndef KLOADER_KERNEL_PATH | 121 | #ifndef KLOADER_KERNEL_PATH | |
122 | #define KLOADER_KERNEL_PATH "/netbsd" | 122 | #define KLOADER_KERNEL_PATH "/netbsd" | |
123 | #endif | 123 | #endif | |
@@ -169,28 +169,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | @@ -169,28 +169,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | |||
169 | #include <zaurus/dev/scoopreg.h> | 169 | #include <zaurus/dev/scoopreg.h> | |
170 | #include <zaurus/dev/zlcdvar.h> | 170 | #include <zaurus/dev/zlcdvar.h> | |
171 | 171 | |||
172 | #include <dev/ic/comreg.h> | 172 | #include <dev/ic/comreg.h> | |
173 | 173 | |||
174 | #if 0 /* XXX */ | 174 | #if 0 /* XXX */ | |
175 | #include "apm.h" | 175 | #include "apm.h" | |
176 | #endif /* XXX */ | 176 | #endif /* XXX */ | |
177 | #if NAPM > 0 | 177 | #if NAPM > 0 | |
178 | #include <zaurus/dev/zapmvar.h> | 178 | #include <zaurus/dev/zapmvar.h> | |
179 | #endif | 179 | #endif | |
180 | 180 | |||
181 | /* Kernel text starts 2MB in from the bottom of the kernel address space. */ | 181 | /* Kernel text starts 2MB in from the bottom of the kernel address space. */ | |
182 | #define KERNEL_TEXT_OFFSET 0x00200000 | 182 | #define KERNEL_TEXT_BASE ((vaddr_t)&KERNEL_BASE_virt) | |
183 | #define KERNEL_TEXT_BASE (KERNEL_BASE + KERNEL_TEXT_OFFSET) | |||
184 | #ifndef KERNEL_VM_BASE | 183 | #ifndef KERNEL_VM_BASE | |
185 | #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000) | 184 | #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000) | |
186 | #endif | 185 | #endif | |
187 | 186 | |||
188 | /* | 187 | /* | |
189 | * The range 0xc4000000 - 0xcfffffff is available for kernel VM space | 188 | * The range 0xc4000000 - 0xcfffffff is available for kernel VM space | |
190 | * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff | 189 | * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff | |
191 | */ | 190 | */ | |
192 | #define KERNEL_VM_SIZE 0x0c000000 | 191 | #define KERNEL_VM_SIZE 0x0c000000 | |
193 | 192 | |||
194 | /* | 193 | /* | |
195 | * Address to call from cpu_reset() to reset the machine. | 194 | * Address to call from cpu_reset() to reset the machine. | |
196 | * This is machine architecture dependent as it varies depending | 195 | * This is machine architecture dependent as it varies depending | |
@@ -255,27 +254,27 @@ const char *console = | @@ -255,27 +254,27 @@ const char *console = | |||
255 | int glass_console = 0; | 254 | int glass_console = 0; | |
256 | 255 | |||
257 | #ifdef KLOADER | 256 | #ifdef KLOADER | |
258 | pv_addr_t bootinfo_pt; | 257 | pv_addr_t bootinfo_pt; | |
259 | pv_addr_t bootinfo_pg; | 258 | pv_addr_t bootinfo_pg; | |
260 | struct kloader_bootinfo kbootinfo; | 259 | struct kloader_bootinfo kbootinfo; | |
261 | int kloader_howto = 0; | 260 | int kloader_howto = 0; | |
262 | #else | 261 | #else | |
263 | struct bootinfo _bootinfo; | 262 | struct bootinfo _bootinfo; | |
264 | #endif | 263 | #endif | |
265 | struct bootinfo *bootinfo; | 264 | struct bootinfo *bootinfo; | |
266 | struct btinfo_howto *bi_howto; | 265 | struct btinfo_howto *bi_howto; | |
267 | 266 | |||
268 | #define KERNEL_BASE_PHYS (PXA2X0_SDRAM0_START + KERNEL_TEXT_OFFSET) | 267 | #define KERNEL_BASE_PHYS ((paddr_t)&KERNEL_BASE_phys) | |
269 | #define BOOTINFO_PAGE (KERNEL_BASE_PHYS - PAGE_SIZE) | 268 | #define BOOTINFO_PAGE (KERNEL_BASE_PHYS - PAGE_SIZE) | |
270 | 269 | |||
271 | /* Prototypes */ | 270 | /* Prototypes */ | |
272 | void consinit(void); | 271 | void consinit(void); | |
273 | void dumpsys(void); | 272 | void dumpsys(void); | |
274 | #ifdef KGDB | 273 | #ifdef KGDB | |
275 | void kgdb_port_init(void); | 274 | void kgdb_port_init(void); | |
276 | #endif | 275 | #endif | |
277 | #ifdef KLOADER | 276 | #ifdef KLOADER | |
278 | static int parseboot(char *arg, char **filename, int *howto); | 277 | static int parseboot(char *arg, char **filename, int *howto); | |
279 | static char *gettrailer(char *arg); | 278 | static char *gettrailer(char *arg); | |
280 | static int parseopts(const char *opts, int *howto); | 279 | static int parseopts(const char *opts, int *howto); | |
281 | #endif | 280 | #endif | |
@@ -630,26 +629,27 @@ hw_isc1000(void) | @@ -630,26 +629,27 @@ hw_isc1000(void) | |||
630 | * This includes | 629 | * This includes | |
631 | * Taking a copy of the boot configuration structure. | 630 | * Taking a copy of the boot configuration structure. | |
632 | * Initialising the physical console so characters can be printed. | 631 | * Initialising the physical console so characters can be printed. | |
633 | * Setting up page tables for the kernel | 632 | * Setting up page tables for the kernel | |
634 | * Relocating the kernel to the bottom of physical memory | 633 | * Relocating the kernel to the bottom of physical memory | |
635 | */ | 634 | */ | |
636 | u_int | 635 | u_int | |
637 | initarm(void *arg) | 636 | initarm(void *arg) | |
638 | { | 637 | { | |
639 | #ifdef DIAGNOSTIC | 638 | #ifdef DIAGNOSTIC | |
640 | extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */ | 639 | extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */ | |
641 | #endif | 640 | #endif | |
642 | extern vaddr_t xscale_cache_clean_addr; | 641 | extern vaddr_t xscale_cache_clean_addr; | |
642 | extern char KERNEL_BASE_phys[], KERNEL_BASE_virt[]; | |||
643 | int loop; | 643 | int loop; | |
644 | int loop1; | 644 | int loop1; | |
645 | u_int l1pagetable; | 645 | u_int l1pagetable; | |
646 | paddr_t memstart; | 646 | paddr_t memstart; | |
647 | psize_t memsize; | 647 | psize_t memsize; | |
648 | struct pxa2x0_gpioconf **zaurus_gpioconf; | 648 | struct pxa2x0_gpioconf **zaurus_gpioconf; | |
649 | u_int *magicaddr; | 649 | u_int *magicaddr; | |
650 | 650 | |||
651 | /* Get ready for zaurus_restart() */ | 651 | /* Get ready for zaurus_restart() */ | |
652 | pxa2x0_memctl_bootstrap(PXA2X0_MEMCTL_BASE); | 652 | pxa2x0_memctl_bootstrap(PXA2X0_MEMCTL_BASE); | |
653 | 653 | |||
654 | /* | 654 | /* | |
655 | * Heads up ... Setup the CPU / MMU / TLB functions | 655 | * Heads up ... Setup the CPU / MMU / TLB functions | |
@@ -921,28 +921,29 @@ initarm(void *arg) | @@ -921,28 +921,29 @@ initarm(void *arg) | |||
921 | printf("Mapping kernel\n"); | 921 | printf("Mapping kernel\n"); | |
922 | #endif | 922 | #endif | |
923 | 923 | |||
924 | /* Now we fill in the L2 pagetable for the kernel static code/data | 924 | /* Now we fill in the L2 pagetable for the kernel static code/data | |
925 | * and the symbol table. */ | 925 | * and the symbol table. */ | |
926 | { | 926 | { | |
927 | extern char etext[], _end[]; | 927 | extern char etext[], _end[]; | |
928 | size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE; | 928 | size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE; | |
929 | size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE; | 929 | size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE; | |
930 | u_int logical; | 930 | u_int logical; | |
931 | 931 | |||
932 | textsize = (textsize + PGOFSET) & ~PGOFSET; | 932 | textsize = (textsize + PGOFSET) & ~PGOFSET; | |
933 | totalsize = (totalsize + PGOFSET) & ~PGOFSET; | 933 | totalsize = (totalsize + PGOFSET) & ~PGOFSET; | |
934 | 934 | |||
935 | logical = KERNEL_TEXT_OFFSET; /* offset of kernel in RAM */ | 935 | /* offset of kernel in RAM */ | |
936 | logical = KERNEL_TEXT_BASE - KERNEL_BASE; | |||
936 | 937 | |||
937 | logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical, | 938 | logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical, | |
938 | physical_start + logical, textsize, | 939 | physical_start + logical, textsize, | |
939 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); | 940 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); | |
940 | pmap_map_chunk(l1pagetable, KERNEL_BASE + logical, | 941 | pmap_map_chunk(l1pagetable, KERNEL_BASE + logical, | |
941 | physical_start + logical, totalsize - textsize, | 942 | physical_start + logical, totalsize - textsize, | |
942 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); | 943 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); | |
943 | } | 944 | } | |
944 | 945 | |||
945 | #ifdef VERBOSE_INIT_ARM | 946 | #ifdef VERBOSE_INIT_ARM | |
946 | printf("Constructing L2 page tables\n"); | 947 | printf("Constructing L2 page tables\n"); | |
947 | #endif | 948 | #endif | |
948 | 949 |