From 4d311943431e367480dec8654d3dcae9113c8350 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 1 May 2015 13:49:26 +0800 Subject: [PATCH] runtime: load idle kernel from flash storage --- soc/runtime/kloader.c | 20 ++++++++++++++++++-- soc/runtime/main.c | 5 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/soc/runtime/kloader.c b/soc/runtime/kloader.c index 715caf8d4..0cf09f261 100644 --- a/soc/runtime/kloader.c +++ b/soc/runtime/kloader.c @@ -2,12 +2,12 @@ #include #include "log.h" +#include "flash_storage.h" #include "mailbox.h" #include "elf_loader.h" #include "services.h" #include "kloader.h" - static struct symbol symtab[128]; static int _symtab_count; static char _symtab_strings[128*16]; @@ -92,11 +92,27 @@ void kloader_start_user_kernel(kernel_function k) void kloader_start_idle_kernel(void) { + char buffer[32*1024]; + int len; + kernel_function k; + if(!kernel_cpu_reset_read()) { log("BUG: attempted to start kernel CPU while already running (idle kernel)"); return; } - /* TODO */ + len = fs_read("idle_kernel", buffer, sizeof(buffer), NULL); + if(len <= 0) + return; + if(!kloader_load(buffer, len)) { + log("Failed to load ELF binary for idle kernel"); + return; + } + k = kloader_find("run"); + if(!k) { + log("Failed to find entry point for ELF kernel"); + return; + } + start_kernel_cpu((void *)k); } void kloader_stop_kernel(void) diff --git a/soc/runtime/main.c b/soc/runtime/main.c index f6facbdd0..8e891cea7 100644 --- a/soc/runtime/main.c +++ b/soc/runtime/main.c @@ -119,11 +119,12 @@ static void network_init(void) static void regular_main(void) { - puts("Accepting sessions on Ethernet"); + puts("Accepting sessions on Ethernet."); clock_init(); network_init(); kserver_init(); + session_end(); while(1) { lwip_service(); kserver_service(); @@ -177,7 +178,7 @@ static void serial_service(void) static void regular_main(void) { - puts("Accepting sessions on serial link"); + puts("Accepting sessions on serial link."); clock_init(); /* Open the session for the serial control. */