|
Part 2: Ethernet-Equipped
RabbitCore Modules
by Fred Eady
Start
• The Networking Core
• Code Names and Comedy
• Where and Why • Completing
Initialization Down
to Business • Now What?
• Sources and PDF
DOWN TO BUSINESS
The first order of
business is to make sure you’re pointed at port
D, which is mimicking the ’9346 data. After that’s
done using the predefined EEPORT variable,
the first thing a real ’9346 wants to see is a start
bit transmitted by the RTL8019AS in Auto-Load mode.
Because the RTL8019AS wants to read the ’9346, a
2-bit Read opcode (10) is clocked out of
the RTL8019AS EEPROM pins. The next thing the ’9346
expects is 6 bits of address information. The RCM2100
microprocessor doesn’t care about the address, so
the code just counts the address clock pulses and
goes on to the next task.
And that task is sending
data to the RTL8019AS that would normally come from
a real ‘9346 configuration EEPROM. The ’9346 responds
to a Read command by clocking out the 16
bits of data at the requested address preceded by
a zero bit. Because you’re really not storing any
vital data in your virtual ’9346, the routine sends
the 16-bit sequence 0x3030 one time. The iteration
count is controlled by the value of register C.
The ‘9346 emulation routine then just sits and waits
long enough for the ’9346 read to complete and sets
the EEDO line level to zero.
Knowing what was and
wasn’t transferred from the ’9346, looking ahead
in the code tells you that you will need an Ethernet
or MAC address to continue with the initialization
process. These hardware addresses, or organizationally
unique identifiers (OUIs), are administered by the
IEEE. The MAC address is a 6-byte identifier with
the first three bytes containing an IEEE-assigned
manufacturer code. The last three bytes are the
unique station ID assigned by the manufacturer.
An array called EthAddress1 is loaded with the RCM2100’s
preassigned MAC address. Although technically the
I/O base address of the RTL8019AS is 0x300 from
its perspective, the I/O base from the RCM2100’s
microprocessor’s perspective is the value of PD_WR1,
which you know is 0xC000. So, a call to the rt_init
function with the MAC address and microprocessor’s
I/O base value will help finish the process.
Listing
6 begins the
final phase of the RTL8019AS hardware initialization
by loading the index register IX with the base I/O
address, you’ll need to finish loading data into
the RTL8019AS internal configuration registers.
After a jump to page one, the RTL8019AS is stopped
and the 6-byte MAC address is written to physical
address registers PAR#0–5.
Just in case this isn’t
the first time this function has been called and
there is activity on the Ethernet, the RTL8019AS
is halted. The 1.6-ms wait is long enough to allow
any transmit or receive activity to complete before
continuing. The RTL8019AS’s data configuration register
is loaded with 0x58, which essentially puts the
NIC in a normal state. The DMA byte count registers
are cleared and the DMA start address is positioned
at the beginning of the on-chip SRAM at 0x4000.
Normally, this chunck of memory would be carved
out of an external SRAM. In either place, it’s officially
called the buffer ring. The buffer ring is a contiguous
set of fixed-length 256-byte buffers. The RTL8019AS
is put into Monitor mode and placed in loop-back
to avoid putting anything that falls into the 8-byte
FIFO into the buffer ring memory.
The receive buffer
ring is delimited by the values in PD_PAGESTART
and PD_PAGESTOP. The DMA function sees this
buffer area as a logical ring. So, when the DMA
address reaches the Page Stop (PSTOP) address, the
DMA address is reset to the Page Start (PSTART)
address. The static PSTART and PSTOP registers are
used in conjunction with two volatile registers,
Current Page (CURR) and Boundary Pointer.
Because each buffer
area in the receive buffer ring is on a 256-byte
boundary, values placed in the Page Start and Boundary
(BNRY) registers must be multiplied by 256. So,
the receive buffer area begins at 0x4600 as 0x46
is loaded into the Page Start register of the RTL8019AS.
The Boundary Pointer
register is used to point to a packet in the receive
buffer ring that has not been picked up by the RCM2100
microprocessor. Because you are in a Reset mode,
the Boundary Pointer is set to match the Page Start
location of 0x4600. In normal operation, each time
a packet is removed from the ring for processing,
the Boundary Pointer is incremented. The end of
the receive ring buffer is defined in Listing 1
as 0x60 in the PD_PAGESTOP definition. This Page
Stop register value sets the optimal receive buffer
ring size for 8-bit operations. Even though the
Realtek has 16 Kb of memory, only 8 Kb is accessible
when using the 8-bit interface. If you could access
the full 16-Kb range, the top of the receive ring
would be 0x8000 instead of 0x6000.
After clearing the
interrupt flags, the Transmit Page Start register
(PD_TXPAGE) points back to the beginning of the
RTL8019AS SRAM. Your receive buffer starts a bit
more than one full Ethernet packet (0x600 bytes)
from the beginning of SRAM and the beginning of
the transmit buffer. Before you turn the RTL8019AS
loose, it would be a good idea to point to the beginning
of the receive ring buffer so the first incoming
packet won’t flow into the transmit buffer at the
beginning of SRAM. After this is done, the code
exits Monitor mode and Loop-back mode, sets up to
listen to the ether, and clears any interrupt flags
that may have popped up. If the RCM2100 is attached
to an active Ethernet network, the activity and
link LEDs illuminate and the Ethernet hardware is
on the air.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for
engineers. Visit www.circuitcellar.com
for more information and additional articles.
For subscription information, call (860) 875-2199,
subscribe@circuitcellar.com
or subscribe
online. ©Circuit Cellar, the Magazine for Computer
Applications. Posted with permission. |