[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: Accessing memory with TNT
- To: Mailing List Recipients <pci-sig-request@znyx.com>
- Subject: re: Accessing memory with TNT
- From: Adam Barnes <amb@transtech.co.uk>
- Date: Wed, 28 Aug 1996 13:06:33 +-100
- Resent-Date: Wed, 28 Aug 1996 13:06:33 +-100
- Resent-From: pci-sig-request@znyx.com
- Resent-Message-Id: <"fhtgg3.0.FU3.CL59o"@dart>
- Resent-Sender: pci-sig-request@znyx.com
>> I am using PharLap's TNT Extender trying to write some code
>> to access share memory on some network adapter board.
>> From the Base Address Register, looks like the board is
>> mapped to 0xF0000000. Now, what system call in TNT (or other
>> ways) can I use to read and write this memory?
>> I've tried all these _dx_??? routines and still couldn't get
>> it to work. May be I wasn't using them right. One more
>> thing, I am using Microsoft Visual C 2.0.
>> Thank you
>> Henry Lau
Try the following at your own risk!
(Based largely on reading section 11.11
of the TNT DOS-Extender Reference Manual).
Compile with:
cl /c filename.c
386link @msvc32.dos filename.obj
/****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <pharlap.h>
#include <pldos32.h>
int map_phys( int phys_base, int size, int *lin_base )
{
CONFIG_INF config ;
UCHAR buf[256] ;
int *p ;
int mypages ;
int mybase ;
int err ;
mybase = phys_base & 0xFFFFF000 ;
mypages = ( size / 4096) ;
if (mypages == 0)
mypages = 1 ;
_dx_config_inf(&config, buf) ;
err = _dx_map_phys( config.c_ds_sel, mybase, mypages, (ULONG *)(&p) ) ;
switch( err )
{
case 0: break ;
case 130: printf( "_dx_map_phys: not supported in this DPMI\n" ) ;
exit( 1 ) ;
case 9: printf( "_dx_map_phys: invalid segment selector\n" ) ;
exit( 1 ) ;
case 8: printf( "_dx_map_phys: insufficient memory for page tables / -NOPAGE\n" ) ;
exit( 1 ) ;
default: printf( "\n\n_dx_map_phys: unknown failure (0x%X)\n", err ) ;
exit( 1 ) ;
}
*lin_base = ((phys_base - mybase) + (int)p ) ;
}
main()
{
int *mem ;
map_phys( 0xF0000000, 0x100000, (int *)&mem ) ;
// mem[X] now corresponds (in this case) to the dword
// at offset X of the 1Mb region at 0xF0000000
// (for 8-bit access declare variable 'mem' as a 'char *')
}
/****************************************************************************/
Adam Barnes
Transtech Parallel Systems
amb@transtech.co.uk
š Ì ¼