diff options
author | Nao Pross <naopross@thearcway.org> | 2017-09-10 17:36:08 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-09-10 17:36:08 +0200 |
commit | e6a3feccab8c555013960e5b730582f24ab55477 (patch) | |
tree | 505a8843ab3dfdf89bbac07f3e3277b0157db519 /sw/z80 | |
parent | new documentation with no styling (diff) | |
download | z80uPC-e6a3feccab8c555013960e5b730582f24ab55477.tar.gz z80uPC-e6a3feccab8c555013960e5b730582f24ab55477.zip |
partial implementation for ctc drivers and memory management
Diffstat (limited to 'sw/z80')
-rw-r--r-- | sw/z80/crt0.rel | 86 | ||||
-rw-r--r-- | sw/z80/kernel/drivers/ctc.c | 1 | ||||
-rw-r--r-- | sw/z80/kernel/include/drivers/ctc.h | 6 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/fs.h | 2 | ||||
-rw-r--r-- | sw/z80/kernel/include/memory.h | 9 | ||||
-rw-r--r-- | sw/z80/kernel/include/types.h | 7 | ||||
-rw-r--r-- | sw/z80/kernel/memory.c | 23 | ||||
-rw-r--r-- | sw/z80/kernel/process.c | 16 |
8 files changed, 53 insertions, 97 deletions
diff --git a/sw/z80/crt0.rel b/sw/z80/crt0.rel deleted file mode 100644 index 880fd57..0000000 --- a/sw/z80/crt0.rel +++ /dev/null @@ -1,86 +0,0 @@ -XL2 -H 14 areas 5 global symbols -M crt0 -S .__.ABS. Def0000 -S _kmain Ref0000 -A _CODE size A flags 0 addr 0 -S __clock Def0000 -S _exit Def0004 -A _HEADER size 0 flags 8 addr 0 -A _HEADER0 size 3 flags 8 addr 0 -A _HEADER1 size 2 flags 8 addr 8 -A _HEADER2 size 2 flags 8 addr 10 -A _HEADER3 size 2 flags 8 addr 18 -A _HEADER4 size 2 flags 8 addr 20 -A _HEADER5 size 2 flags 8 addr 28 -A _HEADER6 size 2 flags 8 addr 30 -A _HEADER7 size 2 flags 8 addr 38 -A _HEADER8 size C flags 8 addr 100 -A _HOME size 0 flags 0 addr 0 -A _INITIALIZER size 0 flags 0 addr 0 -A _GSINIT size 6 flags 0 addr 0 -S gsinit Def0000 -A _GSFINAL size 1 flags 0 addr 0 -A _DATA size 0 flags 0 addr 0 -A _INITIALIZED size 0 flags 0 addr 0 -A _BSEG size 0 flags 0 addr 0 -A _BSS size 0 flags 0 addr 0 -A _HEAP size 0 flags 0 addr 0 -T 00 00 -R 00 00 02 00 -T 00 00 C3 00 01 -R 00 00 02 00 00 03 0A 00 -T 08 00 -R 00 00 03 00 -T 08 00 ED 4D -R 00 00 03 00 -T 10 00 -R 00 00 04 00 -T 10 00 ED 4D -R 00 00 04 00 -T 18 00 -R 00 00 05 00 -T 18 00 ED 4D -R 00 00 05 00 -T 20 00 -R 00 00 06 00 -T 20 00 ED 4D -R 00 00 06 00 -T 28 00 -R 00 00 07 00 -T 28 00 ED 4D -R 00 00 07 00 -T 30 00 -R 00 00 08 00 -T 30 00 ED 4D -R 00 00 08 00 -T 38 00 -R 00 00 09 00 -T 38 00 ED 4D -R 00 00 09 00 -T 00 01 -R 00 00 0A 00 -T 00 01 -R 00 00 0A 00 -T 00 01 31 FF FF CD 00 00 CD 00 00 C3 04 00 -R 00 00 0A 00 00 06 0D 00 02 09 01 00 00 0C 00 00 -T 00 00 -R 00 00 00 00 -T 00 00 3E 02 CF C9 -R 00 00 00 00 -T 04 00 -R 00 00 00 00 -T 04 00 3E 00 CF -R 00 00 00 00 -T 07 00 -R 00 00 00 00 -T 07 00 76 18 FD -R 00 00 00 00 -T 00 00 -R 00 00 0D 00 -T 00 00 78 B1 28 02 ED B0 -R 00 00 0D 00 -T 06 00 -R 00 00 0D 00 -T 00 00 C9 -R 00 00 0E 00 diff --git a/sw/z80/kernel/drivers/ctc.c b/sw/z80/kernel/drivers/ctc.c new file mode 100644 index 0000000..e23ed8e --- /dev/null +++ b/sw/z80/kernel/drivers/ctc.c @@ -0,0 +1 @@ +#include "drivers/ctc.h"
\ No newline at end of file diff --git a/sw/z80/kernel/include/drivers/ctc.h b/sw/z80/kernel/include/drivers/ctc.h new file mode 100644 index 0000000..488e02b --- /dev/null +++ b/sw/z80/kernel/include/drivers/ctc.h @@ -0,0 +1,6 @@ +#ifndef __CTC_H__ +#define __CTC_H__ + +void ctc_control() + +#endif /* __CTC_H__ */
\ No newline at end of file diff --git a/sw/z80/kernel/include/fs/fs.h b/sw/z80/kernel/include/fs/fs.h index 2a0e9d4..81c86b7 100644 --- a/sw/z80/kernel/include/fs/fs.h +++ b/sw/z80/kernel/include/fs/fs.h @@ -53,7 +53,7 @@ struct fs_inode time_t ctime; // creation time /* data storage informations */ - uint24_t size; + uint16_t size; uint16_t blocks[FS_BLOCKS_N]; } diff --git a/sw/z80/kernel/include/memory.h b/sw/z80/kernel/include/memory.h index 60fc98a..67c4b88 100644 --- a/sw/z80/kernel/include/memory.h +++ b/sw/z80/kernel/include/memory.h @@ -6,6 +6,7 @@ /* maximum number of pages on the system */ #define PAGES_MAX_COUNT 32 +#define PAGE_SIZE 1000 /* in our system there are only 16 pages since only 64KB can be addressed * to optimize the memory management in ROM and RAM only pages from this set @@ -31,17 +32,19 @@ #define ADDR_PAGE_14 0xE000 #define ADDR_PAGE_15 0xF000 +#define ADDR_PAGE_FIRST ADDR_PAGE_8 +#define ADDR_PAGE_LAST ADDR_PAGE_15 + struct page { pid_t pid; // process owner of the page (0 if free) uint16_t addr; // physical address }; -extern struct page pages_table[PAGES_MAX_COUNT]; - int mmu_write_table(void); +int page_new(void); int page_map(int page, int pid, uint16_t addr); int page_unmap(int page); -#endif // __MEMORY_H__
\ No newline at end of file +#endif // __MEMORY_H__ diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h index b822144..7f38abb 100644 --- a/sw/z80/kernel/include/types.h +++ b/sw/z80/kernel/include/types.h @@ -10,15 +10,10 @@ #define int8_t char #define uint8_t unsigned char #define int16_t int -#define uint16_t unsigned long int +#define uint16_t unsigned int #define size_t uint16_t #define pid_t uint8_t - #define ino_t uint16_t -typedef struct { - uint data : 24; -} uint24_t; - #endif diff --git a/sw/z80/kernel/memory.c b/sw/z80/kernel/memory.c index ca9f447..cfbcb81 100644 --- a/sw/z80/kernel/memory.c +++ b/sw/z80/kernel/memory.c @@ -1,6 +1,6 @@ #include "memory.h" -struct page pages_table[PAGES_MAX_COUNT]; +static struct page pages_table[PAGES_MAX_COUNT]; int mmu_write_table(void) { @@ -15,6 +15,26 @@ int mmu_write_table(void) return 0; } +int page_new(void) +{ + int i, addr, used; + for (addr = ADDR_PAGE_FIRST; addr < ADDR_PAGE_LAST; addr += PAGE_SIZE) { + used = 0; + + for (i = 0; i < PAGES_MAX_COUNT; i++) { + if (page_map[i].addr == addr) { + used = 1; + break; + } + } + + if (!used) + return i; + } + + return -1; +} + int page_map(int page, int pid, uint16_t addr) { if (page >= PAGES_MAX_COUNT) @@ -38,5 +58,6 @@ int page_unmap(int page) return -2; pages_table[page].pid = 0; + pages_table[page].addr = 0; return 0; } diff --git a/sw/z80/kernel/process.c b/sw/z80/kernel/process.c index b43fa11..049c88c 100644 --- a/sw/z80/kernel/process.c +++ b/sw/z80/kernel/process.c @@ -26,7 +26,23 @@ pid_t newpid(void) int fork(void) { + int i, p; + pid_t child_pid = newpid(); + if (child_pid == 0) + return -1; + + + for (i = 0; i < current_proc.pages; i++) { + p = page_new(); + + if (p == -1) { + + return -2; + } + + proc_table[child_pid].page[i] = p; + } } int exec(char *path, char *args) |