summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include/memory.h
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-07-04 11:35:23 +0200
committerNao Pross <naopross@thearcway.org>2017-07-04 11:35:23 +0200
commitb14d0afe86966b91ad6a40816439cdc34602b49e (patch)
treef0d3bb06a9d41ad4dc5277251f9d82fe40e46595 /sw/z80/kernel/include/memory.h
parentmerge branch 'atlas' into naopross (diff)
downloadz80uPC-b14d0afe86966b91ad6a40816439cdc34602b49e.tar.gz
z80uPC-b14d0afe86966b91ad6a40816439cdc34602b49e.zip
new structure for process management, structures to discuss
the idea behind kernel/include/progman.h was good but the implementation was very not unix-like, so I made a new file under kernel/include/process.h that will implement the same features other changes: - move usart register structs definitions outside of the device - remove old build files - delete boot.h and boot_loader.h (as they weren't used by anything) - change on makefile to build binary with `makebin` instead of `xxd` - new file memory.h to implement memory mapping and mmu control - new type `uint` in types.h
Diffstat (limited to 'sw/z80/kernel/include/memory.h')
-rw-r--r--sw/z80/kernel/include/memory.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/sw/z80/kernel/include/memory.h b/sw/z80/kernel/include/memory.h
new file mode 100644
index 0000000..5bca5a5
--- /dev/null
+++ b/sw/z80/kernel/include/memory.h
@@ -0,0 +1,48 @@
+#ifndef __MEMORY_H__
+#define __MEMORY_H__
+
+#include "types.h"
+#include "devices.h"
+
+/* maximum number of pages on the system */
+#define PAGES_MAX_COUNT 32
+
+/* 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
+ * shall be used
+ */
+// ROM
+#define ADDR_PAGE_0 0x0000
+#define ADDR_PAGE_1 0x1000
+#define ADDR_PAGE_2 0x2000
+#define ADDR_PAGE_3 0x3000
+// IOSPACE
+#define ADDR_PAGE_4 0x4000
+#define ADDR_PAGE_5 0x5000
+#define ADDR_PAGE_6 0x6000
+#define ADDR_PAGE_7 0x7000
+// RAM
+#define ADDR_PAGE_8 0x8000
+#define ADDR_PAGE_9 0x9000
+#define ADDR_PAGE_10 0xA000
+#define ADDR_PAGE_11 0xB000
+#define ADDR_PAGE_12 0xC000
+#define ADDR_PAGE_13 0xD000
+#define ADDR_PAGE_14 0xE000
+#define ADDR_PAGE_15 0xF000
+
+struct page
+{
+ uint used :1;
+ uint8_t pid; // process owner of the page
+ uint16_t addr; // physical address
+};
+
+extern struct page pages_table[PAGES_MAX_COUNT];
+
+int mmu_write_table(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