summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Config.h3
-rw-r--r--Source/Kernel/Core/cppsupport.wtf.cpp2
-rw-r--r--Source/Kernel/Library/Rand.ns.cpp18
-rw-r--r--Source/Kernel/Library/Rand.ns.h12
-rw-r--r--Source/Kernel/Makefile3
-rwxr-xr-xSource/Kernel/Melon.kebin165267 -> 165535 bytes
-rw-r--r--Source/Kernel/Shell/KernelShell.class.cpp1
-rw-r--r--Source/Kernel/TaskManager/Thread.class.cpp1
8 files changed, 35 insertions, 5 deletions
diff --git a/Source/Kernel/Config.h b/Source/Kernel/Config.h
index e5943fb..656089e 100644
--- a/Source/Kernel/Config.h
+++ b/Source/Kernel/Config.h
@@ -1,9 +1,6 @@
#ifndef DEF_MELON_KERNEL_CONFIG
#define DEF_MELON_KERNEL_CONFIG
-#define THIS_IS_MELON
-#undef THIS_IS_NOT_MELON
-
#define OPT_DEBUG
//Color scheme
diff --git a/Source/Kernel/Core/cppsupport.wtf.cpp b/Source/Kernel/Core/cppsupport.wtf.cpp
index 16cd122..bad28f2 100644
--- a/Source/Kernel/Core/cppsupport.wtf.cpp
+++ b/Source/Kernel/Core/cppsupport.wtf.cpp
@@ -9,7 +9,6 @@ extern "C" int __cxa_atexit(void (*f)(void*), void *p, void *d) { return 0; }
//Functions for quad divisions/modulo. Taken and arranged from klibc include/asm/div64.h
//These only work with 32-bit divisors and only return 32-bit remainder.
//TODO : think of some correct quad div/mod algorithms
-extern "C" {
inline u64int doDiv(u64int dividend, u32int divisor, u32int *remainder) {
union {
u64int v64;
@@ -28,6 +27,7 @@ inline u64int doDiv(u64int dividend, u32int divisor, u32int *remainder) {
return d.v64;
}
+extern "C" {
u64int __udivdi3(u64int dividend, u64int b) {
u32int divisor, remainder;
divisor = b;
diff --git a/Source/Kernel/Library/Rand.ns.cpp b/Source/Kernel/Library/Rand.ns.cpp
new file mode 100644
index 0000000..e568678
--- /dev/null
+++ b/Source/Kernel/Library/Rand.ns.cpp
@@ -0,0 +1,18 @@
+#include "Rand.ns.h"
+
+namespace Rand {
+
+u32int m = 2073741824, a = 50000, b = 1534;
+u64int current = RANDOM_SEED;
+
+u64int rand() {
+ current = (u32int)(a*current + b);
+ while (current > m) current -= m;
+ return current;
+}
+
+u64int max() {
+ return m;
+}
+
+}
diff --git a/Source/Kernel/Library/Rand.ns.h b/Source/Kernel/Library/Rand.ns.h
new file mode 100644
index 0000000..3598de0
--- /dev/null
+++ b/Source/Kernel/Library/Rand.ns.h
@@ -0,0 +1,12 @@
+#ifndef DEF_RAND_NS_H
+#define DEF_RAND_NS_H
+
+#include <Core/common.wtf.h>
+
+namespace Rand {
+ u64int rand();
+ u64int max();
+}
+
+#endif
+
diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile
index 76bc9eb..9f300bc 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
+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
ASM = nasm
ASMFLAGS = -f elf
@@ -45,6 +45,7 @@ Objects = Core/loader.wtf.o \
Library/String.class.o \
Library/ByteArray.class.o \
Library/WChar.class.o \
+ Library/Rand.ns.o \
VFS/Partition.class.o \
VFS/Part.ns.o \
VFS/VFS.ns.o \
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
index d511d8b..8a8a0e8 100755
--- a/Source/Kernel/Melon.ke
+++ b/Source/Kernel/Melon.ke
Binary files differ
diff --git a/Source/Kernel/Shell/KernelShell.class.cpp b/Source/Kernel/Shell/KernelShell.class.cpp
index 88b9481..d05487f 100644
--- a/Source/Kernel/Shell/KernelShell.class.cpp
+++ b/Source/Kernel/Shell/KernelShell.class.cpp
@@ -1,6 +1,7 @@
#include "KernelShell.class.h"
#include <VTManager/ScrollableVT.class.h>
#include <DeviceManager/Kbd.ns.h>
+#include <Library/Rand.ns.h>
u32int KernelShell::m_instances = 0;
diff --git a/Source/Kernel/TaskManager/Thread.class.cpp b/Source/Kernel/TaskManager/Thread.class.cpp
index 93a2cd3..072a505 100644
--- a/Source/Kernel/TaskManager/Thread.class.cpp
+++ b/Source/Kernel/TaskManager/Thread.class.cpp
@@ -88,6 +88,7 @@ void Thread::handleException(registers_t regs, int no) {
*(m_process->m_vt) << "\nUnhandled exception " << (s32int)no << " at " << (u32int)regs.cs << ":" <<
(u32int)regs.eip << "\n:: " << exceptions[no];
+ if (m_isKernel) PANIC_DUMP("Exception in kernel thread", &regs);
if (no == 14) { //Page fault
int present = !(regs.err_code & 0x1);