[OpenBIOS] [PATCH 03/14] video: move all non MOL-specific code from molvideo.c to vga.fs
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Thu Aug 8 00:51:07 CEST 2013
This now leaves just the MOL code in packages/molvideo.c and so now we no
longer have a mixture of MOL and non-MOL methods in this packages. As a
result of this, we can now conditionally build molvideo.c only if CONFIG_MOL
is defined.
(Note: I have no way of testing this as I gather that OpenBIOS was pulled from
MOL due to compatibility issues at some point in the past. Perhaps one day
someone will try and update and see what happens?)
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
openbios-devel/drivers/pci.c | 7 +++
openbios-devel/drivers/vga.fs | 31 +++++++++++++
openbios-devel/drivers/vga_vbe.c | 3 --
openbios-devel/forth/device/display.fs | 2 +-
openbios-devel/packages/build.xml | 2 +-
openbios-devel/packages/molvideo.c | 78 ++++++--------------------------
6 files changed, 55 insertions(+), 68 deletions(-)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
index 1b4628e..3f37fd8 100644
--- a/openbios-devel/drivers/pci.c
+++ b/openbios-devel/drivers/pci.c
@@ -24,6 +24,7 @@
#include "drivers/drivers.h"
#include "drivers/vga.h"
+#include "packages/video.h"
#include "timer.h"
#include "pci.h"
#include "pci_database.h"
@@ -773,6 +774,12 @@ int vga_config_cb (const pci_config_t *config)
/* Currently we don't read FCode from the hardware but execute it directly */
feval("['] vga-driver-fcode 2 cells + 1 byte-load");
+
+#ifdef CONFIG_MOL
+ /* Install special words for Mac On Linux */
+ molvideo_init();
+#endif
+
}
return 0;
diff --git a/openbios-devel/drivers/vga.fs b/openbios-devel/drivers/vga.fs
index d3fe95c..43c8819 100644
--- a/openbios-devel/drivers/vga.fs
+++ b/openbios-devel/drivers/vga.fs
@@ -31,6 +31,9 @@ fcode-version3
: depth-bits depth-bits-xt @ ;
: line-bytes line-bytes-xt @ ;
+" fb8-fillrect" (find-xt) value fb8-fillrect-xt
+: fb8-fillrect fb8-fillrect-xt execute ;
+
\
\ IO port words
\
@@ -112,6 +115,9 @@ external
defer mol-color!
\ Hook for MOL (see packages/molvideo.c)
+\
+\ Perhaps for neatness this there should be a separate molvga.fs
+\ but let's leave it here for now.
: hw-set-color ( r g b index -- )
mol-color!
@@ -127,6 +133,31 @@ defer mol-color!
[THEN]
+: color! ( r g b index -- )
+ hw-set-color
+;
+
+: fill-rectangle ( color_ind x y width height -- )
+ fb8-fillrect
+;
+
+: dimensions ( -- width height )
+ openbios-video-width
+ openbios-video-height
+;
+
+: set-colors ( table start count -- )
+ 0 do
+ over dup \ ( table start table table )
+ c@ swap 1+ \ ( table start r table-g )
+ dup c@ swap 1+ \ ( table start r g table-b )
+ c@ 3 pick \ ( table start r g b index )
+ hw-set-color \ ( table start )
+ 1+
+ swap 3 + swap \ ( table+3 start+1 )
+ loop
+;
+
headerless
\
diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c
index 54d9fb1..8c224d6 100644
--- a/openbios-devel/drivers/vga_vbe.c
+++ b/openbios-devel/drivers/vga_vbe.c
@@ -27,7 +27,6 @@
#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
@@ -75,8 +74,6 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size,
ph = get_cur_dev();
#endif
- molvideo_init();
-
chosen = find_dev("/chosen");
push_str(path);
fword("open-dev");
diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs
index 8c4fb45..6d77dfa 100644
--- a/openbios-devel/forth/device/display.fs
+++ b/openbios-devel/forth/device/display.fs
@@ -408,7 +408,7 @@ defer fb8-invertrect
\ If we have a startup splash then display it
[IFDEF] CONFIG_MOL
- startup-splash 2000 ms
+ mol-startup-splash 2000 ms
fb8-erase-screen
[THEN]
;
diff --git a/openbios-devel/packages/build.xml b/openbios-devel/packages/build.xml
index 0384c41..bf49099 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="molvideo.c"/>
+ <object source="molvideo.c" condition="MOL"/>
<object source="xcoff-loader.c" condition="LOADER_XCOFF"/>
</library>
diff --git a/openbios-devel/packages/molvideo.c b/openbios-devel/packages/molvideo.c
index 9dd60b8..787c4dc 100644
--- a/openbios-devel/packages/molvideo.c
+++ b/openbios-devel/packages/molvideo.c
@@ -2,7 +2,7 @@
* Creation Date: <2002/10/23 20:26:40 samuel>
* Time-stamp: <2004/01/07 19:39:15 samuel>
*
- * <video.c>
+ * <molvideo.c>
*
* Mac-on-Linux display node
*
@@ -30,47 +30,6 @@
DECLARE_NODE( video, 0, 0, "Tdisplay" );
-#ifdef CONFIG_MOL
-static void
-molvideo_refresh_palette( void )
-{
-
- if( VIDEO_DICT_VALUE(video.depth) == 8 )
- OSI_RefreshPalette();
-}
-
-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 )
-{
- fword("screen-width");
- fword("screen-height");
-}
-
-/* ( 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];
- video_set_color( i + start, col );
- }
-}
-
/* ( r g b index -- ) */
static void
molvideo_color_bang( void )
@@ -81,31 +40,26 @@ 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 ); */
- video_set_color( index, col );
-}
-/* ( color_ind x y width height -- ) (?) */
-static void
-molvideo_fill_rect ( void )
-{
- video_fill_rect();
+ if( VIDEO_DICT_VALUE(video.depth) == 8 ) {
+ OSI_SetColor( index, col );
+ OSI_RefreshPalette();
+ }
}
/* ( -- ) - 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_DICT_VALUE(video.depth) < 15 )
return;
-#ifdef CONFIG_MOL
+
for( i=0; i<2; i++ ) {
if( !BootHGetStrResInd("bootlogo", buf, sizeof(buf), 0, i) )
return;
@@ -141,23 +95,14 @@ molvideo_startup_splash( void )
}
free( p );
}
-#else
+
/* No bootlogo support yet on other platforms */
return;
-#endif
}
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 },
- {"color!", molvideo_color_bang },
- {"startup-splash", molvideo_startup_splash },
+ {"mol-startup-splash", molvideo_startup_splash },
};
@@ -168,5 +113,12 @@ NODE_METHODS( video ) = {
void
molvideo_init(void)
{
+ xt_t color_bang;
+
REGISTER_NODE( video );
+
+ /* Bind the MOL graphic routines to the mol-color! defer */
+ color_bang = bind_noname_func(molvideo_color_bang);
+ PUSH(color_bang);
+ feval(" to mol-color!");
}
--
1.7.10.4
More information about the OpenBIOS
mailing list