summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp4
-rw-r--r--Source/Kernel/Library/String.class.cpp10
-rw-r--r--Source/Kernel/Library/String.class.h4
-rw-r--r--Source/Kernel/Library/Vector.class.cpp10
-rw-r--r--Source/Kernel/Library/Vector.class.h10
-rwxr-xr-xSource/Kernel/Melon.kebin158798 -> 158901 bytes
-rw-r--r--Source/Kernel/Ressources/keymap-fr.wtf.cxd (renamed from Source/Kernel/Ressources/keymap-fr.wtf.c)0
-rw-r--r--Source/Kernel/Ressources/logo.cxd (renamed from Source/Kernel/Ressources/logo.cd)0
-rw-r--r--Source/Kernel/TaskManager/Mutex.class.cpp14
-rw-r--r--Source/Kernel/TaskManager/Mutex.class.h9
-rw-r--r--Source/Kernel/TaskManager/Task.wtf.asm7
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp4
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.cpp7
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.h5
14 files changed, 52 insertions, 32 deletions
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 857e167..e263393 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -25,8 +25,8 @@
#include <VFS/DirectoryNode.class.h>
#include <VFS/File.class.h>
-#include <Ressources/logo.cd>
-#include <Ressources/keymap-fr.wtf.c>
+#include <Ressources/logo.cxd>
+#include <Ressources/keymap-fr.wtf.cxd>
extern u32int end; //Placement address
diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp
index 9d4083b..7c2bbc0 100644
--- a/Source/Kernel/Library/String.class.cpp
+++ b/Source/Kernel/Library/String.class.cpp
@@ -196,9 +196,10 @@ String String::concat (WChar other) const {
return (ret += other);
}
-s32int String::toInt() const {
+s64int String::toInt() const {
if (m_string == 0) return 0;
- s32int pos = 0, number = 0;
+ s32int pos = 0;
+ s64int number = 0;
bool negative = false;
if (m_string[0].value == '-') {
negative = true;
@@ -213,9 +214,10 @@ s32int String::toInt() const {
return number;
}
-u32int String::toInt16() const {
+u64int String::toInt16() const {
if (m_string == 0) return 0;
- u32int pos = 0, number = 0;
+ u32int pos = 0;
+ u64int number = 0;
if (m_string[0].value == '0' && m_string[1].value == 'x') pos = 2;
while (1) {
char c = m_string[pos];
diff --git a/Source/Kernel/Library/String.class.h b/Source/Kernel/Library/String.class.h
index 6a9de64..6216415 100644
--- a/Source/Kernel/Library/String.class.h
+++ b/Source/Kernel/Library/String.class.h
@@ -46,8 +46,8 @@ class String {
String operator+ (const char* other) const { return concat(other); }
String operator+ (WChar other) const { return concat(other); }
- s32int toInt() const; //Convert from DEC
- u32int toInt16() const; //Convert from HEX
+ s64int toInt() const; //Convert from DEC
+ u64int toInt16() const; //Convert from HEX
WChar& operator[] (int index) const;
diff --git a/Source/Kernel/Library/Vector.class.cpp b/Source/Kernel/Library/Vector.class.cpp
index 8b032ca..02ae9be 100644
--- a/Source/Kernel/Library/Vector.class.cpp
+++ b/Source/Kernel/Library/Vector.class.cpp
@@ -66,7 +66,7 @@ Vector<T>::~Vector() {
}
template <typename T>
-T& Vector<T>::operator[] (u32int index) {
+T& Vector<T>::operator[] (u32int index) const {
return m_data[index];
}
@@ -106,23 +106,23 @@ void Vector<T>::pop() {
}
template <typename T>
-T& Vector<T>::back() {
+T& Vector<T>::back() const {
return m_data[m_size - 1];
}
template <typename T>
-T& Vector<T>::front() {
+T& Vector<T>::front() const {
return m_data[0];
}
template <typename T>
-u32int Vector<T>::size() {
+u32int Vector<T>::size() const {
return m_size;
}
template <typename T>
-bool Vector<T>::empty() {
+bool Vector<T>::empty() const {
return m_size == 0;
}
diff --git a/Source/Kernel/Library/Vector.class.h b/Source/Kernel/Library/Vector.class.h
index ca86c2a..61c26a4 100644
--- a/Source/Kernel/Library/Vector.class.h
+++ b/Source/Kernel/Library/Vector.class.h
@@ -17,17 +17,17 @@ class Vector {
Vector<T>& operator= (const Vector<T> &other);
~Vector();
- T& operator[] (u32int index);
+ T& operator[] (u32int index) const;
void push(const T& element);
//void push(T& element);
void pop();
- T& back();
- T& front();
+ T& back() const;
+ T& front() const;
- u32int size();
- bool empty();
+ u32int size() const;
+ bool empty() const;
void clear();
};
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
index c1e9c75..79d78db 100755
--- a/Source/Kernel/Melon.ke
+++ b/Source/Kernel/Melon.ke
Binary files differ
diff --git a/Source/Kernel/Ressources/keymap-fr.wtf.c b/Source/Kernel/Ressources/keymap-fr.wtf.cxd
index f24c14d..f24c14d 100644
--- a/Source/Kernel/Ressources/keymap-fr.wtf.c
+++ b/Source/Kernel/Ressources/keymap-fr.wtf.cxd
diff --git a/Source/Kernel/Ressources/logo.cd b/Source/Kernel/Ressources/logo.cxd
index 6cacdb1..6cacdb1 100644
--- a/Source/Kernel/Ressources/logo.cd
+++ b/Source/Kernel/Ressources/logo.cxd
diff --git a/Source/Kernel/TaskManager/Mutex.class.cpp b/Source/Kernel/TaskManager/Mutex.class.cpp
index 55226ff..67234d8 100644
--- a/Source/Kernel/TaskManager/Mutex.class.cpp
+++ b/Source/Kernel/TaskManager/Mutex.class.cpp
@@ -1,24 +1,24 @@
#include "Mutex.class.h"
#include <TaskManager/Task.ns.h>
-Mutex::Mutex(bool locked) {
+extern "C" u32int atomic_exchange(u32int* ptr, u32int newval);
+
+Mutex::Mutex(u32int locked) {
m_locked = locked;
}
bool Mutex::lock() {
- if (m_locked) return false;
- m_locked = true;
- return m_locked;
+ if (atomic_exchange(&m_locked, MUTEX_TRUE) == MUTEX_TRUE) return false; //The lock was already locked
+ return true;
}
void Mutex::waitLock() {
- while (m_locked)
+ while (atomic_exchange(&m_locked, MUTEX_TRUE) == MUTEX_TRUE)
Task::currentThread->sleep(10); //Wait 10ms
- m_locked = true;
}
void Mutex::unlock() {
- m_locked = false;
+ m_locked = MUTEX_FALSE;
}
bool Mutex::locked() {
diff --git a/Source/Kernel/TaskManager/Mutex.class.h b/Source/Kernel/TaskManager/Mutex.class.h
index 298ed9c..5545559 100644
--- a/Source/Kernel/TaskManager/Mutex.class.h
+++ b/Source/Kernel/TaskManager/Mutex.class.h
@@ -1,12 +1,17 @@
#ifndef DEF_MUTEX_CLASS_H
#define DEF_MUTEX_CLASS_H
+#include <Core/common.wtf.h>
+
+#define MUTEX_FALSE 0
+#define MUTEX_TRUE 1
+
class Mutex {
private:
- bool m_locked;
+ u32int m_locked;
public:
- Mutex(bool locked = false);
+ Mutex(u32int locked = MUTEX_FALSE);
bool lock(); //Locks the mutex if it is not locked. Returns true if mutex could be locked, false if already locked
void waitLock(); //Locks the mutex, waiting for it to be unlocked before if necessary
void unlock();
diff --git a/Source/Kernel/TaskManager/Task.wtf.asm b/Source/Kernel/TaskManager/Task.wtf.asm
index 2c14f28..77db18e 100644
--- a/Source/Kernel/TaskManager/Task.wtf.asm
+++ b/Source/Kernel/TaskManager/Task.wtf.asm
@@ -9,6 +9,13 @@ idle_task:
hlt
jmp idle_task
+[GLOBAL atomic_exchange]
+atomic_exchange:
+ mov ecx, [esp+4] ; Get lock address
+ mov eax, [esp+8] ; Get new value
+ xchg eax, [ecx] ; Old value goes in eax
+ ret
+
[GLOBAL copy_page_physical]
copy_page_physical:
push ebx ; According to __cdecl, we must preserve the contents of EBX.
diff --git a/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp b/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp
index d40a9a7..7c784fe 100644
--- a/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal-kbd.class.cpp
@@ -4,6 +4,7 @@
using namespace Kbd;
void VirtualTerminal::keyPress(keypress_t kp) {
+ m_kbdbuffMutex.waitLock();
m_kbdbuff.push(kp);
if (!m_kbdMutex.locked()) {
if (kp.haschar && !kp.hascmd) {
@@ -16,6 +17,7 @@ void VirtualTerminal::keyPress(keypress_t kp) {
put("\b");
}
}
+ m_kbdbuffMutex.unlock();
}
keypress_t VirtualTerminal::getKeypress(bool show, bool block) {
@@ -29,12 +31,14 @@ keypress_t VirtualTerminal::getKeypress(bool show, bool block) {
while (m_kbdbuff.empty())
Task::currentThread->sleep(10);
+ m_kbdbuffMutex.waitLock();
keypress_t ret = m_kbdbuff[0];
for (u32int i = 1; i < m_kbdbuff.size(); i++) {
m_kbdbuff[i - 1] = m_kbdbuff[i];
}
m_kbdbuff.pop();
+ m_kbdbuffMutex.unlock();
if (show) {
if (ret.haschar && !ret.hascmd) {
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
index be1299c..7ee360b 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
@@ -136,12 +136,13 @@ void VirtualTerminal::write(const String& s, bool updatecsr) {
if (updatecsr) updateCursor();
}
-void VirtualTerminal::writeDec(s32int i, bool updatecsr) {
+void VirtualTerminal::writeDec(s64int num, bool updatecsr) {
+ u64int i = num;
if (i == 0) {
put('0', false);
- } else if (i < 0) {
+ } else if (num < 0) {
put('-', false);
- i = 0 - i;
+ i = 0 - num;
}
char c[32];
int n = 0;
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h
index 6bdcf84..d8d7104 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.h
@@ -23,7 +23,7 @@ class VirtualTerminal {
u32int m_csrlin, m_csrcol;
- Mutex m_kbdMutex;
+ Mutex m_kbdMutex, m_kbdbuffMutex;
Vector<Kbd::keypress_t> m_kbdbuff; //Key press events buffer
public:
@@ -47,7 +47,7 @@ class VirtualTerminal {
//Display functions
void put(WChar c, bool updatecsr = true);
void write(const String& s, bool updatecsr = true);
- void writeDec(s32int i, bool updatecsr = true);
+ void writeDec(s64int num, bool updatecsr = true);
void writeHex(u32int i, bool updatecsr = true);
void hexDump(u8int* ptr, u32int sz);
@@ -55,6 +55,7 @@ class VirtualTerminal {
inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; }
//inline VirtualTerminal& operator<<(WChar c) { put(c); return *this; }
inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; }
+ inline VirtualTerminal& operator<<(s64int i) { writeDec(i); return *this; }
inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; }
//Keyboard functions