From bd5c0694678df3361eddaedcf9ceca6db687e010 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Fri, 22 May 2015 03:38:45 +0200 Subject: moving/removing some direcories --- xxx/lib/buffer/ringbuffer.c | 76 ------------------------------------ xxx/lib/buffer/ringbuffer.h | 3 -- xxx/lib/logger/log.c | 94 --------------------------------------------- xxx/lib/logger/log.h | 14 ------- 4 files changed, 187 deletions(-) delete mode 100644 xxx/lib/buffer/ringbuffer.c delete mode 100644 xxx/lib/buffer/ringbuffer.h delete mode 100644 xxx/lib/logger/log.c delete mode 100644 xxx/lib/logger/log.h (limited to 'xxx/lib') diff --git a/xxx/lib/buffer/ringbuffer.c b/xxx/lib/buffer/ringbuffer.c deleted file mode 100644 index a121df1..0000000 --- a/xxx/lib/buffer/ringbuffer.c +++ /dev/null @@ -1,76 +0,0 @@ -// can handle one buffer for a start. -// later make it reentrant and manage multiple buffers! -// todo: syncing access to buffer. - -#define FOOLOS_MODULE_NAME "ringbuffer" - -#include "ringbuffer.h" -#include "kernel/x86.h" -#include "lib/logger/log.h" -#include "kernel/spinlock.h" - -#define RINGBUFFER_SIZE 10 -static int size=RINGBUFFER_SIZE; -static volatile int front=RINGBUFFER_SIZE-1; -static volatile int back=RINGBUFFER_SIZE-1; -static volatile char buf[RINGBUFFER_SIZE]; - -static spinlock sl=9; - -bool ringbuffer_put(char c) -{ - - x86_int_disable(); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"put wants lock"); - lock_spin(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"locked by put"); - - if((back-1+size)%size==front) - { - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by put"); - x86_int_enable(); - return false; - } - - buf[back]=c; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"put %d %d (%c)", back, front,c); - back--; - back+=size; - back%=size; - - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by put"); - x86_int_enable(); - - return true; -} - -bool ringbuffer_get(char *c) -{ - x86_int_disable(); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"get wants lock"); - lock_spin(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"locked by get"); - if(front==back) - { - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by get"); - x86_int_enable(); - *c='_'; - return false; - } - - *c=buf[front]; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"get %d %d (%c)", back, front,*c); - - front--; - front+=size; - front%=size; - - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by get"); - x86_int_enable(); - - return true; -} diff --git a/xxx/lib/buffer/ringbuffer.h b/xxx/lib/buffer/ringbuffer.h deleted file mode 100644 index 038e33a..0000000 --- a/xxx/lib/buffer/ringbuffer.h +++ /dev/null @@ -1,3 +0,0 @@ -#include -bool ringbuffer_put(char c); -bool ringbuffer_get(char *c); diff --git a/xxx/lib/logger/log.c b/xxx/lib/logger/log.c deleted file mode 100644 index 430f982..0000000 --- a/xxx/lib/logger/log.c +++ /dev/null @@ -1,94 +0,0 @@ -#define FOOLOS_MODULE_NAME "log" - -#include -#include - -#include "log.h" -#include "kernel/config.h" -#include "terminal/vt52.h" -#include "lib/printf/printf.h" -#include "kernel/timer.h" - - -static char buffer[LOG_BUF_SIZE]; -static int first=0; -static int last=0; -static bool init=true;// - -static void init_log() -{ -} - -void log(char *module_name, int log_level, char *format_string, ...) -{ - - #ifdef FOOLOS_LOG_OFF - return; - #endif - - if(log_level=LOG_BUF_SIZE)first=(first+1)%LOG_BUF_SIZE; - if(last>first)if(LOG_BUF_SIZE-last+first>=LOG_BUF_SIZE)first=(first+1)%LOG_BUF_SIZE; - } - - -} - -void panic(char *module_name, char *message) -{ - char buf_log[256]; - tfp_sprintf(buf_log,"KERNEL PANIC !! %s: %s\n",module_name,message); - //console_put_str_red(buf_log); - - while(1) - { - asm volatile("cli"); - asm volatile("hlt"); - } - -} - -// unused shit! -/* -static void log_log() -{ - #ifdef FOOLOS_LOG_OFF - return; - #endif - - char buf_log[256]; - tfp_sprintf(buf_log,"[ 0.00000] log: buffer state: first=%d, last=%d, buf_size=%d\n",first,last,LOG_BUF_SIZE); - console_put_str_gray(buf_log); - for(int i=first;i!=last;i++) - { - console_put_char_gray(buffer[i]); - - } - - init=true; -} -*/ diff --git a/xxx/lib/logger/log.h b/xxx/lib/logger/log.h deleted file mode 100644 index da27340..0000000 --- a/xxx/lib/logger/log.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef FOOLOS_LOG_H -#define FOOLOS_LOG_H - -#define FOOLOS_LOG_ERROR 5 -#define FOOLOS_LOG_WARNING 4 -#define FOOLOS_LOG_INFO 3 -#define FOOLOS_LOG_DEBUG 2 -#define FOOLOS_LOG_FINE 1 - -void log(char *module_name, int prio, char *format_string, ...); -void panic(char *module_name, char *format_string); -void log_log(); - -#endif -- cgit v1.2.3