[haiku-development] Re: S3 Virge video driver

  • From: Philippe Houdoin <philippe.houdoin@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 21 Jul 2007 01:03:10 +0200

Quoting Gerald Zajac <zajacg@xxxxxxxxxxxxx>:

> If I interpret the above correctly, the code to perform this action
> should be in the driver instead of the accelerant.

Yes, as since R4 the kernel don't export anymore functions to access from
userland PCI bus. That's why since we have a kernelland driver and a userland
accelerant.

  In the driver there
> currently is code to map the MMIO register area by calling
> map_physical_memory().  After this code, I'm planning to insert the code
> to enable MMIO.

Yep, that the way to follow.

> Since these video cards are either AGP or PCI cards, should I be using
> PCI I/O instead of ISA I/O or will either accomplish the same thing
> since I'm only trying to read/write some values in the MMIO area?

Use PCI module to access the card PCI configuration, find out its MMIO physical
address, map this in virtual memory space and enable card MMIO mode by changing
it's PCI configuration (cf Jerome code snippet).

ISA module is only usefull these days for legacy devices like UARTs, NE2000
oldies & co that still use ISA space instead of PCI one.

> Since I'm trying to access values in the MMIO area, is the port address
> the mapped address of the MMIO area plus the offset of the value in the
> MMIO area?

Well, I was showing how to access a ISA IO port, which usually exposed some
registers at well-known fixed addresses. These ISA I/O "ports" are not mapped,
contrary to MMIO.

For MMIO, accessing them is only a matter to map them in virtual memory and
access this memory. Most of the time, registers & co are defined as offset from
the base of MMIO. Base of the mapping in virtual memory + offset give you the
address to read or write. Directly:

*(base + offset)

> Yes, Thanks for the info.  I did not know how to setup to use the
> read_io/write_io functions.

The pre-R4 read_io/write_io* and read/write_pci_config() functions exported by
libroot.so are since available only from kernelland, via the ISA and PCI
modules.
In your case, as the card is a PCI one, the PCI module should give you what you
lack to port this old Virge driver...

Philippe.

Other related posts: