Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing physical addresses in protected mode

19 views
Skip to first unread message

Johann 'Myrkraverk' Oskarsson

unread,
May 27, 2020, 2:10:40 PM5/27/20
to
Dear c.o.m.programmer,

How would I map a physical address into my process address space
in an extended program? Specifically, CauseWay with OpenWatcom.

I am experimenting with PCI device access. I am able to read the
physical address from the config address space with the outpd()/
inpd() functions; specifically d0000008 in my case (3Dfx Voodoo
in DOSBox). And predictably, if I try it directly, I get an
exception thrown.

--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk

Johann 'Myrkraverk' Oskarsson

unread,
May 27, 2020, 3:10:35 PM5/27/20
to
On 28/05/2020 2:10 am, Johann 'Myrkraverk' Oskarsson wrote:
> Dear c.o.m.programmer,
>
> How would I map a physical address into my process address space
> in an extended program?  Specifically, CauseWay with OpenWatcom.
>
> I am experimenting with PCI device access.  I am able to read the
> physical address from the config address space with the outpd()/
> inpd() functions; specifically d0000008 in my case (3Dfx Voodoo
> in DOSBox).  And predictably, if I try it directly, I get an
> exception thrown.
I figured this out. I use DPMI to convert the address. This is the
code.

union REGS registers = { 0 };
registers.w.ax = 0x0800u;
registers.w.bx = (uint32_t)bar >> 16u;
registers.w.cx = (uint32_t)bar & 0xffffu;
registers.w.si = 0x0100u; // 16MB according to the manual.
registers.w.di = 0x0000u; // unnecessary.
uint32_t error = int386( 0x31u, &registers, &registers );

if ( registers.w.cflag ) {
printf( "Error %08x\n", error );
return error;
}

// Then the real pointer is in
uint32_t *voodoo = registers.w.bx << 0x10u | registers.w.cx;

T. Ment

unread,
May 27, 2020, 5:21:15 PM5/27/20
to
On Thu, 28 May 2020 03:10:31 +0800, Johann 'Myrkraverk' Oskarsson wrote:

>> I am experimenting with PCI device access.  I am able to read the
>> physical address from the config address space with the outpd()/
>> inpd() functions; specifically d0000008 in my case (3Dfx Voodoo
>> in DOSBox).  And predictably, if I try it directly, I get an
>> exception thrown.

> I figured this out. I use DPMI to convert the address.

Glad you worked it out, DOSBox and all. Curious about your goal.


Johann 'Myrkraverk' Oskarsson

unread,
May 27, 2020, 5:36:11 PM5/27/20
to
The original goal was to satisfy my need to poke hardware. Now that
I've succeeded, I'm wondering if I can make it do something useful
without going through drivers like Glide, for which some versions
can be had on sourceforge, but I'm also reading the hardware manual
of the voodoo card.

Going from a hardware manual to /something useful/ isn't trivial, so
I'll probably take a look at the Glide source code and/or try to instru-
ment some games.

I'm also attempting to get hold of a real 3Dfx voodoo, but I have no
idea if that'll be successful, given the state of international shipping
these days.
0 new messages