summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-09-10 17:36:08 +0200
committerNao Pross <naopross@thearcway.org>2017-09-10 17:36:08 +0200
commite6a3feccab8c555013960e5b730582f24ab55477 (patch)
tree505a8843ab3dfdf89bbac07f3e3277b0157db519 /sw/z80/kernel
parentnew documentation with no styling (diff)
downloadz80uPC-e6a3feccab8c555013960e5b730582f24ab55477.tar.gz
z80uPC-e6a3feccab8c555013960e5b730582f24ab55477.zip
partial implementation for ctc drivers and memory management
Diffstat (limited to '')
-rw-r--r--sw/z80/kernel/drivers/ctc.c1
-rw-r--r--sw/z80/kernel/include/drivers/ctc.h6
-rw-r--r--sw/z80/kernel/include/fs/fs.h2
-rw-r--r--sw/z80/kernel/include/memory.h9
-rw-r--r--sw/z80/kernel/include/types.h7
-rw-r--r--sw/z80/kernel/memory.c23
-rw-r--r--sw/z80/kernel/process.c16
7 files changed, 53 insertions, 11 deletions
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)