[openfirmware] Troubleshooting VGA under qemu?

Marcin Cieslak saper at saper.info
Thu Oct 1 13:50:56 CET 2015


On Thu, 1 Oct 2015, James Cameron wrote:

> >  -vga vmware -> VMWare (15ad:404) - DOES NOT WORK
> 
> For me, "-vga vmware" reproduces your problem.

So, I got a bit further, although I am still puzzled
a bit. It seems like the registers do not work
initially, the first mapping of the fifo area
causes a Page Fault. However, if you never check
for the magic value in the register 0 AND initialize
the driver again - things magically start to work!

The first virtual mapping of fifo ffc00000 causes
a segfault, but the next one works (fifo at ffbf0000).

After this even "detect-version" works. Qemu complains
on stderr about bad depth:

   vmsvga_value_write: Bad bits per pixel: 16 bits

but it's harmless because we switch automatically
to a 32 bit depth. This message helped me to realize
that we actually start hitting registers at some point.

Below is my patch to the tree to get the debug information
out and provide more-or-less correct "reg" property.
At the bottom a complete transcript of a session.

What is a bit special about this device is that we need
to map the registers first, then we need to read
two values (register 15 and 19) and only then
we can determine the sizes of the requested memory
areas (actually those values match those in BARs).
For now I have just hardcoded those values in the
"reg" property, but once we figure out how to get
registers work at an early stage those values should
be entered into the property.

I actually managed to switch console to vmsvga and
it worked.

Marcin

Index: dev/pcibus.fth
===================================================================
--- dev/pcibus.fth	(wersja 3784)
+++ dev/pcibus.fth	(kopia robocza)
@@ -14,8 +14,8 @@
 defer setup-fcodes   ( -- )  ' noop to setup-fcodes
 defer restore-fcodes ( -- )  ' noop to restore-fcodes
 
-false value pcimsg?	\ Optional Debug Msgs
-false value probemsg?	\ Optional Probing Msgs
+true  value pcimsg?	\ Optional Debug Msgs
+true  value probemsg?	\ Optional Probing Msgs
 
 \ The default value for first-io skips the area where built-in ISA
 \ devices normally live, but stays below 64K, in order to work with
@@ -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	(wersja 3784)
+++ dev/video/controlr/vmsvga.fth	(kopia robocza)
@@ -95,6 +95,8 @@
       /fb 0 my-space  h# 0200.0018 +  /fifo  " map-in" $call-parent  to fifo
    then
    3  my-space   h# 04 + " config-w!" $call-parent
+   cr ." map-mem: fifo@" fifo . ." size= " /fifo .
+   cr ." map-mem: fb@" frame-buffer-adr . ." size= " /fb .
 ;
 : unmap-regs  ( -- )  regs  h# 10  " map-out" $call-parent  ;
 : unmap-mem  ( -- )
@@ -110,6 +112,8 @@
 : fifo-next@ ( -- n ) fifo 2 la+ l@  ; : fifo-next! ( n -- ) fifo 2 la+ l!  ;
 : fifo-stop@ ( -- n ) fifo 3 la+ l@  ; : fifo-stop! ( n -- ) fifo 3 la+ l!  ;
 
+: int+  ( adr len n -- adr' len' )  encode-int encode+  ;
+
 : detect-version  ( -- )
    h# 9000.0002 dup 0 reg!  0 reg@ =  if  exit  then
    h# 9000.0001 dup 0 reg!  0 reg@ =  if  exit  then
@@ -116,6 +120,23 @@
    unmap-regs
    abort  \ We don't support version 0
 ;
+
+: 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+ h# 1000000 int+
+   my-address my-space h# 0200.0018 + encode-phys encode+ 0 int+ h# 10000   int+
+   " reg" property
+;
+
+: probe ( -- )
+ \  map-regs
+ \  map-mem
+   set-reg-property
+ \  unmap-mem
+ \  unmap-regs
+;
+
 : init-fb  ( -- )
    depth 7 reg!  7 reg@ depth <>  if  7 reg@  to depth  then
    
@@ -249,7 +270,7 @@
 
 : init  ( -- )
    map-regs
-   detect-version
+   \ detect-version
    map-mem
    init-fb
    init-fifo
Index: dev/video/vmsvga.bth
===================================================================
--- dev/video/vmsvga.bth	(wersja 3784)
+++ dev/video/vmsvga.bth	(kopia robocza)
@@ -12,6 +12,7 @@
 " display" device-name
 
 fload ${BP}/dev/video/controlr/vmsvga.fth	\ VMware-specific words
+probe
 
 end0
 
---------------------end-----------------------------
------------------- output begin --------------------

Script started on Thu Oct  1 15:30:31 2015
command: qemu-system-i386 -m 32 -bios /var/tmp/openfirmware/cpu/x86/pc/emu/build/emuofw.rom -hda fat:/var/tmp/openfirmware/cpu/x86/pc/emu/build -serial stdio -vga vmware
vvfat /var/tmp/openfirmware/cpu/x86/pc/emu/build chs 1024,16,63
WARNING: Image format was not specified for 'json:{"fat-type": 0, "dir": "/var/tmp/openfirmware/cpu/x86/pc/emu/build", "driver": "vvfat", "floppy": false, "rw": false}' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

