summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-07-04 09:16:59 +0200
committerNao Pross <naopross@thearcway.org>2017-07-04 09:16:59 +0200
commita86838ead76c76e62369d461d5f4ff6ea6b07433 (patch)
treea2a5131ce8a4fb06c6cefceaa5fb9857a42ce553 /sw/z80/kernel/include
parentnew components list and cpld test unit (diff)
parentOrder and update of the struct (diff)
downloadz80uPC-a86838ead76c76e62369d461d5f4ff6ea6b07433.tar.gz
z80uPC-a86838ead76c76e62369d461d5f4ff6ea6b07433.zip
merge branch 'atlas' into naopross
Diffstat (limited to 'sw/z80/kernel/include')
-rw-r--r--sw/z80/kernel/include/login.h23
-rw-r--r--sw/z80/kernel/include/progman.h109
-rw-r--r--sw/z80/kernel/include/syscall.h20
-rw-r--r--sw/z80/kernel/include/sysexe.h55
4 files changed, 207 insertions, 0 deletions
diff --git a/sw/z80/kernel/include/login.h b/sw/z80/kernel/include/login.h
new file mode 100644
index 0000000..5fa4b5e
--- /dev/null
+++ b/sw/z80/kernel/include/login.h
@@ -0,0 +1,23 @@
+#ifndef LOGIN_H
+#define LOGIN_H
+
+#include "types.h"
+
+#define LOGIN_PC // TODO find an address in ROM, to perform jumps
+
+#define PWD_ADDR // TODO find an address in ROM, password
+#define PWD_SIZE 8
+
+/*
+* It returns 1 if succeded, otherwise 0
+*/
+
+int8_t authenticate(const char *pwd);
+
+/*
+* It sets the password in the ROM space, maximum 8 characters
+*/
+
+void set_pwd(const char *pwd);
+
+#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..b59e14a
--- /dev/null
+++ b/sw/z80/kernel/include/progman.h
@@ -0,0 +1,109 @@
+#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 prog_status {
+
+ // 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
+};
+
+/*
+* 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
+*
+* ! Disable virtual addresses when this function is called
+*/
+
+#define PROG_REQ_FULL -1
+
+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 prog_space {
+
+ 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
+};
+
+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 prog_data *data);
+
+/*
+* It sets a quit callback
+*/
+
+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(uint8_t force);
+void prog_1_quit(uint8_t force);
+
+#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/syscall.h b/sw/z80/kernel/include/syscall.h
new file mode 100644
index 0000000..9641f25
--- /dev/null
+++ b/sw/z80/kernel/include/syscall.h
@@ -0,0 +1,20 @@
+#ifndef SYS_CALL
+#define SYS_CALL
+
+/*
+* Enable / disable virtual address traslation
+*/
+
+extern void v_addr(uint8_t flag);
+
+/*
+* Programs execution
+*/
+
+extern void prog_exec_0(void);
+extern void prog_exec_1(void);
+
+extern void prog_stop_0(void);
+extern void prog_stop_1(void);
+
+#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/sysexe.h b/sw/z80/kernel/include/sysexe.h
new file mode 100644
index 0000000..9c13c09
--- /dev/null
+++ b/sw/z80/kernel/include/sysexe.h
@@ -0,0 +1,55 @@
+#ifndef SYS_EXE
+#define SYS_EXE
+
+#define SYS_EXEC_ADDR // TODO find an address in Kernel space
+
+struct sys_progman {
+
+ // program 0 enabled
+
+ uint8_t prog_0_enabled:1;
+
+ // program 1 enabled
+
+ /*
+ * Obs: A program is enabled when its space is allocated
+ * and its virtual program counter is stored in
+ * the hardware or in the silent_pc.
+ * An enabled program is not necessarly running, it
+ * could be paused too.
+ */
+
+ uint8_t prog_1_enabled:1;
+
+ // running's program id
+
+ uint8_t prog_running:1;
+};
+
+struct sys_exec {
+
+ /*
+ * Virtual addresses are activated
+ */
+
+ uint8_t virtual_addr:1;
+
+ struct sys_progman progman;
+
+ /*
+ * The silent_pc is the place designed to store the
+ * program counter of the program that's not running
+ */
+
+ uint8_t silent_pc:12;
+};
+
+/*
+* Function to access informations
+*/
+
+uint8_t vaddr_enabled();
+
+struct sys_progman * sys_prog_data(struct sys_progman *data);
+
+#endif \ No newline at end of file