The IEEE1275 is-install routine needs to call a basic initialisation routine for each driver as typically supplied as an Fcode ROM. Provide a suitable set of basic initialisers for a QEMU host.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/build.xml | 2 ++ openbios-devel/drivers/tcx.fs | 13 +++++++++ openbios-devel/drivers/vga.fs | 13 +++++++++ openbios-devel/forth/device/display.fs | 15 ++++++++++ openbios-devel/libopenbios/video_common.c | 45 +++++++++++++++++++++++++++++ openbios-devel/packages/video.c | 15 ---------- 6 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 openbios-devel/drivers/tcx.fs create mode 100644 openbios-devel/drivers/vga.fs
diff --git a/openbios-devel/drivers/build.xml b/openbios-devel/drivers/build.xml index 75aff87..e564292 100644 --- a/openbios-devel/drivers/build.xml +++ b/openbios-devel/drivers/build.xml @@ -29,6 +29,8 @@ <object source="pci.fs" condition="DRIVER_PCI"/> <object source="sbus.fs" condition="DRIVER_SBUS"/> <object source="esp.fs" condition="DRIVER_ESP"/> + <object source="tcx.fs" condition="DRIVER_SBUS"/> + <object source="vga.fs" condition="DRIVER_VGA"/> </dictionary>
</build> diff --git a/openbios-devel/drivers/tcx.fs b/openbios-devel/drivers/tcx.fs new file mode 100644 index 0000000..4035b45 --- /dev/null +++ b/openbios-devel/drivers/tcx.fs @@ -0,0 +1,13 @@ +\ +\ Fcode payload for QEMU TCX graphics card +\ +\ This is the Forth source for an Fcode payload to initialise +\ the QEMU TCX graphics card. +\ + +: qemu-tcx-driver-init ( -- ) + qemu-video-addr to frame-buffer-adr + default-font set-font + qemu-video-width qemu-video-height over char-width / over char-height / + fb8-install +; diff --git a/openbios-devel/drivers/vga.fs b/openbios-devel/drivers/vga.fs new file mode 100644 index 0000000..632cca0 --- /dev/null +++ b/openbios-devel/drivers/vga.fs @@ -0,0 +1,13 @@ +\ +\ Fcode payload for QEMU VGA graphics card +\ +\ This is the Forth source for an Fcode payload to initialise +\ the QEMU VGA graphics card. +\ + +: qemu-vga-driver-init ( -- ) + qemu-video-addr to frame-buffer-adr + default-font set-font + qemu-video-width qemu-video-height over char-width / over char-height / + fb8-install +; diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index bbd2b13..0df7165 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -44,6 +44,10 @@ hex 0 value foreground-color 0 value background-color
+\ internal values read from QEMU firmware interface +0 value qemu-video-addr +0 value qemu-video-height +0 value qemu-video-width
\ The following wordset is called the "defer word interface" of the \ terminal-emulator support package. It gets overloaded by fb1-install @@ -102,6 +106,8 @@ defer fb-emit ( x -- ) s" open" header 1 , \ colon definition , + ['] (lit) , + -1 , ['] (semis) , reveal s" : write dup >r bounds do i c@ fb-emit loop r> ; " evaluate @@ -242,6 +248,10 @@ defer fb-emit ( x -- ) false to inverse-screen? 0 to foreground-color d# 15 to background-color + + \ override with OpenBIOS defaults + fe to background-color + 0 to foreground-color ;
: fb8-toggle-cursor ( -- ) @@ -363,4 +373,9 @@ defer fb-emit ( x -- ) then to foreground-color to background-color
+ \ ... but let's override with some better defaults + fe to background-color + 0 to foreground-color + + fb8-erase-screen ; diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 0892859..f33286b 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -16,6 +16,8 @@
#include "config.h" #include "libopenbios/bindings.h" +#include "libopenbios/console.h" +#include "libopenbios/fontdata.h" #include "libopenbios/ofmem.h" #include "libopenbios/video.h" #include "packages/video.h" @@ -211,6 +213,26 @@ 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); +} + void init_video( unsigned long fb, int width, int height, int depth, int rb ) { @@ -241,6 +263,15 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) set_int_property( ph, "address", video.fb.mvirt ); 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; @@ -250,6 +281,20 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) PUSH(video.fb.mvirt); feval("to frame-buffer-adr"); + /* Set global variables ready for fb8-install */ + PUSH((ucell)fontdata); + feval("to (romfont)"); + PUSH(FONT_HEIGHT); + feval("to (romfont-height)"); + PUSH(FONT_WIDTH); + feval("to (romfont-width)"); + PUSH(video.fb.mvirt); + feval("to qemu-video-addr"); + PUSH(video.fb.w); + feval("to qemu-video-width"); + PUSH(video.fb.h); + feval("to qemu-video-height"); + #if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) size = ((video.fb.h * video.fb.rb) + 0xfff) & ~0xfff;
diff --git a/openbios-devel/packages/video.c b/openbios-devel/packages/video.c index 2c2aeac..e68faa5 100644 --- a/openbios-devel/packages/video.c +++ b/openbios-devel/packages/video.c @@ -84,26 +84,11 @@ video_fill_rect( void ) fill_rect( color_ind, x, y, w, h ); }
-/* ( 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); -} - NODE_METHODS( video ) = { {"dimensions", video_dimensions }, {"set-colors", video_set_colors }, {"fill-rectangle", video_fill_rect }, {"color!", video_color_bang }, - {"write", video_write }, };