thermosphere: add semihosting support & load a kernel using it when needed
basically host i/o
This commit is contained in:
@@ -2,16 +2,50 @@
|
||||
#include "core_ctx.h"
|
||||
#include "debug_log.h"
|
||||
#include "platform/uart.h"
|
||||
#include "semihosting.h"
|
||||
#include "traps.h"
|
||||
|
||||
extern const u8 __start__[];
|
||||
|
||||
static void loadKernelViaSemihosting(void)
|
||||
{
|
||||
size_t len = 1<<20; // max len
|
||||
uintptr_t buf = (uintptr_t)__start__ + (1<<20);
|
||||
long handle = -1, ret;
|
||||
|
||||
DEBUG("Loading kernel via semihosting file I/O... ");
|
||||
handle = semihosting_file_open("test_kernel.bin", FOPEN_MODE_RB);
|
||||
if (handle < 0) {
|
||||
DEBUG("failed to open file (%ld)!\n", handle);
|
||||
panic();
|
||||
}
|
||||
|
||||
if ((ret = semihosting_file_read(handle, &len, buf)) < 0) {
|
||||
DEBUG("failed to read file (%ld)!\n", ret);
|
||||
panic();
|
||||
}
|
||||
|
||||
DEBUG("OK!");
|
||||
semihosting_file_close(handle);
|
||||
currentCoreCtx->kernelEntrypoint = buf;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
enableTraps();
|
||||
|
||||
if (currentCoreCtx->coreId == 0) {
|
||||
if (currentCoreCtx->isColdBootCore) {
|
||||
uartInit(115200);
|
||||
DEBUG("Hello from Thermosphere!\n");
|
||||
__builtin_trap();
|
||||
if (currentCoreCtx->kernelEntrypoint == 0) {
|
||||
if (semihosting_connection_supported()) {
|
||||
loadKernelViaSemihosting();
|
||||
//panic();
|
||||
} else {
|
||||
DEBUG("Kernel not loaded!\n");
|
||||
panic();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG("Core %u booted\n", currentCoreCtx->coreId);
|
||||
|
||||
Reference in New Issue
Block a user