summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.cpp8
-rw-r--r--Source/Kernel/Linker/ElfBinary.class.cpp2
-rw-r--r--Source/Kernel/Linker/MelonBinary.class.cpp2
-rw-r--r--Source/Kernel/MemoryManager/Mem.ns.cpp4
-rw-r--r--Source/Kernel/MemoryManager/Mem.ns.h4
-rw-r--r--Source/Kernel/MemoryManager/PageAlloc.ns.cpp4
-rw-r--r--Source/Kernel/MemoryManager/PhysMem.ns.cpp2
-rw-r--r--Source/Kernel/Shell/KernelShell-fs.class.cpp4
-rw-r--r--Source/Kernel/SyscallManager/Res.ns.cpp6
-rw-r--r--Source/Kernel/TaskManager/Thread.class.cpp4
-rw-r--r--Source/Kernel/common.h8
-rw-r--r--Source/Library/Common/Bitset.class.cpp4
-rw-r--r--Source/Library/Common/SimpleList.class.h4
-rw-r--r--Source/Library/Common/Vector.class.cpp16
-rw-r--r--Source/Library/Makefile1
15 files changed, 37 insertions, 36 deletions
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
index a224bf8..5997841 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
@@ -112,11 +112,11 @@ bool RamFS::write(FileNode* file, u64int position, u32int length, u8int *data) {
m_usedSize -= node->getLength();
m_usedSize += end;
- u8int* data = (u8int*)Mem::kalloc(end);
+ u8int* data = (u8int*)Mem::alloc(end);
if (data == 0) return false; //Invalid pointer
if (node->m_data != 0) {
memcpy(data, node->m_data, node->getLength());
- Mem::kfree(node->m_data);
+ Mem::free(node->m_data);
}
node->m_data = data;
node->setLength(end);
@@ -129,7 +129,7 @@ bool RamFS::truncate(FileNode* file) {
if (!m_isWritable) return false;
RamFileNode *node = (RamFileNode*) file;
- Mem::kfree(node->m_data);
+ Mem::free(node->m_data);
node->setLength(0);
node->m_data = 0;
@@ -163,7 +163,7 @@ DirectoryNode* RamFS::createDirectory(DirectoryNode* parent, String name) {
bool RamFS::remove(DirectoryNode* parent, FSNode* node) {
if (node->type() == NT_FILE) {
u8int *d = ((RamFileNode*)node)->m_data;
- if (d != 0) Mem::kfree(d);
+ if (d != 0) Mem::free(d);
}
return true;
}
diff --git a/Source/Kernel/Linker/ElfBinary.class.cpp b/Source/Kernel/Linker/ElfBinary.class.cpp
index 450053f..27e5474 100644
--- a/Source/Kernel/Linker/ElfBinary.class.cpp
+++ b/Source/Kernel/Linker/ElfBinary.class.cpp
@@ -26,7 +26,7 @@ Binary* ElfBinary::load(File& file) {
}
//Load data
for (SimpleList<phdr_t> *iter = b->m_phdr; iter != 0; iter = iter->next()) {
- iter->v().data = (u8int*)Mem::kalloc(iter->v().h.p_filesz);
+ iter->v().data = (u8int*)Mem::alloc(iter->v().h.p_filesz);
file.seek(iter->v().h.p_offset, SM_BEGINNING);
file.read(iter->v().h.p_filesz, iter->v().data);
}
diff --git a/Source/Kernel/Linker/MelonBinary.class.cpp b/Source/Kernel/Linker/MelonBinary.class.cpp
index d6074de..0737b71 100644
--- a/Source/Kernel/Linker/MelonBinary.class.cpp
+++ b/Source/Kernel/Linker/MelonBinary.class.cpp
@@ -7,7 +7,7 @@ Binary* MelonBinary::load(File& file) {
MelonBinary* r = new MelonBinary;
file.read<u32int>(&r->m_size);
file.read<u32int>(&r->m_org);
- r->m_data = (u8int*)Mem::kalloc(r->m_size);
+ r->m_data = (u8int*)Mem::alloc(r->m_size);
file.read(r->m_size, r->m_data);
return r;
} else {
diff --git a/Source/Kernel/MemoryManager/Mem.ns.cpp b/Source/Kernel/MemoryManager/Mem.ns.cpp
index c705b3b..c7f07f0 100644
--- a/Source/Kernel/MemoryManager/Mem.ns.cpp
+++ b/Source/Kernel/MemoryManager/Mem.ns.cpp
@@ -39,14 +39,14 @@ void createHeap() {
kheap.create(heapStart, heapSize, heapIndexSize, kernelPageDirectory, false, false);
}
-void *kalloc(u32int sz, bool align) {
+void *alloc(u32int sz, bool align) {
if (!kheap.usable()) return kallocInternal(sz, align);
if (align) return 0;
return kheap.alloc(sz);
}
-void kfree(void *ptr) {
+void free(void *ptr) {
kheap.free(ptr);
}
diff --git a/Source/Kernel/MemoryManager/Mem.ns.h b/Source/Kernel/MemoryManager/Mem.ns.h
index 15935c0..0d2b1da 100644
--- a/Source/Kernel/MemoryManager/Mem.ns.h
+++ b/Source/Kernel/MemoryManager/Mem.ns.h
@@ -8,8 +8,8 @@ namespace Mem {
extern u32int placementAddress;
void createHeap();
- void *kalloc(u32int sz, bool align = false);
- void kfree(void *ptr);
+ void *alloc(u32int sz, bool align = false);
+ void free(void *ptr);
u32int kheapSize(), kheapFree();
}
diff --git a/Source/Kernel/MemoryManager/PageAlloc.ns.cpp b/Source/Kernel/MemoryManager/PageAlloc.ns.cpp
index 34d4f74..d8ede2a 100644
--- a/Source/Kernel/MemoryManager/PageAlloc.ns.cpp
+++ b/Source/Kernel/MemoryManager/PageAlloc.ns.cpp
@@ -14,7 +14,7 @@ bool usable = false, locked = false;
void init() {
freec = CACHED_PAGES;
for (u32int i = 0; i < CACHED_PAGES; i++) {
- freePage[i] = Mem::kalloc(0x1000, true);
+ freePage[i] = Mem::alloc(0x1000, true);
}
usable = true;
}
@@ -26,7 +26,7 @@ void* alloc(u32int* phys) {
locked = true;
void* next = 0;
if (!Mem::pagingEnabled) {
- next = Mem::kalloc(0x1000, true);
+ next = Mem::alloc(0x1000, true);
} else {
u32int i = 0xFFFFF000;
page_t *p;
diff --git a/Source/Kernel/MemoryManager/PhysMem.ns.cpp b/Source/Kernel/MemoryManager/PhysMem.ns.cpp
index 25869f1..1b40e88 100644
--- a/Source/Kernel/MemoryManager/PhysMem.ns.cpp
+++ b/Source/Kernel/MemoryManager/PhysMem.ns.cpp
@@ -14,7 +14,7 @@ void initPaging(u32int mem_size) {
frames = new Bitset(nframes);
- kernelPageDirectory = new (Mem::kalloc(sizeof(PageDirectory), true)) PageDirectory();
+ kernelPageDirectory = new (Mem::alloc(sizeof(PageDirectory), true)) PageDirectory();
u32int i = 0xC0000000;
while (i < Mem::placementAddress) {
diff --git a/Source/Kernel/Shell/KernelShell-fs.class.cpp b/Source/Kernel/Shell/KernelShell-fs.class.cpp
index fe1ecbf..cd52810 100644
--- a/Source/Kernel/Shell/KernelShell-fs.class.cpp
+++ b/Source/Kernel/Shell/KernelShell-fs.class.cpp
@@ -55,11 +55,11 @@ void KernelShell::cat(Vector<String>& args) {
for (u32int i = 1; i < args.size(); i++) {
File f(args[i], FM_READ, m_cwd);
if (f.valid()) {
- u8int *buff = (u8int*)Mem::kalloc(f.length() + 1);
+ u8int *buff = (u8int*)Mem::alloc(f.length() + 1);
f.read(f.length(), buff);
buff[f.length()] = 0;
*m_vt << String((const char*) buff);
- Mem::kfree(buff);
+ Mem::free(buff);
} else {
*m_vt << "Error reading from file " << args[i] << "\n";
}
diff --git a/Source/Kernel/SyscallManager/Res.ns.cpp b/Source/Kernel/SyscallManager/Res.ns.cpp
index 274f6f1..1779a00 100644
--- a/Source/Kernel/SyscallManager/Res.ns.cpp
+++ b/Source/Kernel/SyscallManager/Res.ns.cpp
@@ -12,18 +12,18 @@ u32int size = 0;
void expand() { //Expands size of ressources array of 20 entries
size += 20;
- Ressource** tmp = (Ressource**)Mem::kalloc(size * sizeof(Ressource*));
+ Ressource** tmp = (Ressource**)Mem::alloc(size * sizeof(Ressource*));
for (u32int i = 0; i < size; i++) {
if (i < size - 20) tmp[i] = ressources[i];
else tmp[i] = 0;
}
- Mem::kfree(ressources);
+ Mem::free(ressources);
ressources = tmp;
}
u32int registerRes(Ressource* r) {
if (ressources == 0 or size == 0) {
- ressources = (Ressource**)Mem::kalloc(20 * sizeof(Ressource*));
+ ressources = (Ressource**)Mem::alloc(20 * sizeof(Ressource*));
size = 20;
for (u32int i = 0; i < 20; i++) ressources[i] = 0;
}
diff --git a/Source/Kernel/TaskManager/Thread.class.cpp b/Source/Kernel/TaskManager/Thread.class.cpp
index 2237457..315eae2 100644
--- a/Source/Kernel/TaskManager/Thread.class.cpp
+++ b/Source/Kernel/TaskManager/Thread.class.cpp
@@ -68,7 +68,7 @@ Thread::Thread(Process* process, thread_entry_t entry_point, void* data) : Resso
Thread::~Thread() {
Task::unregisterThread(this);
- Mem::kfree(m_kernelStack.addr);
+ Mem::free(m_kernelStack.addr);
if (m_userStack.addr != 0) {
m_process->getPagedir()->switchTo();
m_process->heap().free(m_userStack.addr);
@@ -82,7 +82,7 @@ void Thread::setup(Process* process, thread_entry_t entry_point, void* data, boo
m_isKernel = isKernel;
m_process = process;
- m_kernelStack.addr = Mem::kalloc(STACKSIZE);
+ m_kernelStack.addr = Mem::alloc(STACKSIZE);
m_kernelStack.size = STACKSIZE;
if (m_isKernel) {
diff --git a/Source/Kernel/common.h b/Source/Kernel/common.h
index c6da25e..86d76cd 100644
--- a/Source/Kernel/common.h
+++ b/Source/Kernel/common.h
@@ -20,9 +20,9 @@ inline void* operator new[](u32int, void *p) { return p; }
inline void operator delete(void*, void*) { }
inline void operator delete[](void*, void*) { }
-inline void* operator new(u32int sz) { return Mem::kalloc(sz); }
-inline void* operator new[](u32int sz) { return Mem::kalloc(sz); }
-inline void operator delete(void *ptr) { Mem::kfree(ptr); }
-inline void operator delete[](void *ptr) { Mem::kfree(ptr); }
+inline void* operator new(u32int sz) { return Mem::alloc(sz); }
+inline void* operator new[](u32int sz) { return Mem::alloc(sz); }
+inline void operator delete(void *ptr) { Mem::free(ptr); }
+inline void operator delete[](void *ptr) { Mem::free(ptr); }
#endif
diff --git a/Source/Library/Common/Bitset.class.cpp b/Source/Library/Common/Bitset.class.cpp
index ec4e62c..a8d7ec8 100644
--- a/Source/Library/Common/Bitset.class.cpp
+++ b/Source/Library/Common/Bitset.class.cpp
@@ -4,7 +4,7 @@ Bitset::Bitset() {
}
Bitset::Bitset(u32int size) {
- init(size, (u32int*)Mem::kalloc(INDEX_FROM_BIT(size)));
+ init(size, (u32int*)Mem::alloc(INDEX_FROM_BIT(size)));
}
Bitset::Bitset(u32int size, u32int *ptr) {
@@ -12,7 +12,7 @@ Bitset::Bitset(u32int size, u32int *ptr) {
}
Bitset::~Bitset() {
- Mem::kfree(m_data);
+ Mem::free(m_data);
}
void Bitset::init(u32int size, u32int *ptr) {
diff --git a/Source/Library/Common/SimpleList.class.h b/Source/Library/Common/SimpleList.class.h
index 3e0f968..7b731db 100644
--- a/Source/Library/Common/SimpleList.class.h
+++ b/Source/Library/Common/SimpleList.class.h
@@ -36,7 +36,7 @@ class SimpleList {
SimpleList<T>* delThis() {
SimpleList<T>* ret = m_next;
- Mem::kfree(this);
+ Mem::free(this);
return ret;
}
@@ -44,7 +44,7 @@ class SimpleList {
if (m_next == 0) return;
SimpleList<T>* temp = m_next;
m_next = m_next->m_next;
- Mem::kfree(temp);
+ Mem::free(temp);
}
SimpleList<T>* removeOnce(const T& value) {
diff --git a/Source/Library/Common/Vector.class.cpp b/Source/Library/Common/Vector.class.cpp
index 02ae9be..c546a42 100644
--- a/Source/Library/Common/Vector.class.cpp
+++ b/Source/Library/Common/Vector.class.cpp
@@ -4,7 +4,7 @@ using namespace CMem; //strlen and memcpy
for (u32int i = 0; i < m_size; i++) { \
m_data[i].~T(); \
} \
- Mem::kfree(m_data); \
+ Mem::free(m_data); \
}
template <typename T>
@@ -25,7 +25,7 @@ Vector<T>::Vector(u32int size) {
template <typename T>
Vector<T>::Vector(u32int size, const T& value) {
//DEBUG_HEX((u32int)this); DEBUG(" NEW FILLED");
- //m_data = (T*)Mem::kalloc(size * sizeof(T));
+ //m_data = (T*)Mem::alloc(size * sizeof(T));
m_data = new T[size];
m_size = size;
for (u32int i = 0; i < m_size; i++) {
@@ -40,7 +40,7 @@ template <typename T>
Vector<T>::Vector(const Vector<T> &other) {
//DEBUG_HEX((u32int)this); DEBUG(" COPY REF");
m_size = other.m_size;
- m_data = (T*)Mem::kalloc(m_size * sizeof(T));
+ m_data = (T*)Mem::alloc(m_size * sizeof(T));
for (u32int i = 0; i < m_size; i++) {
new(&m_data[i]) T(other.m_data[i]);
}
@@ -51,7 +51,7 @@ Vector<T>& Vector<T>::operator= (const Vector<T> &other) {
//DEBUG_HEX((u32int)this); DEBUG(" COPY EQ");
DELDATA;
m_size = other.m_size;
- m_data = (T*)Mem::kalloc(m_size * sizeof(T));
+ m_data = (T*)Mem::alloc(m_size * sizeof(T));
for (u32int i = 0; i < m_size; i++) {
new(&m_data[i]) T(other.m_data[i]);
}
@@ -72,14 +72,14 @@ T& Vector<T>::operator[] (u32int index) const {
template <typename T>
void Vector<T>::push(const T& element) {
- T* newdata = (T*)Mem::kalloc((m_size + 1) * sizeof(T));
+ T* newdata = (T*)Mem::alloc((m_size + 1) * sizeof(T));
if (m_size != 0 and m_data != 0) {
memcpy((u8int*)newdata, (const u8int*) m_data, m_size * sizeof(T));
}
new(&newdata[m_size]) T(element); //Construct by copy
//newdata[m_size] = element;
m_size++;
- Mem::kfree(m_data);
+ Mem::free(m_data);
m_data = newdata;
}
@@ -99,9 +99,9 @@ void Vector<T>::pop() {
m_size--;
//delete(&m_data[m_size], &m_data[m_size]); //implicitly call destructor with placement delete
m_data[m_size].~T(); //Call destructor
- T* newdata = (T*)Mem::kalloc(m_size * sizeof(T));
+ T* newdata = (T*)Mem::alloc(m_size * sizeof(T));
memcpy((u8int*)newdata, (const u8int*) m_data, m_size * sizeof(T));
- Mem::kfree(m_data);
+ Mem::free(m_data);
m_data = newdata;
}
diff --git a/Source/Library/Makefile b/Source/Library/Makefile
index 028e7a4..a4b9b6a 100644
--- a/Source/Library/Makefile
+++ b/Source/Library/Makefile
@@ -15,6 +15,7 @@ Objects = Common/WChar.class.uo \
Common/Mutex.class.uo \
Common/Heap.class.uo \
Common/Heap-index.class.uo \
+ Common/String.class.uo \
Userland/Syscall/Syscall.wtf.uo \
Userland/Syscall/RessourceCaller.class.uo \
Userland/Start.uo