diff options
| author | Miguel <m.i@gmx.at> | 2018-09-15 17:53:27 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-15 17:53:27 +0200 |
| commit | cd50c8d1047832bbb0798b368fde0428ef749422 (patch) | |
| tree | fcacf85f58fefeffa482630f31ef208a8bc9d03a /kernel/ringbuffer.c | |
| parent | 0b010d22dbf845ad030e2e7320f9c5935b2604a4 (diff) | |
improved in-kernel alloc/dealloc. addded colorless logging and struggling with mouse and kb
Diffstat (limited to 'kernel/ringbuffer.c')
| -rw-r--r-- | kernel/ringbuffer.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/kernel/ringbuffer.c b/kernel/ringbuffer.c index fd87727..6700931 100644 --- a/kernel/ringbuffer.c +++ b/kernel/ringbuffer.c @@ -1,12 +1,6 @@ - #include "ringbuffer.h" #include "kmalloc.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) { ringbuffer f; @@ -17,13 +11,15 @@ ringbuffer ringbuffer_init(uint32_t size) return f; } -bool ringbuffer_put(ringbuffer* f,uint8_t c) +void ringbuffer_free(ringbuffer *f) { -// x86_cli(); + kbfree(f->data); +} +bool ringbuffer_put(ringbuffer* f,uint8_t c) +{ if((f->back-1+f->size)%f->size==f->front) { -// x86_sti(); return false; } @@ -31,32 +27,25 @@ bool ringbuffer_put(ringbuffer* f,uint8_t c) f->back--; f->back+=f->size; f->back%=f->size; - -// x86_sti(); return true; } bool ringbuffer_has(ringbuffer* f) { -// x86_cli(); bool res=true; if(f->front==f->back) res=false; - -// x86_sti(); return res; } -uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check first +uint8_t ringbuffer_get(ringbuffer* f) { -// x86_cli(); char c; if(f->front==f->back) { -// x86_sti(); - return ' '; + return 0; } c=f->data[f->front]; @@ -64,7 +53,5 @@ uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check first f->front--; f->front+=f->size; f->front%=f->size; - - // x86_sti(); return c; } |
