From 56bdc29b3e38333b3c95d91cfb809576846fc731 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Janosch=20Gr=C3=A4f?= Date: Wed, 24 Dec 2008 02:11:36 +0100 Subject: [PATCH] console: -debug function +DEBUG macro --- apps/console/console.h | 4 +++- apps/console/keyboard.c | 12 +++++------- apps/console/main.c | 17 ----------------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/apps/console/console.h b/apps/console/console.h index 864ff51..d4180d4 100644 --- a/apps/console/console.h +++ b/apps/console/console.h @@ -24,7 +24,9 @@ #include #include -void debug(const char *fmt,...); +/*#define DEBUG(...) do { printf("console: "); \ + printf(__VA_ARGS__); } while (0);*/ +#define DEBUG(...) // keyboard.c int init_keyboard(); diff --git a/apps/console/keyboard.c b/apps/console/keyboard.c index 0e69235..689abd1 100755 --- a/apps/console/keyboard.c +++ b/apps/console/keyboard.c @@ -67,12 +67,12 @@ static int keyboard_layout_load(const char *filename) { read(fh,&(keyboard.layout.height),4); keyboard.layout.table = calloc(keyboard.layout.width*keyboard.layout.height,sizeof(wchar_t)); read(fh,keyboard.layout.table,keyboard.layout.width*keyboard.layout.height*sizeof(wchar_t)); - debug("keyboard: Layout loaded: %s (width=%d; height=%d; shift=%s; altcap=%s)\n",filename,keyboard.layout.width,keyboard.layout.height,keyboard.layout.has_shift?"yes":"no",keyboard.layout.has_altcap?"yes":"no"); + DEBUG("keyboard: Layout loaded: %s (width=%d; height=%d; shift=%s; altcap=%s)\n",filename,keyboard.layout.width,keyboard.layout.height,keyboard.layout.has_shift?"yes":"no",keyboard.layout.has_altcap?"yes":"no"); close(fh); return 0; } else { - debug("keyboard: %s: %s\n",strerror(errno),filename); + DEBUG("keyboard: %s: %s\n",strerror(errno),filename); return -1; } } @@ -116,7 +116,6 @@ ssize_t onread(devfs_dev_t *dev,void *buffer,size_t count,off_t offset) { * Handles Keyboard IRQ * @param null Unused * @todo Caps lock? - * @todo Escape scancode comes after real scancode */ static void keyboard_irq(void *null) { int released,scancode; @@ -147,9 +146,9 @@ static void keyboard_irq(void *null) { // write key into buffer else if (!released) { wchar_t chr = scancode2wchr(scancode); - if (chr>0x7F) debug("TODO: Wide characters (%s %d)\n",__FILE__,__LINE__); + if (chr>0x7F) DEBUG("TODO: Wide characters (%s %d)\n",__FILE__,__LINE__); else if (chr!=0) { - //debug("keyboard: Read character: '%c' (0x%02x)\n",chr,chr); + //DEBUG("keyboard: Read character: '%c' (0x%02x)\n",chr,chr); keyboard.buffer.buffer[keyboard.buffer.wpos++] = chr; } } @@ -170,7 +169,6 @@ int init_keyboard() { keyboard.buffer.buffer = malloc(keyboard.buffer.size); keyboard_layout_load(KEYBOARD_DEFAULT_LAYOUT); - // to get scancodes that are already in kbc buffer - //keyboard_irq(NULL); + keyboard_irq(NULL); return 0; } diff --git a/apps/console/main.c b/apps/console/main.c index 65b5c1a..21bb9d3 100644 --- a/apps/console/main.c +++ b/apps/console/main.c @@ -22,8 +22,6 @@ #include "console.h" -//#define DEBUG stderr - /** * Initialize console driver */ @@ -41,18 +39,3 @@ int main() { devfs_mainloop(); return 0; } - -/** - * Prints debug message - * @param fmt Format - * @param ... Parameters - */ -void debug(const char *fmt,...) { -#ifdef DEBUG - va_list args; - va_start(args,fmt); - fprintf(DEBUG,"console: "); - vfprintf(DEBUG,fmt,args); - va_end(args); -#endif -} -- 2.11.4.GIT