blob: f49d94c0d7e2ed373461ee13f0faf5901cddeb3c (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stddef.h>
#include <stdint.h>
#include <uart.h>
#include <global.h>
void *const kernel_load_addr = ((void*) 0x8000);
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();
uint32_t kernel_size = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
// load kernel at kernel_load_addr
char *dst = kernel_load_addr, *end = dst + kernel_size;
while (dst < end)
*(dst++) = uart_getc();
// jump to kernel
((void(*)(uint32_t, uint32_t, uint32_t)) kernel_load_addr)
(r0, r1, atags);
}
|