This patch expands on the work from the last patchset and makes the following changes:
- Remove the now-obsolete C console files/functions
- Separate out the video routines into MOL, TCX and VGA paths
- Unify the video descriptor with Forth (instead of having both a C struct and Forth variables holding video information, have the C struct members point directly to the relevant dictionary cells)
- Fix any bugs found as a result of the refactoring above
- Add new debug-type and debug-cr words for debugging over the serial port even when video mode is enabled
- Remove the cls() from the serial console for SPARC32/64
- Fix a decode-string off-by-one property bug
The next stage after this will be to switch the TCX video initialisation path over to use Forth FCode evaluation in conjunction with a set of new probe functions.
Mark Cave-Ayland (20): video_common.c: remove video_open() and video_write() methods libopenbios: remove the C terminal emulator file console_common.c packages: rename video.c to molvideo.c ready for MOL-specific video routines video_common.c: remove manual screen clear since fb8-erase-screen does this now video_common.c: move startup_splash() and refresh_palette() to packages/molvideo.c video_common.c: now fill_rect() is no longer called directly, merge it into the video_fill_rect() video_common.c: remove video_scroll1() and draw_pixel() as they are no longer needed video_common.c: rename get_color() and set_color() functions video_common.c: Move osi_fb_info_t struct contents directly into the video_info struct video_common.c: unify the video_info structure with Forth video_common.c: split video setup routines into setup_video() video_common.c: remove the video_get_res() function video_common.c: move colour palette code into individual devices sbus.c: fix TCX24 initialisation video_common.c: fix 32-bit display modes on 64-bit architectures video_common.c: remove init_video() function console: remove libopenbios/console.h bootstrap.fs: add debug-type and debug-cr words SPARC: remove cls() from the console startup property.fs: fix off-by-one error in decode-string
openbios-devel/arch/sparc32/boot.h | 3 - openbios-devel/arch/sparc32/console.c | 36 +-- openbios-devel/arch/sparc32/openbios.c | 4 +- openbios-devel/arch/sparc64/console.c | 12 - openbios-devel/arch/sparc64/openbios.c | 2 - openbios-devel/arch/x86/openbios.c | 8 +- openbios-devel/config/scripts/switch-arch | 4 + openbios-devel/drivers/sbus.c | 13 + openbios-devel/drivers/vga_vbe.c | 87 +++--- openbios-devel/forth/bootstrap/bootstrap.fs | 2 + openbios-devel/forth/device/display.fs | 38 ++- openbios-devel/forth/device/property.fs | 2 +- openbios-devel/include/arch/sparc32/io.h | 7 + openbios-devel/include/drivers/drivers.h | 1 + openbios-devel/include/libopenbios/console.h | 9 - openbios-devel/include/libopenbios/video.h | 48 +-- openbios-devel/libopenbios/build.xml | 1 - openbios-devel/libopenbios/console_common.c | 416 -------------------------- openbios-devel/libopenbios/video_common.c | 377 +++++++---------------- openbios-devel/packages/build.xml | 2 +- openbios-devel/packages/molvideo.c | 172 +++++++++++ openbios-devel/packages/video.c | 90 ------ 22 files changed, 442 insertions(+), 892 deletions(-) delete mode 100644 openbios-devel/include/libopenbios/console.h delete mode 100644 openbios-devel/libopenbios/console_common.c create mode 100644 openbios-devel/packages/molvideo.c delete mode 100644 openbios-devel/packages/video.c
These were only included to allow switching between the C terminal and the Forth terminal during development.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/libopenbios/video_common.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index d6334de..29ee876 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -319,26 +319,6 @@ refresh_palette( void ) #endif }
-static void -video_open(void) -{ - PUSH(-1); -} - -/* ( addr len -- actual ) */ -static void -video_write(void) -{ - char *addr; - int len; - - len = POP(); - addr = (char *)cell2pointer(POP()); - - console_draw_fstr(addr, len); - PUSH(len); -} - /* ( color_ind x y width height -- ) (?) */ void video_fill_rect(void) @@ -383,14 +363,6 @@ init_video( unsigned long fb, int width, int height, int depth, int rb )
activate_dev(ph);
- if (!find_package_method("open", ph)) { - bind_func("open", video_open); - } - - if (!find_package_method("write", ph)) { - bind_func("write", video_write); - } - molvideo_init(); } video.has_video = 1;
With the advent of the Forth terminal it is no longer required.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/console.c | 2 - openbios-devel/libopenbios/build.xml | 1 - openbios-devel/libopenbios/console_common.c | 416 --------------------------- 3 files changed, 419 deletions(-) delete mode 100644 openbios-devel/libopenbios/console_common.c
diff --git a/openbios-devel/arch/sparc32/console.c b/openbios-devel/arch/sparc32/console.c index 6fe48ac..c986e2b 100644 --- a/openbios-devel/arch/sparc32/console.c +++ b/openbios-devel/arch/sparc32/console.c @@ -39,8 +39,6 @@ void tcx_init(uint64_t base) { vmem = (unsigned char *)ofmem_map_io(base + VMEM_BASE, VMEM_SIZE); dac = (uint32_t *)ofmem_map_io(base + DAC_BASE, DAC_SIZE); - - console_init(); }
#endif diff --git a/openbios-devel/libopenbios/build.xml b/openbios-devel/libopenbios/build.xml index cd15baf..c2f3e0e 100644 --- a/openbios-devel/libopenbios/build.xml +++ b/openbios-devel/libopenbios/build.xml @@ -6,7 +6,6 @@ <object source="bootcode_load.c" condition="LOADER_BOOTCODE"/> <object source="bootinfo_load.c" condition="LOADER_BOOTINFO"/> <object source="client.c"/> - <object source="console_common.c"/> <object source="elf_info.c" /> <object source="elf_load.c" condition="LOADER_ELF"/> <object source="font_8x8.c" condition="FONT_8X8"/> diff --git a/openbios-devel/libopenbios/console_common.c b/openbios-devel/libopenbios/console_common.c deleted file mode 100644 index 1631769..0000000 --- a/openbios-devel/libopenbios/console_common.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - * <console.c> - * - * Simple text console - * - * Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se) - * Copyright (C) 2005 Stefan Reinauer stepan@openbios.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation - * - */ - -#include "config.h" -#include "libopenbios/bindings.h" -#include "libopenbios/fontdata.h" -#include "libopenbios/console.h" -#include "libopenbios/video.h" -#include "packages/video.h" - -#define FONT_ADJ_HEIGHT (FONT_HEIGHT + 2) - -// Warning: will hang on purpose when encountering unknown codes -//#define DEBUG_CONSOLE -#ifdef DEBUG_CONSOLE -#define DPRINTF(fmt, args...) \ - do { \ - printk(fmt , ##args); \ - for (;;); \ - } while (0) -#else -#define DPRINTF(fmt, args...) do {} while(0) -#endif - -typedef enum { - ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey, - EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, - ESpalette -} vc_state_t; - -#define NPAR 16 -static struct { - int inited; - int physw, physh; - int w,h; - - int x,y; - char *buf; - - int cursor_on; - vc_state_t vc_state; - unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current - escape sequence */ -} cons; - -static int -get_conschar( int x, int y ) -{ - if( (unsigned int)x < cons.w && (unsigned int)y < cons.h ) - return cons.buf[y*cons.w + x]; - return ' '; -} - -static void -draw_char( unsigned int h, unsigned int v ) -{ - const unsigned char *c = fontdata; - int x, y, xx, rskip, m; - int invert = (h==cons.x && v==cons.y && cons.cursor_on); - int ch = get_conschar( h, v ); - - while( h >= cons.w || v >= cons.h ) - return; - - h *= FONT_WIDTH; - v *= FONT_ADJ_HEIGHT; - - rskip = (FONT_WIDTH > 8)? 2 : 1; - c += rskip * (unsigned int)(ch & 0xff) * FONT_HEIGHT; - - for( x=0; x<FONT_WIDTH; x++ ) { - xx = x % 8; - if( x && !xx ) - c++; - m = (1<<(7-xx)); - for( y=0; y<FONT_HEIGHT; y++ ){ - int col = ((!(c[rskip*y] & m)) != invert) ? 254 : 0; - draw_pixel( h+x, v+y+1, col ); - } - draw_pixel( h+x, v, 254 ); - draw_pixel( h+x, v+FONT_HEIGHT+1, 254 ); - } -} - -static void -show_cursor( int show ) -{ - if( cons.cursor_on == show ) - return; - cons.cursor_on = show; - draw_char( cons.x, cons.y ); -} - - -static void -draw_line( int n ) -{ - int i; - - if( n >= cons.h || n < 0 ) - return; - for( i=0; i<cons.w; i++ ) - draw_char( i, n ); -} - -#if 0 -static void -refresh( void ) -{ - int i; - for( i=0; i<cons.h; i++ ) - draw_line(i); -} -#endif - -int -console_init( void ) -{ - if( video_get_res(&cons.physw,&cons.physh) < 0 ) - return -1; - - set_color( 0, 0 ); - - cons.w = cons.physw/FONT_WIDTH; - cons.h = cons.physh/FONT_ADJ_HEIGHT; - cons.buf = malloc( cons.w * cons.h ); - cons.inited = 1; - cons.x = cons.y = 0; - cons.vc_state = ESnormal; - return 0; -} - -void -console_close( void ) -{ - if( !cons.inited ) - return; - free( cons.buf ); - cons.inited = 0; -} - -static void -rec_char( int ch, int x, int y ) -{ - if( (unsigned int)x < cons.w && (unsigned int)y < cons.h ) { - cons.buf[y*cons.w + x] = ch; - draw_char( x, y ); - } -} - -static void -scroll1( void ) -{ - int x, y; - - video_scroll(FONT_ADJ_HEIGHT); - - for (y = 1; y < cons.h - 1; y++) { - for (x = 0; x < cons.w; x++) - cons.buf[(y - 1) * cons.w + x] = cons.buf[y * cons.w + x]; - } - for (x = 0; x < cons.w; x++) - cons.buf[(cons.h - 1) * cons.w + x] = ' '; - draw_line(cons.h - 1); -} - -// Insert char -static void csi_at(unsigned int nr) -{ - unsigned int x; - - if (nr > cons.w - cons.x) - nr = cons.w - cons.x; - else if (!nr) - return; - - for (x = cons.x + nr; x < cons.w - 1; x++) - cons.buf[cons.y * cons.w + x - nr] = cons.buf[cons.y * cons.w + x]; - for (x = cons.x; x < cons.x + nr; x++) - cons.buf[cons.y * cons.w + x] = ' '; - draw_line(cons.y); -} - -static void -do_con_trol(unsigned char ch) -{ - unsigned int i, j; - - switch (ch) { - case 7: - // BEL - return; - case 8: - // BS - if (cons.x) - cons.x--; - return; - case 9: - // HT - cons.x = (cons.x + 8) & ~7; - return; - case 10: - // LF - cons.x = 0; - cons.y++; - return; - case 12: - // FF - for (i = 0; i < cons.h; i++) { - for (j = 0; j < cons.w; j++) - cons.buf[i * cons.w + j] = ' '; - draw_line(i); - } - cons.x = cons.y = 0; - return; - case 13: - // CR - cons.x = 0; - return; - case 25: - // EM - return; - case 24: // CAN - case 26: // SUB - cons.vc_state = ESnormal; - return; - case 27: - // ESC - cons.vc_state = ESesc; - return; - } - if (ch < 32) - DPRINTF("Unhandled control char %d\n", ch); - - switch (cons.vc_state) { - case ESesc: - cons.vc_state = ESnormal; - switch (ch) { - case '[': - cons.vc_state = ESsquare; - return; - case 'M': - scroll1(); - return; - default: - DPRINTF("Unhandled basic escape code '%c'\n", ch); - return; - } - return; - case ESsquare: - for(cons.vc_npar = 0; cons.vc_npar < NPAR ; cons.vc_npar++) - cons.vc_par[cons.vc_npar] = 0; - cons.vc_npar = 0; - cons.vc_state = ESgetpars; - // Fall through - case ESgetpars: - if (ch == ';' && cons.vc_npar < NPAR - 1) { - cons.vc_npar++; - return; - } else if (ch >= '0' && ch <= '9') { - cons.vc_par[cons.vc_npar] *= 10; - cons.vc_par[cons.vc_npar] += ch - '0'; - return; - } else - cons.vc_state=ESgotpars; - // Fall through - case ESgotpars: - cons.vc_state = ESnormal; - switch(ch) { - case 'A': - // Cursor up - if (cons.vc_par[0] == 0) - cons.vc_par[0] = 1; - if (cons.y - cons.vc_par[0] > 0) - cons.y -= cons.vc_par[0]; - return; - case 'B': - // Cursor down - if (cons.vc_par[0] == 0) - cons.vc_par[0] = 1; - if (cons.y + cons.vc_par[0] < cons.h - 1) - cons.y += cons.vc_par[0]; - return; - case 'C': - // Cursor right - if (cons.vc_par[0] == 0) - cons.vc_par[0] = 1; - if (cons.x + cons.vc_par[0] < cons.w - 1) - cons.x += cons.vc_par[0]; - return; - case 'D': - // Cursor left - if (cons.vc_par[0] == 0) - cons.vc_par[0] = 1; - if (cons.x - cons.vc_par[0] > 0) - cons.x -= cons.vc_par[0]; - return; - case 'H': - case 'f': - // Set cursor position - if (cons.vc_par[0]) - cons.vc_par[0]--; - - if (cons.vc_par[1]) - cons.vc_par[1]--; - - cons.x = cons.vc_par[1]; - cons.y = cons.vc_par[0]; - return; - case 'J': - if (cons.vc_par[0] == 0 && (unsigned int)cons.y < (unsigned int)cons.h && - (unsigned int)cons.x < (unsigned int)cons.w) { - // erase from cursor to end of display - for (i = cons.x; i < cons.w; i++) - cons.buf[cons.y * cons.w + i] = ' '; - draw_line(cons.y); - for (j = cons.y + 1; j < cons.h; j++) { - for (i = 0; i < cons.w; i++) - cons.buf[j * cons.w + i] = ' '; - draw_line(j); - } - } else { - DPRINTF("Unhandled CSI J code '%c'\n", cons.vc_par[0]); - } - return; - case 'K': - switch (cons.vc_par[0]) { - case 0: /* erase from cursor to end of line */ - for (i = cons.x; i < cons.w; i++) - cons.buf[cons.y * cons.w + i] = ' '; - draw_line(cons.y); - return; - case 1: /* erase from start of line to cursor */ - for (i = 0; i <= cons.x; i++) - cons.buf[cons.y * cons.w + i] = ' '; - draw_line(cons.y); - return; - case 2: /* erase whole line */ - for (i = 0; i < cons.w; i++) - cons.buf[cons.y * cons.w + i] = ' '; - draw_line(cons.y); - return; - default: - DPRINTF("Unhandled CSI K code '%c'\n", cons.vc_par[0]); - return; - } - return; - case 'M': - if (cons.vc_par[0] == 1) - scroll1(); - else - DPRINTF("Unhandled CSI M %d\n", cons.vc_par[0]); - return; - case 'm': - // Attributes are ignored - return; - case '@': - csi_at(cons.vc_par[0]); - return; - default: - DPRINTF("Unhandled escape code '%c', par[%d, %d, %d, %d, %d]\n", - ch, cons.vc_par[0], cons.vc_par[1], cons.vc_par[2], - cons.vc_par[3], cons.vc_par[4]); - return; - } - return; - default: - cons.vc_state = ESnormal; - rec_char(ch, cons.x++, cons.y); - return; - } -} - -int -console_draw_fstr(const char *str, int len) -{ - unsigned int y, x; - unsigned char ch; - - if (!str || len <= 0) { - return 0; - } - - if( !cons.inited && console_init() ) - return -1; - - show_cursor(0); - while((ch = *str++) && len--) { - do_con_trol(ch); - - if( cons.x >= cons.w ) { - cons.x=0, cons.y++; - } - if( cons.y >= cons.h ) { - for( y=0; y<cons.h-1; y++ ) - for( x=0; x<cons.w; x++ ) - cons.buf[y*cons.w + x] = cons.buf[(y+1)*cons.w + x]; - cons.y = cons.h-1; - cons.x = 0; - scroll1(); - } - } - show_cursor(1); - return 0; -}
While we are here, remove the INSTALL_OPEN flag since this is now handled by is-install (removing the "open is not unique" warning on the serial console during startup).
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/packages/build.xml | 2 +- openbios-devel/packages/molvideo.c | 97 ++++++++++++++++++++++++++++++++++++ openbios-devel/packages/video.c | 90 --------------------------------- 3 files changed, 98 insertions(+), 91 deletions(-) create mode 100644 openbios-devel/packages/molvideo.c delete mode 100644 openbios-devel/packages/video.c
diff --git a/openbios-devel/packages/build.xml b/openbios-devel/packages/build.xml index fded77c..0384c41 100644 --- a/openbios-devel/packages/build.xml +++ b/openbios-devel/packages/build.xml @@ -11,7 +11,7 @@ <object source="nvram.c"/> <object source="pc-parts.c" condition="PC_PARTS"/> <object source="sun-parts.c" condition="SUN_PARTS"/> - <object source="video.c"/> + <object source="molvideo.c"/> <object source="xcoff-loader.c" condition="LOADER_XCOFF"/> </library>
diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c new file mode 100644 index 0000000..0e37cb5 --- /dev/null +++ b/openbios-devel/packages/molvideo.c @@ -0,0 +1,97 @@ +/* + * Creation Date: <2002/10/23 20:26:40 samuel> + * Time-stamp: <2004/01/07 19:39:15 samuel> + * + * <video.c> + * + * Mac-on-Linux display node + * + * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libc/diskio.h" +#include "libopenbios/ofmem.h" +#include "drivers/drivers.h" +#include "packages/video.h" +#include "libopenbios/video.h" +#include "libopenbios/console.h" +#include "drivers/vga.h" + + +/************************************************************************/ +/* OF methods */ +/************************************************************************/ + +DECLARE_NODE( video, 0, 0, "Tdisplay" ); + +/* ( -- width height ) (?) */ +static void +molvideo_dimensions( void ) +{ + int w, h; + (void) video_get_res( &w, &h ); + PUSH( w ); + PUSH( h ); +} + +/* ( table start count -- ) (?) */ +static void +molvideo_set_colors( void ) +{ + int count = POP(); + int start = POP(); + unsigned char *p = (unsigned char*)cell2pointer(POP()); + int i; + + for( i=0; i<count; i++, p+=3 ) { + unsigned long col = (p[0] << 16) | (p[1] << 8) | p[2]; + set_color( i + start, col ); + } + refresh_palette(); +} + +/* ( r g b index -- ) */ +static void +molvideo_color_bang( void ) +{ + int index = POP(); + int b = POP(); + int g = POP(); + int r = POP(); + unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff); + /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */ + set_color( index, col ); + refresh_palette(); +} + +/* ( color_ind x y width height -- ) (?) */ +static void +molvideo_fill_rect ( void ) +{ + video_fill_rect(); +} + +NODE_METHODS( video ) = { + {"dimensions", molvideo_dimensions }, + {"set-colors", molvideo_set_colors }, + {"fill-rectangle", molvideo_fill_rect }, + {"color!", molvideo_color_bang }, +}; + + +/************************************************************************/ +/* init */ +/************************************************************************/ + +void +molvideo_init(void) +{ + REGISTER_NODE( video ); +} diff --git a/openbios-devel/packages/video.c b/openbios-devel/packages/video.c deleted file mode 100644 index 99f0c3f..0000000 --- a/openbios-devel/packages/video.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Creation Date: <2002/10/23 20:26:40 samuel> - * Time-stamp: <2004/01/07 19:39:15 samuel> - * - * <video.c> - * - * Mac-on-Linux display node - * - * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation - * - */ - -#include "config.h" -#include "libopenbios/bindings.h" -#include "libc/diskio.h" -#include "libopenbios/ofmem.h" -#include "drivers/drivers.h" -#include "packages/video.h" -#include "libopenbios/video.h" -#include "libopenbios/console.h" -#include "drivers/vga.h" - - -/************************************************************************/ -/* OF methods */ -/************************************************************************/ - -DECLARE_NODE( video, INSTALL_OPEN, 0, "Tdisplay" ); - -/* ( -- width height ) (?) */ -static void -video_dimensions( void ) -{ - int w, h; - (void) video_get_res( &w, &h ); - PUSH( w ); - PUSH( h ); -} - -/* ( table start count -- ) (?) */ -static void -video_set_colors( void ) -{ - int count = POP(); - int start = POP(); - unsigned char *p = (unsigned char*)cell2pointer(POP()); - int i; - - for( i=0; i<count; i++, p+=3 ) { - unsigned long col = (p[0] << 16) | (p[1] << 8) | p[2]; - set_color( i + start, col ); - } - refresh_palette(); -} - -/* ( r g b index -- ) */ -static void -video_color_bang( void ) -{ - int index = POP(); - int b = POP(); - int g = POP(); - int r = POP(); - unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff); - /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */ - set_color( index, col ); - refresh_palette(); -} - -NODE_METHODS( video ) = { - {"dimensions", video_dimensions }, - {"set-colors", video_set_colors }, - {"fill-rectangle", video_fill_rect }, - {"color!", video_color_bang }, -}; - - -/************************************************************************/ -/* init */ -/************************************************************************/ - -void -molvideo_init(void) -{ - REGISTER_NODE( video ); -}
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/libopenbios/video_common.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 29ee876..8649536 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -412,7 +412,6 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) set_color( i, i * 0x010101 );
set_color( 254, 0xffffcc ); - fill_rect( 254, 0, 0, video.fb.w, video.fb.h );
refresh_palette(); startup_splash();
These routines are MOL-specific and currently not required anywhere else.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/device/display.fs | 6 +++ openbios-devel/include/libopenbios/video.h | 1 - openbios-devel/libopenbios/video_common.c | 67 -------------------------- openbios-devel/packages/molvideo.c | 71 +++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 70 deletions(-)
diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index b6e8bb8..7a0e4fa 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -375,4 +375,10 @@ defer fb8-invertrect 0 to foreground-color
fb8-erase-screen + + \ If we have a startup splash then display it + [IFDEF] CONFIG_MOL + startup-splash 2000 ms + fb8-erase-screen + [THEN] ; diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 668e3e4..ae82007 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -2,7 +2,6 @@ void init_video(unsigned long fb, int width, int height, int depth, int rb); unsigned long get_color(int col_ind); void set_color(int ind, unsigned long color); -void refresh_palette(void); int video_get_res(int *w, int *h); void draw_pixel(int x, int y, int colind); void video_scroll(int height); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 8649536..b853872 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -67,61 +67,6 @@ set_color( int ind, unsigned long color ) #endif }
-static void -startup_splash( void ) -{ -#ifdef CONFIG_MOL - int fd, s, i, y, x, dx, dy; - int width, height; - char *pp, *p; - char buf[64]; -#endif - - /* only draw logo in 24-bit mode (for now) */ - if( video.fb.depth < 15 ) - return; -#ifdef CONFIG_MOL - for( i=0; i<2; i++ ) { - if( !BootHGetStrResInd("bootlogo", buf, sizeof(buf), 0, i) ) - return; - *(!i ? &width : &height) = atol(buf); - } - - if( (s=width * height * 3) > 0x20000 ) - return; - - if( (fd=open_io("pseudo:,bootlogo")) >= 0 ) { - p = malloc( s ); - if( read_io(fd, p, s) != s ) - printk("bootlogo size error\n"); - close_io( fd ); - - dx = (video.fb.w - width)/2; - dy = (video.fb.h - height)/3; - - pp = (char*)video.fb.mvirt + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2); - - for( y=0 ; y<height; y++, pp += video.fb.rb ) { - if( video.fb.depth >= 24 ) { - unsigned long *d = (unsigned long*)pp; - for( x=0; x<width; x++, p+=3, d++ ) - *d = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; - } else if( video.fb.depth == 15 ) { - unsigned short *d = (unsigned short*)pp; - for( x=0; x<width; x++, p+=3, d++ ) { - int col = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; - *d = ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); - } - } - } - free( p ); - } -#else - /* No bootlogo support yet on other platforms */ - return; -#endif -} - int video_get_res( int *w, int *h ) { @@ -310,15 +255,6 @@ fill_rect( int col_ind, int x, int y, int w, int h ) } }
-void -refresh_palette( void ) -{ -#ifdef CONFIG_MOL - if( video.fb.depth == 8 ) - OSI_RefreshPalette(); -#endif -} - /* ( color_ind x y width height -- ) (?) */ void video_fill_rect(void) @@ -412,7 +348,4 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) set_color( i, i * 0x010101 );
set_color( 254, 0xffffcc ); - - refresh_palette(); - startup_splash(); } diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 0e37cb5..3498056 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -31,6 +31,15 @@
DECLARE_NODE( video, 0, 0, "Tdisplay" );
+static void +molvideo_refresh_palette( void ) +{ +#ifdef CONFIG_MOL + if( video.fb.depth == 8 ) + OSI_RefreshPalette(); +#endif +} + /* ( -- width height ) (?) */ static void molvideo_dimensions( void ) @@ -54,7 +63,7 @@ molvideo_set_colors( void ) unsigned long col = (p[0] << 16) | (p[1] << 8) | p[2]; set_color( i + start, col ); } - refresh_palette(); + molvideo_refresh_palette(); }
/* ( r g b index -- ) */ @@ -68,7 +77,7 @@ molvideo_color_bang( void ) unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff); /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */ set_color( index, col ); - refresh_palette(); + molvideo_refresh_palette(); }
/* ( color_ind x y width height -- ) (?) */ @@ -78,11 +87,69 @@ molvideo_fill_rect ( void ) video_fill_rect(); }
+/* ( -- ) - really should be reworked as draw-logo */ +static void +molvideo_startup_splash( void ) +{ +#ifdef CONFIG_MOL + int fd, s, i, y, x, dx, dy; + int width, height; + char *pp, *p; + char buf[64]; +#endif + + /* only draw logo in 24-bit mode (for now) */ + if( video.fb.depth < 15 ) + return; +#ifdef CONFIG_MOL + for( i=0; i<2; i++ ) { + if( !BootHGetStrResInd("bootlogo", buf, sizeof(buf), 0, i) ) + return; + *(!i ? &width : &height) = atol(buf); + } + + if( (s=width * height * 3) > 0x20000 ) + return; + + if( (fd=open_io("pseudo:,bootlogo")) >= 0 ) { + p = malloc( s ); + if( read_io(fd, p, s) != s ) + printk("bootlogo size error\n"); + close_io( fd ); + + dx = (video.fb.w - width)/2; + dy = (video.fb.h - height)/3; + + pp = (char*)video.fb.mvirt + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2); + + for( y=0 ; y<height; y++, pp += video.fb.rb ) { + if( video.fb.depth >= 24 ) { + unsigned long *d = (unsigned long*)pp; + for( x=0; x<width; x++, p+=3, d++ ) + *d = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; + } else if( video.fb.depth == 15 ) { + unsigned short *d = (unsigned short*)pp; + for( x=0; x<width; x++, p+=3, d++ ) { + int col = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; + *d = ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); + } + } + } + free( p ); + } +#else + /* No bootlogo support yet on other platforms */ + return; +#endif +} + + NODE_METHODS( video ) = { {"dimensions", molvideo_dimensions }, {"set-colors", molvideo_set_colors }, {"fill-rectangle", molvideo_fill_rect }, {"color!", molvideo_color_bang }, + {"startup-splash", molvideo_startup_splash }, };
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 1 - openbios-devel/libopenbios/video_common.c | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index ae82007..b30d408 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -5,7 +5,6 @@ void set_color(int ind, unsigned long color); int video_get_res(int *w, int *h); void draw_pixel(int x, int y, int colind); void video_scroll(int height); -void fill_rect(int col_ind, int x, int y, int w, int h); void video_mask_blit(void); void video_invert_rect(void); void video_fill_rect(void); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index b853872..37c0498 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -225,9 +225,16 @@ video_scroll( int height ) } }
+/* ( color_ind x y width height -- ) (?) */ void -fill_rect( int col_ind, int x, int y, int w, int h ) +video_fill_rect(void) { + int h = POP(); + int w = POP(); + int y = POP(); + int x = POP(); + int col_ind = POP(); + char *pp; unsigned long col = get_color(col_ind);
@@ -255,19 +262,6 @@ fill_rect( int col_ind, int x, int y, int w, int h ) } }
-/* ( color_ind x y width height -- ) (?) */ -void -video_fill_rect(void) -{ - int h = POP(); - int w = POP(); - int y = POP(); - int x = POP(); - int color_ind = POP(); - - fill_rect( color_ind, x, y, w, h ); -} - void init_video( unsigned long fb, int width, int height, int depth, int rb ) {
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 2 -- openbios-devel/libopenbios/video_common.c | 41 ---------------------------- 2 files changed, 43 deletions(-)
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index b30d408..55d3d0e 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -3,8 +3,6 @@ void init_video(unsigned long fb, int width, int height, int depth, int rb); unsigned long get_color(int col_ind); void set_color(int ind, unsigned long color); int video_get_res(int *w, int *h); -void draw_pixel(int x, int y, int colind); -void video_scroll(int height); void video_mask_blit(void); void video_invert_rect(void); void video_fill_rect(void); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 37c0498..cd6a9e7 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -184,47 +184,6 @@ video_invert_rect( void ) } }
-void -draw_pixel( int x, int y, int colind ) -{ - char *p = (char*)video.fb.mvirt + video.fb.rb * y; - int color, d = video.fb.depth; - - if( x < 0 || y < 0 || x >= video.fb.w || y >=video.fb.h ) - return; - color = get_color( colind ); - - if( d >= 24 ) - *((unsigned long*)p + x) = color; - else if( d >= 15 ) - *((short*)p + x) = color; - else - *(p + x) = color; -} - -void -video_scroll( int height ) -{ - int i, offs, size, *dest, *src; - - if (height <= 0 || height >= video.fb.h) { - return; - } - offs = video.fb.rb * height; - size = (video.fb.h * video.fb.rb - offs)/16; - dest = (int*)video.fb.mvirt; - src = (int*)(video.fb.mvirt + offs); - - for( i=0; i<size; i++ ) { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - dest[3] = src[3]; - dest += 4; - src += 4; - } -} - /* ( color_ind x y width height -- ) (?) */ void video_fill_rect(void)
These are now called video_get_color() and video_set_color() respectively.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 4 ++-- openbios-devel/libopenbios/video_common.c | 18 +++++++++--------- openbios-devel/packages/molvideo.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 55d3d0e..6492473 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -1,7 +1,7 @@
void init_video(unsigned long fb, int width, int height, int depth, int rb); -unsigned long get_color(int col_ind); -void set_color(int ind, unsigned long color); +unsigned long video_get_color(int col_ind); +void video_set_color(int ind, unsigned long color); int video_get_res(int *w, int *h); void video_mask_blit(void); void video_invert_rect(void); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index cd6a9e7..10d5b12 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -26,7 +26,7 @@ struct video_info video;
unsigned long -get_color( int col_ind ) +video_get_color( int col_ind ) { unsigned long col; if( !video.has_video || col_ind < 0 || col_ind > 255 ) @@ -42,7 +42,7 @@ get_color( int col_ind ) }
void -set_color( int ind, unsigned long color ) +video_set_color( int ind, unsigned long color ) { if( !video.has_video || ind < 0 || ind > 255 ) return; @@ -95,8 +95,8 @@ video_mask_blit(void) unsigned char *dst, *rowdst; int x, y, m, b, d, depthbytes;
- fgcolor = get_color(fgcolor); - bgcolor = get_color(bgcolor); + fgcolor = video_get_color(fgcolor); + bgcolor = video_get_color(bgcolor); d = video.fb.depth; depthbytes = (video.fb.depth + 1) >> 3;
@@ -142,8 +142,8 @@ video_invert_rect( void ) int x = POP(); char *pp;
- bgcolor = get_color(bgcolor); - fgcolor = get_color(fgcolor); + bgcolor = video_get_color(bgcolor); + fgcolor = video_get_color(fgcolor);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || x + w > video.fb.w || y + h > video.fb.h) @@ -195,7 +195,7 @@ video_fill_rect(void) int col_ind = POP();
char *pp; - unsigned long col = get_color(col_ind); + unsigned long col = video_get_color(col_ind);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || x + w > video.fb.w || y + h > video.fb.h) @@ -298,7 +298,7 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) #endif
for( i=0; i<256; i++ ) - set_color( i, i * 0x010101 ); + video_set_color( i, i * 0x010101 );
- set_color( 254, 0xffffcc ); + video_set_color( 254, 0xffffcc ); } diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 3498056..0b672ba 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -61,7 +61,7 @@ molvideo_set_colors( void )
for( i=0; i<count; i++, p+=3 ) { unsigned long col = (p[0] << 16) | (p[1] << 8) | p[2]; - set_color( i + start, col ); + video_set_color( i + start, col ); } molvideo_refresh_palette(); } @@ -76,7 +76,7 @@ molvideo_color_bang( void ) int r = POP(); unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff); /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */ - set_color( index, col ); + video_set_color( index, col ); molvideo_refresh_palette(); }
Despite the name, osi_fb_info_t doesn't seem to be used by MOL and is just a general holder for video parameters. So let's move everything into a single struct to make future dereferencing easier.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 10 ++-- openbios-devel/libopenbios/video_common.c | 82 ++++++++++++++-------------- openbios-devel/packages/molvideo.c | 16 +++--- 3 files changed, 53 insertions(+), 55 deletions(-)
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 6492473..c40c456 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -7,14 +7,12 @@ void video_mask_blit(void); void video_invert_rect(void); void video_fill_rect(void);
-typedef struct osi_fb_info { - unsigned long mphys; +extern struct video_info { + int has_video; + + phys_addr_t mphys; unsigned long mvirt; int rb, w, h, depth; -} osi_fb_info_t;
-extern struct video_info { - int has_video; - osi_fb_info_t fb; unsigned long *pal; /* 256 elements */ } video; diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 10d5b12..0683707 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -31,12 +31,12 @@ video_get_color( int col_ind ) unsigned long col; if( !video.has_video || col_ind < 0 || col_ind > 255 ) return 0; - if( video.fb.depth == 8 ) + if( video.depth == 8 ) return col_ind; col = video.pal[col_ind]; - if( video.fb.depth == 24 || video.fb.depth == 32 ) + if( video.depth == 24 || video.depth == 32 ) return col; - if( video.fb.depth == 15 ) + if( video.depth == 15 ) return ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); return 0; } @@ -49,11 +49,11 @@ video_set_color( int ind, unsigned long color ) video.pal[ind] = color;
#ifdef CONFIG_MOL - if( video.fb.depth == 8 ) + if( video.depth == 8 ) OSI_SetColor( ind, color ); #elif defined(CONFIG_SPARC32) #if defined(CONFIG_DEBUG_CONSOLE_VIDEO) - if( video.fb.depth == 8 ) { + if( video.depth == 8 ) { dac[0] = ind << 24; dac[1] = ((color >> 16) & 0xff) << 24; // Red dac[1] = ((color >> 8) & 0xff) << 24; // Green @@ -74,8 +74,8 @@ video_get_res( int *w, int *h ) *w = *h = 0; return -1; } - *w = video.fb.w; - *h = video.fb.h; + *w = video.w; + *h = video.h; return 0; }
@@ -97,8 +97,8 @@ video_mask_blit(void)
fgcolor = video_get_color(fgcolor); bgcolor = video_get_color(bgcolor); - d = video.fb.depth; - depthbytes = (video.fb.depth + 1) >> 3; + d = video.depth; + depthbytes = (video.depth + 1) >> 3;
dst = fbaddr; for( y = 0; y < height; y++) { @@ -125,7 +125,7 @@ video_mask_blit(void) mask++; } dst = rowdst; - dst += video.fb.rb; + dst += video.rb; } }
@@ -146,13 +146,13 @@ video_invert_rect( void ) fgcolor = video_get_color(fgcolor);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || - x + w > video.fb.w || y + h > video.fb.h) + x + w > video.w || y + h > video.h) return;
- pp = (char*)video.fb.mvirt + video.fb.rb * y; - for( ; h--; pp += video.fb.rb ) { + pp = (char*)video.mvirt + video.rb * y; + for( ; h--; pp += video.rb ) { int ww = w; - if( video.fb.depth == 24 || video.fb.depth == 32 ) { + if( video.depth == 24 || video.depth == 32 ) { unsigned long *p = (unsigned long*)pp + x; while( ww-- ) { if (*p == fgcolor) { @@ -161,7 +161,7 @@ video_invert_rect( void ) *p++ = fgcolor; } } - } else if( video.fb.depth == 16 || video.fb.depth == 15 ) { + } else if( video.depth == 16 || video.depth == 15 ) { unsigned short *p = (unsigned short*)pp + x; while( ww-- ) { if (*p == (unsigned short)fgcolor) { @@ -198,17 +198,17 @@ video_fill_rect(void) unsigned long col = video_get_color(col_ind);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || - x + w > video.fb.w || y + h > video.fb.h) + x + w > video.w || y + h > video.h) return;
- pp = (char*)video.fb.mvirt + video.fb.rb * y; - for( ; h--; pp += video.fb.rb ) { + pp = (char*)video.mvirt + video.rb * y; + for( ; h--; pp += video.rb ) { int ww = w; - if( video.fb.depth == 24 || video.fb.depth == 32 ) { + if( video.depth == 24 || video.depth == 32 ) { unsigned long *p = (unsigned long*)pp + x; while( ww-- ) *p++ = col; - } else if( video.fb.depth == 16 || video.fb.depth == 15 ) { + } else if( video.depth == 16 || video.depth == 15 ) { unsigned short *p = (unsigned short*)pp + x; while( ww-- ) *p++ = col; @@ -230,25 +230,25 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) #endif phandle_t ph=0, saved_ph=0;
- video.fb.mphys = video.fb.mvirt = fb; + video.mphys = video.mvirt = fb;
#if defined(CONFIG_SPARC64) /* Fix virtual address on SPARC64 somewhere else */ - video.fb.mvirt = 0xfe000000; + video.mvirt = 0xfe000000; #endif
- video.fb.w = width; - video.fb.h = height; - video.fb.depth = depth; - video.fb.rb = rb; + video.w = width; + video.h = height; + video.depth = depth; + video.rb = rb;
saved_ph = get_cur_dev(); while( (ph=dt_iterate_type(ph, "display")) ) { - set_int_property( ph, "width", video.fb.w ); - set_int_property( ph, "height", video.fb.h ); - set_int_property( ph, "depth", video.fb.depth ); - set_int_property( ph, "linebytes", video.fb.rb ); - set_int_property( ph, "address", video.fb.mvirt ); + set_int_property( ph, "width", video.w ); + set_int_property( ph, "height", video.h ); + set_int_property( ph, "depth", video.depth ); + set_int_property( ph, "linebytes", video.rb ); + set_int_property( ph, "address", video.mvirt );
activate_dev(ph);
@@ -258,7 +258,7 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) video.pal = malloc( 256 * sizeof(unsigned long) ); activate_dev(saved_ph);
- PUSH(video.fb.mvirt); + PUSH(video.mvirt); feval("to frame-buffer-adr");
/* Set global variables ready for fb8-install */ @@ -272,9 +272,9 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) fword("is-noname-cfunc"); feval("to fb8-invertrect");
- PUSH((video.fb.depth + 1) >> 3); + PUSH((video.depth + 1) >> 3); feval("to depth-bytes"); - PUSH(video.fb.rb); + PUSH(video.rb); feval("to line-bytes"); PUSH((ucell)fontdata); feval("to (romfont)"); @@ -282,19 +282,19 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) feval("to (romfont-height)"); PUSH(FONT_WIDTH); feval("to (romfont-width)"); - PUSH(video.fb.mvirt); + PUSH(video.mvirt); feval("to qemu-video-addr"); - PUSH(video.fb.w); + PUSH(video.w); feval("to qemu-video-width"); - PUSH(video.fb.h); + PUSH(video.h); feval("to qemu-video-height");
#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) - size = ((video.fb.h * video.fb.rb) + 0xfff) & ~0xfff; + size = ((video.h * video.rb) + 0xfff) & ~0xfff;
- ofmem_claim_phys( video.fb.mphys, size, 0 ); - ofmem_claim_virt( video.fb.mvirt, size, 0 ); - ofmem_map( video.fb.mphys, video.fb.mvirt, size, ofmem_arch_io_translation_mode(video.fb.mphys) ); + ofmem_claim_phys( video.mphys, size, 0 ); + ofmem_claim_virt( video.mvirt, size, 0 ); + ofmem_map( video.mphys, video.mvirt, size, ofmem_arch_io_translation_mode(video.mphys) ); #endif
for( i=0; i<256; i++ ) diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 0b672ba..2d79e1d 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -35,7 +35,7 @@ static void molvideo_refresh_palette( void ) { #ifdef CONFIG_MOL - if( video.fb.depth == 8 ) + if( video.depth == 8 ) OSI_RefreshPalette(); #endif } @@ -99,7 +99,7 @@ molvideo_startup_splash( void ) #endif
/* only draw logo in 24-bit mode (for now) */ - if( video.fb.depth < 15 ) + if( video.depth < 15 ) return; #ifdef CONFIG_MOL for( i=0; i<2; i++ ) { @@ -117,17 +117,17 @@ molvideo_startup_splash( void ) printk("bootlogo size error\n"); close_io( fd );
- dx = (video.fb.w - width)/2; - dy = (video.fb.h - height)/3; + dx = (video.w - width)/2; + dy = (video.h - height)/3;
- pp = (char*)video.fb.mvirt + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2); + pp = (char*)video.mvirt + dy * video.rb + dx * (video.depth >= 24 ? 4 : 2);
- for( y=0 ; y<height; y++, pp += video.fb.rb ) { - if( video.fb.depth >= 24 ) { + for( y=0 ; y<height; y++, pp += video.rb ) { + if( video.depth >= 24 ) { unsigned long *d = (unsigned long*)pp; for( x=0; x<width; x++, p+=3, d++ ) *d = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; - } else if( video.fb.depth == 15 ) { + } else if( video.depth == 15 ) { unsigned short *d = (unsigned short*)pp; for( x=0; x<width; x++, p+=3, d++ ) { int col = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2];
At the moment there are two sets of video parameters being used: those internal to Forth and those internal to C. Unify these two structures by redefining video_info to contain pointers to relevant values, and then changing init_video() to set the pointers to the relevant values in the Forth dictionary.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/device/display.fs | 7 +- openbios-devel/include/libopenbios/video.h | 10 +-- openbios-devel/libopenbios/video_common.c | 103 +++++++++++++++------------- openbios-devel/packages/molvideo.c | 16 ++--- 4 files changed, 74 insertions(+), 62 deletions(-)
diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index 7a0e4fa..85a0001 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -43,9 +43,10 @@ hex
0 value foreground-color 0 value background-color +create color-palette 100 cells allot
2 value font-spacing -0 value depth-bytes +0 value depth-bits 0 value line-bytes
\ internal values read from QEMU firmware interface @@ -71,6 +72,10 @@ defer draw-logo ( line# addr width height -- )
defer fb-emit ( x -- )
+: depth-bytes ( bits -- bytes ) + depth-bits 1+ 8 / +; + \ \ 5.3.6.2 Frame-buffer support routines \ diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index c40c456..8f322bd 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -10,9 +10,11 @@ void video_fill_rect(void); extern struct video_info { int has_video;
- phys_addr_t mphys; - unsigned long mvirt; - int rb, w, h, depth; + volatile phys_addr_t mphys; + volatile ucell *mvirt; + volatile ucell *rb, *w, *h, *depth;
- unsigned long *pal; /* 256 elements */ + volatile ucell *pal; /* 256 elements */ } video; + +#define VIDEO_DICT_VALUE(x) (*(ucell *)(x)) diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 0683707..0f733ad 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -31,12 +31,12 @@ video_get_color( int col_ind ) unsigned long col; if( !video.has_video || col_ind < 0 || col_ind > 255 ) return 0; - if( video.depth == 8 ) + if( VIDEO_DICT_VALUE(video.depth) == 8 ) return col_ind; col = video.pal[col_ind]; - if( video.depth == 24 || video.depth == 32 ) + if( VIDEO_DICT_VALUE(video.depth) == 24 || VIDEO_DICT_VALUE(video.depth) == 32 ) return col; - if( video.depth == 15 ) + if( VIDEO_DICT_VALUE(video.depth) == 15 ) return ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); return 0; } @@ -49,11 +49,11 @@ video_set_color( int ind, unsigned long color ) video.pal[ind] = color;
#ifdef CONFIG_MOL - if( video.depth == 8 ) + if( VIDEO_DICT_VALUE(video.depth) == 8 ) OSI_SetColor( ind, color ); #elif defined(CONFIG_SPARC32) #if defined(CONFIG_DEBUG_CONSOLE_VIDEO) - if( video.depth == 8 ) { + if( VIDEO_DICT_VALUE(video.depth) == 8 ) { dac[0] = ind << 24; dac[1] = ((color >> 16) & 0xff) << 24; // Red dac[1] = ((color >> 8) & 0xff) << 24; // Green @@ -74,8 +74,8 @@ video_get_res( int *w, int *h ) *w = *h = 0; return -1; } - *w = video.w; - *h = video.h; + *w = VIDEO_DICT_VALUE(video.w); + *h = VIDEO_DICT_VALUE(video.h); return 0; }
@@ -97,8 +97,8 @@ video_mask_blit(void)
fgcolor = video_get_color(fgcolor); bgcolor = video_get_color(bgcolor); - d = video.depth; - depthbytes = (video.depth + 1) >> 3; + d = VIDEO_DICT_VALUE(video.depth); + depthbytes = (d + 1) >> 3;
dst = fbaddr; for( y = 0; y < height; y++) { @@ -125,7 +125,7 @@ video_mask_blit(void) mask++; } dst = rowdst; - dst += video.rb; + dst += VIDEO_DICT_VALUE(video.rb); } }
@@ -146,13 +146,13 @@ video_invert_rect( void ) fgcolor = video_get_color(fgcolor);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || - x + w > video.w || y + h > video.h) + x + w > VIDEO_DICT_VALUE(video.w) || y + h > VIDEO_DICT_VALUE(video.h)) return;
- pp = (char*)video.mvirt + video.rb * y; - for( ; h--; pp += video.rb ) { + pp = (char*)VIDEO_DICT_VALUE(video.mvirt) + VIDEO_DICT_VALUE(video.rb) * y; + for( ; h--; pp += *(video.rb) ) { int ww = w; - if( video.depth == 24 || video.depth == 32 ) { + if( VIDEO_DICT_VALUE(video.depth) == 24 || VIDEO_DICT_VALUE(video.depth) == 32 ) { unsigned long *p = (unsigned long*)pp + x; while( ww-- ) { if (*p == fgcolor) { @@ -161,7 +161,7 @@ video_invert_rect( void ) *p++ = fgcolor; } } - } else if( video.depth == 16 || video.depth == 15 ) { + } else if( VIDEO_DICT_VALUE(video.depth) == 16 || VIDEO_DICT_VALUE(video.depth) == 15 ) { unsigned short *p = (unsigned short*)pp + x; while( ww-- ) { if (*p == (unsigned short)fgcolor) { @@ -198,17 +198,17 @@ video_fill_rect(void) unsigned long col = video_get_color(col_ind);
if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || - x + w > video.w || y + h > video.h) + x + w > VIDEO_DICT_VALUE(video.w) || y + h > VIDEO_DICT_VALUE(video.h)) return;
- pp = (char*)video.mvirt + video.rb * y; - for( ; h--; pp += video.rb ) { + pp = (char*)VIDEO_DICT_VALUE(video.mvirt) + VIDEO_DICT_VALUE(video.rb) * y; + for( ; h--; pp += VIDEO_DICT_VALUE(video.rb) ) { int ww = w; - if( video.depth == 24 || video.depth == 32 ) { + if( VIDEO_DICT_VALUE(video.depth) == 24 || VIDEO_DICT_VALUE(video.depth) == 32 ) { unsigned long *p = (unsigned long*)pp + x; while( ww-- ) *p++ = col; - } else if( video.depth == 16 || video.depth == 15 ) { + } else if( VIDEO_DICT_VALUE(video.depth) == 16 || VIDEO_DICT_VALUE(video.depth) == 15 ) { unsigned short *p = (unsigned short*)pp + x; while( ww-- ) *p++ = col; @@ -230,37 +230,51 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) #endif phandle_t ph=0, saved_ph=0;
- video.mphys = video.mvirt = fb; + video.mphys = fb; + + /* Make everything inside the video_info structure point to the + values in the Forth dictionary. Hence everything is always in + sync. */ + + feval("['] qemu-video-addr cell+"); + video.mvirt = cell2pointer(POP()); + feval("['] qemu-video-width cell+"); + video.w = cell2pointer(POP()); + feval("['] qemu-video-height cell+"); + video.h = cell2pointer(POP()); + feval("['] depth-bits cell+"); + video.depth = cell2pointer(POP()); + feval("['] line-bytes cell+"); + video.rb = cell2pointer(POP()); + feval("['] color-palette cell+"); + video.pal = cell2pointer(POP()); + + VIDEO_DICT_VALUE(video.mvirt) = (ucell)fb; + VIDEO_DICT_VALUE(video.w) = (ucell)width; + VIDEO_DICT_VALUE(video.h) = (ucell)height; + VIDEO_DICT_VALUE(video.depth) = (ucell)depth; + VIDEO_DICT_VALUE(video.rb) = (ucell)rb;
#if defined(CONFIG_SPARC64) /* Fix virtual address on SPARC64 somewhere else */ - video.mvirt = 0xfe000000; + VIDEO_DICT_VALUE(video.mvirt) = 0xfe000000ULL; #endif
- video.w = width; - video.h = height; - video.depth = depth; - video.rb = rb; - saved_ph = get_cur_dev(); while( (ph=dt_iterate_type(ph, "display")) ) { - set_int_property( ph, "width", video.w ); - set_int_property( ph, "height", video.h ); - set_int_property( ph, "depth", video.depth ); - set_int_property( ph, "linebytes", video.rb ); - set_int_property( ph, "address", video.mvirt ); + set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) ); + set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) ); + set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) ); + set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) ); + set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) );
activate_dev(ph);
molvideo_init(); } video.has_video = 1; - video.pal = malloc( 256 * sizeof(unsigned long) ); activate_dev(saved_ph);
- PUSH(video.mvirt); - feval("to frame-buffer-adr"); - /* Set global variables ready for fb8-install */ PUSH( pointer2cell(video_mask_blit) ); fword("is-noname-cfunc"); @@ -272,29 +286,20 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) fword("is-noname-cfunc"); feval("to fb8-invertrect");
- PUSH((video.depth + 1) >> 3); - feval("to depth-bytes"); - PUSH(video.rb); - feval("to line-bytes"); + /* Static information */ PUSH((ucell)fontdata); feval("to (romfont)"); PUSH(FONT_HEIGHT); feval("to (romfont-height)"); PUSH(FONT_WIDTH); feval("to (romfont-width)"); - PUSH(video.mvirt); - feval("to qemu-video-addr"); - PUSH(video.w); - feval("to qemu-video-width"); - PUSH(video.h); - feval("to qemu-video-height");
#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) - size = ((video.h * video.rb) + 0xfff) & ~0xfff; + size = ((VIDEO_DICT_VALUE(video.h) * VIDEO_DICT_VALUE(video.rb)) + 0xfff) & ~0xfff;
ofmem_claim_phys( video.mphys, size, 0 ); - ofmem_claim_virt( video.mvirt, size, 0 ); - ofmem_map( video.mphys, video.mvirt, size, ofmem_arch_io_translation_mode(video.mphys) ); + ofmem_claim_virt( VIDEO_DICT_VALUE(video.mvirt), size, 0 ); + ofmem_map( video.mphys, VIDEO_DICT_VALUE(video.mvirt), size, ofmem_arch_io_translation_mode(video.mphys) ); #endif
for( i=0; i<256; i++ ) diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 2d79e1d..df70749 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -35,7 +35,7 @@ static void molvideo_refresh_palette( void ) { #ifdef CONFIG_MOL - if( video.depth == 8 ) + if( VIDEO_DICT_VALUE(video.depth) == 8 ) OSI_RefreshPalette(); #endif } @@ -99,7 +99,7 @@ molvideo_startup_splash( void ) #endif
/* only draw logo in 24-bit mode (for now) */ - if( video.depth < 15 ) + if( VIDEO_DICT_VALUE(video.depth) < 15 ) return; #ifdef CONFIG_MOL for( i=0; i<2; i++ ) { @@ -117,17 +117,17 @@ molvideo_startup_splash( void ) printk("bootlogo size error\n"); close_io( fd );
- dx = (video.w - width)/2; - dy = (video.h - height)/3; + dx = (VIDEO_DICT_VALUE(video.w) - width)/2; + dy = (VIDEO_DICT_VALUE(video.h) - height)/3;
- pp = (char*)video.mvirt + dy * video.rb + dx * (video.depth >= 24 ? 4 : 2); + pp = (char*)VIDEO_DICT_VALUE(video.mvirt) + dy * VIDEO_DICT_VALUE(video.rb) + dx * (VIDEO_DICT_VALUE(video.depth) >= 24 ? 4 : 2);
- for( y=0 ; y<height; y++, pp += video.rb ) { - if( video.depth >= 24 ) { + for( y=0 ; y<height; y++, pp += VIDEO_DICT_VALUE(video.rb) ) { + if( VIDEO_DICT_VALUE(video.depth) >= 24 ) { unsigned long *d = (unsigned long*)pp; for( x=0; x<width; x++, p+=3, d++ ) *d = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2]; - } else if( video.depth == 15 ) { + } else if( VIDEO_DICT_VALUE(video.depth) == 15 ) { unsigned short *d = (unsigned short*)pp; for( x=0; x<width; x++, p+=3, d++ ) { int col = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2];
Leave per-device work in init_video() for the moment.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/openbios.c | 3 +- openbios-devel/arch/x86/openbios.c | 8 ++- openbios-devel/config/scripts/switch-arch | 4 ++ openbios-devel/drivers/vga_vbe.c | 62 ++++++------------- openbios-devel/forth/device/display.fs | 2 +- openbios-devel/include/arch/sparc32/io.h | 7 +++ openbios-devel/include/libopenbios/video.h | 23 ++++++- openbios-devel/libopenbios/video_common.c | 89 +++++++++++++++++----------- 8 files changed, 114 insertions(+), 84 deletions(-)
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index ef3c973..84dd3f6 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -875,7 +875,8 @@ arch_init( void ) #endif #ifdef CONFIG_DRIVER_SBUS #ifdef CONFIG_DEBUG_CONSOLE_VIDEO - init_video((unsigned long)vmem, 1024, 768, 8, 1024); + setup_video(hwdef->tcx_base + 0x00800000ULL, (unsigned long)vmem); + init_video(); #endif ob_sbus_init(hwdef->iommu_base + 0x1000ULL, qemu_machine_type); #endif diff --git a/openbios-devel/arch/x86/openbios.c b/openbios-devel/arch/x86/openbios.c index dd444fa..4c18952 100644 --- a/openbios-devel/arch/x86/openbios.c +++ b/openbios-devel/arch/x86/openbios.c @@ -16,6 +16,7 @@ #include "drivers/drivers.h" #include "drivers/pci.h" #include "libopenbios/sys_info.h" +#include "libopenbios/video.h" #include "openbios.h" #include "relocate.h" #include "boot.h" @@ -61,7 +62,12 @@ arch_init( void ) ob_floppy_init("/isa", "floppy0", 0x3f0, 0); #endif #ifdef CONFIG_XBOX - init_video(phys_to_virt(0x3C00000), 640, 480, 32, 2560); + setup_video(0x3C00000, phys_to_virt(0x3C00000)); + + /* Force video to 32-bit depth */ + VIDEO_DICT_VALUE(video.depth) = 32; + + init_video(); node_methods_init(); #endif device_end(); diff --git a/openbios-devel/config/scripts/switch-arch b/openbios-devel/config/scripts/switch-arch index f92d730..dccf5c0 100755 --- a/openbios-devel/config/scripts/switch-arch +++ b/openbios-devel/config/scripts/switch-arch @@ -198,6 +198,10 @@ for ARCH in $arch_list; do xbox-x86) xbox="yes" ;; + builtin-sparc32) + builtin="yes" + qemu="yes" + ;; builtin-sparc64) builtin="yes" qemu="yes" diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c index f7a736f..884c261 100644 --- a/openbios-devel/drivers/vga_vbe.c +++ b/openbios-devel/drivers/vga_vbe.c @@ -103,50 +103,24 @@ void vga_vbe_set_mode(int width, int height, int depth) vga_build_rgb_palette(); }
-#ifdef CONFIG_VGA_WIDTH -#define VGA_DEFAULT_WIDTH CONFIG_VGA_WIDTH -#else -#define VGA_DEFAULT_WIDTH 800 -#endif - -#ifdef CONFIG_VGA_HEIGHT -#define VGA_DEFAULT_HEIGHT CONFIG_VGA_HEIGHT -#else -#define VGA_DEFAULT_HEIGHT 600 -#endif - -#ifdef CONFIG_VGA_DEPTH -#define VGA_DEFAULT_DEPTH CONFIG_VGA_DEPTH -#else -#define VGA_DEFAULT_DEPTH 8 -#endif - -#define VGA_DEFAULT_LINEBYTES (VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8)) - void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, unsigned long rom, uint32_t rom_size) { + phys_addr_t phys; phandle_t ph, chosen, aliases, options; char buf[6]; - int width = VGA_DEFAULT_WIDTH; - int height = VGA_DEFAULT_HEIGHT; - int depth = VGA_DEFAULT_DEPTH; - int linebytes = VGA_DEFAULT_LINEBYTES; - -#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)) - int w, h, d; - w = fw_cfg_read_i16(FW_CFG_ARCH_WIDTH); - h = fw_cfg_read_i16(FW_CFG_ARCH_HEIGHT); - d = fw_cfg_read_i16(FW_CFG_ARCH_DEPTH); - if (w && h && d) { - width = w; - height = h; - depth = d; - linebytes = (width * ((depth + 7) / 8)); - } + + phys = fb; + +#if defined(CONFIG_SPARC64) + /* Fix virtual address on SPARC64 somewhere else */ + fb = 0xfe000000ULL; #endif
- vga_vbe_set_mode(width, height, depth); + setup_video(phys, fb); + vga_vbe_set_mode(VIDEO_DICT_VALUE(video.w), + VIDEO_DICT_VALUE(video.h), + VIDEO_DICT_VALUE(video.depth));
#if 0 ph = find_dev(path); @@ -154,10 +128,10 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, ph = get_cur_dev(); #endif
- set_int_property(ph, "width", width); - set_int_property(ph, "height", height); - set_int_property(ph, "depth", depth); - set_int_property(ph, "linebytes", linebytes); + set_int_property(ph, "width", VIDEO_DICT_VALUE(video.w)); + set_int_property(ph, "height", VIDEO_DICT_VALUE(video.h)); + set_int_property(ph, "depth", VIDEO_DICT_VALUE(video.depth)); + set_int_property(ph, "linebytes", VIDEO_DICT_VALUE(video.rb)); set_int_property(ph, "address", (u32)(fb & ~0x0000000F));
chosen = find_dev("/chosen"); @@ -169,9 +143,9 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, set_property(aliases, "screen", path, strlen(path) + 1);
options = find_dev("/options"); - snprintf(buf, sizeof(buf), "%d", width / FONT_WIDTH); + snprintf(buf, sizeof(buf), FMT_ucell, VIDEO_DICT_VALUE(video.w) / FONT_WIDTH); set_property(options, "screen-#columns", buf, strlen(buf) + 1); - snprintf(buf, sizeof(buf), "%d", height / FONT_HEIGHT); + snprintf(buf, sizeof(buf), FMT_ucell, VIDEO_DICT_VALUE(video.h) / FONT_HEIGHT); set_property(options, "screen-#rows", buf, strlen(buf) + 1);
if (rom_size >= 8) { @@ -186,5 +160,5 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, } }
- init_video(fb, width, height, depth, linebytes); + init_video(); } diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index 85a0001..cf709fa 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -72,7 +72,7 @@ defer draw-logo ( line# addr width height -- )
defer fb-emit ( x -- )
-: depth-bytes ( bits -- bytes ) +: depth-bytes ( -- bytes ) depth-bits 1+ 8 / ;
diff --git a/openbios-devel/include/arch/sparc32/io.h b/openbios-devel/include/arch/sparc32/io.h index 2241bb4..011770a 100644 --- a/openbios-devel/include/arch/sparc32/io.h +++ b/openbios-devel/include/arch/sparc32/io.h @@ -191,4 +191,11 @@ extern void outl(u32 reg, u32 val); extern void outsw(u32 reg, const void *addr, unsigned long count); #endif #endif + +#if defined(CONFIG_QEMU) +#define FW_CFG_ARCH_DEPTH (FW_CFG_ARCH_LOCAL + 0x00) +#define FW_CFG_ARCH_WIDTH (FW_CFG_ARCH_LOCAL + 0x01) +#define FW_CFG_ARCH_HEIGHT (FW_CFG_ARCH_LOCAL + 0x02) +#endif + #endif /* _ASM_IO_H */ diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 8f322bd..20ba6c8 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -1,5 +1,26 @@
-void init_video(unsigned long fb, int width, int height, int depth, int rb); +#ifdef CONFIG_VGA_WIDTH +#define VGA_DEFAULT_WIDTH CONFIG_VGA_WIDTH +#else +#define VGA_DEFAULT_WIDTH 800 +#endif + +#ifdef CONFIG_VGA_HEIGHT +#define VGA_DEFAULT_HEIGHT CONFIG_VGA_HEIGHT +#else +#define VGA_DEFAULT_HEIGHT 600 +#endif + +#ifdef CONFIG_VGA_DEPTH +#define VGA_DEFAULT_DEPTH CONFIG_VGA_DEPTH +#else +#define VGA_DEFAULT_DEPTH 8 +#endif + +#define VGA_DEFAULT_LINEBYTES (VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8)) + +void setup_video(phys_addr_t phys, ucell virt); +void init_video(void); unsigned long video_get_color(int col_ind); void video_set_color(int ind, unsigned long color); int video_get_res(int *w, int *h); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 0f733ad..64e43cc 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -22,6 +22,8 @@ #include "libopenbios/video.h" #include "packages/video.h" #include "drivers/vga.h" +#define NO_QEMU_PROTOS +#include "arch/common/fw_cfg.h"
struct video_info video;
@@ -221,21 +223,14 @@ video_fill_rect(void) } }
-void -init_video( unsigned long fb, int width, int height, int depth, int rb ) +void setup_video(phys_addr_t phys, ucell virt) { - int i; -#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) - int size; -#endif - phandle_t ph=0, saved_ph=0; - - video.mphys = fb; - /* Make everything inside the video_info structure point to the values in the Forth dictionary. Hence everything is always in sync. */
+ video.mphys = phys; + feval("['] qemu-video-addr cell+"); video.mvirt = cell2pointer(POP()); feval("['] qemu-video-width cell+"); @@ -249,32 +244,6 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) feval("['] color-palette cell+"); video.pal = cell2pointer(POP());
- VIDEO_DICT_VALUE(video.mvirt) = (ucell)fb; - VIDEO_DICT_VALUE(video.w) = (ucell)width; - VIDEO_DICT_VALUE(video.h) = (ucell)height; - VIDEO_DICT_VALUE(video.depth) = (ucell)depth; - VIDEO_DICT_VALUE(video.rb) = (ucell)rb; - -#if defined(CONFIG_SPARC64) - /* Fix virtual address on SPARC64 somewhere else */ - VIDEO_DICT_VALUE(video.mvirt) = 0xfe000000ULL; -#endif - - saved_ph = get_cur_dev(); - while( (ph=dt_iterate_type(ph, "display")) ) { - set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) ); - set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) ); - set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) ); - set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) ); - set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) ); - - activate_dev(ph); - - molvideo_init(); - } - video.has_video = 1; - activate_dev(saved_ph); - /* Set global variables ready for fb8-install */ PUSH( pointer2cell(video_mask_blit) ); fword("is-noname-cfunc"); @@ -294,6 +263,54 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) PUSH(FONT_WIDTH); feval("to (romfont-width)");
+ /* Initialise the structure */ + VIDEO_DICT_VALUE(video.mvirt) = virt; + VIDEO_DICT_VALUE(video.w) = VGA_DEFAULT_WIDTH; + VIDEO_DICT_VALUE(video.h) = VGA_DEFAULT_HEIGHT; + VIDEO_DICT_VALUE(video.depth) = VGA_DEFAULT_DEPTH; + VIDEO_DICT_VALUE(video.rb) = VGA_DEFAULT_LINEBYTES; + +#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)) + /* If running from QEMU, grab the parameters from the firmware interface */ + int w, h, d; + + w = fw_cfg_read_i16(FW_CFG_ARCH_WIDTH); + h = fw_cfg_read_i16(FW_CFG_ARCH_HEIGHT); + d = fw_cfg_read_i16(FW_CFG_ARCH_DEPTH); + if (w && h && d) { + VIDEO_DICT_VALUE(video.w) = w; + VIDEO_DICT_VALUE(video.h) = h; + VIDEO_DICT_VALUE(video.depth) = d; + VIDEO_DICT_VALUE(video.rb) = (w * ((d + 7) / 8)); + } +#endif +} + +void +init_video(void) +{ + int i; +#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) + int size; +#endif + phandle_t ph=0, saved_ph=0; + + saved_ph = get_cur_dev(); + while( (ph=dt_iterate_type(ph, "display")) ) { + video.has_video = 1; + + set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) ); + set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) ); + set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) ); + set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) ); + set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) ); + + activate_dev(ph); + + molvideo_init(); + } + activate_dev(saved_ph); + #if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) size = ((VIDEO_DICT_VALUE(video.h) * VIDEO_DICT_VALUE(video.rb)) + 0xfff) & ~0xfff;
Now that we've unified the video variables between C and Forth, there is no need to have a dedicated C function to return the current dimensions.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 1 - openbios-devel/libopenbios/video_common.c | 12 ------------ openbios-devel/packages/molvideo.c | 6 ++---- 3 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 20ba6c8..bcd024e 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -23,7 +23,6 @@ void setup_video(phys_addr_t phys, ucell virt); void init_video(void); unsigned long video_get_color(int col_ind); void video_set_color(int ind, unsigned long color); -int video_get_res(int *w, int *h); void video_mask_blit(void); void video_invert_rect(void); void video_fill_rect(void); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 64e43cc..9d45e69 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -69,18 +69,6 @@ video_set_color( int ind, unsigned long color ) #endif }
-int -video_get_res( int *w, int *h ) -{ - if( !video.has_video ) { - *w = *h = 0; - return -1; - } - *w = VIDEO_DICT_VALUE(video.w); - *h = VIDEO_DICT_VALUE(video.h); - return 0; -} - /* ( fbaddr maskaddr width height fgcolor bgcolor -- ) */
void diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index df70749..742f516 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -44,10 +44,8 @@ molvideo_refresh_palette( void ) static void molvideo_dimensions( void ) { - int w, h; - (void) video_get_res( &w, &h ); - PUSH( w ); - PUSH( h ); + fword("screen-width"); + fword("screen-height"); }
/* ( table start count -- ) (?) */
Instead if having a large #ifdef .. #endif section in video_set_color(), move the device-specific hardware setters into each display device package.
To do this, we keep track of the display ihandle in the video structure and use it to invoke the low-level hardware setter routine (and optional palette refresh) if required.
Also since the display-ih isn't called until is-install, defer the colour palette initialisation from init_video() to is-install.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/console.c | 17 ++++++++++ openbios-devel/drivers/sbus.c | 1 + openbios-devel/drivers/vga_vbe.c | 18 +++++++++++ openbios-devel/forth/device/display.fs | 25 +++++++++++++++ openbios-devel/include/drivers/drivers.h | 1 + openbios-devel/include/libopenbios/video.h | 1 + openbios-devel/libopenbios/video_common.c | 46 ++++++++++++++-------------- openbios-devel/packages/molvideo.c | 19 +++++++++--- 8 files changed, 101 insertions(+), 27 deletions(-)
diff --git a/openbios-devel/arch/sparc32/console.c b/openbios-devel/arch/sparc32/console.c index c986e2b..53aa77f 100644 --- a/openbios-devel/arch/sparc32/console.c +++ b/openbios-devel/arch/sparc32/console.c @@ -11,6 +11,7 @@ #include "openbios.h" #include "libopenbios/console.h" #include "libopenbios/ofmem.h" +#include "libopenbios/video.h"
void cls(void);
@@ -41,6 +42,22 @@ void tcx_init(uint64_t base) dac = (uint32_t *)ofmem_map_io(base + DAC_BASE, DAC_SIZE); }
+/* ( r g b index -- ) */ +void tcx_hw_set_color(void) +{ + int index = POP(); + int b = POP(); + int g = POP(); + int r = POP(); + + if( VIDEO_DICT_VALUE(video.depth) == 8 ) { + dac[0] = index << 24; + dac[1] = r << 24; // Red + dac[1] = g << 24; // Green + dac[1] = b << 24; // Blue + } +} + #endif
/* ****************************************************************** diff --git a/openbios-devel/drivers/sbus.c b/openbios-devel/drivers/sbus.c index d171018..fbac2d7 100644 --- a/openbios-devel/drivers/sbus.c +++ b/openbios-devel/drivers/sbus.c @@ -329,6 +329,7 @@ ob_tcx_init(unsigned int slot, const char *path) fword("property"); }
+ bind_func("hw-set-color", tcx_hw_set_color); feval("['] qemu-tcx-driver-init is-install");
chosen = find_dev("/chosen"); diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c index 884c261..33765b6 100644 --- a/openbios-devel/drivers/vga_vbe.c +++ b/openbios-devel/drivers/vga_vbe.c @@ -103,6 +103,22 @@ void vga_vbe_set_mode(int width, int height, int depth) vga_build_rgb_palette(); }
+/* Low-level Forth accessor to update VGA color registers */ + +/* ( r g b index -- ) */ +static +void vga_hw_set_color(void) +{ + int index = POP(); + int b = POP(); + int g = POP(); + int r = POP(); + + vga_set_color(index, (r & 0xff), + (g & 0xff), + (b & 0xff)); +} + void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, unsigned long rom, uint32_t rom_size) { @@ -128,6 +144,8 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, ph = get_cur_dev(); #endif
+ bind_func("hw-set-color", vga_hw_set_color); + set_int_property(ph, "width", VIDEO_DICT_VALUE(video.w)); set_int_property(ph, "height", VIDEO_DICT_VALUE(video.h)); set_int_property(ph, "depth", VIDEO_DICT_VALUE(video.depth)); diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index cf709fa..ae7bdeb 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -48,6 +48,7 @@ create color-palette 100 cells allot 2 value font-spacing 0 value depth-bits 0 value line-bytes +0 value display-ih
\ internal values read from QEMU firmware interface 0 value qemu-video-addr @@ -353,6 +354,8 @@ defer fb8-invertrect 0 to inverse? 0 to inverse-screen?
+ my-self to display-ih + \ set defer functions to 8bit versions
['] fb8-draw-character to draw-character @@ -375,6 +378,28 @@ defer fb8-invertrect then to foreground-color to background-color
+ \ setup palette + 10101 ['] color-palette cell+ ff 0 do + dup 2 pick i * swap ! cell+ + loop 2drop + + \ special background color + ffffcc ['] color-palette cell+ fe cells + ! + + \ load palette onto the hardware + ['] color-palette cell+ ff 0 do + dup @ ff0000 and d# 16 rshift + 1 pick @ ff00 and d# 8 rshift + 2 pick @ ff and + i + s" hw-set-color" $find if + execute + else + 2drop + then + cell+ + loop drop + \ ... but let's override with some better defaults fe to background-color 0 to foreground-color diff --git a/openbios-devel/include/drivers/drivers.h b/openbios-devel/include/drivers/drivers.h index d139ace..d041e81 100644 --- a/openbios-devel/include/drivers/drivers.h +++ b/openbios-devel/include/drivers/drivers.h @@ -47,6 +47,7 @@ int ob_sbus_init(uint64_t base, int machine_id);
/* arch/sparc32/console.c */ void tcx_init(uint64_t base); +void tcx_hw_set_color(void); void kbd_init(uint64_t base); #endif #ifdef CONFIG_DRIVER_IDE diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index bcd024e..cf2b5db 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -30,6 +30,7 @@ void video_fill_rect(void); extern struct video_info { int has_video;
+ volatile ihandle_t *ih; volatile phys_addr_t mphys; volatile ucell *mvirt; volatile ucell *rb, *w, *h, *depth; diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 9d45e69..ca2826e 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -46,27 +46,30 @@ video_get_color( int col_ind ) void video_set_color( int ind, unsigned long color ) { + xt_t hw_xt = 0; + if( !video.has_video || ind < 0 || ind > 255 ) return; video.pal[ind] = color;
-#ifdef CONFIG_MOL - if( VIDEO_DICT_VALUE(video.depth) == 8 ) - OSI_SetColor( ind, color ); -#elif defined(CONFIG_SPARC32) -#if defined(CONFIG_DEBUG_CONSOLE_VIDEO) - if( VIDEO_DICT_VALUE(video.depth) == 8 ) { - dac[0] = ind << 24; - dac[1] = ((color >> 16) & 0xff) << 24; // Red - dac[1] = ((color >> 8) & 0xff) << 24; // Green - dac[1] = (color & 0xff) << 24; // Blue - } -#endif -#else - vga_set_color(ind, ((color >> 16) & 0xff), - ((color >> 8) & 0xff), - (color & 0xff)); -#endif + /* Call the low-level hardware setter in the + display package */ + hw_xt = find_ih_method("hw-set-color", VIDEO_DICT_VALUE(video.ih)); + if (hw_xt) { + PUSH((color >> 16) & 0xff); // Red + PUSH((color >> 8) & 0xff); // Green + PUSH(color & 0xff); // Blue + PUSH(ind); + PUSH(hw_xt); + fword("execute"); + } + + /* Call the low-level palette update if required */ + hw_xt = find_ih_method("hw-refresh-palette", VIDEO_DICT_VALUE(video.ih)); + if (hw_xt) { + PUSH(hw_xt); + fword("execute"); + } }
/* ( fbaddr maskaddr width height fgcolor bgcolor -- ) */ @@ -219,6 +222,9 @@ void setup_video(phys_addr_t phys, ucell virt)
video.mphys = phys;
+ feval("['] display-ih cell+"); + video.ih = cell2pointer(POP()); + feval("['] qemu-video-addr cell+"); video.mvirt = cell2pointer(POP()); feval("['] qemu-video-width cell+"); @@ -277,7 +283,6 @@ void setup_video(phys_addr_t phys, ucell virt) void init_video(void) { - int i; #if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) int size; #endif @@ -306,9 +311,4 @@ init_video(void) ofmem_claim_virt( VIDEO_DICT_VALUE(video.mvirt), size, 0 ); ofmem_map( video.mphys, VIDEO_DICT_VALUE(video.mvirt), size, ofmem_arch_io_translation_mode(video.mphys) ); #endif - - for( i=0; i<256; i++ ) - video_set_color( i, i * 0x010101 ); - - video_set_color( 254, 0xffffcc ); } diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 742f516..24cc2fd 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -31,15 +31,24 @@
DECLARE_NODE( video, 0, 0, "Tdisplay" );
+#ifdef CONFIG_MOL static void molvideo_refresh_palette( void ) { -#ifdef CONFIG_MOL + if( VIDEO_DICT_VALUE(video.depth) == 8 ) OSI_RefreshPalette(); -#endif }
+static void +molvideo_hw_set_color( void ) +{ + + if( VIDEO_DICT_VALUE(video.depth) == 8 ) + OSI_SetColor( ind, color ); +} +#endif + /* ( -- width height ) (?) */ static void molvideo_dimensions( void ) @@ -61,7 +70,6 @@ molvideo_set_colors( void ) unsigned long col = (p[0] << 16) | (p[1] << 8) | p[2]; video_set_color( i + start, col ); } - molvideo_refresh_palette(); }
/* ( r g b index -- ) */ @@ -75,7 +83,6 @@ molvideo_color_bang( void ) unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff); /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */ video_set_color( index, col ); - molvideo_refresh_palette(); }
/* ( color_ind x y width height -- ) (?) */ @@ -143,6 +150,10 @@ molvideo_startup_splash( void )
NODE_METHODS( video ) = { +#ifdef CONFIG_MOL + {"hw-set-color", molvideo_hw_set_color }, + {"hw-refresh-palette", molvideo_refresh_palette}, +#endif {"dimensions", molvideo_dimensions }, {"set-colors", molvideo_set_colors }, {"fill-rectangle", molvideo_fill_rect },
Even though we boot in 24-bit enabled mode, OpenBIOS only uses the 8-bit framebuffer. Hence we need to override the depth/linebytes obtained from QEMU to force the graphics subsystem into 8-bit mode, which was what seems to have been happening before this patch series.
Note: it seems strange that we have to update the package linebytes property too, however Debian etch freezes if we don't set it to match the 8-bit framebuffer even though it correctly switches to 24-bit mode.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/sbus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/openbios-devel/drivers/sbus.c b/openbios-devel/drivers/sbus.c index fbac2d7..8cc0bf9 100644 --- a/openbios-devel/drivers/sbus.c +++ b/openbios-devel/drivers/sbus.c @@ -17,6 +17,7 @@ #include "libc/vsprintf.h" #include "drivers/drivers.h" #include "libopenbios/ofmem.h" +#include "libopenbios/video.h"
#define SBUS_REGS 0x28 #define SBUS_SLOTS 16 @@ -329,6 +330,17 @@ ob_tcx_init(unsigned int slot, const char *path) fword("property"); }
+ /* Even with a 24-bit enabled TCX card, the control plane is + used in 8-bit mode. So force the video subsystem into 8-bit + mode before initialisation. */ + if (graphic_depth == 24) { + VIDEO_DICT_VALUE(video.depth) = 8; + VIDEO_DICT_VALUE(video.rb) = VIDEO_DICT_VALUE(video.w); + + chosen = get_cur_dev(); + set_int_property(chosen, "linebytes", VIDEO_DICT_VALUE(video.rb)); + } + bind_func("hw-set-color", tcx_hw_set_color); feval("['] qemu-tcx-driver-init is-install");
Switch from using unsigned long to uint32_t in the 32-bit primitives and unsigned short to uint16_t in the 16-bit primitives. While not a complete fix (endian-swapping, 24-bit mode) it does fix 32-bit display depth on 64-bit architectures such as SPARC64.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/libopenbios/video_common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index ca2826e..83270a0 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -107,9 +107,9 @@ video_mask_blit(void) }
if( d >= 24 ) - *((unsigned long*)dst) = color; + *((uint32_t*)dst) = color; else if( d >= 15 ) - *((short*)dst) = color; + *((uint16_t*)dst) = color; else *dst = color;
@@ -146,7 +146,7 @@ video_invert_rect( void ) for( ; h--; pp += *(video.rb) ) { int ww = w; if( VIDEO_DICT_VALUE(video.depth) == 24 || VIDEO_DICT_VALUE(video.depth) == 32 ) { - unsigned long *p = (unsigned long*)pp + x; + uint32_t *p = (uint32_t*)pp + x; while( ww-- ) { if (*p == fgcolor) { *p++ = bgcolor; @@ -155,11 +155,11 @@ video_invert_rect( void ) } } } else if( VIDEO_DICT_VALUE(video.depth) == 16 || VIDEO_DICT_VALUE(video.depth) == 15 ) { - unsigned short *p = (unsigned short*)pp + x; + uint16_t *p = (uint16_t*)pp + x; while( ww-- ) { - if (*p == (unsigned short)fgcolor) { + if (*p == (uint16_t)fgcolor) { *p++ = bgcolor; - } else if (*p == (unsigned short)bgcolor) { + } else if (*p == (uint16_t)bgcolor) { *p++ = fgcolor; } } @@ -198,11 +198,11 @@ video_fill_rect(void) for( ; h--; pp += VIDEO_DICT_VALUE(video.rb) ) { int ww = w; if( VIDEO_DICT_VALUE(video.depth) == 24 || VIDEO_DICT_VALUE(video.depth) == 32 ) { - unsigned long *p = (unsigned long*)pp + x; + uint32_t *p = (uint32_t*)pp + x; while( ww-- ) *p++ = col; } else if( VIDEO_DICT_VALUE(video.depth) == 16 || VIDEO_DICT_VALUE(video.depth) == 15 ) { - unsigned short *p = (unsigned short*)pp + x; + uint16_t *p = (uint16_t*)pp + x; while( ww-- ) *p++ = col; } else {
Finally we now have a set of common video routines in video_common.c with per bus initialisers for SBus and PCI. Hence we can remove the now obsolete init_video() function.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/openbios.c | 1 - openbios-devel/drivers/vga_vbe.c | 13 +++++++-- openbios-devel/include/libopenbios/video.h | 3 -- openbios-devel/libopenbios/video_common.c | 41 +++------------------------- 4 files changed, 15 insertions(+), 43 deletions(-)
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index 84dd3f6..0437b9c 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -876,7 +876,6 @@ arch_init( void ) #ifdef CONFIG_DRIVER_SBUS #ifdef CONFIG_DEBUG_CONSOLE_VIDEO setup_video(hwdef->tcx_base + 0x00800000ULL, (unsigned long)vmem); - init_video(); #endif ob_sbus_init(hwdef->iommu_base + 0x1000ULL, qemu_machine_type); #endif diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c index 33765b6..75b232e 100644 --- a/openbios-devel/drivers/vga_vbe.c +++ b/openbios-devel/drivers/vga_vbe.c @@ -27,6 +27,7 @@ #include "drivers/vga.h" #include "libopenbios/video.h" #include "libopenbios/ofmem.h" +#include "packages/video.h"
/* VGA init. We use the Bochs VESA VBE extensions */ #define VBE_DISPI_INDEX_ID 0x0 @@ -125,6 +126,7 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, phys_addr_t phys; phandle_t ph, chosen, aliases, options; char buf[6]; + int size;
phys = fb;
@@ -152,6 +154,8 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, set_int_property(ph, "linebytes", VIDEO_DICT_VALUE(video.rb)); set_int_property(ph, "address", (u32)(fb & ~0x0000000F));
+ molvideo_init(); + chosen = find_dev("/chosen"); push_str(path); fword("open-dev"); @@ -168,7 +172,6 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size,
if (rom_size >= 8) { const char *p; - int size;
p = (const char *)rom; if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') { @@ -178,5 +181,11 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, } }
- init_video(); +#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) + size = ((VIDEO_DICT_VALUE(video.h) * VIDEO_DICT_VALUE(video.rb)) + 0xfff) & ~0xfff; + + ofmem_claim_phys( video.mphys, size, 0 ); + ofmem_claim_virt( VIDEO_DICT_VALUE(video.mvirt), size, 0 ); + ofmem_map( video.mphys, VIDEO_DICT_VALUE(video.mvirt), size, ofmem_arch_io_translation_mode(video.mphys) ); +#endif } diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index cf2b5db..5e9abb7 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -20,7 +20,6 @@ #define VGA_DEFAULT_LINEBYTES (VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8))
void setup_video(phys_addr_t phys, ucell virt); -void init_video(void); unsigned long video_get_color(int col_ind); void video_set_color(int ind, unsigned long color); void video_mask_blit(void); @@ -28,8 +27,6 @@ void video_invert_rect(void); void video_fill_rect(void);
extern struct video_info { - int has_video; - volatile ihandle_t *ih; volatile phys_addr_t mphys; volatile ucell *mvirt; diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 83270a0..748742f 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -31,7 +31,7 @@ unsigned long video_get_color( int col_ind ) { unsigned long col; - if( !video.has_video || col_ind < 0 || col_ind > 255 ) + if( !VIDEO_DICT_VALUE(video.ih) || col_ind < 0 || col_ind > 255 ) return 0; if( VIDEO_DICT_VALUE(video.depth) == 8 ) return col_ind; @@ -48,7 +48,7 @@ video_set_color( int ind, unsigned long color ) { xt_t hw_xt = 0;
- if( !video.has_video || ind < 0 || ind > 255 ) + if( !VIDEO_DICT_VALUE(video.ih) || ind < 0 || ind > 255 ) return; video.pal[ind] = color;
@@ -138,7 +138,7 @@ video_invert_rect( void ) bgcolor = video_get_color(bgcolor); fgcolor = video_get_color(fgcolor);
- if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || + if (!VIDEO_DICT_VALUE(video.ih) || x < 0 || y < 0 || w <= 0 || h <= 0 || x + w > VIDEO_DICT_VALUE(video.w) || y + h > VIDEO_DICT_VALUE(video.h)) return;
@@ -190,7 +190,7 @@ video_fill_rect(void) char *pp; unsigned long col = video_get_color(col_ind);
- if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || + if (!VIDEO_DICT_VALUE(video.ih) || x < 0 || y < 0 || w <= 0 || h <= 0 || x + w > VIDEO_DICT_VALUE(video.w) || y + h > VIDEO_DICT_VALUE(video.h)) return;
@@ -279,36 +279,3 @@ void setup_video(phys_addr_t phys, ucell virt) } #endif } - -void -init_video(void) -{ -#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) - int size; -#endif - phandle_t ph=0, saved_ph=0; - - saved_ph = get_cur_dev(); - while( (ph=dt_iterate_type(ph, "display")) ) { - video.has_video = 1; - - set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) ); - set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) ); - set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) ); - set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) ); - set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) ); - - activate_dev(ph); - - molvideo_init(); - } - activate_dev(saved_ph); - -#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) - size = ((VIDEO_DICT_VALUE(video.h) * VIDEO_DICT_VALUE(video.rb)) + 0xfff) & ~0xfff; - - ofmem_claim_phys( video.mphys, size, 0 ); - ofmem_claim_virt( VIDEO_DICT_VALUE(video.mvirt), size, 0 ); - ofmem_map( video.mphys, VIDEO_DICT_VALUE(video.mvirt), size, ofmem_arch_io_translation_mode(video.mphys) ); -#endif -}
After all of the shuffling, this file is no longer required. Remove it.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/console.c | 1 - openbios-devel/include/libopenbios/console.h | 9 --------- openbios-devel/libopenbios/video_common.c | 1 - openbios-devel/packages/molvideo.c | 1 - 4 files changed, 12 deletions(-) delete mode 100644 openbios-devel/include/libopenbios/console.h
diff --git a/openbios-devel/arch/sparc32/console.c b/openbios-devel/arch/sparc32/console.c index 53aa77f..55a0ee7 100644 --- a/openbios-devel/arch/sparc32/console.c +++ b/openbios-devel/arch/sparc32/console.c @@ -9,7 +9,6 @@ #include "kernel/kernel.h" #include "drivers/drivers.h" #include "openbios.h" -#include "libopenbios/console.h" #include "libopenbios/ofmem.h" #include "libopenbios/video.h"
diff --git a/openbios-devel/include/libopenbios/console.h b/openbios-devel/include/libopenbios/console.h deleted file mode 100644 index 817a021..0000000 --- a/openbios-devel/include/libopenbios/console.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef VIDEO_CONSOLE_H -#define VIDEO_CONSOLE_H - -/* libopenbios/console_common.c */ -int console_draw_fstr(const char *str, int len); -int console_init(void); -void console_close(void); - -#endif /* VIDEO_CONSOLE_H */ diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 748742f..084a6c6 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -16,7 +16,6 @@
#include "config.h" #include "libopenbios/bindings.h" -#include "libopenbios/console.h" #include "libopenbios/fontdata.h" #include "libopenbios/ofmem.h" #include "libopenbios/video.h" diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c index 24cc2fd..9dd60b8 100644 --- a/openbios-devel/packages/molvideo.c +++ b/openbios-devel/packages/molvideo.c @@ -21,7 +21,6 @@ #include "drivers/drivers.h" #include "packages/video.h" #include "libopenbios/video.h" -#include "libopenbios/console.h" #include "drivers/vga.h"
These words always output to the debug (serial) port even if video mode is enabled. This makes debugging the video routines much easier when starting QEMU with the -serial stdio option.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/bootstrap/bootstrap.fs | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/openbios-devel/forth/bootstrap/bootstrap.fs b/openbios-devel/forth/bootstrap/bootstrap.fs index 6878449..0668cf7 100644 --- a/openbios-devel/forth/bootstrap/bootstrap.fs +++ b/openbios-devel/forth/bootstrap/bootstrap.fs @@ -660,6 +660,7 @@ defer emit
\ : type 0 do count emit loop drop ;
+: debug-type bounds ?do i c@ (emit) loop ;
\ \ 7.3.4.1 Text Input @@ -863,6 +864,7 @@ variable span 0 span ! \
: cr linefeed emit ; +: debug-cr linefeed (emit) ; : (cr carret emit ; : space bl emit ; : spaces 0 ?do space loop ;
The video_cls() function is no longer needed, since the fb8-install routines now handle the video initialisation instead.
Remove the serial_cls() functions to make SPARC consistent with PPC and aid debugging.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/boot.h | 3 --- openbios-devel/arch/sparc32/console.c | 18 ------------------ openbios-devel/arch/sparc32/openbios.c | 2 -- openbios-devel/arch/sparc64/console.c | 12 ------------ openbios-devel/arch/sparc64/openbios.c | 2 -- 5 files changed, 37 deletions(-)
diff --git a/openbios-devel/arch/sparc32/boot.h b/openbios-devel/arch/sparc32/boot.h index fa701e5..55e391a 100644 --- a/openbios-devel/arch/sparc32/boot.h +++ b/openbios-devel/arch/sparc32/boot.h @@ -22,9 +22,6 @@ extern void go(void); extern unsigned int qemu_mem_size; extern void collect_sys_info(struct sys_info *info);
-// console.c -void cls(void); - // romvec.c extern struct linux_arguments_v0 obp_arg; extern const void *romvec; diff --git a/openbios-devel/arch/sparc32/console.c b/openbios-devel/arch/sparc32/console.c index 55a0ee7..91587fc 100644 --- a/openbios-devel/arch/sparc32/console.c +++ b/openbios-devel/arch/sparc32/console.c @@ -12,8 +12,6 @@ #include "libopenbios/ofmem.h" #include "libopenbios/video.h"
-void cls(void); - #ifdef CONFIG_DEBUG_CONSOLE
/* ****************************************************************** @@ -30,11 +28,6 @@ void cls(void); unsigned char *vmem; volatile uint32_t *dac;
-static void video_cls(void) -{ - memset((void *)vmem, 0, VMEM_SIZE); -} - void tcx_init(uint64_t base) { vmem = (unsigned char *)ofmem_map_io(base + VMEM_BASE, VMEM_SIZE); @@ -97,15 +90,4 @@ int getchar(void) return 0; }
-void cls(void) -{ -#ifdef CONFIG_DEBUG_CONSOLE_SERIAL - serial_cls(); -#endif -#ifdef CONFIG_DEBUG_CONSOLE_VIDEO - video_cls(); -#endif -} - - #endif // CONFIG_DEBUG_CONSOLE diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index 0437b9c..40948d1 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -971,8 +971,6 @@ int openbios(void) tcx_init(hwdef->tcx_base); kbd_init(hwdef->ms_kb_base); #endif - /* Clear the screen. */ - cls(); #endif
collect_sys_info(&sys_info); diff --git a/openbios-devel/arch/sparc64/console.c b/openbios-devel/arch/sparc64/console.c index b4b4b76..ec7571c 100644 --- a/openbios-devel/arch/sparc64/console.c +++ b/openbios-devel/arch/sparc64/console.c @@ -58,16 +58,4 @@ int getchar(void) return 0; }
-void cls(void) -{ -#ifdef CONFIG_DEBUG_CONSOLE_SERIAL - serial_putchar(27); - serial_putchar('['); - serial_putchar('H'); - serial_putchar(27); - serial_putchar('['); - serial_putchar('J'); -#endif -} - #endif // CONFIG_DEBUG_CONSOLE diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c index 6b2b041..b1e5f47 100644 --- a/openbios-devel/arch/sparc64/openbios.c +++ b/openbios-devel/arch/sparc64/openbios.c @@ -619,8 +619,6 @@ int openbios(void) #ifdef CONFIG_DEBUG_CONSOLE_SERIAL uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED); #endif - /* Clear the screen. */ - cls(); printk("OpenBIOS for Sparc64\n"); #endif
The sequence 's" test" encode-string decode-string' suffered from an off-by-one error whereby the trailing '\0' would still be left at the end of the decoded string.
This fixes the extra "space" appearing at the end of property names, e.g. such as in the output of "show-devs".
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/device/property.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openbios-devel/forth/device/property.fs b/openbios-devel/forth/device/property.fs index d19546c..f9769fb 100644 --- a/openbios-devel/forth/device/property.fs +++ b/openbios-devel/forth/device/property.fs @@ -185,7 +185,7 @@ >r >r >r ( R: prop-addr1 prop-addr2 prop-len2 nlen ) drop r> r> r> ( nlen prop-len2 prop-addr2 ) - -rot swap ( prop-addr2 prop-len2 nlen ) + -rot swap 1- ( prop-addr2 prop-len2 nlen ) r> swap ( prop-addr2 prop-len2 str len ) else 0 0