-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: new serial protocol, support multiple entry points and log m…
…essages
1 parent
f529361
commit 11d8840
Showing
12 changed files
with
270 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#ifndef __CORECOM_H | ||
#define __CORECOM_H | ||
|
||
int ident_and_download_kernel(void *buffer, int maxlength); | ||
int rpc(int rpc_num, int n_args, ...); | ||
void kernel_finished(void); | ||
typedef int (*object_loader)(void *, int); | ||
typedef int (*kernel_runner)(const char *); | ||
|
||
void corecom_serve(object_loader load_object, kernel_runner run_kernel); | ||
int corecom_rpc(int rpc_num, int n_args, ...); | ||
void corecom_log(const char *fmt, ...); | ||
|
||
#endif /* __CORECOM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,90 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <irq.h> | ||
#include <uart.h> | ||
#include <system.h> | ||
|
||
#include "corecom.h" | ||
#include "elf_loader.h" | ||
#include "symbols.h" | ||
#include "services.h" | ||
#include "rtio.h" | ||
#include "dds.h" | ||
|
||
static unsigned char kcode[256*1024]; | ||
|
||
static struct symbol symtab[128]; | ||
static int _symtab_count; | ||
static char _symtab_strings[128*16]; | ||
static char *_symtab_strptr; | ||
|
||
|
||
static void symtab_init(void) | ||
{ | ||
memset(symtab, 0, sizeof(symtab)); | ||
_symtab_count = 0; | ||
_symtab_strptr = _symtab_strings; | ||
} | ||
|
||
static int symtab_add(const char *name, void *target) | ||
{ | ||
if(_symtab_count >= sizeof(symtab)/sizeof(symtab[0])) { | ||
corecom_log("Too many provided symbols in object"); | ||
symtab_init(); | ||
return 0; | ||
} | ||
symtab[_symtab_count].name = _symtab_strptr; | ||
symtab[_symtab_count].target = target; | ||
_symtab_count++; | ||
|
||
while(1) { | ||
if(_symtab_strptr >= &_symtab_strings[sizeof(_symtab_strings)]) { | ||
corecom_log("Provided symbol string table overflow"); | ||
symtab_init(); | ||
return 0; | ||
} | ||
*_symtab_strptr = *name; | ||
_symtab_strptr++; | ||
if(*name == 0) | ||
break; | ||
name++; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
static int load_object(void *buffer, int length) | ||
{ | ||
symtab_init(); | ||
return load_elf( | ||
resolve_service_symbol, symtab_add, | ||
buffer, length, kcode, sizeof(kcode)); | ||
} | ||
|
||
typedef void (*kernel_function)(void); | ||
|
||
int main(void) | ||
static int run_kernel(const char *kernel_name) | ||
{ | ||
unsigned char kbuf[256*1024]; | ||
unsigned char kcode[256*1024]; | ||
kernel_function k; | ||
int length; | ||
|
||
k = find_symbol(symtab, kernel_name); | ||
if(k == NULL) { | ||
corecom_log("Failed to find kernel entry point '%s' in object", kernel_name); | ||
return 0; | ||
} | ||
rtio_init(); | ||
flush_cpu_icache(); | ||
k(); | ||
return 1; | ||
} | ||
|
||
int main(void) | ||
{ | ||
irq_setmask(0); | ||
irq_setie(1); | ||
uart_init(); | ||
|
||
puts("ARTIQ runtime built "__DATE__" "__TIME__"\n"); | ||
|
||
while(1) { | ||
length = ident_and_download_kernel(kbuf, sizeof(kbuf)); | ||
if(length > 0) { | ||
k = load_elf(resolve_symbol, "run", kbuf, length, kcode, sizeof(kcode)); | ||
if(k != NULL) { | ||
rtio_init(); | ||
dds_init(); | ||
flush_cpu_icache(); | ||
k(); | ||
kernel_finished(); | ||
} | ||
} | ||
} | ||
|
||
dds_init(); | ||
corecom_serve(load_object, run_kernel); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __SERVICES_H | ||
#define __SERVICES_H | ||
|
||
void *resolve_service_symbol(const char *name); | ||
|
||
#endif /* __SERVICES_H */ |
This file was deleted.
Oops, something went wrong.