summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Makefile2
-rwxr-xr-xSource/Kernel/Melon.kebin610322 -> 0 bytes
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp23
-rw-r--r--Source/Kernel/TaskManager/Process.class.h14
-rw-r--r--Source/Kernel/TaskManager/Task.ns.cpp2
-rw-r--r--Source/Kernel/TaskManager/Thread.class.cpp4
6 files changed, 25 insertions, 20 deletions
diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile
index b28f487..56754d0 100644
--- a/Source/Kernel/Makefile
+++ b/Source/Kernel/Makefile
@@ -5,7 +5,7 @@ CXX = g++
LD = ld
LDFLAGS = -T Link.ld -Map Map.txt --oformat=elf32-i386
CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -Werror -I .
-CXXFLAGS = -nostartfiles -nostdlib -fno-exceptions -fno-rtti -I . -Wall -Werror -Wno-write-strings -funsigned-char -D THIS_IS_MELON -D RANDOM_SEED=`date +%N`LL -g
+CXXFLAGS = -nostartfiles -nostdlib -fno-exceptions -fno-rtti -I . -Wall -Werror -Wno-write-strings -funsigned-char -D THIS_IS_MELON -D RANDOM_SEED=1`date +%N`LL
ASM = nasm
ASMFLAGS = -f elf
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
deleted file mode 100755
index 3eb5982..0000000
--- a/Source/Kernel/Melon.ke
+++ /dev/null
Binary files differ
diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp
index 2706986..d7fba80 100644
--- a/Source/Kernel/TaskManager/Process.class.cpp
+++ b/Source/Kernel/TaskManager/Process.class.cpp
@@ -3,6 +3,10 @@
#include <MemoryManager/PhysMem.ns.h>
#include <VFS/File.class.h>
+namespace Mem {
+ extern Heap kheap;
+}
+
Process::Process() { //Private constructor, does nothing
}
@@ -14,7 +18,7 @@ Process* Process::createKernel(String cmdline, VirtualTerminal *vt) {
p->m_state = P_RUNNING;
p->m_pagedir = kernelPageDirectory;
p->m_uid = 0;
- p->m_stacksstart = 0;
+ p->m_userHeap = &Mem::kheap;
p->m_vt = vt;
Thread* t = new Thread();
@@ -35,24 +39,19 @@ Process::Process(String cmdline, u32int uid) {
m_cmdline = cmdline;
m_retval = 0;
m_state = P_RUNNING;
- m_pagedir = new PageDirectory(kernelPageDirectory);
m_uid = uid;
m_vt = Task::currProcess()->getVirtualTerminal();
- m_stacksstart = 0xC0000000;
+ //Create page directory and user heap
+ m_pagedir = new PageDirectory(kernelPageDirectory);
+ m_userHeap = new Heap();
+ u32int heapIdxSize = PhysMem::total() * 16 + 0x10000;
+ m_userHeap->create(USERHEAPSTART, USERHEAPINITSIZE + heapIdxSize, heapIdxSize, m_pagedir, true, true);
}
Process::~Process() {
exit(); //Kill all threads
delete m_pagedir;
-}
-
-u32int Process::stackAlloc() {
- if (m_stacksstart < STACKSIZE) return 0;
- for (u32int i = m_stacksstart - STACKSIZE; i < m_stacksstart; i += 0x1000) {
- m_pagedir->allocFrame(i & 0xFFFFF000, true, true);
- }
- m_stacksstart -= STACKSIZE;
- return m_stacksstart;
+ delete m_userHeap;
}
void Process::exit() {
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index b975db1..ac9614e 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -5,6 +5,7 @@
#include <Library/Vector.class.h>
#include <Library/SimpleList.class.h>
#include <MemoryManager/PageDirectory.class.h>
+#include <MemoryManager/Heap.class.h>
#include <VTManager/VirtualTerminal.proto.h>
#define P_ZOMBIE 0
@@ -15,7 +16,10 @@
#define E_ABORTED 0x0FFFFF01
#define E_UNHANDLED_EXCEPTION 0x0FFFFF02
-#define STACKSIZE 4096 //Can change
+#define STACKSIZE 4096 //Could change
+
+#define USERHEAPINITSIZE 0x00010000 //Heap initially is 64k, but can grow
+#define USERHEAPSTART 0xB7000000 //Heap is at 0xB7000000, 128Mo before kernel space.
class Thread;
class File;
@@ -32,9 +36,10 @@ class Process {
u8int m_state; //Is one of P_* defined above
PageDirectory* m_pagedir;
u32int m_uid; //User ID
- u32int m_stacksstart;
VirtualTerminal *m_vt;
+ Heap *m_userHeap;
+
Vector<Thread*> m_threads;
SimpleList<File*> *m_fileDescriptors;
@@ -43,8 +48,9 @@ class Process {
Process(String cmdline, u32int uid);
~Process();
- u32int stackAlloc(); //Allocates pages for STACKSIZE bytes at end of app memory (just before 0xC0000000)
- void exit(); //Exits properly process by killing all threads
+ Heap& heap() { return *m_userHeap; }
+
+ void exit(); //Exits properly process by killing all threads and deleting file descriptors
void registerThread(Thread* t); //Called when a thread starts
void threadFinishes(Thread* thread, u32int retval); //Called when a thread finishes
diff --git a/Source/Kernel/TaskManager/Task.ns.cpp b/Source/Kernel/TaskManager/Task.ns.cpp
index 66eca94..a34f14f 100644
--- a/Source/Kernel/TaskManager/Task.ns.cpp
+++ b/Source/Kernel/TaskManager/Task.ns.cpp
@@ -3,7 +3,7 @@
#include <MemoryManager/PhysMem.ns.h>
#define INVALID_TASK_MAGIC 0xBEEFFEED
-#define TEMP_STACK_SIZE 128 //This must be big enough so that we can call all we need to call when a task finishes
+#define TEMP_STACK_SIZE 256 //This must be big enough so that we can call all we need to call when a task finishes
//From Task.wtf.asm
extern "C" u32int read_eip();
diff --git a/Source/Kernel/TaskManager/Thread.class.cpp b/Source/Kernel/TaskManager/Thread.class.cpp
index fe1d08e..20d6cd4 100644
--- a/Source/Kernel/TaskManager/Thread.class.cpp
+++ b/Source/Kernel/TaskManager/Thread.class.cpp
@@ -22,14 +22,14 @@ Thread::Thread(thread_entry_t entry_point, void* data, bool iskernel) {
} else {
m_isKernel = false;
m_process = Task::currProcess();
- setup(entry_point, data, m_process->stackAlloc() + STACKSIZE);
+ setup(entry_point, data, (u32int)(m_process->heap().alloc(STACKSIZE)) + STACKSIZE);
}
}
Thread::Thread(Process* process, thread_entry_t entry_point, void* data) {
m_isKernel = false;
m_process = process;
- setup(entry_point, data, m_process->stackAlloc() + STACKSIZE);
+ setup(entry_point, data, (u32int)(m_process->heap().alloc(STACKSIZE)) + STACKSIZE);
}
Thread::~Thread() {