From fc58e30c96a1301d7189a1708a0504bfafd98e01 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sun, 25 Jul 2010 17:34:13 +0000 Subject: [PATCH] Create a C wrapper around the Forth key word to be used in the debugger instead of calling availchar()/getchar(). Using this wrapper means that the debugger now works correctly under PPC. Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@822 f158a5a8-5612-0410-a976-696ce0be7e32 --- kernel/internal.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/kernel/internal.c b/kernel/internal.c index 56dcad5..be1f216 100644 --- a/kernel/internal.c +++ b/kernel/internal.c @@ -446,6 +446,27 @@ int printf_console( const char *fmt, ... ) return i; } +static +int getchar_console( void ) +{ + cell tmp; + + /* Push to the Forth interpreter for console output */ + tmp = rstackcnt; + + trampoline[1] = findword("key"); + + PUSHR(PC); + PC = pointer2cell(trampoline); + + while (rstackcnt > tmp) { + dbg_interp_printk("getchar_console: NEXT\n"); + next(); + } + + return POP(); +} + static void display_dbg_dstack ( void ) { @@ -567,8 +588,7 @@ do_source_dbg( struct debug_xt *debug_xt_item ) return; /* Otherwise in step mode, prompt for a keypress */ - while (!availchar()); - k = getchar(); + k = getchar_console(); /* Only proceed if done is true */ while (!done) @@ -601,8 +621,7 @@ do_source_dbg( struct debug_xt *debug_xt_item ) /* Down - mark current word for debug and step into it */ done = add_debug_xt(read_ucell(cell2pointer(PC))); if (!done) { - while (!availchar()); - k = getchar(); + k = getchar_console(); } break; @@ -618,8 +637,7 @@ do_source_dbg( struct debug_xt *debug_xt_item ) /* Display rstack */ display_dbg_rstack(); done = 0; - while (!availchar()); - k = getchar(); + k = getchar_console(); break; case 'f': @@ -636,8 +654,7 @@ do_source_dbg( struct debug_xt *debug_xt_item ) default: /* Display debug banner */ printf_console(DEBUG_BANNER); - while (!availchar()); - k = getchar(); + k = getchar_console(); } } }