diff --git a/arch/ppc/mol/methods.c b/arch/ppc/mol/methods.c index cd2f535..bfaf515 100644 --- a/arch/ppc/mol/methods.c +++ b/arch/ppc/mol/methods.c @@ -85,14 +85,9 @@ stdout_write( void ) { int len = POP(); char *addr = (char*)POP(); - char *s = malloc( len + 1 ); - - strncpy_nopad( s, addr, len ); - s[len]=0; /* printk( "%s", s ); */ - console_draw_str( s ); - free( s ); + console_draw_fstr(addr, len); PUSH( len ); } diff --git a/arch/ppc/mol/mol.h b/arch/ppc/mol/mol.h index e9cbceb..cea15a3 100644 --- a/arch/ppc/mol/mol.h +++ b/arch/ppc/mol/mol.h @@ -24,7 +24,7 @@ extern void draw_pixel( int x, int y, int colind ); extern void set_color( int index, unsigned long color ); /* console.c */ -extern int console_draw_str( const char *str ); +extern int console_draw_fstr(const char *str, int len); extern void console_close( void ); /* pseudodisk.c */ diff --git a/arch/ppc/pearpc/methods.c b/arch/ppc/pearpc/methods.c index bbc88ca..ae3ab44 100644 --- a/arch/ppc/pearpc/methods.c +++ b/arch/ppc/pearpc/methods.c @@ -70,16 +70,10 @@ stdout_write( void ) { int len = POP(); char *addr = (char*)POP(); - char *s = malloc( len + 1 ); - - strncpy_nopad( s, addr, len ); - s[len]=0; printk( "%s", s ); //vfd_draw_str( s ); - console_draw_str( s ); - - free( s ); + console_draw_fstr(addr, len); PUSH( len ); } diff --git a/arch/ppc/pearpc/pearpc.h b/arch/ppc/pearpc/pearpc.h index 2ad648e..44497d7 100644 --- a/arch/ppc/pearpc/pearpc.h +++ b/arch/ppc/pearpc/pearpc.h @@ -19,7 +19,7 @@ extern int vfd_draw_str( const char *str ); extern void vfd_close( void ); -extern int console_draw_str( const char *str ); +extern int console_draw_fstr(const char *str, int len); #include "kernel.h" diff --git a/arch/sparc32/console.c b/arch/sparc32/console.c index d3a73ff..52e4827 100644 --- a/arch/sparc32/console.c +++ b/arch/sparc32/console.c @@ -32,12 +32,11 @@ volatile uint32_t *dac; static void video_putchar(int c) { - char buf[2]; + char buf; - buf[0] = c & 0xff; - buf[1] = 0; + buf = c & 0xff; - console_draw_str(buf); + console_draw_fstr(&buf, 1); } static void video_cls(void) diff --git a/arch/x86/xbox/methods.c b/arch/x86/xbox/methods.c index 50cca32..741d15c 100644 --- a/arch/x86/xbox/methods.c +++ b/arch/x86/xbox/methods.c @@ -35,16 +35,10 @@ stdout_write( void ) { int len = POP(); char *addr = (char*)POP(); - char *s = malloc( len + 1 ); - - strncpy_nopad( s, addr, len ); - s[len]=0; printk( "%s", s ); //vfd_draw_str( s ); - console_draw_str( s ); - - free( s ); + console_draw_fstr(addr, len); PUSH( len ); } diff --git a/include/libopenbios/console.h b/include/libopenbios/console.h index 54b21f8..817a021 100644 --- a/include/libopenbios/console.h +++ b/include/libopenbios/console.h @@ -2,7 +2,7 @@ #define VIDEO_CONSOLE_H /* libopenbios/console_common.c */ -int console_draw_str(const char *str); +int console_draw_fstr(const char *str, int len); int console_init(void); void console_close(void); diff --git a/libopenbios/console_common.c b/libopenbios/console_common.c index 05bd216..22ec230 100644 --- a/libopenbios/console_common.c +++ b/libopenbios/console_common.c @@ -382,12 +382,12 @@ do_con_trol(unsigned char ch) } int -console_draw_str( const char *str ) +console_draw_fstr(const char *str, int len) { unsigned int y, x; unsigned char ch; - if (!str) { + if (!str || len <= 0) { return 0; } @@ -395,7 +395,7 @@ console_draw_str( const char *str ) return -1; show_cursor(0); - while( (ch=*str++) ) { + while((ch = *str++) && len--) { do_con_trol(ch); if( cons.x >= cons.w ) { diff --git a/packages/video.c b/packages/video.c index d1639ed..32a4469 100644 --- a/packages/video.c +++ b/packages/video.c @@ -288,11 +288,10 @@ video_write(void) char *addr; int len; - len = GETTOS(); - addr = pop_fstr_copy(); + len = POP(); + addr = (char *)POP(); - console_draw_str(addr); - free(addr); + console_draw_fstr(addr, len); PUSH(len); }