aboutsummaryrefslogtreecommitdiff
path: root/demo_functionality.c
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 /demo_functionality.c
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
Diffstat (limited to 'demo_functionality.c')
-rw-r--r--demo_functionality.c21
1 files changed, 16 insertions, 5 deletions
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");
}