summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/memory.c
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-09-10 17:50:20 +0200
committerNao Pross <naopross@thearcway.org>2017-09-10 17:50:20 +0200
commit828c21bd4dc3b168a3182458ca167d742a192bd6 (patch)
tree81a0616d958d1d26bc2035e303ff84fc17ed624b /sw/z80/kernel/memory.c
parentpartial implementation for ctc drivers and memory management (diff)
parentmacro fix (diff)
downloadz80uPC-828c21bd4dc3b168a3182458ca167d742a192bd6.tar.gz
z80uPC-828c21bd4dc3b168a3182458ca167d742a192bd6.zip
Merge remote-tracking branch 'origin/atlas' into naopross
Diffstat (limited to '')
-rw-r--r--sw/z80/kernel/memory.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/z80/kernel/memory.c b/sw/z80/kernel/memory.c
index cfbcb81..cda62ca 100644
--- a/sw/z80/kernel/memory.c
+++ b/sw/z80/kernel/memory.c
@@ -61,3 +61,32 @@ int page_unmap(int page)
pages_table[page].addr = 0;
return 0;
}
+
+/* k_malloc manager */
+/*
+struct k_buf_entry k_buf_table[K_BUF_MAX_COUNT];
+
+struct k_buf k_buffers[K_BUF_MAX_COUNT];
+
+void * k_malloc()
+{
+ for (uint8_t i = 0; i < K_BUF_TABLE_COUNT; i++)
+ {
+ for (uint8_t bit = 0x80, j = 0; j < 8; bit >>= 1, j++)
+ {
+ if (bit & k_buf_table[i])
+ {
+ k_buf_table[i] |= bit;
+ return &k_buffers[8 * i + j];
+ }
+ }
+ }
+}
+
+void k_free(void * ptr)
+{
+ uint8_t index = (ptr - &k_buffers[0]) / K_BUF_SIZE;
+
+ if (index < K_BUF_MAX_COUNT)
+ k_buf_table[index / 8] ^= 0x80 >> index % 8;
+}*/