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/kernel/memory.c | |
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 '')
-rw-r--r-- | sw/z80/kernel/memory.c | 23 |
1 files changed, 22 insertions, 1 deletions
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; } |