[openfirmware] Troubleshooting VGA under qemu? [patch]

Marcin Cieslak saper at saper.info
Thu Oct 1 22:36:24 CET 2015


On Fri, 2 Oct 2015, James Cameron wrote:

> Thanks.
> 
> Some quick thoughts;
> 
> Suggest borrowing my-w@ and my-w! from other drivers instead

done

> Several other drivers also impose a symmetry and undo in unmap-regs

done

> Is needed?

not sure, it works. Only right now qemu reports 4x more PCI remappings
done

> > +: set-reg-property
> > +   my-address my-space encode-phys                        0 int+ h# 0    int+
> > +   my-address my-space h# 0100.0010 + encode-phys encode+ 0 int+ h# 10   int+
> > +   my-address my-space h# 0200.0014 + encode-phys encode+ 0 int+ /fb     int+
> > +   my-address my-space h# 0200.0018 + encode-phys encode+ 0 int+ /fifo   int+
> > +   " reg" property
> > +;
> 
> Most other drivers set this property at load time outside the colon
> definitions; is there a reason for doing it after map-regs?

That's a whole point here - /fb and /fifo are taken from the mapped registers.

Some other video drivers have a more sophisticated machinery to construct
that property - encode-reg-property, >reg-props

Unfortunately I cannot test it on a real "hardware", i.e. under VMware :)

Marcin

Index: dev/pcibus.fth
===================================================================
--- dev/pcibus.fth	(revision 3784)
+++ dev/pcibus.fth	(working copy)
@@ -1183,7 +1183,8 @@
             4                                               ( increment )
          then                                               ( increment )
       +loop
-
+   else
+      " reg property missing!" diag-type-cr
    then
    r> finish-aa-property
 ;
Index: dev/video/controlr/vmsvga.fth
===================================================================
--- dev/video/controlr/vmsvga.fth	(revision 3784)
+++ dev/video/controlr/vmsvga.fth	(working copy)
@@ -39,6 +39,9 @@
 : reg@  ( index -- value )  regs rl!  regs 1+ rl@  ;
 : reg!  ( value index -- )  regs rl!  regs 1+ rl!  ;
 
+: my-w@  ( offset -- w )  my-space +  " config-w@" $call-parent  ;
+: my-w!  ( w offset -- )  my-space +  " config-w!" $call-parent  ;
+
 \ Here are the register numbers.  Most of these registers are
 \ accessed only once, so I don't define access words for many of them.
 \ (W) means that it is meaningful for you to write to this register
@@ -85,6 +88,7 @@
 h# 200.0000 instance value /mem
 : map-regs  ( -- )
    0 0 my-space h# 0100.0010 +  h# 10  " map-in" $call-parent to regs
+   4 my-w@ 1 or 4 my-w!
 ;
 : map-mem  ( -- )
    my-space h# 14 +  " config-l@" $call-parent   if
@@ -94,12 +98,16 @@
       0   0 my-space  h# 0200.0018 +  /fb    " map-in" $call-parent  to frame-buffer-adr
       /fb 0 my-space  h# 0200.0018 +  /fifo  " map-in" $call-parent  to fifo
    then
-   3  my-space   h# 04 + " config-w!" $call-parent
+   4 my-w@ 2 or 4 my-w!
 ;
-: unmap-regs  ( -- )  regs  h# 10  " map-out" $call-parent  ;
+: unmap-regs  ( -- )
+   regs  h# 10  " map-out" $call-parent
+   4 my-w@ 1 invert and 4 my-w!
+;
 : unmap-mem  ( -- )
    fifo              /fifo  " map-out" $call-parent
    frame-buffer-adr  /fb    " map-out" $call-parent
+   4 my-w@ 2 invert and 4 my-w!
 ;
 
 \ Min and Max are the static limits of the FIFO area.
@@ -116,6 +124,23 @@
    unmap-regs
    abort  \ We don't support version 0
 ;
+
+: int+  ( adr len n -- adr' len' )  encode-int encode+  ;
+
+: set-reg-property
+   my-address my-space encode-phys                        0 int+ h# 0    int+
+   my-address my-space h# 0100.0010 + encode-phys encode+ 0 int+ h# 10   int+
+   my-address my-space h# 0200.0014 + encode-phys encode+ 0 int+ /fb     int+
+   my-address my-space h# 0200.0018 + encode-phys encode+ 0 int+ /fifo   int+
+   " reg" property
+;
+
+: probe ( -- )
+   map-regs
+   set-reg-property
+   unmap-regs
+;
+
 : init-fb  ( -- )
    depth 7 reg!  7 reg@ depth <>  if  7 reg@  to depth  then
    
Index: dev/video/vmsvga.bth
===================================================================
--- dev/video/vmsvga.bth	(revision 3784)
+++ dev/video/vmsvga.bth	(working copy)
@@ -12,6 +12,7 @@
 " display" device-name
 
 fload ${BP}/dev/video/controlr/vmsvga.fth	\ VMware-specific words
+probe
 
 end0
 
Service unavailableService unavailableService unavailable



More information about the openfirmware mailing list