Revision 03e9c04a
untarred prex
prex-0.9.0/Makefile | ||
---|---|---|
1 |
SUBDIR:= bsp sys usr |
|
2 |
SRCDIR:= $(CURDIR) |
|
3 |
export SRCDIR |
|
4 |
|
|
5 |
include $(SRCDIR)/mk/image.mk |
prex-0.9.0/bsp/Makefile | ||
---|---|---|
1 |
include $(SRCDIR)/mk/own.mk |
|
2 |
|
|
3 |
SUBDIR:= boot hal drv |
|
4 |
|
|
5 |
include $(SRCDIR)/mk/subdir.mk |
prex-0.9.0/bsp/boot/Makefile | ||
---|---|---|
1 |
# Rules to compile boot loader |
|
2 |
|
|
3 |
include $(SRCDIR)/mk/own.mk |
|
4 |
|
|
5 |
TARGET:= bootldr |
|
6 |
|
|
7 |
#MAP:= bootldr.map |
|
8 |
#DISASM:= bootldr.lst |
|
9 |
#SYMBOL:= bootldr.sym |
|
10 |
|
|
11 |
_KERNEL_:= 1 |
|
12 |
DEFS+= KERNEL |
|
13 |
|
|
14 |
include $(CURDIR)/$(ARCH)/$(PLATFORM)/Makefile.inc |
|
15 |
include $(CURDIR)/$(ARCH)/arch/Makefile.inc |
|
16 |
include $(CURDIR)/common/Makefile.inc |
|
17 |
|
|
18 |
LIBSDIR+= $(SRCDIR)/conf |
|
19 |
INCSDIR+= $(CURDIR)/include $(CURDIR)/$(ARCH) |
|
20 |
ifndef LDSCRIPT |
|
21 |
LDSCRIPT:= $(CURDIR)/$(ARCH)/arch/boot.ld |
|
22 |
endif |
|
23 |
|
|
24 |
include $(SRCDIR)/mk/common.mk |
|
25 |
|
|
26 |
$(TARGET): $(OBJS) $(LIBS) $(LDSCRIPT) |
|
27 |
$(call echo-file,LD ,$@) |
|
28 |
$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(OBJS) $(LIBS) $(PLATFORM_LIBS) |
|
29 |
$(ASMGEN) |
|
30 |
$(SYMGEN) |
|
31 |
$(OBJCOPY) -O binary -R .note -R .comment -S $@ |
prex-0.9.0/bsp/boot/arm/arch/Makefile.inc | ||
---|---|---|
1 |
|
|
2 |
SRCS+= arm/arch/elf_reloc.c |
prex-0.9.0/bsp/boot/arm/arch/boot.ld | ||
---|---|---|
1 |
/* |
|
2 |
* Linker script for boot loader |
|
3 |
*/ |
|
4 |
INCLUDE config.ld |
|
5 |
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") |
|
6 |
OUTPUT_ARCH(arm) |
|
7 |
SECTIONS { |
|
8 |
. = CONFIG_LOADER_TEXT ; |
|
9 |
|
|
10 |
.text . : { |
|
11 |
*(.text) |
|
12 |
} |
|
13 |
. = ALIGN(4); |
|
14 |
.rodata . : { |
|
15 |
*(.rodata) |
|
16 |
*(.rodata.*) |
|
17 |
} |
|
18 |
. = ALIGN(4); |
|
19 |
.data . : { |
|
20 |
*(.data) |
|
21 |
} |
|
22 |
. = ALIGN(4); |
|
23 |
.bss . : { |
|
24 |
*(.bss) |
|
25 |
*(COMMON) |
|
26 |
} |
|
27 |
. = CONFIG_LOADER_TEXT + 0x1fff; |
|
28 |
.tail : { |
|
29 |
*(.tail) |
|
30 |
} |
|
31 |
} |
prex-0.9.0/bsp/boot/arm/arch/elf_reloc.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2006, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
#include <sys/param.h> |
|
31 |
#include <sys/elf.h> |
|
32 |
#include <boot.h> |
|
33 |
|
|
34 |
int |
|
35 |
relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect) |
|
36 |
{ |
|
37 |
Elf32_Addr *where, tmp; |
|
38 |
Elf32_Sword addend; |
|
39 |
|
|
40 |
where = (Elf32_Addr *)(target_sect + rel->r_offset); |
|
41 |
|
|
42 |
switch (ELF32_R_TYPE(rel->r_info)) { |
|
43 |
case R_ARM_NONE: |
|
44 |
break; |
|
45 |
case R_ARM_ABS32: |
|
46 |
*where += (vaddr_t)ptokv(sym_val); |
|
47 |
ELFDBG(("R_ARM_ABS32: %lx -> %lx\n", |
|
48 |
(long)where, (long)*where)); |
|
49 |
break; |
|
50 |
case R_ARM_PC24: |
|
51 |
case R_ARM_PLT32: |
|
52 |
case R_ARM_CALL: |
|
53 |
case R_ARM_JUMP24: |
|
54 |
addend = (Elf32_Sword)(*where & 0x00ffffff); |
|
55 |
if (addend & 0x00800000) |
|
56 |
addend |= 0xff000000; |
|
57 |
tmp = sym_val - (Elf32_Addr)where + (addend << 2); |
|
58 |
tmp >>= 2; |
|
59 |
*where = (*where & 0xff000000) | (tmp & 0x00ffffff); |
|
60 |
ELFDBG(("R_ARM_PC24: %lx -> %lx\n", |
|
61 |
(long)where, (long)*where)); |
|
62 |
break; |
|
63 |
default: |
|
64 |
ELFDBG(("Unkown relocation type=%d\n", |
|
65 |
ELF32_R_TYPE(rel->r_info))); |
|
66 |
panic("relocation fail"); |
|
67 |
return -1; |
|
68 |
} |
|
69 |
return 0; |
|
70 |
} |
|
71 |
|
|
72 |
int |
|
73 |
relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sec) |
|
74 |
{ |
|
75 |
|
|
76 |
panic("invalid relocation type"); |
|
77 |
return -1; |
|
78 |
} |
prex-0.9.0/bsp/boot/arm/arch/head.S | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2008, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
* head.S - generic header code for ARM platforms. |
|
32 |
*/ |
|
33 |
|
|
34 |
#include <conf/config.h> |
|
35 |
#include <machine/memory.h> |
|
36 |
#include <machine/syspage.h> |
|
37 |
|
|
38 |
#define ENTRY(x) .global x; .align; x##: |
|
39 |
|
|
40 |
.section ".text","ax" |
|
41 |
.code 32 |
|
42 |
/* |
|
43 |
* Loader entry point |
|
44 |
*/ |
|
45 |
ENTRY(boot_entry) |
|
46 |
b start_vector |
|
47 |
|
|
48 |
.align |
|
49 |
.code 32 |
|
50 |
stack_end: .word (BOOTSTKTOP - KERNBASE) |
|
51 |
|
|
52 |
start_vector: |
|
53 |
mov r0, #0xd3 /* Enter SVC mode, Disable IRQ,FIQ */ |
|
54 |
msr cpsr_c, r0 |
|
55 |
ldr sp, stack_end |
|
56 |
|
|
57 |
adr r0, thumb_mode + 1 |
|
58 |
bx r0 |
|
59 |
.code 16 |
|
60 |
thumb_mode: |
|
61 |
|
|
62 |
ldr r0, =main |
|
63 |
bx r0 /* Change to ARM mode */ |
|
64 |
|
|
65 |
.section .tail,"ax" |
|
66 |
dummy: |
|
67 |
.byte 0xff |
|
68 |
|
|
69 |
.end |
prex-0.9.0/bsp/boot/arm/gba/Makefile.inc | ||
---|---|---|
1 |
|
|
2 |
SRCS:= arm/gba/head.S \ |
|
3 |
arm/gba/startup.c \ |
|
4 |
arm/gba/debug.c |
|
5 |
|
prex-0.9.0/bsp/boot/arm/gba/debug.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
#include <sys/param.h> |
|
31 |
#include <boot.h> |
|
32 |
|
|
33 |
#if defined(DEBUG) && defined(CONFIG_DIAG_VBA) |
|
34 |
extern void vba_putc(int); |
|
35 |
#endif |
|
36 |
|
|
37 |
/* |
|
38 |
* Print one chracter |
|
39 |
*/ |
|
40 |
void |
|
41 |
debug_putc(int c) |
|
42 |
{ |
|
43 |
|
|
44 |
#if defined(DEBUG) && defined(CONFIG_DIAG_VBA) |
|
45 |
vba_putc(c); |
|
46 |
#endif |
|
47 |
} |
|
48 |
|
|
49 |
/* |
|
50 |
* Initialize debug port. |
|
51 |
*/ |
|
52 |
void |
|
53 |
debug_init(void) |
|
54 |
{ |
|
55 |
/* DO NOTHING */ |
|
56 |
} |
|
57 |
|
prex-0.9.0/bsp/boot/arm/gba/head.S | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
* head.S - low level platform support |
|
32 |
* |
|
33 |
* This file contains the code from crt0.S which is released under |
|
34 |
* public domain by Jeff Frohwein. |
|
35 |
*/ |
|
36 |
|
|
37 |
/*- |
|
38 |
* Memory usage: |
|
39 |
* |
|
40 |
* 0x02000000 - 0x0203ffff : EWRAM (256K) |
|
41 |
* 0x03000000 - 0x03007fff : IWRAM (32K) |
|
42 |
* 0x04000000 - 0x040003ff : I/O Register (1K) |
|
43 |
* 0x05000000 - 0x050003ff : Palette RAM (1K) |
|
44 |
* 0x06000000 - 0x06017fff : VRAM (96K) |
|
45 |
* |
|
46 |
* Note: |
|
47 |
* 0x03007f00 - 0x03007fff is reserved by GBA BIOS. |
|
48 |
*/ |
|
49 |
|
|
50 |
#include <conf/config.h> |
|
51 |
#include <machine/memory.h> |
|
52 |
#include <machine/syspage.h> |
|
53 |
|
|
54 |
#define ENTRY(x) .global x; .align; x##: |
|
55 |
|
|
56 |
.section ".text","ax" |
|
57 |
.code 32 |
|
58 |
/* |
|
59 |
* Loader start point |
|
60 |
*/ |
|
61 |
ENTRY(boot_entry) |
|
62 |
b rom_header_end |
|
63 |
|
|
64 |
/* |
|
65 |
* GBA ROM header |
|
66 |
*/ |
|
67 |
|
|
68 |
/* Nintendo Logo Character Data (8000004h) */ |
|
69 |
.fill 156,1,0 |
|
70 |
|
|
71 |
/* Game Title (80000A0h) */ |
|
72 |
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
|
73 |
.byte 0x00,0x00,0x00,0x00 |
|
74 |
|
|
75 |
/* Game Code (80000ACh) */ |
|
76 |
.byte 0x00,0x00,0x00,0x00 |
|
77 |
|
|
78 |
/* Maker Code (80000B0h) */ |
|
79 |
.byte 0x30,0x31 |
|
80 |
|
|
81 |
/* Fixed Value (80000B2h) */ |
|
82 |
.byte 0x96 |
|
83 |
|
|
84 |
/* Main Unit Code (80000B3h) */ |
|
85 |
.byte 0x00 |
|
86 |
|
|
87 |
/* Device Type (80000B4h) */ |
|
88 |
.byte 0x00 |
|
89 |
|
|
90 |
/* Unused Data (7Byte) (80000B5h) */ |
|
91 |
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
|
92 |
|
|
93 |
/* Software Version No (80000BCh) */ |
|
94 |
.byte 0x00 |
|
95 |
|
|
96 |
/* Complement Check (80000BDh) */ |
|
97 |
.byte 0xf0 |
|
98 |
|
|
99 |
/* Checksum (80000BEh) */ |
|
100 |
.byte 0x00,0x00 |
|
101 |
|
|
102 |
.align |
|
103 |
.code 32 |
|
104 |
|
|
105 |
rom_header_end: |
|
106 |
b start_vector |
|
107 |
|
|
108 |
.global __boot_method, __slave_number |
|
109 |
|
|
110 |
__boot_method: |
|
111 |
.byte 0 /* boot method (0=ROM boot, 3=Multiplay boot) */ |
|
112 |
__slave_number: |
|
113 |
.byte 0 /* slave # (1=slave#1, 2=slave#2, 3=slave#3) */ |
|
114 |
|
|
115 |
.byte 0 |
|
116 |
.byte 0 |
|
117 |
.word 0 |
|
118 |
.word 0 |
|
119 |
.word 0 |
|
120 |
.word 0 |
|
121 |
.word 0 |
|
122 |
.word 0 |
|
123 |
|
|
124 |
.align |
|
125 |
.code 32 |
|
126 |
stack_top: .word (BOOTSTKTOP - KERNBASE) |
|
127 |
|
|
128 |
start_vector: |
|
129 |
mov r0, #0xd3 /* Enter SVC mode, Disable IRQ,FIQ */ |
|
130 |
msr cpsr_c, r0 |
|
131 |
ldr sp, stack_top |
|
132 |
|
|
133 |
adr r0, thumb_mode + 1 |
|
134 |
bx r0 |
|
135 |
.code 16 |
|
136 |
thumb_mode: |
|
137 |
|
|
138 |
/* |
|
139 |
* Relocate the loader code |
|
140 |
*/ |
|
141 |
mov r3, #0x40 |
|
142 |
lsl r3, r3, #7 /* r3 = 0x2000 (8K) */ |
|
143 |
mov r2, #3 |
|
144 |
lsl r2, r2, #24 /* r2 = 0x3000000 */ |
|
145 |
lsl r1, r3, #14 /* r1 = 0x8000000 */ |
|
146 |
|
|
147 |
copy_loop: |
|
148 |
ldmia r1!, {r0} |
|
149 |
stmia r2!, {r0} |
|
150 |
sub r3, r3, #4 |
|
151 |
bne copy_loop |
|
152 |
|
|
153 |
ldr r0, =main |
|
154 |
bx r0 /* Change to ARM mode */ |
|
155 |
|
|
156 |
.code 32 |
|
157 |
|
|
158 |
#if defined(DEBUG) && defined(CONFIG_DIAG_VBA) |
|
159 |
/* |
|
160 |
* Put one character to Visual Boy Advance (VBA) emulator console. |
|
161 |
* |
|
162 |
* Important: |
|
163 |
* This BIOS call is not supported by actual GBA BIOS. So, you must |
|
164 |
* disable this function when you run it on actual GBA H/W. |
|
165 |
* Otherwise, it will hang. |
|
166 |
*/ |
|
167 |
putbuf: |
|
168 |
.long 0 |
|
169 |
|
|
170 |
ENTRY(vba_putc) |
|
171 |
ldr r1, =putbuf |
|
172 |
str r0, [r1] |
|
173 |
mov r0, r1 |
|
174 |
swi $0xff0000 |
|
175 |
mov pc, lr |
|
176 |
#endif |
|
177 |
|
|
178 |
.section .tail,"ax" |
|
179 |
dummy: |
|
180 |
.byte 0xff |
|
181 |
|
|
182 |
.end |
prex-0.9.0/bsp/boot/arm/gba/startup.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
#include <sys/param.h> |
|
31 |
#include <sys/bootinfo.h> |
|
32 |
#include <boot.h> |
|
33 |
|
|
34 |
/* |
|
35 |
* Setup boot information. |
|
36 |
*/ |
|
37 |
static void |
|
38 |
bootinfo_init(void) |
|
39 |
{ |
|
40 |
struct bootinfo *bi = bootinfo; |
|
41 |
|
|
42 |
/* |
|
43 |
* Screen size |
|
44 |
*/ |
|
45 |
bi->video.text_x = 30; |
|
46 |
bi->video.text_y = 20; |
|
47 |
|
|
48 |
/* |
|
49 |
* EWRAM - 256K |
|
50 |
*/ |
|
51 |
bi->ram[0].base = 0x2000000; |
|
52 |
bi->ram[0].size = 0x40000; |
|
53 |
bi->ram[0].type = MT_USABLE; |
|
54 |
|
|
55 |
bi->nr_rams = 1; |
|
56 |
} |
|
57 |
|
|
58 |
void |
|
59 |
startup(void) |
|
60 |
{ |
|
61 |
|
|
62 |
bootinfo_init(); |
|
63 |
} |
prex-0.9.0/bsp/boot/arm/integrator/Makefile.inc | ||
---|---|---|
1 |
|
|
2 |
SRCS:= arm/arch/head.S \ |
|
3 |
arm/integrator/startup.c \ |
|
4 |
arm/integrator/debug.c |
|
5 |
|
prex-0.9.0/bsp/boot/arm/integrator/debug.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2008-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
#include <sys/param.h> |
|
31 |
#include <boot.h> |
|
32 |
|
|
33 |
#define UART_BASE 0x16000000 |
|
34 |
#define UART_CLK 14745600 |
|
35 |
#define BAUD_RATE 115200 |
|
36 |
|
|
37 |
/* UART Registers */ |
|
38 |
#define UART_DR (*(volatile uint32_t *)(UART_BASE + 0x00)) |
|
39 |
#define UART_RSR (*(volatile uint32_t *)(UART_BASE + 0x04)) |
|
40 |
#define UART_ECR (*(volatile uint32_t *)(UART_BASE + 0x04)) |
|
41 |
#define UART_FR (*(volatile uint32_t *)(UART_BASE + 0x18)) |
|
42 |
#define UART_IBRD (*(volatile uint32_t *)(UART_BASE + 0x24)) |
|
43 |
#define UART_FBRD (*(volatile uint32_t *)(UART_BASE + 0x28)) |
|
44 |
#define UART_LCRH (*(volatile uint32_t *)(UART_BASE + 0x2c)) |
|
45 |
#define UART_CR (*(volatile uint32_t *)(UART_BASE + 0x30)) |
|
46 |
#define UART_IMSC (*(volatile uint32_t *)(UART_BASE + 0x38)) |
|
47 |
#define UART_MIS (*(volatile uint32_t *)(UART_BASE + 0x40)) |
|
48 |
#define UART_ICR (*(volatile uint32_t *)(UART_BASE + 0x44)) |
|
49 |
|
|
50 |
/* Flag register */ |
|
51 |
#define FR_RXFE 0x10 /* Receive FIFO empty */ |
|
52 |
#define FR_TXFF 0x20 /* Transmit FIFO full */ |
|
53 |
|
|
54 |
/* Masked interrupt status register */ |
|
55 |
#define MIS_RX 0x10 /* Receive interrupt */ |
|
56 |
#define MIS_TX 0x20 /* Transmit interrupt */ |
|
57 |
|
|
58 |
/* Interrupt clear register */ |
|
59 |
#define ICR_RX 0x10 /* Clear receive interrupt */ |
|
60 |
#define ICR_TX 0x20 /* Clear transmit interrupt */ |
|
61 |
|
|
62 |
/* Line control register (High) */ |
|
63 |
#define LCRH_WLEN8 0x60 /* 8 bits */ |
|
64 |
#define LCRH_FEN 0x10 /* Enable FIFO */ |
|
65 |
|
|
66 |
/* Control register */ |
|
67 |
#define CR_UARTEN 0x0001 /* UART enable */ |
|
68 |
#define CR_TXE 0x0100 /* Transmit enable */ |
|
69 |
#define CR_RXE 0x0200 /* Receive enable */ |
|
70 |
|
|
71 |
/* Interrupt mask set/clear register */ |
|
72 |
#define IMSC_RX 0x10 /* Receive interrupt mask */ |
|
73 |
#define IMSC_TX 0x20 /* Transmit interrupt mask */ |
|
74 |
|
|
75 |
/* |
|
76 |
* Print one chracter |
|
77 |
*/ |
|
78 |
void |
|
79 |
debug_putc(int c) |
|
80 |
{ |
|
81 |
|
|
82 |
#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL) |
|
83 |
while (UART_FR & FR_TXFF) |
|
84 |
; |
|
85 |
UART_DR = c; |
|
86 |
#endif |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* Initialize debug port. |
|
91 |
*/ |
|
92 |
void |
|
93 |
debug_init(void) |
|
94 |
{ |
|
95 |
|
|
96 |
#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL) |
|
97 |
unsigned int divider; |
|
98 |
unsigned int remainder; |
|
99 |
unsigned int fraction; |
|
100 |
|
|
101 |
UART_CR = 0x0; /* Disable everything */ |
|
102 |
UART_ICR = 0x07ff; /* Clear all interrupt status */ |
|
103 |
|
|
104 |
/* |
|
105 |
* Set baud rate: |
|
106 |
* IBRD = UART_CLK / (16 * BAUD_RATE) |
|
107 |
* FBRD = ROUND((64 * MOD(UART_CLK,(16 * BAUD_RATE))) / (16 * BAUD_RATE)) |
|
108 |
*/ |
|
109 |
divider = UART_CLK / (16 * BAUD_RATE); |
|
110 |
remainder = UART_CLK % (16 * BAUD_RATE); |
|
111 |
fraction = (8 * remainder / BAUD_RATE) >> 1; |
|
112 |
fraction += (8 * remainder / BAUD_RATE) & 1; |
|
113 |
UART_IBRD = divider; |
|
114 |
UART_FBRD = fraction; |
|
115 |
|
|
116 |
UART_LCRH = (LCRH_WLEN8 | LCRH_FEN); /* N, 8, 1, FIFO enable */ |
|
117 |
UART_CR = (CR_RXE | CR_TXE | CR_UARTEN); /* Enable UART */ |
|
118 |
#endif |
|
119 |
} |
prex-0.9.0/bsp/boot/arm/integrator/startup.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2008-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
#include <sys/param.h> |
|
31 |
#include <sys/bootinfo.h> |
|
32 |
#include <boot.h> |
|
33 |
|
|
34 |
/* |
|
35 |
* Setup boot information. |
|
36 |
*/ |
|
37 |
static void |
|
38 |
bootinfo_init(void) |
|
39 |
{ |
|
40 |
struct bootinfo *bi = bootinfo; |
|
41 |
|
|
42 |
/* |
|
43 |
* Screen size |
|
44 |
*/ |
|
45 |
bi->video.text_x = 80; |
|
46 |
bi->video.text_y = 25; |
|
47 |
|
|
48 |
/* |
|
49 |
* On-board SSRAM - 4M |
|
50 |
*/ |
|
51 |
bi->ram[0].base = 0; |
|
52 |
bi->ram[0].size = 0x400000; |
|
53 |
bi->ram[0].type = MT_USABLE; |
|
54 |
|
|
55 |
bi->nr_rams = 1; |
|
56 |
} |
|
57 |
|
|
58 |
void |
|
59 |
startup(void) |
|
60 |
{ |
|
61 |
|
|
62 |
bootinfo_init(); |
|
63 |
} |
prex-0.9.0/bsp/boot/common/Makefile.inc | ||
---|---|---|
1 |
|
|
2 |
SRCS+= common/main.c \ |
|
3 |
common/bootinfo.c \ |
|
4 |
common/load.c \ |
|
5 |
common/elf.c \ |
|
6 |
common/splash.c \ |
|
7 |
common/string.c \ |
|
8 |
common/printf.c |
prex-0.9.0/bsp/boot/common/bootinfo.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
* bootinfo.c - Boot information |
|
32 |
*/ |
|
33 |
|
|
34 |
#include <boot.h> |
|
35 |
#include <sys/bootinfo.h> |
|
36 |
#include <machine/syspage.h> |
|
37 |
|
|
38 |
/* |
|
39 |
* Boot information holds various platform dependent data that |
|
40 |
* can be referred by kernel/drivers. |
|
41 |
*/ |
|
42 |
struct bootinfo *const bootinfo = (struct bootinfo *)kvtop(BOOTINFO); |
|
43 |
|
|
44 |
|
|
45 |
#if defined(DEBUG) && defined(DEBUG_BOOTINFO) |
|
46 |
static void |
|
47 |
print_module(struct module *m) |
|
48 |
{ |
|
49 |
|
|
50 |
printf("%lx %lx %x %lx %lx %x %x %x %s\n", |
|
51 |
m->entry, m->phys, m->size, |
|
52 |
m->text, m->data, m->textsz, |
|
53 |
m->datasz, m->bsssz, m->name); |
|
54 |
} |
|
55 |
|
|
56 |
void |
|
57 |
dump_bootinfo(void) |
|
58 |
{ |
|
59 |
static const char strtype[][9] = \ |
|
60 |
{ "", "USABLE", "MEMHOLE", "RESERVED", "BOOTDISK" }; |
|
61 |
struct module *m; |
|
62 |
struct bootinfo *bi = bootinfo; |
|
63 |
int i; |
|
64 |
|
|
65 |
printf("[Boot information]\n"); |
|
66 |
|
|
67 |
printf("nr_rams=%d\n", bi->nr_rams); |
|
68 |
for (i = 0; i < bi->nr_rams; i++) { |
|
69 |
if (bi->ram[i].type != 0) { |
|
70 |
printf("ram[%d]: base=%lx size=%x type=%s\n", i, |
|
71 |
bi->ram[i].base, |
|
72 |
bi->ram[i].size, |
|
73 |
strtype[bi->ram[i].type]); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
printf("bootdisk: base=%lx size=%x\n", |
|
78 |
bi->bootdisk.base, |
|
79 |
bi->bootdisk.size); |
|
80 |
|
|
81 |
printf("entry phys size text data textsz datasz bsssz module\n"); |
|
82 |
printf("-------- -------- -------- -------- -------- -------- -------- -------- ------\n"); |
|
83 |
print_module(&bi->kernel); |
|
84 |
print_module(&bi->driver); |
|
85 |
|
|
86 |
m = (struct module *)&bi->tasks[0]; |
|
87 |
for (i = 0; i < bi->nr_tasks; i++, m++) |
|
88 |
print_module(m); |
|
89 |
} |
|
90 |
#else |
|
91 |
void |
|
92 |
dump_bootinfo(void) |
|
93 |
{ |
|
94 |
} |
|
95 |
#endif |
prex-0.9.0/bsp/boot/common/elf.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005-2006, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
* elf.c - ELF file format support |
|
32 |
*/ |
|
33 |
|
|
34 |
#include <boot.h> |
|
35 |
#include <load.h> |
|
36 |
#include <sys/elf.h> |
|
37 |
#include <elf_reloc.h> |
|
38 |
|
|
39 |
/* forward declarations */ |
|
40 |
static int load_executable(char *, struct module *); |
|
41 |
static int load_relocatable(char *, struct module *); |
|
42 |
|
|
43 |
#define SHF_VALID (SHF_ALLOC | SHF_EXECINSTR | SHF_ALLOC | SHF_WRITE) |
|
44 |
|
|
45 |
static char *sect_addr[32]; /* array of section address */ |
|
46 |
static int strshndx; /* index of string section */ |
|
47 |
|
|
48 |
/* |
|
49 |
* Load the program from specified ELF image stored in memory. |
|
50 |
* The boot information is filled after loading the program. |
|
51 |
*/ |
|
52 |
int |
|
53 |
load_elf(char *img, struct module *m) |
|
54 |
{ |
|
55 |
Elf32_Ehdr *ehdr; |
|
56 |
Elf32_Phdr *phdr; |
|
57 |
|
|
58 |
ELFDBG(("\nelf_load\n")); |
|
59 |
|
|
60 |
ehdr = (Elf32_Ehdr *)img; |
|
61 |
|
|
62 |
/* Check ELF header */ |
|
63 |
if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) || |
|
64 |
(ehdr->e_ident[EI_MAG1] != ELFMAG1) || |
|
65 |
(ehdr->e_ident[EI_MAG2] != ELFMAG2) || |
|
66 |
(ehdr->e_ident[EI_MAG3] != ELFMAG3)) { |
|
67 |
DPRINTF(("Invalid ELF image\n")); |
|
68 |
return -1; |
|
69 |
} |
|
70 |
|
|
71 |
phdr = (Elf32_Phdr *)((paddr_t)ehdr + ehdr->e_ehsize); |
|
72 |
|
|
73 |
if (nr_img == 0) { |
|
74 |
/* Initialize the load address */ |
|
75 |
load_base = (vaddr_t)ptokv(phdr->p_paddr); |
|
76 |
if (load_base == 0) { |
|
77 |
DPRINTF(("Invalid load address\n")); |
|
78 |
return -1; |
|
79 |
} |
|
80 |
ELFDBG(("kernel base=%lx\n", load_base)); |
|
81 |
load_start = load_base; |
|
82 |
} |
|
83 |
else if (nr_img == 1) { |
|
84 |
/* 2nd image => Driver */ |
|
85 |
ELFDBG(("driver base=%lx\n", load_base)); |
|
86 |
} |
|
87 |
else { |
|
88 |
/* Other images => Boot tasks */ |
|
89 |
ELFDBG(("task base=%lx\n", load_base)); |
|
90 |
} |
|
91 |
|
|
92 |
switch (ehdr->e_type) { |
|
93 |
case ET_EXEC: |
|
94 |
if (load_executable(img, m) != 0) |
|
95 |
return -1; |
|
96 |
break; |
|
97 |
case ET_REL: |
|
98 |
if (load_relocatable(img, m) != 0) |
|
99 |
return -1; |
|
100 |
break; |
|
101 |
default: |
|
102 |
ELFDBG(("Unsupported file type\n")); |
|
103 |
return -1; |
|
104 |
} |
|
105 |
nr_img++; |
|
106 |
return 0; |
|
107 |
} |
|
108 |
|
|
109 |
static int |
|
110 |
load_executable(char *img, struct module *m) |
|
111 |
{ |
|
112 |
Elf32_Ehdr *ehdr; |
|
113 |
Elf32_Phdr *phdr; |
|
114 |
paddr_t phys_base; |
|
115 |
int i; |
|
116 |
|
|
117 |
phys_base = load_base; |
|
118 |
ehdr = (Elf32_Ehdr *)img; |
|
119 |
phdr = (Elf32_Phdr *)((paddr_t)ehdr + ehdr->e_phoff); |
|
120 |
m->phys = load_base; |
|
121 |
phys_base = load_base; |
|
122 |
ELFDBG(("phys addr=%lx\n", phys_base)); |
|
123 |
|
|
124 |
for (i = 0; i < (int)ehdr->e_phnum; i++, phdr++) { |
|
125 |
if (phdr->p_type != PT_LOAD) |
|
126 |
continue; |
|
127 |
|
|
128 |
ELFDBG(("p_flags=%x\n", (int)phdr->p_flags)); |
|
129 |
ELFDBG(("p_align=%x\n", (int)phdr->p_align)); |
|
130 |
ELFDBG(("p_paddr=%x\n", phdr->p_paddr)); |
|
131 |
|
|
132 |
if (i >= 2) { |
|
133 |
ELFDBG(("skipping extra phdr\n")); |
|
134 |
continue; |
|
135 |
} |
|
136 |
if (phdr->p_flags & PF_X) { |
|
137 |
/* Text */ |
|
138 |
m->text = phdr->p_vaddr; |
|
139 |
m->textsz = (size_t)phdr->p_memsz; |
|
140 |
} else { |
|
141 |
/* Data & BSS */ |
|
142 |
m->data = phdr->p_vaddr; |
|
143 |
m->datasz = (size_t)phdr->p_filesz; |
|
144 |
m->bsssz = |
|
145 |
(size_t)(phdr->p_memsz - phdr->p_filesz); |
|
146 |
load_base = phys_base + (m->data - m->text); |
|
147 |
} |
|
148 |
if (phdr->p_filesz > 0) { |
|
149 |
memcpy((char *)load_base, img + phdr->p_offset, |
|
150 |
(size_t)phdr->p_filesz); |
|
151 |
ELFDBG(("load: offset=%lx size=%x\n", |
|
152 |
load_base, (int)phdr->p_filesz)); |
|
153 |
} |
|
154 |
if (!(phdr->p_flags & PF_X)) { |
|
155 |
if (m->bsssz > 0) { |
|
156 |
/* Zero fill BSS */ |
|
157 |
memset((char *)load_base + m->datasz, |
|
158 |
0, m->bsssz); |
|
159 |
} |
|
160 |
load_base += phdr->p_memsz; |
|
161 |
} |
|
162 |
} |
|
163 |
/* workaround for data/bss size is 0 */ |
|
164 |
if (m->data == 0) |
|
165 |
load_base = phys_base + m->textsz; |
|
166 |
|
|
167 |
load_base = round_page(load_base); |
|
168 |
m->size = (size_t)(load_base - m->phys); |
|
169 |
m->entry = ehdr->e_entry; |
|
170 |
ELFDBG(("module size=%x entry=%lx\n", m->size, m->entry)); |
|
171 |
|
|
172 |
if (m->size == 0) |
|
173 |
panic("Module size is 0!"); |
|
174 |
return 0; |
|
175 |
} |
|
176 |
|
|
177 |
static int |
|
178 |
relocate_section_rela(Elf32_Sym *sym_table, Elf32_Rela *rela, |
|
179 |
char *target_sect, int nr_reloc, char *strtab) |
|
180 |
{ |
|
181 |
Elf32_Sym *sym; |
|
182 |
Elf32_Addr sym_val; |
|
183 |
int i; |
|
184 |
|
|
185 |
for (i = 0; i < nr_reloc; i++) { |
|
186 |
sym = &sym_table[ELF32_R_SYM(rela->r_info)]; |
|
187 |
ELFDBG(("%s\n", strtab + sym->st_name)); |
|
188 |
if (sym->st_shndx != STN_UNDEF) { |
|
189 |
sym_val = (Elf32_Addr)sect_addr[sym->st_shndx] |
|
190 |
+ sym->st_value; |
|
191 |
if (relocate_rela(rela, sym_val, target_sect) != 0) |
|
192 |
return -1; |
|
193 |
} else if (ELF32_ST_BIND(sym->st_info) != STB_WEAK) { |
|
194 |
DPRINTF(("Undefined symbol for rela[%x] sym=%lx\n", |
|
195 |
i, (long)sym)); |
|
196 |
return -1; |
|
197 |
} else { |
|
198 |
DPRINTF(("Undefined weak symbol for rela[%x]\n", i)); |
|
199 |
} |
|
200 |
rela++; |
|
201 |
} |
|
202 |
return 0; |
|
203 |
} |
|
204 |
|
|
205 |
static int |
|
206 |
relocate_section_rel(Elf32_Sym *sym_table, Elf32_Rel *rel, |
|
207 |
char *target_sect, int nr_reloc, char *strtab) |
|
208 |
{ |
|
209 |
Elf32_Sym *sym; |
|
210 |
Elf32_Addr sym_val; |
|
211 |
int i; |
|
212 |
|
|
213 |
for (i = 0; i < nr_reloc; i++) { |
|
214 |
sym = &sym_table[ELF32_R_SYM(rel->r_info)]; |
|
215 |
ELFDBG(("%s\n", strtab + sym->st_name)); |
|
216 |
if (sym->st_shndx != STN_UNDEF) { |
|
217 |
sym_val = (Elf32_Addr)sect_addr[sym->st_shndx] |
|
218 |
+ sym->st_value; |
|
219 |
if (relocate_rel(rel, sym_val, target_sect) != 0) |
|
220 |
return -1; |
|
221 |
} else if (ELF32_ST_BIND(sym->st_info) != STB_WEAK) { |
|
222 |
DPRINTF(("Undefined symbol for rel[%x] sym=%lx\n", |
|
223 |
i, (long)sym)); |
|
224 |
return -1; |
|
225 |
} else { |
|
226 |
DPRINTF(("Undefined weak symbol for rel[%x]\n", i)); |
|
227 |
} |
|
228 |
rel++; |
|
229 |
} |
|
230 |
return 0; |
|
231 |
} |
|
232 |
|
|
233 |
static int |
|
234 |
relocate_section(char *img, Elf32_Shdr *shdr) |
|
235 |
{ |
|
236 |
Elf32_Sym *symtab; |
|
237 |
char *target_sect; |
|
238 |
int nr_reloc, error; |
|
239 |
char *strtab; |
|
240 |
|
|
241 |
ELFDBG(("relocate_section\n")); |
|
242 |
|
|
243 |
if (shdr->sh_entsize == 0) |
|
244 |
return 0; |
|
245 |
if ((target_sect = sect_addr[shdr->sh_info]) == 0) |
|
246 |
return -1; |
|
247 |
if ((symtab = (Elf32_Sym *)sect_addr[shdr->sh_link]) == 0) |
|
248 |
return -1; |
|
249 |
if ((strtab = sect_addr[strshndx]) == 0) |
|
250 |
return -1; |
|
251 |
ELFDBG(("strtab=%x\n", strtab)); |
|
252 |
|
|
253 |
nr_reloc = (int)(shdr->sh_size / shdr->sh_entsize); |
|
254 |
switch (shdr->sh_type) { |
|
255 |
case SHT_REL: |
|
256 |
error = relocate_section_rel(symtab, |
|
257 |
(Elf32_Rel *)(img + shdr->sh_offset), |
|
258 |
target_sect, nr_reloc, strtab); |
|
259 |
break; |
|
260 |
|
|
261 |
case SHT_RELA: |
|
262 |
error = relocate_section_rela(symtab, |
|
263 |
(Elf32_Rela *)(img + shdr->sh_offset), |
|
264 |
target_sect, nr_reloc, strtab); |
|
265 |
break; |
|
266 |
|
|
267 |
default: |
|
268 |
error = -1; |
|
269 |
break; |
|
270 |
} |
|
271 |
return error; |
|
272 |
} |
|
273 |
|
|
274 |
static int |
|
275 |
load_relocatable(char *img, struct module *m) |
|
276 |
{ |
|
277 |
Elf32_Ehdr *ehdr; |
|
278 |
Elf32_Shdr *shdr; |
|
279 |
paddr_t sect_base, bss_base; |
|
280 |
int i; |
|
281 |
|
|
282 |
strshndx = 0; |
|
283 |
ehdr = (Elf32_Ehdr *)img; |
|
284 |
shdr = (Elf32_Shdr *)((paddr_t)ehdr + ehdr->e_shoff); |
|
285 |
bss_base = 0; |
|
286 |
m->phys = load_base; |
|
287 |
ELFDBG(("phys addr=%lx\n", load_base)); |
|
288 |
|
|
289 |
/* Copy sections */ |
|
290 |
for (i = 0; i < (int)ehdr->e_shnum; i++, shdr++) { |
|
291 |
sect_addr[i] = 0; |
|
292 |
if (shdr->sh_type == SHT_PROGBITS) { |
|
293 |
|
|
294 |
ELFDBG(("sh_addr=%x\n", shdr->sh_addr)); |
|
295 |
ELFDBG(("sh_size=%x\n", shdr->sh_size)); |
|
296 |
ELFDBG(("sh_offset=%x\n", shdr->sh_offset)); |
|
297 |
ELFDBG(("sh_flags=%x\n", shdr->sh_flags)); |
|
298 |
|
|
299 |
switch (shdr->sh_flags & SHF_VALID) { |
|
300 |
case (SHF_ALLOC | SHF_EXECINSTR): |
|
301 |
/* Text */ |
|
302 |
m->text = (vaddr_t)ptokv(load_base); |
|
303 |
break; |
|
304 |
case (SHF_ALLOC | SHF_WRITE): |
|
305 |
/* Data */ |
|
306 |
if (m->data == 0) { |
|
307 |
m->data = (vaddr_t)ptokv(load_base + |
|
308 |
shdr->sh_addr); |
|
309 |
} |
|
310 |
break; |
|
311 |
case SHF_ALLOC: |
|
312 |
/* rodata */ |
|
313 |
/* Note: rodata is treated as text. */ |
|
314 |
break; |
|
315 |
default: |
|
316 |
continue; |
|
317 |
} |
|
318 |
sect_base = load_base + shdr->sh_addr; |
|
319 |
memcpy((char *)sect_base, img + shdr->sh_offset, |
|
320 |
(size_t)shdr->sh_size); |
|
321 |
ELFDBG(("load: offset=%lx size=%x\n", |
|
322 |
sect_base, (int)shdr->sh_size)); |
|
323 |
|
|
324 |
sect_addr[i] = (char *)sect_base; |
|
325 |
} else if (shdr->sh_type == SHT_NOBITS) { |
|
326 |
/* BSS */ |
|
327 |
m->bsssz = (size_t)shdr->sh_size; |
|
328 |
sect_base = load_base + shdr->sh_addr; |
|
329 |
bss_base = sect_base; |
|
330 |
|
|
331 |
/* Zero fill BSS */ |
|
332 |
memset((char *)bss_base, 0, (size_t)shdr->sh_size); |
|
333 |
|
|
334 |
sect_addr[i] = (char *)sect_base; |
|
335 |
} else if (shdr->sh_type == SHT_SYMTAB) { |
|
336 |
/* Symbol table */ |
|
337 |
ELFDBG(("load: symtab index=%d link=%d\n", |
|
338 |
i, shdr->sh_link)); |
|
339 |
sect_addr[i] = img + shdr->sh_offset; |
|
340 |
if (strshndx != 0) |
|
341 |
panic("Multiple symtab found!"); |
|
342 |
strshndx = (int)shdr->sh_link; |
|
343 |
} else if (shdr->sh_type == SHT_STRTAB) { |
|
344 |
/* String table */ |
|
345 |
sect_addr[i] = img + shdr->sh_offset; |
|
346 |
ELFDBG(("load: strtab index=%d addr=%x\n", |
|
347 |
i, sect_addr[i])); |
|
348 |
} |
|
349 |
} |
|
350 |
m->textsz = (size_t)(m->data - m->text); |
|
351 |
m->datasz = (size_t)((char *)ptokv(bss_base) - m->data); |
|
352 |
|
|
353 |
load_base = bss_base + m->bsssz; |
|
354 |
load_base = round_page(load_base); |
|
355 |
|
|
356 |
ELFDBG(("module load_base=%lx text=%lx\n", load_base, m->text)); |
|
357 |
m->size = (size_t)(load_base - kvtop(m->text)); |
|
358 |
m->entry = (vaddr_t)ptokv(ehdr->e_entry + m->phys); |
|
359 |
ELFDBG(("module size=%x entry=%lx\n", m->size, m->entry)); |
|
360 |
|
|
361 |
/* Process relocation */ |
|
362 |
shdr = (Elf32_Shdr *)((paddr_t)ehdr + ehdr->e_shoff); |
|
363 |
for (i = 0; i < (int)ehdr->e_shnum; i++, shdr++) { |
|
364 |
if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) { |
|
365 |
if (relocate_section(img, shdr) != 0) { |
|
366 |
DPRINTF(("Relocation error: module=%s\n", m->name)); |
|
367 |
return -1; |
|
368 |
} |
|
369 |
} |
|
370 |
} |
|
371 |
return 0; |
|
372 |
} |
prex-0.9.0/bsp/boot/common/load.c | ||
---|---|---|
1 |
/*- |
|
2 |
* Copyright (c) 2005-2009, Kohsuke Ohtani |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors |
|
14 |
* may be used to endorse or promote products derived from this software |
|
15 |
* without specific prior written permission. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
27 |
* SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
* load.c - Load OS modules |
|
32 |
*/ |
|
33 |
|
|
34 |
#include <boot.h> |
|
35 |
#include <load.h> |
|
36 |
#include <sys/ar.h> |
|
37 |
#include <sys/bootinfo.h> |
|
38 |
|
|
39 |
/* forward declarations */ |
|
40 |
static int load_module(struct ar_hdr *, struct module *); |
|
41 |
static void setup_bootdisk(struct ar_hdr *); |
|
42 |
|
|
43 |
paddr_t load_base; /* current load address */ |
|
44 |
paddr_t load_start; /* start address for loading */ |
|
45 |
int nr_img; /* number of module images */ |
|
46 |
|
|
47 |
|
|
48 |
/* |
|
49 |
* Load OS images - kernel, driver and boot tasks. |
|
50 |
* |
|
51 |
* It reads each module file image and copy it to the appropriate |
|
52 |
* memory area. The image is built as generic an archive (.a) file. |
|
53 |
* |
|
54 |
* The image information is stored into the boot information area. |
|
55 |
*/ |
|
56 |
void |
|
57 |
load_os(void) |
|
58 |
{ |
|
59 |
char *hdr; |
|
60 |
struct bootinfo *bi = bootinfo; |
|
61 |
struct module *m; |
|
62 |
char *magic; |
|
63 |
int i; |
|
64 |
long len; |
|
65 |
|
|
66 |
/* |
|
67 |
* Initialize our data. |
|
68 |
*/ |
|
69 |
load_base = 0; |
|
70 |
load_start = 0; |
|
71 |
nr_img = 0; |
|
72 |
|
|
73 |
/* |
|
74 |
* Sanity check of archive image. |
|
75 |
*/ |
|
76 |
magic = (char *)kvtop(CONFIG_BOOTIMG_BASE); |
|
77 |
if (strncmp(magic, ARMAG, 8)) |
|
78 |
panic("Invalid OS image"); |
|
79 |
|
|
80 |
/* |
|
81 |
* Load kernel module. |
|
82 |
*/ |
|
83 |
hdr = (char *)((paddr_t)magic + 8); |
|
84 |
if (load_module((struct ar_hdr *)hdr, &bi->kernel)) |
|
85 |
panic("Can not load kernel"); |
|
86 |
|
|
87 |
/* |
|
88 |
* Load driver module. |
|
89 |
*/ |
|
90 |
len = atol((char *)&((struct ar_hdr *)hdr)->ar_size); |
|
91 |
len += len % 2; /* even alignment */ |
|
92 |
if (len == 0) |
|
93 |
panic("Invalid driver image"); |
|
94 |
hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len); |
|
95 |
if (load_module((struct ar_hdr *)hdr, &bi->driver)) |
|
96 |
panic("Can not load driver"); |
|
97 |
|
|
98 |
/* |
|
99 |
* Load boot tasks. |
|
100 |
*/ |
|
101 |
i = 0; |
|
102 |
m = (struct module *)&bi->tasks[0]; |
|
103 |
while (1) { |
|
104 |
/* Proceed to next archive header */ |
|
105 |
len = atol((char *)&((struct ar_hdr *)hdr)->ar_size); |
|
106 |
len += len % 2; /* even alignment */ |
|
107 |
if (len == 0) |
|
108 |
break; |
|
109 |
hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len); |
|
110 |
|
|
111 |
/* Check archive header */ |
|
112 |
if (strncmp((char *)&((struct ar_hdr *)hdr)->ar_fmag, |
|
113 |
ARFMAG, 2)) |
|
114 |
break; |
|
115 |
|
|
116 |
/* Load boot disk image */ |
|
117 |
if (!strncmp((char *)&((struct ar_hdr *)hdr)->ar_name, |
|
118 |
"bootdisk.a", 10)) { |
|
119 |
setup_bootdisk((struct ar_hdr *)hdr); |
|
120 |
continue; |
|
121 |
} |
|
122 |
|
|
123 |
/* Load task */ |
|
124 |
if (load_module((struct ar_hdr *)hdr, m)) |
|
125 |
break; |
|
126 |
i++; |
|
127 |
m++; |
|
128 |
} |
|
129 |
|
|
130 |
bi->nr_tasks = i; |
|
131 |
|
|
132 |
if (bi->nr_tasks == 0) |
|
133 |
panic("No boot task found!"); |
|
134 |
|
|
135 |
/* |
|
136 |
* Reserve single memory block for all boot modules. |
|
137 |
* This includes kernel, driver, and boot tasks. |
|
138 |
*/ |
|
139 |
i = bi->nr_rams; |
|
140 |
bi->ram[i].base = load_start; |
|
141 |
bi->ram[i].size = (size_t)(load_base - load_start); |
|
142 |
bi->ram[i].type = MT_RESERVED; |
|
143 |
bi->nr_rams++; |
|
144 |
} |
|
145 |
|
|
146 |
/* |
|
147 |
* Load module. |
|
148 |
* Return 0 on success, -1 on failure. |
|
149 |
*/ |
|
150 |
static int |
|
151 |
load_module(struct ar_hdr *hdr, struct module *m) |
|
152 |
{ |
|
153 |
char *c; |
|
154 |
|
|
155 |
if (strncmp((char *)&hdr->ar_fmag, ARFMAG, 2)) { |
|
156 |
DPRINTF(("Invalid image %s\n", hdr->ar_name)); |
|
157 |
return -1; |
|
158 |
} |
|
159 |
strlcpy(m->name, hdr->ar_name, sizeof(m->name)); |
|
160 |
c = m->name; |
|
161 |
while (*c != '/' && *c != ' ') |
|
162 |
c++; |
|
163 |
*c = '\0'; |
|
164 |
|
|
165 |
DPRINTF(("loading: hdr=%lx module=%lx name=%s\n", |
|
166 |
(paddr_t)hdr, (paddr_t)m, m->name)); |
|
167 |
|
|
168 |
if (load_elf((char *)hdr + sizeof(struct ar_hdr), m)) |
|
169 |
panic("Load error"); |
|
170 |
|
|
171 |
return 0; |
|
172 |
} |
|
173 |
|
|
174 |
/* |
|
175 |
* Setup boot disk |
|
176 |
*/ |
|
177 |
static void |
|
178 |
setup_bootdisk(struct ar_hdr *hdr) |
|
179 |
{ |
|
180 |
struct bootinfo *bi = bootinfo; |
|
181 |
paddr_t base; |
|
182 |
size_t size; |
|
183 |
|
|
184 |
/* |
|
185 |
* Store image information. |
|
186 |
*/ |
|
187 |
if (strncmp((char *)&hdr->ar_fmag, ARFMAG, 2)) { |
|
188 |
DPRINTF(("Invalid bootdisk image\n")); |
|
189 |
return; |
|
190 |
} |
|
191 |
size = (size_t)atol((char *)&hdr->ar_size); |
|
192 |
size += size % 2; /* even alignment */ |
|
193 |
if (size == 0) { |
|
194 |
DPRINTF(("Size of bootdisk is zero\n")); |
|
195 |
return; |
|
196 |
} |
|
197 |
base = (paddr_t)hdr + sizeof(struct ar_hdr); |
Also available in: Unified diff