diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/memory.h | 37 | ||||
-rw-r--r-- | include/shim.h | 14 |
2 files changed, 32 insertions, 19 deletions
diff --git a/include/memory.h b/include/memory.h index bec05f8..cbed363 100644 --- a/include/memory.h +++ b/include/memory.h @@ -2,19 +2,7 @@ #include <stddef.h> #include <stdint.h> - -struct memory_segment { - uint64_t addr; - uint64_t len; - uint32_t type; - uint32_t reserved; -} __attribute__((packed)); - -struct memory_map { - uint32_t size; - uint32_t version; - struct memory_segment entries[]; -} __attribute__((packed)); +#include <shim.h> /** * Initalize system memory allocator @@ -61,10 +49,23 @@ extern void *alloc_page(void); extern void *alloc_pages(int count); /** - * Frees a single page in memory + * Frees a signle page in memory. + * Must be a page aligned allocated vitural pointer. + * Freeing in the middle of a block is allowed. * @param page - the pointer to the page */ extern void free_page(void *page); +// TODO: implement free_page + +/** + * Frees block of pages in memory. + * Must be a page aligned allocated vitural pointer. + * Freeing int he middle of a block is allowed, + * free_pages will from *page to end of block allocated. + * @param page - the pointer to the page + */ +extern void free_pages(void *page); +// TODO: implement freeing in middle of block /** * Allocates at least len bytes of memory starting at @@ -85,11 +86,11 @@ extern void *mmap(void *addr, size_t len); extern void unmap(void *addr); /** - * Allocates size_t bytes in memory + * Allocates size_t bytes in memory * @param size - the amount of bytes to allocate * @retruns the address allocated or NULL on failure */ -extern void *malloc(size_t size); +extern void *kalloc(size_t size); /** * Reallocates a given allocated ptr to a new size of bytes in memory. @@ -98,10 +99,10 @@ extern void *malloc(size_t size); * @param size - the amount of bytes to set the pointer to * @returns the address allocated or NULL on failure */ -extern void *realloc(void *ptr, size_t size); +extern void *krealloc(void *ptr, size_t size); /** * Frees a allocated pointer in memory * @param ptr - the pointer to free */ -extern void free(void *ptr); +extern void kfree(void *ptr); diff --git a/include/shim.h b/include/shim.h index 9f80abc..dc8c19c 100644 --- a/include/shim.h +++ b/include/shim.h @@ -4,8 +4,20 @@ #define CMDLINE_MAX 32 +struct memory_segment { + uint64_t addr; + uint64_t len; + uint32_t type; +}; + +struct memory_map { + uint32_t entry_count; + uint32_t entry_length; + struct memory_segment *entries; +}; + struct boot_info { - struct memory_map *map; + struct memory_map map; void *symbol_table; void *acpi_table; char cmdline[CMDLINE_MAX]; |