mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-08 03:47:15 -04:00
Rename malloc in kalloc
This commit is contained in:
parent
842370208b
commit
857557a94c
@ -10,7 +10,7 @@
|
||||
|
||||
#include <types.hpp>
|
||||
|
||||
namespace malloc {
|
||||
namespace kalloc {
|
||||
|
||||
void init();
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "ata.hpp"
|
||||
#include "kernel_utils.hpp"
|
||||
#include "timer.hpp"
|
||||
#include "malloc.hpp"
|
||||
#include "kalloc.hpp"
|
||||
#include "thor.hpp"
|
||||
#include "interrupts.hpp"
|
||||
#include "console.hpp"
|
||||
|
@ -5,7 +5,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "malloc.hpp"
|
||||
#include "kalloc.hpp"
|
||||
#include "console.hpp"
|
||||
#include "physical_allocator.hpp"
|
||||
#include "paging.hpp"
|
||||
@ -308,7 +308,7 @@ malloc_header_chunk* coalesce(malloc_header_chunk* b){
|
||||
|
||||
} //end of anonymous namespace
|
||||
|
||||
void malloc::init(){
|
||||
void kalloc::init(){
|
||||
//Init the fake head
|
||||
init_head();
|
||||
|
||||
@ -316,7 +316,7 @@ void malloc::init(){
|
||||
expand_heap(malloc_head);
|
||||
}
|
||||
|
||||
void* malloc::k_malloc(uint64_t bytes){
|
||||
void* kalloc::k_malloc(uint64_t bytes){
|
||||
auto current = malloc_head->next();
|
||||
|
||||
//Try not to create too small blocks
|
||||
@ -400,7 +400,7 @@ void* malloc::k_malloc(uint64_t bytes){
|
||||
return reinterpret_cast<void*>(block_start);
|
||||
}
|
||||
|
||||
void malloc::k_free(void* block){
|
||||
void kalloc::k_free(void* block){
|
||||
auto free_header = reinterpret_cast<malloc_header_chunk*>(
|
||||
reinterpret_cast<uintptr_t>(block) - sizeof(malloc_header_chunk));
|
||||
|
||||
@ -424,15 +424,15 @@ void malloc::k_free(void* block){
|
||||
debug_malloc<DEBUG_MALLOC>("after free");
|
||||
}
|
||||
|
||||
size_t malloc::allocated_memory(){
|
||||
size_t kalloc::allocated_memory(){
|
||||
return _allocated_memory;
|
||||
}
|
||||
|
||||
size_t malloc::used_memory(){
|
||||
size_t kalloc::used_memory(){
|
||||
return _used_memory;
|
||||
}
|
||||
|
||||
size_t malloc::free_memory(){
|
||||
size_t kalloc::free_memory(){
|
||||
size_t memory_free = 0;
|
||||
|
||||
auto it = malloc_head;
|
||||
@ -445,7 +445,7 @@ size_t malloc::free_memory(){
|
||||
return memory_free;
|
||||
}
|
||||
|
||||
void malloc::debug(){
|
||||
void kalloc::debug(){
|
||||
size_t memory_free = 0;
|
||||
size_t non_free_blocks = 0;
|
||||
size_t inconsistent = 0;
|
@ -9,7 +9,7 @@
|
||||
#include "physical_allocator.hpp"
|
||||
#include "virtual_allocator.hpp"
|
||||
#include "paging.hpp"
|
||||
#include "malloc.hpp"
|
||||
#include "kalloc.hpp"
|
||||
#include "timer.hpp"
|
||||
#include "shell.hpp"
|
||||
#include "keyboard.hpp"
|
||||
@ -44,11 +44,11 @@ void kernel_main(){
|
||||
//Init all the physical
|
||||
paging::init();
|
||||
|
||||
//Finalize physical allocator initialization for malloc
|
||||
//Finalize physical allocator initialization for kalloc
|
||||
physical_allocator::init();
|
||||
|
||||
//Init dynamic memory allocation
|
||||
malloc::init();
|
||||
kalloc::init();
|
||||
|
||||
//Install drivers
|
||||
timer::install();
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "physical_allocator.hpp"
|
||||
#include "virtual_allocator.hpp"
|
||||
#include "malloc.hpp"
|
||||
#include "kalloc.hpp"
|
||||
#include "e820.hpp"
|
||||
|
||||
namespace {
|
||||
@ -54,7 +54,7 @@ void date_command(const std::vector<std::string>& params);
|
||||
void echo_command(const std::vector<std::string>& params);
|
||||
void mmap_command(const std::vector<std::string>& params);
|
||||
void memory_command(const std::vector<std::string>& params);
|
||||
void mallocdebug_command(const std::vector<std::string>& params);
|
||||
void kallocdebug_command(const std::vector<std::string>& params);
|
||||
void disks_command(const std::vector<std::string>& params);
|
||||
void partitions_command(const std::vector<std::string>& params);
|
||||
void mount_command(const std::vector<std::string>& params);
|
||||
@ -85,7 +85,7 @@ command_definition commands[24] = {
|
||||
{"echo", echo_command},
|
||||
{"mmap", mmap_command},
|
||||
{"memory", memory_command},
|
||||
{"mallocdebug", mallocdebug_command},
|
||||
{"kallocdebug", kallocdebug_command},
|
||||
{"disks", disks_command},
|
||||
{"partitions", partitions_command},
|
||||
{"mount", mount_command},
|
||||
@ -270,13 +270,13 @@ void memory_command(const std::vector<std::string>&){
|
||||
k_printf("\tFree: %m (%h)\n", virtual_allocator::free(), virtual_allocator::free());
|
||||
|
||||
k_print_line("Dynamic:");
|
||||
k_printf("\tAllocated: %m (%h)\n", malloc::allocated_memory(), malloc::allocated_memory());
|
||||
k_printf("\tUsed: %m (%h)\n", malloc::used_memory(), malloc::used_memory());
|
||||
k_printf("\tFree: %m (%h)\n", malloc::free_memory(), malloc::free_memory());
|
||||
k_printf("\tAllocated: %m (%h)\n", kalloc::allocated_memory(), kalloc::allocated_memory());
|
||||
k_printf("\tUsed: %m (%h)\n", kalloc::used_memory(), kalloc::used_memory());
|
||||
k_printf("\tFree: %m (%h)\n", kalloc::free_memory(), kalloc::free_memory());
|
||||
}
|
||||
|
||||
void mallocdebug_command(const std::vector<std::string>&){
|
||||
malloc::debug();
|
||||
void kallocdebug_command(const std::vector<std::string>&){
|
||||
kalloc::debug();
|
||||
}
|
||||
|
||||
void disks_command(const std::vector<std::string>& params){
|
||||
|
@ -6,22 +6,22 @@
|
||||
//=======================================================================
|
||||
|
||||
#include "thor.hpp"
|
||||
#include "malloc.hpp"
|
||||
#include "kalloc.hpp"
|
||||
|
||||
void* operator new(uint64_t size){
|
||||
return malloc::k_malloc(size);
|
||||
return kalloc::k_malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void* p){
|
||||
malloc::k_free(p);
|
||||
kalloc::k_free(p);
|
||||
}
|
||||
|
||||
void* operator new[](uint64_t size){
|
||||
return malloc::k_malloc(size);
|
||||
return kalloc::k_malloc(size);
|
||||
}
|
||||
|
||||
void operator delete[](void* p){
|
||||
return malloc::k_free(p);
|
||||
return kalloc::k_free(p);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user