#include #include #include #include #include #include #include #include #include "elf_loader.h" static void receive_sync(void) { char c; int recognized; recognized = 0; while(1) { c = readchar(); if(c == 0x5a) { recognized++; if(recognized == 4) return; } else recognized = 0; } } static int receive_length(void) { unsigned int r; int i; r = 0; for(i=0;i<4;i++) { r <<= 8; r |= (unsigned char)readchar(); } return r; } static int download_kernel(void *buffer, int maxlength) { int length; int i; unsigned char *_buffer = buffer; receive_sync(); length = receive_length(); if(length > maxlength) return -1; for(i=0;i 0) { load_elf(syscalls, kbuf, length, kcode, sizeof(kcode)); flush_cpu_icache(); k(); } } return 0; }