[openfirmware] [commit] r2222 - cpu/x86/pc/biosload dev/video/controlr

repository service svn at openfirmware.info
Wed May 25 09:03:40 CEST 2011


Author: wmb
Date: Wed May 25 09:03:39 2011
New Revision: 2222
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2222

Log:
BIOSload version - added a VESA linear framebuffer driver.

Added:
   dev/video/controlr/vesalfb.fth
Modified:
   cpu/x86/pc/biosload/callvbe.fth
   cpu/x86/pc/biosload/config-usbkey.fth
   cpu/x86/pc/biosload/devices.fth
   cpu/x86/pc/biosload/fw.bth
   cpu/x86/pc/biosload/ofw.bth

Modified: cpu/x86/pc/biosload/callvbe.fth
==============================================================================
--- cpu/x86/pc/biosload/callvbe.fth	Tue May 24 23:16:47 2011	(r2221)
+++ cpu/x86/pc/biosload/callvbe.fth	Wed May 25 09:03:39 2011	(r2222)
@@ -103,19 +103,54 @@
    repeat                                        ( 'mode-list n mode# )
    drop nip                                      ( n )
 ;
-: .vesa-modes  ( -- )
+0 value vesa-modes-adr
+: vesa-mode-list  ( -- adr )
+   vesa-modes-adr ?dup  if  exit  then   ( )
    vbe-info                     ( adr )
-   dup l@  h# 41534556 <>  if   ( adr )
-      ." VBE info call failed" cr
-      drop exit
-   then                         ( adr )
-   dup 6 + seg:off@  .cstr cr   ( adr )
+   dup l@  h# 41534556 <>       ( adr flag )
+   abort" VBE info call failed" ( adr )
+\  dup 6 + seg:off@  .cstr cr   ( adr )
    d# 14 + seg:off@             ( 'mode-list )
    dup #vesa-modes 1+           ( 'mode-list #modes )
    /w* dup alloc-mem            ( 'mode-list modes-len adr )
    dup >r swap move r>          ( adr )
-   begin  dup w@ dup h# ffff <>  while  .vesa-mode-info  wa1+  repeat  cr  2drop
+   dup to vesa-modes-adr        ( adr )
+;
+: .vesa-modes  ( -- )
+   vesa-mode-list
+   begin                     ( adr )
+      dup w@ dup h# ffff <>  ( adr mode# flag )
+      exit? 0=  and          ( adr mode# flag )
+   while                     ( adr mode# )
+      .vesa-mode-info  wa1+  ( adr' )
+   repeat  cr                ( adr mode# )
+   2drop                     ( )
+;
+: vesa-mode-match?  ( x y depth mode# -- x y depth mode# match? )
+   dup vesa-mode-info >r          ( x y depth mode# r: adr )
+   3 pick  r@ h# 12 + w@  <>  if  ( x y depth mode# r: adr )
+      r> drop false exit          ( -- x y depth mode# false )
+   then                           ( x y depth mode# r: adr )
+   2 pick  r@ h# 14 + w@  <>  if  ( x y depth mode# r: adr )
+      r> drop false exit          ( -- x y depth mode# false )
+   then                           ( x y depth mode# r: adr )
+   1 pick  r@ h# 19 + c@  <>  if  ( x y depth mode# r: adr )
+      r> drop false exit          ( -- x y depth mode# false )
+   then                           ( x y depth mode# r: adr )
+   r> drop true
 ;
+: find-vesa-mode  ( x y depth -- mode# )
+   vesa-mode-list                        ( x y depth adr )
+   begin  dup w@ dup h# ffff <>  while   ( x y depth adr mode# )
+      swap >r                            ( x y depth mode#  r: adr )
+      vesa-mode-match?  if               ( x y depth mode#  r: adr )
+         nip nip nip  r> drop            ( mode# )
+         exit                            ( -- mode# )
+      then                               ( x y depth mode#  r: adr )
+      drop r> wa1+                       ( x y depth )
+   repeat                                ( x y depth adr )
+   4drop 0
+;   
 
 [ifdef] Commentary
 00.w mode attributes

Modified: cpu/x86/pc/biosload/config-usbkey.fth
==============================================================================
--- cpu/x86/pc/biosload/config-usbkey.fth	Tue May 24 23:16:47 2011	(r2221)
+++ cpu/x86/pc/biosload/config-usbkey.fth	Wed May 25 09:03:39 2011	(r2222)
@@ -17,7 +17,8 @@
 \ create virtual-mode
 create use-root-isa
 create use-isa-ide
-create use-ega
+create use-ega          \ For text-mode display
+\ create use-vesa         \ For graphics-mode display
 create use-elf
 create use-ne2000
 create use-watch-all

Modified: cpu/x86/pc/biosload/devices.fth
==============================================================================
--- cpu/x86/pc/biosload/devices.fth	Tue May 24 23:16:47 2011	(r2221)
+++ cpu/x86/pc/biosload/devices.fth	Wed May 25 09:03:39 2011	(r2222)
@@ -236,6 +236,15 @@
 end-package
 [then]
 
+[ifdef] use-vesa
+0 0  " "  " /" begin-package
+   " display" name
+   " vesa" " compatible" string-property
+   fload ${BP}/dev/video/controlr/vesalfb.fth
+end-package
+devalias screen /display		\ Explicit, because it's not probed
+[then]
+
 [ifdef] use-ct65550
 0 0  " i3b0" " /isa" begin-package
    fload ${BP}/dev/ct6555x/loadpkg.fth	\ Video driver

Modified: cpu/x86/pc/biosload/fw.bth
==============================================================================
--- cpu/x86/pc/biosload/fw.bth	Tue May 24 23:16:47 2011	(r2221)
+++ cpu/x86/pc/biosload/fw.bth	Wed May 25 09:03:39 2011	(r2222)
@@ -183,6 +183,12 @@
 [then]
 [then]
 
+fload ${BP}/cpu/x86/pc/rmtools.fth
+
+[ifdef] syslinux-loaded
+fload ${BP}/cpu/x86/pc/biosload/callvbe.fth
+[then]
+
 fload ${BP}/cpu/x86/pc/biosload/devices.fth
 
 fload ${BP}/dev/scsi/probscsi.fth	\ probe-scsi and probe-scsi-all
@@ -240,14 +246,10 @@
 ;
 
 fload ${BP}/cpu/x86/pc/biosload/usb.fth
-fload ${BP}/cpu/x86/pc/rmtools.fth
+
 fload ${BP}/cpu/x86/pc/biosload/callbios.fth
 \ fload ${BP}/cpu/x86/pc/biosload/rmenter.fth
 
-[ifdef] syslinux-loaded
-fload ${BP}/cpu/x86/pc/biosload/callvbe.fth
-[then]
-
 \ false to stand-init-debug?
 true to stand-init-debug?
 

Modified: cpu/x86/pc/biosload/ofw.bth
==============================================================================
--- cpu/x86/pc/biosload/ofw.bth	Tue May 24 23:16:47 2011	(r2221)
+++ cpu/x86/pc/biosload/ofw.bth	Wed May 25 09:03:39 2011	(r2222)
@@ -157,6 +157,9 @@
 [ifdef] use-vga
    " ${BP}/ofw/termemu/cp881-16.obf"            " font"        $add-deflated-dropin
 [then]
+[ifdef] use-vesa
+   " ${BP}/ofw/termemu/cp881-16.obf"            " font"        $add-deflated-dropin
+[then]
 
 [ifdef] grub-loaded
    ofd @ fsize h# 60 -  pad !      \ file size; store in memory for convenience below

Added: dev/video/controlr/vesalfb.fth
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dev/video/controlr/vesalfb.fth	Wed May 25 09:03:39 2011	(r2222)
@@ -0,0 +1,130 @@
+\ See license at end of file
+purpose: Display driver for VESA linear framebuffer
+
+d# 640 instance value width			  \ Active screen width
+d# 480 instance value height			  \ Active screen height
+d# 32 instance value depth
+d# 640 4 * instance value /scanline		  \ Active screen width
+: (set-resolution)  ( width height depth -- )
+   to depth  to height  to width
+   width  depth 8 /  *  to /scanline
+;
+
+0 value mode#
+0 value old-mode#
+: set-vesa-resolution  ( -- )
+   mode# vesa-mode-info
+   dup h# 10 + w@  to /scanline
+   dup h# 12 + w@  to width
+   dup h# 14 + w@  to height
+   h# 19 + c@ to depth   
+;
+: fb-size  ( -- len )
+   height /scanline *  h# 1000 round-up
+;
+
+h# 200.0000 instance value /mem
+: map-mem  ( -- )
+   mode# vesa-lfb-adr  fb-size  " map-in" $call-parent  to frame-buffer-adr
+;
+: unmap-mem  ( -- )
+   frame-buffer-adr  fb-size    " map-out" $call-parent
+;
+
+headers
+
+: declare-props  ( -- )		\ Instantiate screen properties
+   " width" get-my-property  if  
+      width  encode-int " width"     property
+      height encode-int " height"    property
+      depth  encode-int " depth"     property
+      /scanline  encode-int " linebytes" property
+   else
+      2drop
+   then
+;
+
+: choose-mode  ( -- )
+   mode#  if  exit  then
+   \ Lower-resolution modes scroll faster.  32-bit often works better than 16
+   d#  640 d# 480  d# 32  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d#  640 d# 480  d# 16  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d#  800 d# 600  d# 32  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d#  800 d# 600  d# 16  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d# 1024 d# 768  d# 32  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d# 1024 d# 768  d# 16  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d# 1280 d# 1024 d# 32  find-vesa-mode  ?dup  if  to mode#  exit  then
+   d# 1280 d# 1024 d# 16  find-vesa-mode  ?dup  if  to mode#  exit  then
+   -1 throw
+;
+: init  ( -- )
+   current-vesa-mode to old-mode#
+   choose-mode
+   set-vesa-resolution
+   mode# set-linear-mode
+   map-mem
+   declare-props
+;
+
+: init-hook  ( -- )  ;
+: display-remove  ( -- )  unmap-mem  old-mode# set-vesa-mode  ;
+
+hex
+headers
+
+" display"                      device-type
+" ISO8859-1" encode-string    " character-set" property
+0 0  encode-bytes  " iso6429-1983-colors"  property
+
+: display-selftest  ( -- failed? )  false  ;
+
+: display-install  ( -- )
+   init
+   default-font set-font
+   width  height  over char-width /  over char-height /
+   /scanline  depth  " fb-install" eval
+
+;
+
+' display-install  is-install
+' display-remove   is-remove
+' display-selftest is-selftest
+
+\ We could use the hardware blitter but it's hardly worth the effort.
+\ Modern CPUs can pump bits into memory at a blistering rate.
+
+fload ${BP}/dev/video/common/rectangle16.fth
+
+: save-rectangle  ( n x y w h -- x w y h  n  x y w h )
+   4 roll >r         ( x y w h  r: n )
+   swap -rot         ( x w y h  r: n )
+   r>                ( x w y h  n )
+   4 pick  3 pick    ( x w y h  n  x y )
+   5 pick  4 pick    ( x w y h  n  x y w h )
+;
+
+: text-mode3  ( -- )  3 set-vesa-mode  ;  \ Disable SVGA, thus reverting to text mode
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 FirmWorks
+\ 
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\ 
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\ 
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END



More information about the openfirmware mailing list