diff options
author | leleraffa97@hotmail.it <leleraffa97@hotmail.it> | 2017-06-15 19:16:17 +0200 |
---|---|---|
committer | leleraffa97@hotmail.it <leleraffa97@hotmail.it> | 2017-06-15 19:16:17 +0200 |
commit | 2429b5fe88f7ce886b73c52168a802bff842f47f (patch) | |
tree | 9cf05169a300cb1866aa70c1e660546964347f7b /sw/z80/kernel/programs.c | |
parent | Kernel memory mapping setup (diff) | |
download | z80uPC-2429b5fe88f7ce886b73c52168a802bff842f47f.tar.gz z80uPC-2429b5fe88f7ce886b73c52168a802bff842f47f.zip |
Boot loader structures (WORK IN PROGRESS)
Some Program manager structures, macros and functions (WORK IN PROGRESS)
Diffstat (limited to 'sw/z80/kernel/programs.c')
-rw-r--r-- | sw/z80/kernel/programs.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/sw/z80/kernel/programs.c b/sw/z80/kernel/programs.c new file mode 100644 index 0000000..31593d1 --- /dev/null +++ b/sw/z80/kernel/programs.c @@ -0,0 +1,100 @@ +#include "progman.h" + +#define EMPTY_PROG_INFO 0x0 + +struct program_info *prog_0 = PROG_0_INFO, + *prog_1 = PROG_1_INFO; + +void progman_init() { + + *prog_0 = EMPTY_PROG_INFO; + *prog_1 = EMPTY_PROG_INFO; + + // TODO other stuff +} + +int8_t prog_req(struct program_info *info) { + + uint8_t prog; + + if (!prog_0->enabled) { + + prog = PROG_0; + *info = *prog_0; + + } else if (!prog_1->enabled) { + + prog = PROG_1; + *info = *prog_1; + + } else { + + return PROG_REQ_FULL; + } + + return prog; +} + +void prog_0_qcb(void (*callback)(void)) { + + prog_0->quit_cb = callback; +} + +void prog_1_qcb(void (*callback)(void)) { + + prog_1->quit_cb = callback; +} + +void prog_0_quit() { + + if (!prog_0->enabled || prog_0->exiting) + return; + + if (prog_0->quit_cb) + prog_0->quit_cb(); + + // TODO free space in RAM + + *prog_0 = EMPTY_PROG_INFO; + + // TODO jump program counter +} + +void prog_1_quit() { + + if (!prog_1->enabled || prog_1->exiting) + return; + + if (prog_1->quit_cb) + prog_1->quit_cb(); + + // TODO free space in RAM + + *prog_1 = EMPTY_PROG_INFO; + + // TODO jump program counter +} + +void prog_0_fquit() { + + if (!prog_0->enabled) + return; + + // TODO free space in RAM + + *prog_0 = EMPTY_PROG_INFO; + + // TODO jump program counter +} + +void prog_1_fquit() { + + if (!prog_1->enabled) + return; + + // TODO free space in RAM + + *prog_1 = EMPTY_PROG_INFO; + + // TODO jump program counter +}
\ No newline at end of file |