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/progman.h | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sw/z80/kernel/include/progman.h (limited to 'sw/z80/kernel/include/progman.h') 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 From f85e54f7982d5fefecddccbb11f5aabd478b91d6 Mon Sep 17 00:00:00 2001 From: "leleraffa97@hotmail.it" Date: Mon, 19 Jun 2017 13:46:16 +0200 Subject: Authentication section Programs management --- sw/z80/kernel/include/progman.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sw/z80/kernel/include/progman.h') diff --git a/sw/z80/kernel/include/progman.h b/sw/z80/kernel/include/progman.h index b37e9e9..0f56bb3 100644 --- a/sw/z80/kernel/include/progman.h +++ b/sw/z80/kernel/include/progman.h @@ -39,6 +39,29 @@ void progman_init(); int8_t prog_req(struct program_info *info); +/* +* It allocates a program in the RAM +* To obtain the right id call prog_req() first +* Basic informations must be allocated and referenced by a program_base struct +*/ + +struct program_base { + + void * inst_set; // pointer to the instructions set + size_t inst_size; // size of the instructions set + void * bss_data; // pointer to the bss/data space + size_t data_size; // size of the bss/data space + size_t stack_size; // size of the stack to determine the stack limit +}; + +void prog_alloc(int8_t id, struct program_info *info, const struct program_base *base); + +/* +* It jumps the program counter to the given one +*/ + +void prog_exec(int8_t id, struct program_info *info); + /* * It sets a quit callback */ -- cgit v1.2.1 From acee9e74f6bd183b284af028b1f08aab666df9be Mon Sep 17 00:00:00 2001 From: "leleraffa97@hotmail.it" Date: Mon, 19 Jun 2017 15:06:25 +0200 Subject: libc memset, memcmp boot improved program allocation --- sw/z80/kernel/include/progman.h | 1 - 1 file changed, 1 deletion(-) (limited to 'sw/z80/kernel/include/progman.h') diff --git a/sw/z80/kernel/include/progman.h b/sw/z80/kernel/include/progman.h index 0f56bb3..5d01f1c 100644 --- a/sw/z80/kernel/include/progman.h +++ b/sw/z80/kernel/include/progman.h @@ -51,7 +51,6 @@ struct program_base { size_t inst_size; // size of the instructions set void * bss_data; // pointer to the bss/data space size_t data_size; // size of the bss/data space - size_t stack_size; // size of the stack to determine the stack limit }; void prog_alloc(int8_t id, struct program_info *info, const struct program_base *base); -- cgit v1.2.1 From ac89960fbe89141aea31da9a329bfa39d67eede7 Mon Sep 17 00:00:00 2001 From: "leleraffa97@hotmail.it" Date: Fri, 23 Jun 2017 12:18:24 +0200 Subject: Order and update of the struct Separation of boot and login sections Improuved program manager system --- sw/z80/kernel/include/progman.h | 68 ++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 22 deletions(-) (limited to 'sw/z80/kernel/include/progman.h') diff --git a/sw/z80/kernel/include/progman.h b/sw/z80/kernel/include/progman.h index 5d01f1c..b59e14a 100644 --- a/sw/z80/kernel/include/progman.h +++ b/sw/z80/kernel/include/progman.h @@ -13,13 +13,41 @@ #define PROG_0_INFO // TODO #define PROG_1_INFO // TODO find a space in the ram -struct program_info { +struct prog_status { - volatile int enabled:1; - volatile int running:1; - volatile int exiting:1; - volatile int heap_addr:13; - volatile void (*quit_cb)(void); // 16 + // The program is in execution + + uint8_t running:1; + + // The program is executing its quit callback + + uint8_t exiting:1; + + uint8_t unused:6; // TODO, find a usage for these bits +}: + +struct prog_data { + + struct prog_status status; + + /* + * The following addresses are needed to map + * map the usable memory for dynamic allocations + */ + + // Virtual address of the heap + + uint8_t heap_addr:12; + + // Virtual address of the stack limit + + uint8_t stack_limit:12; + + /* + * Function called when the program exits normally + */ + + void (*quit_cb)(void); // 16 }; /* @@ -32,20 +60,23 @@ 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 +* +* ! Disable virtual addresses when this function is called */ #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); +int8_t prog_req(); /* * It allocates a program in the RAM * To obtain the right id call prog_req() first * Basic informations must be allocated and referenced by a program_base struct +* +* ! Disable virtual addresses when this function is called */ -struct program_base { +struct prog_space { void * inst_set; // pointer to the instructions set size_t inst_size; // size of the instructions set @@ -53,33 +84,26 @@ struct program_base { size_t data_size; // size of the bss/data space }; -void prog_alloc(int8_t id, struct program_info *info, const struct program_base *base); +void prog_alloc(int8_t id, struct prog_data *data, const struct prog_space *space); /* * It jumps the program counter to the given one */ -void prog_exec(int8_t id, struct program_info *info); +void prog_exec(int8_t id, struct prog_data *data); /* * It sets a quit callback */ -void prog_0_qcb(void (*callback)(void)); -void prog_1_qcb(void (*callback)(void)); +void prog_0_set_qcb(void (*callback)(void)); +void prog_1_set_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(); +void prog_0_quit(uint8_t force); +void prog_1_quit(uint8_t force); #endif \ No newline at end of file -- cgit v1.2.1