Subject: Re: vgahw and so on
To: netbsd-macppc <port-macppc@NetBSD.org>
From: Matthieu Herrb <matthieu.herrb@laas.fr>
List: port-macppc
Date: 07/16/2004 18:11:37
Michael wrote:
> Hello,
> 
> maybe I've found a way to get vgahw to work without too much pain... 
> powerpc/pio.h defines a bunch of macros that mimic the x86 I/O 
> instructions, and after some fiddling I found that I could - sort of - 
> access the IO part of some PCI device after mmap()ing the IO space and 
> using these macros...  maybe it's enough just to mmap the VGA registers 
> ( their location is hardwired and can't be changed ) and use the mmio 
> stuff already found in vgahw - sounds a little frivolous but may work.
> 
> So - questions for the gurus again:
> Is that the 'proper' way to access PCI IO stuff on PowerPCs? Pretend 
> it's memory and use some additional sync instruction after each operation?

XFree86 already provides this level of abstraction, to handle the needed 
cache flushes (and even the various MMIO base adresses for multiple 
cards on different busses attached to different host bridges).

See the xf86{Read,Write}Mmio() functions in 
xc/programs/Xserver/hw/xfree86/common/compiler.h.

> Getting vgahw to work would allow quite a lot of graphics boards to work...

There is a fundamental problem with PCI/AGP vga cards on powerpc (and 
PCI based sparc[64] machines too) that XFree86 doesn't solve correctly 
for now: how to recognize (and handle) a x86 BIOS based card from an 
OpenFirmware based card. For now, the ati and nv drivers have quite a 
bit of #ifdef __powerpc__ code that assume that the card uses OpenFirmware.

In theory you can plug a card using a x86 BIOS as secondary head and get 
it running in you mac (it could even be the primary head if you use a 
serial console of some sort for booting). But the current drivers will 
probably fail to get x86 based cards because of the powerpc specific 
code there. XFree86 needs a way do detect the kind of BIOS at run-time 
and adapt the driver at run-time, not at compile time.

-- 
Matthieu Herrb