hw2 done
This commit is contained in:
@@ -2,20 +2,44 @@
|
||||
#include <shell.h>
|
||||
#include <uart.h>
|
||||
|
||||
extern byte_t __kernel[];
|
||||
byte_t *kernel = __kernel;
|
||||
// extern uint64_t __kernel;
|
||||
uint64_t __kernel = 0x80000;
|
||||
|
||||
void main()
|
||||
typedef void (*main_func_t)(void *);
|
||||
|
||||
void main(void *dtb)
|
||||
{
|
||||
uart_init();
|
||||
|
||||
uart_getc();
|
||||
uart_puts("waiting for kernel to be sent ..." ENDL);
|
||||
|
||||
union {
|
||||
int 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_int(kernel_header.size);
|
||||
uart_puts(ENDL);
|
||||
|
||||
uart_puts("loaded addr: ");
|
||||
uart_hex((unsigned int)(unsigned long)main);
|
||||
uart_puts(ENDL);
|
||||
|
||||
int shell_cont = 1;
|
||||
while (shell_cont) {
|
||||
shell_cont = shell();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user