forked from Bananymous/banan-os
Kernel: Hacky kmalloc quick fix
Remove GeneralAllocator from kmalloc as it is not CriticalScope safe. This requires increasing kmalloc memory.
This commit is contained in:
parent
8b2bb95b81
commit
18d582c6ce
|
@ -12,9 +12,7 @@ extern uint8_t g_kernel_end[];
|
|||
|
||||
static constexpr size_t s_kmalloc_min_align = alignof(max_align_t);
|
||||
|
||||
static uint8_t s_kmalloc_storage[2 * MB];
|
||||
|
||||
static BAN::UniqPtr<Kernel::GeneralAllocator> s_general_allocator;
|
||||
static uint8_t s_kmalloc_storage[20 * MB];
|
||||
|
||||
struct kmalloc_node
|
||||
{
|
||||
|
@ -303,19 +301,6 @@ void* kmalloc(size_t size, size_t align, bool force_indentity_map)
|
|||
|
||||
Kernel::CriticalScope critical;
|
||||
|
||||
// FIXME: this is a hack to make more dynamic kmalloc memory
|
||||
if (size > PAGE_SIZE && !force_indentity_map)
|
||||
{
|
||||
using namespace Kernel;
|
||||
|
||||
if (!s_general_allocator)
|
||||
s_general_allocator = MUST(GeneralAllocator::create(PageTable::kernel(), (vaddr_t)g_kernel_end));
|
||||
|
||||
auto vaddr = s_general_allocator->allocate(size);
|
||||
if (vaddr)
|
||||
return (void*)vaddr;
|
||||
}
|
||||
|
||||
if (size == 0 || size >= info.size)
|
||||
goto no_memory;
|
||||
|
||||
|
@ -350,9 +335,6 @@ void kfree(void* address)
|
|||
|
||||
Kernel::CriticalScope critical;
|
||||
|
||||
if (s_general_allocator && s_general_allocator->deallocate((Kernel::vaddr_t)address))
|
||||
return;
|
||||
|
||||
if (s_kmalloc_fixed_info.base <= address_uint && address_uint < s_kmalloc_fixed_info.end)
|
||||
{
|
||||
auto& info = s_kmalloc_fixed_info;
|
||||
|
@ -414,13 +396,6 @@ BAN::Optional<Kernel::paddr_t> kmalloc_paddr_of(Kernel::vaddr_t vaddr)
|
|||
{
|
||||
using namespace Kernel;
|
||||
|
||||
if (s_general_allocator)
|
||||
{
|
||||
auto paddr = s_general_allocator->paddr_of(vaddr);
|
||||
if (paddr.has_value())
|
||||
return paddr.value();
|
||||
}
|
||||
|
||||
if ((vaddr_t)s_kmalloc_storage <= vaddr && vaddr < (vaddr_t)s_kmalloc_storage + sizeof(s_kmalloc_storage))
|
||||
return V2P(vaddr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue