summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/programs.c
diff options
context:
space:
mode:
authorleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-06-19 15:06:25 +0200
committerleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-06-19 15:06:25 +0200
commitacee9e74f6bd183b284af028b1f08aab666df9be (patch)
tree02d8df6267dd75dd92760ab9b8e924f4f4b8b400 /sw/z80/kernel/programs.c
parentMerge branch 'master' of github.com:NaoPross/z80uPC into atlas (diff)
downloadz80uPC-master.tar.gz
z80uPC-master.zip
libc memset, memcmpHEADmaster
boot improved program allocation
Diffstat (limited to 'sw/z80/kernel/programs.c')
-rw-r--r--sw/z80/kernel/programs.c29
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