From bedf6a20ba49d7da460de862a58f8eb04bad1514 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 22 Oct 2014 10:39:56 +0200 Subject: migrating shell to "userspace" --- kernel/shell.c | 127 ------------------------------------------------------ kernel/syscalls.c | 7 +-- kernel/vesa.c | 2 +- 3 files changed, 5 insertions(+), 131 deletions(-) (limited to 'kernel') 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(pos0); - 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 %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;iconsole_cols)PutConsoleNL(); + if(console_x>=console_cols)PutConsoleNL(); #endif } -- cgit v1.2.3