/branches/arm/boot/arch/arm32/Makefile.inc |
---|
1,5 → 1,5 |
# |
# Copyright (c) 2007 Jakub Jermar |
# Copyright (c) 2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
26,6 → 26,17 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
# |
# So far, this is just a placeholder. |
# |
build: $(BASE)/image.boot |
$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot |
cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot |
depend: |
-rm arch/$(ARCH)/loader/image.boot |
arch/$(ARCH)/loader/image.boot: |
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE) |
clean: |
make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE) |
-rm -f $(BASE)/image.boot |
/branches/arm/boot/arch/arm32/loader/asm.S |
---|
0,0 → 1,175 |
# |
# Copyright (c) 2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
.text |
.align 2 |
different_aligns: |
/* We must do byte copies */ |
stmfd r13!, {r0, lr } |
byte_loop: |
ldrb r3, [r1], #1 |
strb r3, [r0], #1 |
subs r2, r2, #1 |
bne byte_loop |
ldmfd r13!, {r0, pc } |
.global memcpy |
.type memcpy, %function |
memcpy: |
@void* memcpy( void* dst, const void* src, size_t len ) |
@@ Register usage: |
@@ r0: dst |
@@ r1: src |
@@ r2: len |
@@ |
@@ r3: various bitmasks, load and store for different_aligns loop |
@@ r4: counter for multi loop, not used for different_aligns |
@@ r5-r8: load and store, not used for different_aligns |
cmp r2, #0 |
moveq pc, lr @ just return if caller wants to copy zero bytes |
cmp r2, #8 |
bls different_aligns |
/*check for src alignment*/ |
eor r3, r0, r1 @ r3 = dest | src |
tst r3, #3 @ test for same alignment |
bne different_aligns @ jump if align( r1 ) != align( ro ) |
/* else, they have the same same alignment */ |
stmfd r13!, {r0, r4-r8, lr } @ save regs |
ands r3, r0, #3 @ find out what that alignment is |
beq multi @ iff align( r1 ) == align( r0 ) == 0 skip to multi |
/* otherwise, move up to three bytes to get to a word alignment |
if align = 1, we need to move forward 3 bytes to get to a word boundry |
if align = 2, we need to move forward 2 bytes to get to a word boundry |
if align = 3, we need to move forward 1 byte to get to a word boundry |
*/ |
cmp r3, #2 @ "subtract" 2 from either 1, 2, or 3 |
ldrneb r4, [r1], #1 @ one aligned or three aligned ( 1 != 2 || 3 !- 2 ), ((byte*) src)++ |
strneb r4, [r0], #1 @ one aligned or three aligned ( 1 != 2 || 3 !- 2 ), store to *dst++ |
@ldrlsh r4, [r1], #2 @ one or two ( 1 <= 2 || 2 <= 2 ) aligned, ((halfword*) src)++ |
@strlsh r4, [r0], #2 @ one or two ( 1 <= 2 || 2 <= 2 ) aligned, store to *dst++ |
ldrlsb r4, [r1], #1 @ one aligned or two aligned, ((byte*) src)++ |
strlsb r4, [r0], #1 @ one aligned or two aligned, store to *dst++ |
ldrlsb r4, [r1], #1 @ one aligned or two aligned, ((byte*) src)++ |
strlsb r4, [r0], #1 @ one aligned or two aligned, store to *dst++ |
sub r3, r3, #4 |
add r2, r2, r3 @ length -= bytes written |
multi: |
/* once we get here, we're word aligned */ |
/* |
bytes = length |
words = byte / 4, rem = byte moves |
instr = quadword = words / 4, rem = partial instructions |
loop = instr / 4, rem = jump to instr |
010101010 |
llliiwwbb |
21 |
52631 |
684268421 |
*/ |
ands r3, r2, #48 @ #32 | #16, r3 = partial loop count << 3 |
mov r4, r2, LSR #6 @ r4 = loop count |
/* Now, like Duff's device, jump into the loop to perform the extra instructions */ |
/* Replace later with direct adjustment of PC */ |
beq loop_test |
cmp r3, #32 @r3 = 16 or 32 or 48, corresponding to 1 or 2 or 3 |
bhi loop3 |
beq loop2 |
blo loop1 |
loop: |
ldmia r1!, { r5-r8 } @load four registers |
stmia r0!, { r5-r8 } @store four registers |
loop3: |
ldmia r1!, { r5-r8 } @load four registers |
stmia r0!, { r5-r8 } @store four registers |
loop2: |
ldmia r1!, { r5-r8 } @load four registers |
stmia r0!, { r5-r8 } @store four registers |
loop1: |
ldmia r1!, { r5-r8 } @load four registers |
stmia r0!, { r5-r8 } @store four registers |
loop_test: |
cmp r4, #0 |
subne r4, r4, #1 |
bne loop |
/* Now do the extra words */ |
ands r3, r2, #12 @ #8 | #4, r3 = extra words << 2 |
beq extra_bytes |
cmp r3, #8 |
ldrne r5, [r1], #4 @ if r5 !=8 then it's 4 or 12, so load and store |
strne r5, [r0], #4 |
ldmhsia r1!, {r5-r6} @ if r5 >= 8, it's 8 or 12, so load and store 2 |
stmhsia r0!, {r5-r6} |
/* Now do the extra bytes */ |
extra_bytes: |
tst r2, #2 @ any extra bytes? |
beq clean_up |
cmp r3, #2 @ subtract 2 from either 1, 2, or 3 |
ldrneb r5, [r1], #1 @ load and store one byte iff r3 != 2 (i.e, r3 == 1 || r3 == 3) |
strneb r5, [r0], #1 @ 1 or 3 |
ldrhsb r5, [r1], #1 @ load and store a byte iff r3 >= 2 |
strhsb r5, [r0], #1 @ 2 or 3 |
ldrhsb r5, [r1], #1 @ load and store a byte iff r3 > 2 |
strhsb r5, [r0], #1 @ 2 or 3 |
clean_up: |
ldmfd r13!, {r0, r4-r8, pc } @r0 is the retval, must equal original dst |
end: |
.size different_aligns, .end-memcpy |
.align 2 |
@ Local Variables: |
@ asm-comment-char: ?@ |
@ comment-start: "@ " |
@ block-comment-start: "/*" |
@ block-comment-end: "*/" |
@ indent-tabs-mode: t |
@ End: |
/branches/arm/boot/arch/arm32/loader/boot.S |
---|
0,0 → 1,42 |
# |
# Copyright (c) 2007 Michal Kebrt |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#define INITIAL_STACK 0x80040000 |
.section BOOTSTRAP |
.global start |
.global jump_to_kernel |
start: |
b bootstrap |
jump_to_kernel: |
b 0x00100000 |
/branches/arm/boot/arch/arm32/loader/main.c |
---|
0,0 → 1,108 |
/* |
* Copyright (c) 2005 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include "main.h" |
#include "asm.h" |
#include "_components.h" |
#include <printf.h> |
#define KERNEL_PHY_ADDRESS 0x00100000 |
char *release = RELEASE; |
#ifdef REVISION |
char *revision = ", revision " REVISION; |
#else |
char *revision = ""; |
#endif |
#ifdef TIMESTAMP |
char *timestamp = "\nBuilt on " TIMESTAMP; |
#else |
char *timestamp = ""; |
#endif |
/** Print version information. */ |
static void version_print(void) |
{ |
printf("HelenOS ARM32 Bootloader\nRelease %s%s%s\nCopyright (c) 2007 HelenOS project\n", |
release, revision, timestamp); |
} |
void bootstrap(void) |
{ |
version_print(); |
component_t components[COMPONENTS]; |
bootinfo_t bootinfo; |
init_components(components); |
printf("\nMemory statistics\n"); |
printf(" kernel entry point at %L\n", KERNEL_PHY_ADDRESS); |
printf(" %L: boot info structure\n", &bootinfo); |
unsigned int i, j; |
for (i = 0; i < COMPONENTS; i++) { |
printf(" %L: %s image (size %d bytes)\n", |
components[i].start, components[i].name, components[i].size); |
} |
printf("\nCopying components\n"); |
unsigned int top = 0; |
bootinfo.cnt = 0; |
for (i = 0; i < COMPONENTS; i++) { |
printf(" %s...", components[i].name); |
top = ALIGN_UP(top, PAGE_SIZE); |
//printf("top %x", KERNEL_PHY_ADDRESS + top); |
memcpy(((void *) KERNEL_PHY_ADDRESS) + top, components[i].start, components[i].size); |
if (i > 0) { |
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_PHY_ADDRESS) + top; |
bootinfo.tasks[bootinfo.cnt].size = components[i].size; |
bootinfo.cnt++; |
} |
/* TODO: memcpy test -> to be deleted */ |
/* |
unsigned char x, y; |
for (j=0; j < 20; ++j) { |
x = *((unsigned char *) components[i].start + j); |
y = *((unsigned char *) KERNEL_PHY_ADDRESS + top + j); |
if (x != y) { |
printf("!!! Error, %x != %x\n", x,y); |
} |
} |
*/ |
top += components[i].size; |
printf("done.\n"); |
} |
printf("\nBooting the kernel...\n"); |
jump_to_kernel((void *) KERNEL_PHY_ADDRESS, &bootinfo, sizeof(bootinfo)); |
} |
/branches/arm/boot/arch/arm32/loader/asm.h |
---|
0,0 → 1,40 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __ASM_H__ |
#define __ASM_H__ |
#define PAGE_SIZE 16384 |
#define PAGE_WIDTH 14 |
//#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
void memcpy(void *dst, void *src, int cnt); |
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn)); |
#endif |
/branches/arm/boot/arch/arm32/loader/io.c |
---|
0,0 → 1,50 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <printf.h> |
#define PUTC_ADDRESS 0x10000000 |
/** |
* Prints a character to console. |
* |
* @param ch character to be printed |
*/ |
static void putc(char ch) { |
*((volatile char *)PUTC_ADDRESS) = ch; |
} |
void write(const char *str, const int len) { |
int i; |
for (i = 0; i < len; ++i) { |
putc(str[i]); |
} |
} |
/branches/arm/boot/arch/arm32/loader/main.h |
---|
0,0 → 1,54 |
/* |
* Copyright (c) 2005 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __MAIN_H__ |
#define __MAIN_H__ |
/** Align to the nearest higher address. |
* |
* @param addr Address or size to be aligned. |
* @param align Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) |
#define TASKMAP_MAX_RECORDS 32 |
typedef struct { |
void *addr; |
unsigned int size; |
} task_t; |
typedef struct { |
unsigned int cnt; |
task_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
extern void start(void); |
extern void bootstrap(void); |
#endif |
/branches/arm/boot/arch/arm32/loader/types.h |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef TYPES_H__ |
#define TYPES_H__ |
#include <gentypes.h> |
typedef signed char int8_t; |
typedef unsigned char uint8_t; |
typedef unsigned short uint16_t; |
typedef unsigned int uint32_t; |
typedef unsigned long long uint64_t; |
typedef uint32_t uintptr_t; |
typedef uint32_t unative_t; |
#endif |
/branches/arm/boot/arch/arm32/loader/Makefile |
---|
0,0 → 1,107 |
# |
# Copyright (c) 2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
include ../../../../version |
include ../../../../Makefile.config |
## Toolchain configuration |
# |
TARGET = arm-linux-gnu |
TOOLCHAIN_DIR = /usr/local/arm/bin |
ifeq ($(COMPILER),native) |
CC = gcc |
AS = as |
LD = ld |
OBJCOPY = objcopy |
OBJDUMP = objdump |
else |
CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc |
AS = $(TOOLCHAIN_DIR)/$(TARGET)-as |
LD = $(TOOLCHAIN_DIR)/$(TARGET)-ld |
OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy |
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump |
endif |
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -I../../.. -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 |
ifdef REVISION |
CFLAGS += "-DREVISION=\"$(REVISION)\"" |
endif |
ifdef TIMESTAMP |
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\"" |
endif |
SOURCES = \ |
main.c \ |
boot.S \ |
asm.S \ |
io.c \ |
../../../generic/printf.c \ |
../../../genarch/division.c |
COMPONENTS = \ |
$(KERNELDIR)/kernel.bin \ |
$(USPACEDIR)/ns/ns \ |
$(USPACEDIR)/init/init \ |
$(USPACEDIR)/fb/fb \ |
$(USPACEDIR)/kbd/kbd \ |
$(USPACEDIR)/console/console \ |
$(USPACEDIR)/tetris/tetris \ |
$(USPACEDIR)/ipcc/ipcc \ |
$(USPACEDIR)/klog/klog |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS)))) |
.PHONY: all clean depend |
all: image.boot |
-include Makefile.depend |
image.boot: depend _components.h _link.ld $(OBJECTS) |
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@ |
depend: |
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null |
clean: |
-rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend |
_components.h _link.ld $(COMPONENT_OBJECTS): |
./pack $(IMAGE) $(OBJCOPY) $(COMPONENTS) |
%.o: %.S |
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
%.o: %.c |
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |
/branches/arm/boot/arch/arm32/loader/pack |
---|
0,0 → 1,113 |
#! /bin/sh |
# |
# Copyright (C) 2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
OBJCOPY="$1" |
LINK="_link.ld" |
HEADER="_components.h" |
shift 1 |
echo "OUTPUT_FORMAT(\"elf32-littlearm\") |
ENTRY(start) |
SECTIONS { |
.boot 0x0: AT (0) { |
*(BOOTSTRAP); |
*(.text); |
*(.rodata); |
*(.rodata.*); |
*(.data); /* initialized data */ |
*(.sdata); |
*(.sdata2); |
*(.sbss); |
*(.scommon); |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
*(.reginfo);" > "$LINK" |
echo '#ifndef ___COMPONENTS_H__ |
#define ___COMPONENTS_H__ |
typedef struct { |
char *name; |
void *start; |
void *end; |
unsigned int size; |
} component_t;' > "$HEADER" |
COUNT="0" |
DATA="" |
for TASK in "$@" ; do |
BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`" |
OBJECT="${BASENAME}.o" |
SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`" |
MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`" |
echo "$TASK -> $OBJECT" |
echo " |
. = ALIGN(4096); |
*(.${BASENAME}_image);" >> "$LINK" |
echo " |
extern int ${SYMBOL}_start; |
extern int ${SYMBOL}_end; |
#define ${MACRO}_START ((void *) &${SYMBOL}_start) |
#define ${MACRO}_END ((void *) &${SYMBOL}_end) |
#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER" |
"$OBJCOPY" -I binary -O elf32-littlearm -B arm --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT" |
DATA="${DATA} |
components[$COUNT].name = \"${BASENAME}\"; |
components[$COUNT].start = ${MACRO}_START; |
components[$COUNT].end = ${MACRO}_END; |
components[$COUNT].size = ${MACRO}_SIZE;"; |
COUNT="`expr "$COUNT" + 1`" |
done |
echo ' } |
}' >> "$LINK" |
echo " |
#define COMPONENTS $COUNT |
static void init_components(component_t components[]) |
{ |
$DATA |
} |
#endif |
" >> "$HEADER" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |