From a6184be79e3918764d5e683796afbd8e8ccba018 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Mon, 18 May 2015 09:20:01 +0200 Subject: fifo through ringbuffer(stdin) and vt52(stdout) finally working! --- fs/ringbuffer.c | 71 --------------------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 fs/ringbuffer.c (limited to 'fs/ringbuffer.c') diff --git a/fs/ringbuffer.c b/fs/ringbuffer.c deleted file mode 100644 index 449ad88..0000000 --- a/fs/ringbuffer.c +++ /dev/null @@ -1,71 +0,0 @@ -#define FOOLOS_MODULE_NAME "ringbuffer" -#include "lib/logger/log.h" - -#include "ringbuffer.h" - -static int sl=9; - -ringbuffer ringbuffer_init(uint32_t size) -{ - ringbuffer f; - f.data=kballoc(size); - f.size=size*4096; - f.front=f.size-1; - f.back=f.size-1; - return f; -} - -bool ringbuffer_put(ringbuffer* f,uint8_t c) -{ - x86_int_disable(); - lock_spin(sl); - - if((f->back-1+f->size)%f->size==f->front) - { - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by put"); - x86_int_enable(); - return false; - } - - f->data[f->back]=c; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"put %d %d (%c)", f->back, f->front,c); - f->back--; - f->back+=f->size; - f->back%=f->size; - - lock_release(sl); - x86_int_enable(); - - return true; -} - -uint8_t ringbuffer_get(ringbuffer* f) // blocking -{ - - char c; - - x86_int_disable(); - lock_spin(sl); - - if(f->front==f->back) - { - lock_release(sl); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by get"); - x86_int_enable(); - c='_'; - return false; - } - - c=f->data[f->front]; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"get %d %d (%c)", f->back, f->front,c); - - f->front--; - f->front+=f->size; - f->front%=f->size; - - lock_release(sl); - x86_int_enable(); - - return true; -} -- cgit v1.2.3