重构内存分配器、增加中断支持、整理rust运行时环境 #4

Merged
pointer-to-bios merged 39 commits from downstream into main 2024-04-11 00:36:14 +08:00
3 changed files with 9 additions and 9 deletions
Showing only changes of commit 7e22dd604f - Show all commits

View File

@ -23,7 +23,7 @@
/* 只分配不映射空间 */
#define MEMM_ALLOC_ONLY_MEMORY (128 * 1024 * 1024)
typedef void *(*memm_allocate_t)(void *allocator, usize size, usize align);
typedef void *(*memm_allocate_t)(void *allocator, usize size);
typedef void (*memm_free_t)(void *allocator, void *mem);
/*

View File

@ -13,7 +13,7 @@ void raw_allocator_new(raw_allocator_t *allocator, usize size)
allocator->cells[0].length = 0;
}
void *raw_allocator_allocate(raw_allocator_t *allocator, usize size, usize align)
void *raw_allocator_allocate(raw_allocator_t *allocator, usize size)
{
usize real_size = size;
align_to(real_size, 16);

View File

@ -24,7 +24,7 @@ mem_manager_t *memm_new(usize mem_size)
MEMM_RAW_ALLOCATOR, 0);
allocator_iterator_t *alcatr_ind = allocator0->allocate(
&allocator0->allocator_instance, sizeof(allocator_iterator_t), 0);
&allocator0->allocator_instance, sizeof(allocator_iterator_t));
alcatr_ind->allocator = allocator0;
alcatr_ind->left = nullptr;
@ -37,7 +37,7 @@ mem_manager_t *memm_new(usize mem_size)
align_to(pmc_size, 8);
pmc_size /= 8;
memory_manager.page_map = allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0);
memory_manager.page_map = allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.page_map, 0, pmc_size);
memset(memory_manager.page_map, 0xff, MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8);
for (usize i = (MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8) * (u8)8;
@ -48,7 +48,7 @@ mem_manager_t *memm_new(usize mem_size)
// 配置分配器页地图
memory_manager.map_with_allocator =
allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0);
allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.map_with_allocator, 0, pmc_size);
for (usize i = kernel_initial_size / MEMM_PAGE_SIZE;
i < MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE;
@ -59,7 +59,7 @@ mem_manager_t *memm_new(usize mem_size)
// 分配器释放页地图
memory_manager.map_with_destructed_allocator =
allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0);
allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.map_with_destructed_allocator, 0, pmc_size);
// 配置空闲页线段搜索表
@ -103,14 +103,14 @@ void *memm_find_and_allocate(allocator_iterator_t *allocator_ind, usize size, us
allocator_t *allocator = allocator_ind->allocator;
if (allocator->pid == pid && allocator->full == false)
{ // 尝试用本节点分配
if ((ptr = allocator->allocate(&allocator->allocator_instance, size, 0)) != nullptr)
if ((ptr = allocator->allocate(&allocator->allocator_instance, size)) != nullptr)
{
*writeback = allocator;
return ptr;
}
else
{
if ((ptr = allocator->allocate(&allocator->allocator_instance, 0, 0)) == nullptr)
if ((ptr = allocator->allocate(&allocator->allocator_instance, 0)) == nullptr)
allocator->full = true;
}
}
@ -197,7 +197,7 @@ void *memm_allocate(usize size, usize pid)
allind->left = nullptr;
allind->right = nullptr;
insert_allocator(memory_manager.allocators, allind);
ptr = new_allocator->allocate(&new_allocator->allocator_instance, orgsize, 0);
ptr = new_allocator->allocate(&new_allocator->allocator_instance, orgsize);
after_allocation:
if (ptr != nullptr)