summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/config.h4
-rw-r--r--src/kernel/core/sys.cpp8
-rw-r--r--src/kernel/task/task.cpp10
-rw-r--r--src/kernel/task/task.h6
-rw-r--r--src/kernel/ui/vt.cpp41
-rw-r--r--src/kernel/ui/vt.h2
-rw-r--r--src/kernel/vfs/node.h3
7 files changed, 27 insertions, 47 deletions
diff --git a/src/kernel/config.h b/src/kernel/config.h
index 74d0933..b7f6a17 100644
--- a/src/kernel/config.h
+++ b/src/kernel/config.h
@@ -2,7 +2,7 @@
#define DEF_CONFIG_H
#define K_OS_NAME "T/CE"
-#define K_OS_VER "0.1.3"
-#define K_OS_CODENAME "FWIcKet"
+#define K_OS_VER "0.1.4"
+#define K_OS_CODENAME "VivaElC"
#endif
diff --git a/src/kernel/core/sys.cpp b/src/kernel/core/sys.cpp
index 32ed988..01a3c20 100644
--- a/src/kernel/core/sys.cpp
+++ b/src/kernel/core/sys.cpp
@@ -32,7 +32,7 @@ void stack_trace(size_t bp) {
uint32_t *stack = (uint32_t*)bp, i;
for (i = 0; i < 5 && (size_t)stack > K_HIGHHALF_ADDR && (size_t)stack < (bp + 0x8000); i++) {
*ke_vt << " | " << (size_t)stack;
- *ke_vt << "\tnext:" << stack[0] << "\t\tret:" << stack[1] << "\n";
+ *ke_vt << "\tnext:" << stack[0] << "\t\tret:" << stack[1] << " \n";
stack = (uint32_t*)stack[0];
}
}
@@ -40,8 +40,8 @@ void stack_trace(size_t bp) {
/* For internal use only. Used by panic and panic_assert. */
static void panic_do(char* file, int line) {
asm volatile("cli;");
- *ke_vt << "\n File:\t\t" << file << ":" << line;
- *ke_vt << "\nTrace:\n";
+ *ke_vt << " \n File:\t\t" << file << ":" << line;
+ *ke_vt << " \nTrace: \n";
size_t bp; asm volatile("mov %%ebp,%0" : "=r"(bp)); stack_trace(bp);
*ke_vt << "\n\t\tSystem halted -_-'";
asm volatile("hlt");
@@ -52,6 +52,7 @@ void panic(char* message, char* file, int line) {
ke_vt->fgcolor = TC_WHITE;
ke_vt->bgcolor = TC_BLUE;
ke_vt->outputTo(text_display);
+ *ke_vt << " * * * * * * * * * * * * * * * * * * * * * * * * * * ";
*ke_vt << "\nPANIC:\t" << message;
panic_do(file, line);
}
@@ -60,6 +61,7 @@ void panic_assert(char* assertion, char* file, int line) {
ke_vt->fgcolor = TC_WHITE;
ke_vt->bgcolor = TC_RED;
ke_vt->outputTo(text_display);
+ *ke_vt << " * * * * * * * * * * * * * * * * * * * * * * * * * * ";
*ke_vt << "\nASSERT FAILED:\t" << assertion;
panic_do(file, line);
}
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 4a802b8..91f802d 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -119,10 +119,10 @@ uint32_t tasking_handleException(registers *regs) {
*ke_vt << "\n (PID " << current_thread->process->pid << ") ";
if (regs->int_no == 14) {
*ke_vt << ">>> Process exiting.\n";
- thread_exit_stackJmp(EX_PR_EXCEPTION);
+ thread_exit_stackJmp(EX_PAGEFAULT);
} else {
*ke_vt << ">>> Thread exiting.\n";
- thread_exit_stackJmp(EX_TH_EXCEPTION);
+ thread_exit_stackJmp(EX_EXCEPTION);
}
PANIC("This should never have happened. Please report this.");
return 0;
@@ -160,7 +160,7 @@ void thread_exit2(uint32_t reason) { //See EX_TH_* defines in task.h
process* pr;
if (th == 0 || th->process == 0) goto retrn;
pr = th->process;
- if ((reason == EX_TH_NORMAL || reason == EX_TH_EXCEPTION) && pr->thread_count > 1) {
+ if ((reason == EX_NOTHREADS || reason == EX_EXCEPTION) && pr->thread_count > 1) {
delete th;
} else {
pr->finish(reason);
@@ -188,12 +188,12 @@ void thread_exit_stackJmp(uint32_t reason) {
/* System call. Exit the current thread. */
void thread_exit() {
- thread_exit_stackJmp(EX_TH_NORMAL);
+ thread_exit_stackJmp(EX_NOTHREADS);
}
/* System call. Exit the current process. */
void process_exit(size_t retval) {
- if (retval == EX_TH_NORMAL || retval == EX_TH_EXCEPTION) retval = EX_PR_EXCEPTION;
+ if (retval == EX_EXCEPTION || retval == EX_NOTHREADS || retval == EX_PAGEFAULT) retval = EX_INVALID;
thread_exit_stackJmp(retval);
}
diff --git a/src/kernel/task/task.h b/src/kernel/task/task.h
index fa748c2..5cd3fb2 100644
--- a/src/kernel/task/task.h
+++ b/src/kernel/task/task.h
@@ -15,14 +15,12 @@
#define PL_USER 1
#define PL_KERNEL 0
-#define EX_TH_NORMAL 0x10000 //ERROR code : just one thread exits, because it has to
-#define EX_TH_EXCEPTION 0x10001 //ERROR code : just one thread exits, because of an unhandled exception
-#define EX_PR_EXCEPTION 0x10002 //ERROR code : all process finishes, because of an unhandled exception
-
#define USER_STACK_SIZE 0x10000 //64k, but pages will be mapped one by one as they are used
typedef void (*thread_entry)(void*);
+typedef int FILE; // DUPLICATE FROM vfs/node.h
+
class thread;
class node;
class process {
diff --git a/src/kernel/ui/vt.cpp b/src/kernel/ui/vt.cpp
index 3bed897..6876806 100644
--- a/src/kernel/ui/vt.cpp
+++ b/src/kernel/ui/vt.cpp
@@ -18,7 +18,6 @@ vt::vt(node* parent, int ww, int hh) : node(parent, FT_TERMINAL) {
bgcolor = TC_BLACK;
output = 0;
cursor_visible = true;
- keyboard_echo = false;
csr_l = csr_c = 0;
kbd_buffer_filled = 0;
@@ -194,9 +193,12 @@ void vt::keyboardInput(keypress kp, keyboard* from) {
if ((kp.command == 0 || kp.command == KB_ENTER || kp.command == KB_TAB || kp.command == KB_BACKSPACE)
&& kp.character != 0 && kp.pressed) {
b[n++] = (char)kp.character;
- } else if (kp.command == KB_CMD_ALT && kp.character >= 64 && kp.character <= 126 && kp.pressed) {
+ } else if ((kp.command & KB_CMD_ALT) && kp.character >= 64 && kp.character <= 126 && kp.pressed) {
b[n++] = 27;
b[n++] = kp.character;
+ } else if ((kp.command & KB_CMD_CTRL) && kp.character >= 'A' && kp.character <= 'z' && kp.pressed) {
+ if (kp.character >= 'A' && kp.character <= 'Z') b[n++] = 1 + kp.character - 'A';
+ if (kp.character >= 'a' && kp.character <= 'z') b[n++] = 1 + kp.character - 'a';
} else if (kb_cmd_esc[kp.command & 0x3F] != 0 && kp.pressed) {
int i;
for (i = 0; kb_cmd_esc[kp.command & 0x3F][i] != 0; i++) {
@@ -330,10 +332,6 @@ int vt::write(size_t offset, size_t len, char* buffer) {
} else if (buffer[i] == 'p') { // restore cursor position
csr_l = save_csr_l;
csr_c = save_csr_c;
- } else if (buffer[i] == 'e') { // CUSTOM : enable keyboard echo
- keyboard_echo = true;
- } else if (buffer[i] == 'h') { // CUSTOM : disable keyboard echo
- keyboard_echo = false;
} else if (buffer[i] == '?') {
if (buffer[++i] == '2' && buffer[++i] == '5') {
if (buffer[++i] == 'l') cursor_visible = false;
@@ -361,38 +359,17 @@ int vt::read(size_t offset, size_t len, char* buffer) {
unsigned c = 0;
while (true) {
- bool end = false;
if (kbd_buffer_filled > 0) {
int r = 0;
- if (keyboard_echo) {
- for (; r < kbd_buffer_filled; r++) {
- if (kbd_buffer[r] == '\b') {
- if (c > 0) {
- c--;
- put('\b');
- }
- } else if (kbd_buffer[r] == '\n') {
- buffer[c++] = '\n';
- c++;
- put('\n');
- end = true;
- break;
- } else if (kbd_buffer[r] >= ' ') {
- buffer[c++] = kbd_buffer[r];
- put(buffer[c]);
- }
- if (c == len) break;
- }
- } else {
- while (r < kbd_buffer_filled && c < len) {
- buffer[c++] = kbd_buffer[r++];
- }
- end = true;
+ while (r < kbd_buffer_filled && c < len) {
+ buffer[c++] = kbd_buffer[r++];
}
+
memcpy(kbd_buffer + r, kbd_buffer, (kbd_buffer_filled - r));
kbd_buffer_filled -= r;
+
+ return c;
}
- if (end || c == len) return c;
if (kbd_waiter != 0) return c;
kbd_waiter = current_thread;
diff --git a/src/kernel/ui/vt.h b/src/kernel/ui/vt.h
index a29716f..8a169b4 100644
--- a/src/kernel/ui/vt.h
+++ b/src/kernel/ui/vt.h
@@ -19,7 +19,7 @@ class vt : public node {
vt_char *text;
void put_at(int l, int c, int ch);
- bool cursor_visible, keyboard_echo;
+ bool cursor_visible;
int kbd_buffer_filled;
char kbd_buffer[KBD_BUFFER_SIZE];
diff --git a/src/kernel/vfs/node.h b/src/kernel/vfs/node.h
index 2ebf93b..3b1c700 100644
--- a/src/kernel/vfs/node.h
+++ b/src/kernel/vfs/node.h
@@ -4,6 +4,7 @@
#include <tce/vfs.h>
#include <tce/syscalls.h>
+
#include <task/task.h>
class display;
@@ -38,6 +39,8 @@ node* vfs_find(node* root, char* filename);
extern node *root, *dot_dev, *dot_ui;
+typedef int FILE; // file descriptor type, DIFFERENT FROM FILE TYPE IN USERLAND !!!
+
// syscall interface
FILE open(char* filename, int mode);
FILE open_relative(FILE root, char* filename, int mode);