diff cos/kernel/kernel.h @ 40:24ce177e01e8

Added more malloc stuff. Added mem usage
author windel
date Tue, 24 Jan 2012 17:54:16 +0100
parents 5c20bd53cccd
children 35cc54e078dd
line wrap: on
line diff
--- a/cos/kernel/kernel.h	Mon Jan 16 21:38:55 2012 +0100
+++ b/cos/kernel/kernel.h	Tue Jan 24 17:54:16 2012 +0100
@@ -147,7 +147,6 @@
    uint64_t physicalAddress;
 } PD_t;
 
-
 typedef struct
 {
    unsigned present : 1;
@@ -181,6 +180,20 @@
 // Make memmap a PML4 type:
 typedef PML4_t memmap_t;
 
+// Malloc related functions
+typedef struct {
+   uint64_t magic;
+   uint64_t state;
+   uint64_t size;
+} heap_header_t;
+
+typedef struct
+{
+   heap_header_t *first_block;
+   uint64_t start_address;
+   uint64_t end_address;
+} heap_t;
+
 // Task related types:
 typedef struct 
 {
@@ -263,23 +276,25 @@
 /* Global variables */
 extern uint64_t kernel_end;
 extern uint64_t placement_address;
+extern memmap_t* kernel_map;
 
 /* Procedures */
 
 // memory functions:
 // TODO: remove some redundant API functions:
-void init_heap();
 void init_memory(uint64_t total_mem_size);
 page_t* get_page(uint64_t address, memmap_t*);
-void* kmalloc(uint64_t size);
-void kfree(void* ptr);
-void* kmalloc_int(uint64_t size);
-void* kmalloc_aligned_int(uint64_t size);
-void mappage(uint64_t address);
+void alloc_frame(page_t *page);
 void loadPageTable(void* tableAddress);
 void switch_mapping(memmap_t* mapping);
 void enablePaging();
 
+// Malloc related:
+void* kmalloc(uint64_t size);
+void* kmalloc_a(uint64_t size); // Aligned on a 4 KiB page.
+void kfree(void* ptr);
+heap_t* create_heap(uint64_t location, uint64_t size);
+
 // task related functions:
 void initialize_tasking();
 void new_task();