summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-10-21 19:08:03 +0200
committerMichal Idziorek <m.i@gmx.at>2014-10-21 19:08:03 +0200
commitd25834310293c8a30b4a31418ff4ffd8fad8ef24 (patch)
tree97ae696211f7709002d80ecbfb8595123611d3c1 /kernel
parent5b9ea685dfd12415774e4e97ad387c601dd2b43b (diff)
started implementing our first fool-shell.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kernel.c9
-rw-r--r--kernel/keyboard.c67
-rw-r--r--kernel/spinlock.c4
-rw-r--r--kernel/syscalls.c32
4 files changed, 63 insertions, 49 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 34f3d69..dd5cc15 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -98,6 +98,7 @@ void kernel_main(uint32_t initial_stack, int mp)
// self-log message of logger :P
log_log();
+
//
// Print initial address of the esp stack pointer
//
@@ -147,6 +148,10 @@ void kernel_main(uint32_t initial_stack, int mp)
// init spinlocks
init_spinlocks();
+
+ // ringbuffer for stdin!
+ ringbuffer_init();
+
//
// Start the other Processors (also before paging for some reason!)
//
@@ -185,7 +190,7 @@ void kernel_main(uint32_t initial_stack, int mp)
// Will process input from the keyboard but will be completely
// redesigned soon. TODO!!
//
- shell_init();
+ //shell_init();
//
// Initialize Multitasking
@@ -206,8 +211,10 @@ void kernel_main(uint32_t initial_stack, int mp)
// autorun "user-space" prog
asm("push $0x80800");
asm("ret");
+
while(1)
{
+
}
diff --git a/kernel/keyboard.c b/kernel/keyboard.c
index c70a03f..083e553 100644
--- a/kernel/keyboard.c
+++ b/kernel/keyboard.c
@@ -8,19 +8,15 @@
/// keyboard driver ////
+
void keyboard_handle(uint8_t in)
{
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"scancode 0x%x",in);
-
- int i=0;
- //
- //print_hex(int_count);
uint8_t make_codes[]={
0x1e, // A
0x30, // B
0x2e, // C
- 0x20, // s/OSDev19.htmlD
+ 0x20, // D
0x12, // E
0x21, // F
0x22, // G
@@ -78,51 +74,32 @@ void keyboard_handle(uint8_t in)
uint8_t break_key_space=0xb9;
uint8_t break_key_backspace=0x8e;
- //if(last_code==*int_count)return;
-/*
- for(i=0;i<26;i++)
- {
- if(make_codes[i]==in)
- {
-// print_char_col(cursor,20,'A'+i,0xf);
-// scr_put_char('A'+i);
- }
- }
- */
+ char ascii;
- if(break_key_space==in)
- {
- scr_put_char(' ');
- shell_put(' ');
- return;
- }
+ // optimize this!
+ if(break_key_space==in)ascii=' ';
+ else if(break_key_backspace==in)ascii='x';
+ else if(break_key_enter==in)ascii='\n';
- if(break_key_backspace==in)
+ else for(int i=0;i<26;i++)
{
- scr_backspace();
- shell_backspace();
- return;
- }
-
- if(break_key_enter==in)
- {
- scr_nextline();
- shell_execute();
- return;
- }
-
- for(i=0;i<26;i++)
- {
- if(break_alpha[i]==in)
+ if(break_alpha[i]==in)
{
- //print_char_col(cursor++,20,'a'+i,SCR_RED);
- scr_put_char('A'+i);
- shell_put('A'+i);
- return;
+ ascii=('A'+i);
+ break;
+ }
+ if(i==25)
+ {
+ return;
}
}
-// last_code=in;
+
+ PutConsoleChar(ascii,0b1111100000011111);
+
+
+ if(!ringbuffer_put(ascii))
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"ringbuffer full..");
}
@@ -134,6 +111,8 @@ void int_kb_handler()
static uint8_t kb_in;
__asm__("in $0x60, %al");
__asm__("mov %%al, %0"::"m" (kb_in));
+
+ //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"scancode 0x%x",kb_in);
keyboard_handle(kb_in);
X86_IRQ_END
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index c7f5062..975de68 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -18,7 +18,7 @@ volatile void lock_spin(int i)
{
spinlock *addr=spinlocks+i;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"locking %d (0x%08X)",i,addr);
+// log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"locking %d (0x%08X)",i,addr);
while(x86_xchg(addr,1));
}
@@ -26,7 +26,7 @@ volatile void lock_spin(int i)
void lock_release(int i)
{
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocking %d",i);
+// log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"unlocking %d",i);
spinlock *addr=spinlocks+i;
asm("movb $0,%0"::"m"(*addr));
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index bf875fd..470939c 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -1,11 +1,39 @@
#define FOOLOS_MODULE_NAME "syscalls"
#include "lib/logger/log.h"
+#include "lib/bool/bool.h"
//
-void syscall_outbyte(char c)
+int syscall_write(int file, char *buf, int len)
{
- PutConsoleChar(c,0b1111111111000000);
+ for(int i=0;i<len;i++)
+ PutConsoleChar(buf[i],0b1111111111000000);
+
+ return len;
+}
+
+int syscall_read(int file, char *buf, int len)
+{
+
+ char c;
+
+ while(1)
+ {
+ asm("cli");
+ bool ret=ringbuffer_get(&c);
+ asm("sti");
+
+ if(ret)
+ {
+ *buf=c;
+ return 1;
+ }
+
+// if(ret) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"read kb buffer: %d",c);
+ }
+
+
}
+//
int example_syscall(int x,int y)
{