Forthmacs 
Type 'i' to interrupt stand-init sequence
First stand-init:
Exceptions
CIF
DHCP init
memory node
Probing memory
MMU
Reclaim dictionary
PCI host bridge
ISA
Calibrating millisecond timer
RTC
CPU nodes
Pseudo-NVRAM
Can't read the configuration memory
The configuration memory is invalid.  Using default values.
Sound
Probe IDE
Unimplemented package interface procedure
nvramrc
Probing
probe-pci
PCI PROBE-SELF:  Phys.hi = 0 
  Checking for built-in FCode match for 
  Vendor:8086  Device:1237
  Checking for built-in FCode match... PCI PROBE-SELF:  Phys.hi = 800 
  Checking for built-in FCode match for 
  Vendor:8086  Device:7010
  Checking for built-in FCode match... DROPIN CLASS MATCH 
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 81000000  0  0     
  Checking for built-in FCode match for 
  Vendor:8086  Device:7113
  Checking for built-in FCode match... PCI PROBE-SELF:  Phys.hi = 1000 
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001030  0  0     
Assigning PCI Space of length    10000
Memory Space...
  Base Reg: 2001030  = 11010000 
  Function:15ad  Function: 405
  Non FCode Format ROM Image. 
  Checking for built-in FCode match for 
  Vendor:15ad  Device: 405
  Checking for built-in FCode match... DROPIN NAME MATCH 
PCI PROBE-SELF:  Phys.hi = 1800 
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001830  0  0     
Assigning PCI Space of length    40000
Memory Space...
  Base Reg: 2001830  = 10040000 
  Function:8086  Function:100e
  Non FCode Format ROM Image. 
  Function:8086  Function:100e
  Non FCode Format ROM Image. 
  Function:8086  Function:100e
  Non FCode Format ROM Image. 
  Checking for built-in FCode match for 
  Vendor:8086  Device:100e
  Checking for built-in FCode match... PCI PROBE-SELF:  Phys.hi = 2000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 2800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 3000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 3800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 4000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 4800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 5000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 5800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 6000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 6800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 7000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 7800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 8000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 8800 
Nothing there
PCI PROBE-SELF:  Phys.hi = 9000 
Nothing there
PCI PROBE-SELF:  Phys.hi = 9800 
Nothing there
PCI PROBE-SELF:  Phys.hi = a000 
Nothing there
PCI PROBE-SELF:  Phys.hi = a800 
Nothing there
PCI PROBE-SELF:  Phys.hi = b000 
Nothing there
PCI PROBE-SELF:  Phys.hi = b800 
Nothing there
PCI PROBE-SELF:  Phys.hi = c000 
Nothing there
PCI PROBE-SELF:  Phys.hi = c800 
Nothing there
PCI PROBE-SELF:  Phys.hi = d000 
Nothing there
PCI PROBE-SELF:  Phys.hi = d800 
Nothing there
PCI PROBE-SELF:  Phys.hi = e000 
Nothing there
PCI PROBE-SELF:  Phys.hi = e800 
Nothing there
PCI PROBE-SELF:  Phys.hi = f000 
Nothing there
PCI PROBE-SELF:  Phys.hi = f800 
Nothing there
Assigning PCI Space of length       10
I/O Space...
  Base Reg: 1000920  = 8000 
Assigning PCI Space of length       10
I/O Space...
  Base Reg: 1001010  = 8010 
Assigning PCI Space of length  1000000
Memory Space...
  Base Reg: 2001014  = 10000000 
Assigning PCI Space of length    10000
Memory Space...
  Base Reg: 2001018  = 11000000 
Assigning PCI Space of length    20000
Memory Space...
  Base Reg: 2001810  = 11020000 
Assigning PCI Space of length       40
I/O Space...
  Base Reg: 1001814  = 8040 
USB2 devices:
USB1 devices:
Install console
Generic PC, Serial #0, 32 MiB memory installed
Open Firmware  
Copyright 1999 FirmWorks  All Rights Reserved

Open Firmware demonstration version by FirmWorks (info at firmworks.com)
Type any key to interrupt automatic startup
6 
5 
4 
3 
2 
ok select /pci/display at 2
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1001010  0  0     
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001014  0  0     
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001018  0  0     
map-mem: fifo at ffc00000 size= 10000 
map-mem: fb at ffc00000 size= 1000000 vmsvga_value_write: Bad bits per pixel: 16 bits
Page Fault
ok dev /pci/display at 2
ok 0 reg@ .
90000002 
ok select /pci/display at 2
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1001010  0  0     
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001014  0  0     
PCI-MAP-IN: Bus: 0 , MEM, PCI PHYS.HI..LO = 2001018  0  0     
map-mem: fifo at ffbf0000 size= 10000 
map-mem: fb at fe800000 size= 1000000 vmsvga_value_write: Bad bits per pixel: 16 bits

ok use-ks
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 81000000  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1000920  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 81000000  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1000920  0  0     input-device =  keyboard
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 81000000  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1000920  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 81000000  0  0     
PCI-MAP-IN: Bus: 0 , I/O, PCI PHYS.HI..LO = 1000920  0  0     output-device =  screen
ok install-console
ok power-off

Script done on Thu Oct  1 15:31:56 2015




More information about the openfirmware mailing list