forked from M-Labs/artiq
runtime: load idle kernel from flash storage
This commit is contained in:
parent
d3753c9643
commit
4d31194343
@ -2,12 +2,12 @@
|
|||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "flash_storage.h"
|
||||||
#include "mailbox.h"
|
#include "mailbox.h"
|
||||||
#include "elf_loader.h"
|
#include "elf_loader.h"
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
#include "kloader.h"
|
#include "kloader.h"
|
||||||
|
|
||||||
|
|
||||||
static struct symbol symtab[128];
|
static struct symbol symtab[128];
|
||||||
static int _symtab_count;
|
static int _symtab_count;
|
||||||
static char _symtab_strings[128*16];
|
static char _symtab_strings[128*16];
|
||||||
@ -92,11 +92,27 @@ void kloader_start_user_kernel(kernel_function k)
|
|||||||
|
|
||||||
void kloader_start_idle_kernel(void)
|
void kloader_start_idle_kernel(void)
|
||||||
{
|
{
|
||||||
|
char buffer[32*1024];
|
||||||
|
int len;
|
||||||
|
kernel_function k;
|
||||||
|
|
||||||
if(!kernel_cpu_reset_read()) {
|
if(!kernel_cpu_reset_read()) {
|
||||||
log("BUG: attempted to start kernel CPU while already running (idle kernel)");
|
log("BUG: attempted to start kernel CPU while already running (idle kernel)");
|
||||||
return;
|
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)
|
void kloader_stop_kernel(void)
|
||||||
|
@ -119,11 +119,12 @@ static void network_init(void)
|
|||||||
|
|
||||||
static void regular_main(void)
|
static void regular_main(void)
|
||||||
{
|
{
|
||||||
puts("Accepting sessions on Ethernet");
|
puts("Accepting sessions on Ethernet.");
|
||||||
clock_init();
|
clock_init();
|
||||||
network_init();
|
network_init();
|
||||||
kserver_init();
|
kserver_init();
|
||||||
|
|
||||||
|
session_end();
|
||||||
while(1) {
|
while(1) {
|
||||||
lwip_service();
|
lwip_service();
|
||||||
kserver_service();
|
kserver_service();
|
||||||
@ -177,7 +178,7 @@ static void serial_service(void)
|
|||||||
|
|
||||||
static void regular_main(void)
|
static void regular_main(void)
|
||||||
{
|
{
|
||||||
puts("Accepting sessions on serial link");
|
puts("Accepting sessions on serial link.");
|
||||||
clock_init();
|
clock_init();
|
||||||
|
|
||||||
/* Open the session for the serial control. */
|
/* Open the session for the serial control. */
|
||||||
|
Loading…
Reference in New Issue
Block a user