j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Laurent Vivier wrote:
In the meantime, I've looked again at the v2 patch I posted and I still can't work out why the debugging output by printk() doesn't appear on a VNC display for Qemu SPARC64, while it appears fine when Qemu SPARC64 is invoked in -nographic mode. Can anyone shed any light on this?
Because "printk()" are sent to serial and must use only for debug purpose. You must use forth words like "emit" or "type" to send characters to
display. For instance, look at "modules/cmdline.c":
static void emit( int ch ) { PUSH( ch ); fword("emit"); }
static int emit_str( const char *str ) { int n = 0; while( *str ) { n++; emit( *str++ ); } return n; }
Yeah, I did consider that this might be the case but it still doesn't seem to make sense looking at the code. The source for the forth emit word can be found in kernel/forth.c:
/*
- emit ( char -- )
*/
static void emit(void) { #ifndef FCOMPILER cell tmp = POP(); putchar(tmp); #else (void) POP(); #endif }
while for SPARC64 the source for printk() can be found in arch/sparc64/lib.c:
/* Format a string and print it on the screen, just like the libc
- function printf.
*/ int printk( const char *fmt, ... ) { char *p, buf[512]; va_list args; int i;
va_start(args, fmt); i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); for( p=buf; *p; p++ ) putchar(*p); return i;
}
Both of these use putchar() in order to write characters out to the console, and yet one of them works in a graphical terminal and one of them doesn't...
But "emit" is redefined later to "io-emit" which use "stdout" which can be serial or graphic:
0- arch/ppc/qemu/start.S:_entry (this is the bootstrap)
... bl entry ...
1- arch/ppc/qemu/init.c:entry()
... initialize_forth(); ...
2- arch/ppc/qemu/kernel.c:initialize_forth()
... PUSH_xt( bind_noname_func(arch_of_init) ); fword("PREPOST-initializer");
PC = (ucell)findword("initialize-of"); ...
3- forth/system/main.fs:initialize-of
... install-console ...
4- forth/admin/iocontrol.fs:install-console
... ['] io-emit to emit ...
where io-emit is:
: io-emit ( char -- ) io-out-char c! io-out-char 1 " write" stdout @ $call-method drop ;
And stdout is defined in arch/ppc/qemu/init.c:arch_of_init() (see 2- )
Regards, Laurent
Laurent Vivier wrote:
(lots cut)
4- forth/admin/iocontrol.fs:install-console
... ['] io-emit to emit ...
where io-emit is:
: io-emit ( char -- ) io-out-char c! io-out-char 1 " write" stdout @ $call-method drop ;
And stdout is defined in arch/ppc/qemu/init.c:arch_of_init() (see 2- )
Thank you - now I see that the defer word "emit" is not set to execute the C function emit, which is what was confusing me.
Here's a proof-of-concept v3 patch which bounces off the forth trampoline in order to perform console output which seems to work for me on SPARC64 with VNC - please can you check it works for you?
Note this patch isn't ready to be applied yet, since I haven't had enough time to implement a patch to ensure that there is no speed penalty when debug mode is disabled.
Many thanks,
Mark.