mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +00:00
Kernel: Move all code into the Kernel namespace
This commit is contained in:
parent
d42f0f4661
commit
a356e48150
201 changed files with 907 additions and 111 deletions
|
@ -29,6 +29,8 @@
|
|||
#include <Kernel/Heap/kmalloc.h>
|
||||
#include <Kernel/VM/Region.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
template<size_t templated_slab_size>
|
||||
class SlabAllocator {
|
||||
public:
|
||||
|
@ -160,3 +162,5 @@ void slab_alloc_stats(Function<void(size_t slab_size, size_t allocated, size_t f
|
|||
callback(allocator.slab_size(), allocator.num_allocated(), allocator.num_free());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
#define SLAB_ALLOC_SCRUB_BYTE 0xab
|
||||
#define SLAB_DEALLOC_SCRUB_BYTE 0xbc
|
||||
|
||||
|
@ -43,3 +45,5 @@ public: \
|
|||
void operator delete(void* ptr) { slab_dealloc(ptr, sizeof(type)); } \
|
||||
\
|
||||
private:
|
||||
|
||||
}
|
||||
|
|
|
@ -112,21 +112,21 @@ void* kmalloc_page_aligned(size_t size)
|
|||
|
||||
void* kmalloc_impl(size_t size)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
Kernel::InterruptDisabler disabler;
|
||||
++g_kmalloc_call_count;
|
||||
|
||||
if (g_dump_kmalloc_stacks && ksyms_ready) {
|
||||
if (g_dump_kmalloc_stacks && Kernel::ksyms_ready) {
|
||||
dbgprintf("kmalloc(%u)\n", size);
|
||||
dump_backtrace();
|
||||
Kernel::dump_backtrace();
|
||||
}
|
||||
|
||||
// We need space for the allocation_t structure at the head of the block.
|
||||
size_t real_size = size + sizeof(allocation_t);
|
||||
|
||||
if (sum_free < real_size) {
|
||||
dump_backtrace();
|
||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", current->process().name().characters(), current->pid(), sum_free, real_size);
|
||||
hang();
|
||||
Kernel::dump_backtrace();
|
||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", Kernel::current->process().name().characters(), Kernel::current->pid(), sum_free, real_size);
|
||||
Kernel::hang();
|
||||
}
|
||||
|
||||
size_t chunks_needed = real_size / CHUNK_SIZE;
|
||||
|
@ -177,9 +177,9 @@ void* kmalloc_impl(size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->process().name().characters(), current->pid(), size);
|
||||
dump_backtrace();
|
||||
hang();
|
||||
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", Kernel::current->process().name().characters(), Kernel::current->pid(), size);
|
||||
Kernel::dump_backtrace();
|
||||
Kernel::hang();
|
||||
}
|
||||
|
||||
void kfree(void* ptr)
|
||||
|
@ -187,7 +187,7 @@ void kfree(void* ptr)
|
|||
if (!ptr)
|
||||
return;
|
||||
|
||||
InterruptDisabler disabler;
|
||||
Kernel::InterruptDisabler disabler;
|
||||
++g_kfree_call_count;
|
||||
|
||||
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
||||
|
@ -208,7 +208,7 @@ void* krealloc(void* ptr, size_t new_size)
|
|||
if (!ptr)
|
||||
return kmalloc(new_size);
|
||||
|
||||
InterruptDisabler disabler;
|
||||
Kernel::InterruptDisabler disabler;
|
||||
|
||||
auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
|
||||
size_t old_size = a->nchunk * CHUNK_SIZE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue