From 2429b5fe88f7ce886b73c52168a802bff842f47f Mon Sep 17 00:00:00 2001 From: "leleraffa97@hotmail.it" Date: Thu, 15 Jun 2017 19:16:17 +0200 Subject: Boot loader structures (WORK IN PROGRESS) Some Program manager structures, macros and functions (WORK IN PROGRESS) --- sw/z80/kernel/include/boot.h | 18 ++++++++++++ sw/z80/kernel/include/progman.h | 63 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 sw/z80/kernel/include/boot.h create mode 100644 sw/z80/kernel/include/progman.h (limited to 'sw/z80/kernel/include') diff --git a/sw/z80/kernel/include/boot.h b/sw/z80/kernel/include/boot.h new file mode 100644 index 0000000..d581687 --- /dev/null +++ b/sw/z80/kernel/include/boot.h @@ -0,0 +1,18 @@ +#ifndef BOOT_H +#define BOOT_H + +#define LOGIN_PC // TODO find an address in ROM, to perform jumps + +#define EXEC_STATUS // TODO find an address in Kernel space + +struct exec_status { + + volatile int logged_in:1; // authenticated + volatile int k_control:1; // no running programs + volatile int program_id:1; // current running program id, see "progman.h" + volatile int hidden_pc:13; // program counter of the paused program +}; + +void boot_init(); + +#endif \ No newline at end of file diff --git a/sw/z80/kernel/include/progman.h b/sw/z80/kernel/include/progman.h new file mode 100644 index 0000000..b37e9e9 --- /dev/null +++ b/sw/z80/kernel/include/progman.h @@ -0,0 +1,63 @@ +#ifndef PROGRAM_MAN +#define PROGRAM_MAN + +#include "types.h" + +#define PROG_0 0x0 +#define PROG_1 0x1 + +#define PROG_VSTART 0x1000 +#define PROG_0_PREFIX 0xA000 +#define PROG_1_PREFIX 0xC000 + +#define PROG_0_INFO // TODO +#define PROG_1_INFO // TODO find a space in the ram + +struct program_info { + + volatile int enabled:1; + volatile int running:1; + volatile int exiting:1; + volatile int heap_addr:13; + volatile void (*quit_cb)(void); // 16 +}; + +/* +* Initialize the program manager system +*/ + +void progman_init(); + +/* +* Check if it can start a new program +* If it succedes, the program id is returned, +* otherwise it is returned an error number +*/ + +#define PROG_REQ_FULL -1 +#define PROG_REQ_ERR -2 // Maybe we don't need this, but just in case + +int8_t prog_req(struct program_info *info); + +/* +* It sets a quit callback +*/ + +void prog_0_qcb(void (*callback)(void)); +void prog_1_qcb(void (*callback)(void)); + +/* +* It quits a program, if a callback is set, it will be called +*/ + +void prog_0_quit(); +void prog_1_quit(); + +/* +* It forces a program to quit +*/ + +void prog_0_fquit(); +void prog_1_fquit(); + +#endif \ No newline at end of file -- cgit v1.2.1