summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/memory.c
diff options
context:
space:
mode:
authorleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-31 17:27:10 +0200
committerleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-08-31 17:27:10 +0200
commitad0a29a314d090ee820694c39ea7d11addb8742f (patch)
tree18800d634bb9f29d13baa1ec86be24d73bd8d66c /sw/z80/kernel/memory.c
parentFile system interface (diff)
downloadz80uPC-ad0a29a314d090ee820694c39ea7d11addb8742f.tar.gz
z80uPC-ad0a29a314d090ee820694c39ea7d11addb8742f.zip
Some untracked files from last commit
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 f174906..bcda3c3 100644
--- a/sw/z80/kernel/memory.c
+++ b/sw/z80/kernel/memory.c
@@ -41,3 +41,32 @@ int page_unmap(int page)
pages_table[page].used = 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;
+}*/