Texas Instruments TNETE100A Network Card User Manual


 
Internal Registers
2-13
ThunderLAN Registers
is used to set the network transmit commit level. The
BSIZEreg register is used
to set the bus burst size on both Tx and Rx frames.
The internal registers are accessed via the DIO_DATA and DIO_ADR host
registers. DIO_ADR holds the DIO address of the register. The data is then
read from or written to DIO_DATA.
Before one can write to an internal register, one must find the proper address
for the host registers to use as pointers to the internal register block, and de-
cide whether to use the memory pointer or the I/O port pointer value. Following
is an example of x86 C code to access a byte from an internal register using
the I/O port pointer value:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// DioRdByte() – Read byte from adapter internal register
//
// Parameters:
// base_addr WORD base address of TLAN internal registers
// addr WORD offset of register to read
//
// Return val:
// BYTE value read
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––
BYTE DioRdByte(WORD base_addr, WORD addr)
{
outpw(base_addr+OFF_DIO_ADDR, addr);
return(inp((base_addr+OFF_DIO_DATA) + (addr&3)));
}
The address of the register being read is determined by the calling program
and is passed to this routine as a parameter, along with the the I/O base ad-
dress. An output is executed to the DIO_ADR host register as part of setting
up the pointer address. In x86 architectures, there are separate instructions
for 16-bit port writes and 8-bit port writes; the 16-bit version is used to write all
the address field’s 16 bits in one operation. Internally, this causes the data from
the internal register at that address to be deposited in the DIO_DATA host reg-
ister. A byte read of the data register gets the LSbyte (addr&3). A more sophis-
ticated routine honors the address of the byte specifically requested and sees
that those eight bits are shifted down to a byte to be returned. If you want to
read a whole word from one of the internal registers (32 bits), you could per-
form two 16-bit reads and merge the values to be returned as a 32-bit value
like this: