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, ®isters, ®isters );
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;