diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/shell.c | 127 | ||||
| -rw-r--r-- | kernel/syscalls.c | 7 | ||||
| -rw-r--r-- | kernel/vesa.c | 2 |
3 files changed, 5 insertions, 131 deletions
diff --git a/kernel/shell.c b/kernel/shell.c index 2e00bd0..b28b04f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -1,130 +1,3 @@ -#include "interrupts.h" -#include "time.h" -#include "smp.h" -#include "lib/logger/log.h" // logger facilities -#include "lib/bool/bool.h" -#include "lib/int/stdint.h" - -#define FOOLOS_MODULE_NAME "shell" - -#define COMMAND_LENGTH 255 - -uint32_t cpu_counter[SMP_MAX_PROC]; -static char command[COMMAND_LENGTH]; -static int pos=0; -uint32_t c1,c2,c3; - -// in timer: -uint16_t timer16; - -void shell_init() -{ - pos=0; - command[0]=0; -} - -void shell_put(char x) -{ - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_DEBUG,"char:%c",x); - - if(pos<COMMAND_LENGTH-2); - - command[pos]=x; - pos++; - - command[pos]=0; - -} - -void shell_backspace() -{ - if(pos>0); - pos--; - command[pos]=0; - -} - - -// TODO: EXECUTE LATER not inside INTERRUPT !!! -void shell_execute() -{ - //scr_nextline(); - //scr_put_string(" processing command: "); - //scr_put_string_nl(command); - - if(1==strcmp(command,"TIME",0)) - { - uint32_t time=task_system_clock; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d seconds passed since system start.",(time/25)); - } - else if(1==strcmp(command,"MEM",0)) - { - mmap_show_free(); - } - else if(1==strcmp(command,"PROC",0)) - { - for(int i=0;i<SMP_MAX_PROC;i++) - { - if(cpu_counter[i]!=0) - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"cpu: %d => %d.",i,cpu_counter[i]); - } - } - else if(1==strcmp(command,"TASKS",0)) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d %d %d",c1,c2,c2); - } - else if(1==strcmp(command,"ALLOC",0)) - { - uint32_t *malloc= pmmngr_alloc_block(); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"allocated 4KB block at: %08x.",malloc); - } - else if(1==strcmp(command,"READ",0)) - { -// uint8_t *read= flpydsk_read_sector (10); - } - else if(1==strcmp(command,"SYSCALL",0)) - { - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call 10"); - uint32_t ebx; // will hold return value; - // system call - asm("pusha"); - asm("mov $10,%eax"); // select syscall 10 (example_syscall) - asm("mov $666,%edx"); - asm("mov $333,%ecx"); - asm("int $0x80"); // actual syscall ! interrupt - asm("mov %%ebx, %0": "=b" (ebx)); - asm("popa"); - // - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call returned %d",ebx); - - } - else if(1==strcmp(command,"TWO",0)) - { - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call 20"); - uint32_t ebx; // will hold return value; - // system call - asm("pusha"); - asm("mov $20,%eax"); // select syscall2 20 (example_syscall) - asm("mov $566,%edx"); - asm("mov $233,%ecx"); - asm("int $0x80"); // actual syscall ! interrupt - asm("mov %%ebx, %0": "=b" (ebx)); - asm("popa"); - // - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call returned %d",ebx); - - } - else - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"command unknown"); - } - - pos=0; -} diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 470939c..1eca490 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -6,8 +6,9 @@ int syscall_write(int file, char *buf, int len) { for(int i=0;i<len;i++) + { PutConsoleChar(buf[i],0b1111111111000000); - + } return len; } @@ -37,14 +38,14 @@ int syscall_read(int file, char *buf, int len) int example_syscall(int x,int y) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall called with %d + %d",x,y); +// log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall called with %d + %d",x,y); return x+y; } int example_syscall_2(int x,int y) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall 2 called with %d - %d",x,y); + // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall 2 called with %d - %d",x,y); return x-y; } diff --git a/kernel/vesa.c b/kernel/vesa.c index b0e9885..25c92a1 100644 --- a/kernel/vesa.c +++ b/kernel/vesa.c @@ -182,7 +182,7 @@ void PutConsoleChar(char c, int color) #ifdef FOOLOS_CONSOLE_AUTOBREAK - if(console_x>console_cols)PutConsoleNL(); + if(console_x>=console_cols)PutConsoleNL(); #endif } |
