diff options
author | leleraffa97@hotmail.it <leleraffa97@hotmail.it> | 2017-06-19 15:06:25 +0200 |
---|---|---|
committer | leleraffa97@hotmail.it <leleraffa97@hotmail.it> | 2017-06-19 15:06:25 +0200 |
commit | acee9e74f6bd183b284af028b1f08aab666df9be (patch) | |
tree | 02d8df6267dd75dd92760ab9b8e924f4f4b8b400 /sw/z80/kernel/programs.c | |
parent | Merge branch 'master' of github.com:NaoPross/z80uPC into atlas (diff) | |
download | z80uPC-master.tar.gz z80uPC-master.zip |
boot improved
program allocation
Diffstat (limited to 'sw/z80/kernel/programs.c')
-rw-r--r-- | sw/z80/kernel/programs.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sw/z80/kernel/programs.c b/sw/z80/kernel/programs.c index 0f75887..705ea96 100644 --- a/sw/z80/kernel/programs.c +++ b/sw/z80/kernel/programs.c @@ -1,4 +1,5 @@ #include "progman.h" +#include "string.h" #define EMPTY_PROG_INFO 0x0 @@ -37,9 +38,35 @@ int8_t prog_req(struct program_info *info) { void prog_alloc(int8_t id, struct program_info *info, const struct program_base *base) { - // TODO, implements program allocation + void *addr = (id ? PROG_1_PREFIX : PROG_0_PREFIX) + PROG_VSTART; + + if (info->enabled) { + + if (id) + prog_1_fquit(); // force quit operation + else + prog_0_fquit(); + } + + + memcpy(addr, base->inst_set, base->inst_size); + + addr += base->inst_size; + + memcpy(addr, base->bss_data, base->data_size); + + addr += base->data_size; + + // TODO, empty heap and stack } +/* +* TODO Called from the assembly, system calls +*/ + +extern void exec_0(void); +extern void exec_1(void); + void prog_exec(int8_t id, struct program_info *info) { // TODO, perform a program counter jump |