diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | demo_functionality.c | 12 | ||||
-rw-r--r-- | linker.ld | 63 |
3 files changed, 25 insertions, 57 deletions
@@ -5,8 +5,6 @@ ARM_OBJECTS=kernel.o paging.o demo_functionality.o PL0_test.o uart.o loader_stag EMBEDDABLE_OBJECTS=PL_0_test_embeddable.o loader_stage2_embeddable.o -RENAME_FLAGS=--rename-section .data=.renamed_data --rename-section .rodata=.renamed_rodata --rename-section .text=.renamed_text --rename-section .bss=.renamed_bss - all : kernel7.img %.o : %.c @@ -21,13 +19,10 @@ all : kernel7.img %_embeddable.o : %.img arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata $^ $@ -libkernel_renamed.o : libkernel.o - arm-none-eabi-objcopy $(RENAME_FLAGS) $^ $@ - PL_0_test.elf : PL0_test.o uart.o arm-none-eabi-gcc -T PL0_test.ld -o $@ $(ELFFLAGS) $^ -kernel.elf : boot.o kernel.o uart.o PL_0_test_embeddable.o demo_functionality.o paging.o libkernel_renamed.o interrupt_vector.o interrupts.o +kernel.elf : boot.o kernel.o uart.o PL_0_test_embeddable.o demo_functionality.o paging.o libkernel.o interrupt_vector.o interrupts.o arm-none-eabi-gcc -T linker.ld -o $@ $(ELFFLAGS) $^ loader.elf : boot.o loader_stage1.o loader_stage2.o uart.o diff --git a/demo_functionality.c b/demo_functionality.c index 19a5c38..aedab08 100644 --- a/demo_functionality.c +++ b/demo_functionality.c @@ -57,9 +57,9 @@ void demo_current_mode(void) ((short_section_descriptor_t volatile*) TRANSLATION_TABLE_BASE) extern char - __renamed_start, - __renamed_end, - __renamed_size; + __libkernel_start, + __libkernel_end, + __libkernel_size; void demo_setup_libkernel(void) { short_section_descriptor_t volatile *libkernel_section_entry = @@ -82,9 +82,9 @@ void demo_setup_libkernel(void) { "isb" :: "r" (0) : "memory"); // copy libkernel code to libkernel section - for (size_t i = 0; i < (size_t) &__renamed_size; i++) + for (size_t i = 0; i < (size_t) &__libkernel_size; i++) ((volatile char*) LIBKERNEL_SECTION_START)[i] = - (&__renamed_start)[i]; + (&__libkernel_start)[i]; } extern char @@ -146,7 +146,7 @@ void demo_setup_PL0(void) void demo_go_unprivileged(void) { size_t call_unprivileged_offset = - (size_t) &call_unprivileged - (size_t) &__renamed_start; + (size_t) &call_unprivileged - (size_t) &__libkernel_start; void *call_unprivileged_new_location = (void*) (LIBKERNEL_SECTION_START + call_unprivileged_offset); @@ -1,18 +1,21 @@ -ENTRY(_start) +ENTRY(_start) /* defined in boot.S */ SECTIONS { - /* Starts at LOADER_ADDR, which is 0x8000 - that's where RPis in */ - /* 32-bit mode load kernel at. */ + /* Starts at 0x8000 - that's where RPis in 32-bit mode load kernel at. */ /* My experiments do, however, show, that qemu emulating RPi2 */ /* loads the kernel at 0x10000! (took some pain to find out). */ - /* Since we're using a bootloader now, we can compile the kernel */ - /* for 0x8000 and bootloader will load it properly (although it */ - /* itself still has to be compiled for 0x10000) */ - /* rpi-open-firmware, ont he other hand, loads kernel at 0x2000000 */ - /* This issue is also to be avoided by the use of bootloader */ + /* rpi-open-firmware, on the other hand, loads kernel at 0x2000000! */ + /* This is not really a problem, since: */ + /* 1. We can use out bootloader to load the kernel at 0x8000 */ + /* 2. We compile kernel with -fPIC, so it should be able to work with */ + /* any load addr. + /* 3. In qemu, we can load kernel.elf instead of raw binary */ + /* (qemu will do the loading then) */ + . = 0x8000; - /* For AArch64, use . = 0x80000; Unless this too is wrong in qemu… */ + + /* For AArch64, use . = 0x80000 */ __start = .; __text_start = .; @@ -51,44 +54,14 @@ SECTIONS __bss_size = __bss_end - __bss_start; - - /* Here come the definitions for renamed sections */ - __renamed_start = .; - __renamed_text_start = .; - .renamed_text : - { - *(.renamed_text) - } - . = ALIGN(4096); /* align to page size */ - __renamed_text_end = .; - - __renamed_rodata_start = .; - .renamed_rodata : - { - *(.renamed_rodata) - } - . = ALIGN(4096); /* align to page size */ - __renamed_rodata_end = .; - - __renamed_data_start = .; - .renamed_data : - { - *(.renamed_data) - } - . = ALIGN(4096); /* align to page size */ - __renamed_data_end = .; - - __renamed_bss_start = .; - .renamed_bss : + /* libkernel */ + .libkernel : { - renamed_bss = .; - *(.renamed_bss) + __libkernel_start = .; + libkernel.o + __libkernel_end = .; } - . = ALIGN(4096); /* align to page size */ - __renamed_bss_end = .; - __renamed_bss_size = __renamed_bss_end - __renamed_bss_start; - __renamed_end = .; - __renamed_size = __renamed_end - __renamed_start; + __libkernel_size = __libkernel_end - __libkernel_start; . = ALIGN(4096); /* align to page size */ |