aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-28 14:01:14 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-28 14:01:14 +0100
commit826d5b3ba04a8b830c8a92a6f69ca4e223257c5b (patch)
tree6702ee0e8e70d9098e3f3cfe56ee857ed01bb3e8
parent5b5ed23b44ae9eb845ebbac284e0b27822e45ed1 (diff)
downloadrpi-MMU-example-826d5b3ba04a8b830c8a92a6f69ca4e223257c5b.tar.gz
rpi-MMU-example-826d5b3ba04a8b830c8a92a6f69ca4e223257c5b.zip
place PL_0_test.img in ramfs instead of embedding it directly
-rw-r--r--Makefile7
-rw-r--r--demo_functionality.c21
-rw-r--r--linker.ld4
3 files changed, 25 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 3d6b095..b8800cc 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ 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
+RAMFS_FILES=PL_0_test.img
+
all : kernel7.img
%.o : %.c
@@ -22,7 +24,7 @@ all : kernel7.img
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.o interrupt_vector.o interrupts.o
+kernel.elf : boot.o kernel.o uart.o demo_functionality.o paging.o libkernel.o interrupt_vector.o interrupts.o ramfs_embeddable.o ramfs.o
arm-none-eabi-gcc -T linker.ld -o $@ $(ELFFLAGS) $^
loader.elf : boot.o loader_stage1.o loader_stage2.o uart.o
@@ -49,6 +51,9 @@ pipe_image : pipe_image.c lib/rs232/rs232.c
makefs : makefs.c
gcc -Wall -std=gnu99 -O3 $^ -o $@
+ramfs.img : makefs $(RAMFS_FILES)
+ ./makefs $(RAMFS_FILES) > $@
+
clean :
-rm *.img *.elf *.o pipe_image
diff --git a/demo_functionality.c b/demo_functionality.c
index c6f7e5c..206dd2b 100644
--- a/demo_functionality.c
+++ b/demo_functionality.c
@@ -3,6 +3,7 @@
#include "memory.h"
#include "translation_table_descriptors.h"
#include "libkernel.h"
+#include "ramfs.h"
void demo_paging_support(void)
{
@@ -88,12 +89,22 @@ void demo_setup_libkernel(void) {
}
extern char
- _binary_PL_0_test_img_start,
- _binary_PL_0_test_img_end,
- _binary_PL_0_test_img_size;
+ _binary_ramfs_img_start,
+ _binary_ramfs_img_end,
+ _binary_ramfs_img_size;
void demo_setup_PL0(void)
{
+ // find PL_0_test.img im ramfs
+ struct ramfile PL_0_test_img;
+
+ if (find_file(&_binary_ramfs_img_start, "PL_0_test.img",
+ &PL_0_test_img))
+ {
+ uart_puts("PL_0_test.img not found :(\r\n");
+ asm volatile ("wfi");
+ }
+
short_section_descriptor_t volatile *PL0_section_entry =
&TRANSLATION_TABLE[PL0_SECTION_NUMBER];
short_section_descriptor_t volatile *UART_memory_section_entry =
@@ -136,9 +147,9 @@ void demo_setup_PL0(void)
uart_puts((char*) VIRTUAL_PL0_MEMORY_START);
// now paste a userspace program to that section
- for (size_t i = 0; i < (size_t) &_binary_PL_0_test_img_size; i++)
+ for (uint32_t i = 0; i < PL_0_test_img.file_size; i++)
((volatile char*) VIRTUAL_PL0_MEMORY_START)[i] =
- (&_binary_PL_0_test_img_start)[i];
+ PL_0_test_img.file_contents[i];
uart_puts("copied PL0 and libkernel code to their sections\n\r");
}
diff --git a/linker.ld b/linker.ld
index e0e72b2..7b585dc 100644
--- a/linker.ld
+++ b/linker.ld
@@ -23,7 +23,9 @@ SECTIONS
{
__kernel_start = .;
KEEP(boot.o)
- *(EXCLUDE_FILE (libkernel.o interrupt_vector.o interrupts.o) *)
+ *(EXCLUDE_FILE (ramfs_embeddable.o libkernel.o interrupt_vector.o interrupts.o) *)
+ . = ALIGN(4);
+ ramfs_embeddable.o
__kernel_end = .;
}
__kernel_size = __kernel_end - __kernel_start;