Page allocation uses new external library, libmalloc

This commit is contained in:
2023-01-09 01:56:09 -06:00
parent 1be6de1a26
commit 6af84b247f
9 changed files with 63 additions and 411 deletions

View File

@@ -1,13 +1,13 @@
#pragma once
#include "avltree.h"
#include "memmap.h"
#include "priorityqueue.h"
#include "queue.h"
#include "mmgr.h"
#include "syscalls.h"
#include "types/syscallid.h"
#include "types/status.h"
#include <libmalloc/memmap.h>
#include <stddef.h>
#define MAX_SYSCALL_ID 256
@@ -38,7 +38,7 @@ struct boot_info_t
char *bootloader;
char *parameters;
size_t memory_size;
struct memory_map_t map;
memory_map_t map;
size_t module_count;
struct module_t modules[module_limit];
};

View File

@@ -1,27 +0,0 @@
#pragma once
#include "types/physaddr.h"
#include <stddef.h>
enum memory_type_t
{
M_AVAILABLE = 1,
M_UNAVAILABLE = 2,
M_DEFECTIVE = 3
};
struct memory_region_t
{
physaddr_t location;
size_t size;
unsigned int type;
};
struct memory_map_t
{
struct memory_region_t *array;
size_t size;
size_t capacity;
};
void insert_region(struct memory_map_t *map, physaddr_t location, size_t size, enum memory_type_t type);

View File

@@ -1,9 +1,9 @@
#pragma once
#include "memmap.h"
#include "platform/paging.h"
#include "types/physaddr.h"
#include "types/status.h"
#include "libmalloc/memmap.h"
#include <stddef.h>
extern const size_t page_size;
@@ -14,7 +14,7 @@ extern const size_t page_size;
* @param size
* @return physaddr_t
*/
physaddr_t reserve_region(size_t size);
physaddr_t reserve_pages(size_t size);
/**
* @brief
@@ -23,7 +23,7 @@ physaddr_t reserve_region(size_t size);
* @param size
* @return int
*/
int free_region(physaddr_t location, size_t size);
int free_pages(physaddr_t location, size_t size);
/**
* @brief Reserves a single page and returns its physical address.
@@ -72,7 +72,7 @@ void *page_map_end();
* @param block_size
* @return enum error_t
*/
error_t initialize_page_map(struct memory_map_t *map, void *base, size_t memory_size, unsigned long block_size);
error_t initialize_page_map(memory_map_t *map, void *base, size_t memory_size, unsigned long block_size);
/**
* @brief Create a new top-level page table and map the kernel in it.