45 lines
951 B
C
45 lines
951 B
C
#include <stddef.h>
|
|
#include <uart.h>
|
|
|
|
// extern uint64_t __kernel;
|
|
uint64_t __kernel = 0x80000;
|
|
|
|
typedef void (*main_func_t)(void *);
|
|
|
|
void main(void *dtb)
|
|
{
|
|
uart_init();
|
|
|
|
uart_puts("waiting for kernel to be sent ..." ENDL);
|
|
|
|
union {
|
|
int32_t size;
|
|
uint8_t buf[4];
|
|
} kernel_header;
|
|
kernel_header.size = 0;
|
|
for (int i = 0; i < (int)sizeof(kernel_header); ++i)
|
|
kernel_header.buf[i] = uart_getb();
|
|
|
|
uart_puts("received kernel size: ");
|
|
uart_hex(kernel_header.size);
|
|
uart_puts(ENDL);
|
|
|
|
uart_puts("loaded addr: ");
|
|
uart_hex((unsigned int)(unsigned long)main);
|
|
uart_puts(ENDL);
|
|
|
|
uart_puts("dtb addr: ");
|
|
uart_hex((unsigned int)(unsigned long)dtb);
|
|
uart_puts(ENDL);
|
|
|
|
uint8_t *kernel = (void *)__kernel;
|
|
uart_puts("kernel addr: ");
|
|
uart_hex((unsigned int)(unsigned long)kernel);
|
|
uart_puts("$" ENDL);
|
|
|
|
for (int i = 0; i < kernel_header.size; ++i)
|
|
kernel[i] = uart_getb();
|
|
|
|
((main_func_t)kernel)(dtb);
|
|
}
|