aboutsummaryrefslogtreecommitdiff
path: root/loader_stage2.c
diff options
context:
space:
mode:
authorvetch <vetch97@gmail.com>2020-01-02 17:54:31 +0100
committervetch <vetch97@gmail.com>2020-01-02 17:54:31 +0100
commitab7b754bb32022336527c1a2d5d710b95a589d0e (patch)
tree19f508f06c72efcbdd2cfad46949ed6f1ae45a3c /loader_stage2.c
parent5e1e6796109c892c4300c3da17c35e7874a40107 (diff)
parent6bf5a3b8c6e8a5d1cb3fb4880a5d9688ab094c62 (diff)
downloadrpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.tar.gz
rpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.zip
Merge branch 'bob' of https://repo.or.cz/RPi-MMU-example into alice
# Conflicts: # .gitignore # PL0_test.ld # demo_functionality.c # interrupt_vector.S # interrupts.c # kernel.c # memory.h
Diffstat (limited to 'loader_stage2.c')
-rw-r--r--loader_stage2.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/loader_stage2.c b/loader_stage2.c
index e221dda..15d2003 100644
--- a/loader_stage2.c
+++ b/loader_stage2.c
@@ -1,27 +1,22 @@
#include <stddef.h>
#include <stdint.h>
#include <uart.h>
+#include <io.h>
#include <global.h>
void *const kernel_load_addr = ((void*) 0x8000);
-void __attribute__((section(".text.stage2main")))
-stage2(uint32_t r0, uint32_t r1, uint32_t atags)
+void _stage2_main(uint32_t r0, uint32_t r1, uint32_t atags)
{
- // Declare as unused
- (void) r0;
- (void) r1;
- (void) atags;
-
uart_init();
// get kernel size via uart (little endian)
uint32_t b0, b1, b2, b3;
- b0 = uart_getc();
- b1 = uart_getc();
- b2 = uart_getc();
- b3 = uart_getc();
+ b0 = getchar();
+ b1 = getchar();
+ b2 = getchar();
+ b3 = getchar();
uint32_t kernel_size = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
@@ -29,12 +24,10 @@ stage2(uint32_t r0, uint32_t r1, uint32_t atags)
char *dst = kernel_load_addr, *end = dst + kernel_size;
while (dst < end)
- *(dst++) = uart_getc();
+ *(dst++) = getchar();
// jump to kernel
- // TODO also forward arguments (r0, r1, atags)
- asm volatile("bx %0" :: "r" (kernel_load_addr) : "memory");
+ ((void(*)(uint32_t, uint32_t, uint32_t)) kernel_load_addr)
+ (r0, r1, atags);
}
-void *const _start = ((void*) stage2); // for linker script
-