From 566134df26612d34f2a377659c55fb0f1ae9dfa4 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sat, 23 May 2015 00:40:15 +0200 Subject: reverted interrupts disabling to conservative. and starting fs layer --- kernel/ringbuffer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'kernel/ringbuffer.c') diff --git a/kernel/ringbuffer.c b/kernel/ringbuffer.c index a749b16..cba7eb4 100644 --- a/kernel/ringbuffer.c +++ b/kernel/ringbuffer.c @@ -1,10 +1,14 @@ #define FOOLOS_MODULE_NAME "ringbuffer" #include "lib/logger/log.h" -// TODO: why do we disable interrupts? (Eg. kb input) - #include "ringbuffer.h" + + +// TODO: this is disabled because a kb interrupt can occur anytime +// and the kernel will need to access the ringbuffer while we are accessing! +// DO WE need a spinlock in general? do not use a global one anyway!!!! + static int sl=9; ringbuffer ringbuffer_init(uint32_t size) @@ -38,15 +42,14 @@ volatile bool ringbuffer_put(ringbuffer* f,uint8_t c) lock_release(sl); x86_int_enable(); - return true; } volatile bool ringbuffer_has(ringbuffer* f) { + x86_int_disable(); bool res=true; - x86_int_disable(); lock_spin(sl); if(f->front==f->back) @@ -54,15 +57,14 @@ volatile bool ringbuffer_has(ringbuffer* f) lock_release(sl); x86_int_enable(); - return res; } volatile uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check first { + x86_int_disable(); char c; - x86_int_disable(); lock_spin(sl); if(f->front==f->back) @@ -80,6 +82,5 @@ volatile uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check fi lock_release(sl); x86_int_enable(); - return c; } -- cgit v1.2.3