Reorganised some code. Moved new/delete out of process
This commit is contained in:
parent
e06d98b22a
commit
0f5e080e15
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ DISK_IMG_FILES = build/kernel/kernel.bin hello.txt alpha.txt
|
||||
KERNEL_OBJS = build/kernel/entry.o build/kernel/screenstuff.o build/kernel/io.o build/kernel/idt.o build/kernel/keyboard.o \
|
||||
build/kernel/strings.o build/kernel/atapio.o build/kernel/kernel.o build/kernel/paging.o build/kernel/allocate.o \
|
||||
build/kernel/gdt.o build/kernel/memory.o build/kernel/process.o build/kernel/datatypes/hash.o \
|
||||
build/kernel/terminal.o
|
||||
build/kernel/terminal.o build/kernel/global.o
|
||||
STAGE2_OBS = build/c_code_entry.o build/boot_stage2/io.o build/boot_stage2/atapio.o build/boot_stage2/strings.o build/boot_stage2/screenstuff.o build/boot_stage2/stage2.o build/boot_stage2/paging.o
|
||||
|
||||
run: disk.img
|
||||
|
@ -1,4 +1,24 @@
|
||||
#include "global.h"
|
||||
namespace Global {
|
||||
Allocator* allocator;
|
||||
Allocator* allocator = 0;
|
||||
}
|
||||
|
||||
void* operator new (uint32_t size) {
|
||||
return Global::allocator->allocate(size);
|
||||
}
|
||||
|
||||
void operator delete (void* ptr) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void operator delete (void* ptr, unsigned int size) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void* operator new[] (uint32_t size) {
|
||||
return Global::allocator->allocate(size);
|
||||
}
|
||||
|
||||
void operator delete[] (void* ptr) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
@ -7,4 +7,11 @@ namespace Global {
|
||||
extern Allocator* allocator;
|
||||
}
|
||||
|
||||
void* operator new (uint32_t size);
|
||||
void operator delete (void* ptr);
|
||||
void operator delete (void* ptr, unsigned int size);
|
||||
|
||||
void* operator new[] (uint32_t size);
|
||||
void operator delete[] (void* ptr);
|
||||
|
||||
#endif
|
@ -83,28 +83,6 @@ uint32_t Process::count_allocations(uint32_t address) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Allocator* Global::allocator;
|
||||
|
||||
Kernel::Kernel(PageDirectory* page_directory, PageMap* phys, PageMap* virt, uint32_t virt_alloc_base)
|
||||
: Process(0, page_directory, phys, virt, virt_alloc_base)
|
||||
{}
|
||||
|
||||
void* operator new (uint32_t size) {
|
||||
return Global::allocator->allocate(size);
|
||||
}
|
||||
|
||||
void operator delete (void* ptr) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void operator delete (void* ptr, unsigned int size) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
||||
|
||||
void* operator new[] (uint32_t size) {
|
||||
return Global::allocator->allocate(size);
|
||||
}
|
||||
|
||||
void operator delete[] (void* ptr) {
|
||||
Global::allocator->deallocate((uint32_t)ptr);
|
||||
}
|
@ -24,6 +24,8 @@ private:
|
||||
uint32_t last_page_pointer;
|
||||
uint32_t page_remaining;
|
||||
|
||||
void* stack;
|
||||
|
||||
// List of pages this process has allocated
|
||||
xnoe::linkedlist<AllocTracker> allocations;
|
||||
|
||||
@ -45,11 +47,4 @@ public:
|
||||
Kernel(PageDirectory* page_directory, PageMap* phys, PageMap* virt, uint32_t virt_alloc_base);
|
||||
};
|
||||
|
||||
void* operator new (uint32_t size);
|
||||
void operator delete (void* ptr);
|
||||
void operator delete (void* ptr, unsigned int size);
|
||||
|
||||
void* operator new[] (uint32_t size);
|
||||
void operator delete[] (void* ptr);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user