⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 using.phtml.htm

📁 嵌入式系统的TCP/IP源代码
💻 HTM
📖 第 1 页 / 共 2 页
字号:
uses the first 6 bytes at the start of array to program the NIC with the
MAC address programmed on the card. You could, but not recommended is to
program the NIC with your own MAC address. If you have multiple NICs on
the network with the same MAC address, you will create communication problems
- enough said.</P>

<P><A NAME="Multibyte"></A><B>Multibyte:</B> Along with receiving normal
packets addressed for the MAC address of the card, you can also program
the card to accept Multicast packets. Normally, the value of this should
be 00h. See the 8390 datasheet for an explanation of this feature. Normally,
leave this value at 00h.</P>

<P><A NAME="eidebug"></A><B>EIDebug:</B> For production code, set this to
FALSE (0). Leaving this active will display some diagnostic messages if
certain conditions are met, i.e. unknown interrupt.</P>

<P><A NAME="rxbuffer"></A><B>RXBuffer:</B> This is the location of the start
of the receive buffer. If the EI_RXD variable is true, then the data in
this buffer is deemed to be valid and required to be processed. The maximum
length of data in this buffer will not exceed 1540 bytes, which the standard
MTU (Maximum Transmission Unit) used on ethernet. The length of the buffer
can be shorter, but should a packet be received which is longer than the
buffer it will overwrite other areas of memory! The data from the NIC is
entered into the buffer with the following characteristics:<BR>
<TABLE BORDER="1" HEIGHT="132" CELLSPACING="2" CELLPADDING="0">
<TR>
<TH><P ALIGN=LEFT>Representation</TH>
<TH WIDTH="266"><P ALIGN=LEFT>Function</TH>
<TH><P ALIGN=LEFT>Number of Bytes</TH></TR>
<TR>
<TD>Frame Status</TD>
<TD WIDTH="266">Status of the received frame.</TD>
<TD>1</TD></TR>
<TR>
<TD>Next Packet Pointer</TD>
<TD WIDTH="266">Pointer to pointer to the next received packet</TD>
<TD>1</TD></TR>
<TR>
<TD>Length</TD>
<TD WIDTH="266">Length of the frame</TD>
<TD>2, low byte first</TD></TR>
<TR>
<TD>Source Address</TD>
<TD WIDTH="266">MAC address of the card that the frame is destined for</TD>
<TD>6</TD></TR>
<TR>
<TD>Destination Address</TD>
<TD WIDTH="266">MAC Address of the card that sent the packet</TD>
<TD>6</TD></TR>
<TR>
<TD>Type of Service</TD>
<TD WIDTH="266">Type of packet, i.e 0800h = IP, 0806h = ARP</TD>
<TD>2</TD></TR>
<TR>
<TD HEIGHT="22">REST OF FRAME</TD>
<TD WIDTH="266" HEIGHT="22">Remaining data within the frame. Will include other headers, i.e. IP.</TD>
<TD HEIGHT="22">1...1518 bytes</TD></TR>
</TABLE>
The length of the actual frame required for processing is calcutated with
the following formula: LENGTH (Bytes 2 and 3) - 18. The Frame Status and
Next Packet Pointer are copied for completeness, but are of no value to
the programmer. The remaining bytes before the REST OF FRAME are required
for transmit data formation and Type Of Service program branching.</P>

<P><A NAME="txbuffer"></A><B>TXBuffer: </B>This points to the start of the
transmit buffer. This buffer should be set the size of the largest transmitted
packet + 14 bytes. The format of the transmit packet is as follows:</P>

<P><TABLE BORDER="1" CELLSPACING="2" CELLPADDING="0">
<TR>
<TH WIDTH="100"><P ALIGN=LEFT>Description</TH>
<TH WIDTH="268"><P ALIGN=LEFT>Description</TH>
<TH><P ALIGN=LEFT>Number of Bytes</TH></TR>
<TR>
<TD WIDTH="100">Destination Address</TD>
<TD WIDTH="268">MAC Address of the computer to send the packet too</TD>
<TD>6</TD></TR>
<TR>
<TD WIDTH="100">Source Address</TD>
<TD WIDTH="268">MAC Address of this device, ie. of the NIC</TD>
<TD>6</TD></TR>
<TR>
<TD WIDTH="100" HEIGHT="28">Type of Service</TD>
<TD WIDTH="268" HEIGHT="28">Type of information the packet contains, i.e. 0806 = ARP, 0800 = IP</TD>
<TD HEIGHT="28">2</TD></TR>
<TR>
<TD WIDTH="100">REST OF FRAME</TD>
<TD WIDTH="268">Rest of the frame data, includes IP, ARP etc header and data. Note</TD>
<TD>1...</TD></TR>
</TABLE>
Note that no range checking of the size of the packet is performed. It is
up to the programmer to make sure that the size of the packet exceeds 50
bytes, and is less than 1518 bytes. Should the packet be less than 50 bytes,
some network cards will reject the packet, and not pass it up to the stack.
This also happens if the length of the packet exceeds 1518 bytes.</P>

<P><FONT SIZE=+2>System Variables:</FONT></P>

<P><A NAME="eitxing"></A><B>ei_Txing: </B>This flag is set to true if the
NIC is sending data onto the network. It is used to prevent sending more
than one packet at a time. This flag is cleared within the interrupt subroutine
when an end of transmit interrupt occurs. If the program is transmitting
multiple packets, it should check the status of this flag before beginning
to assemble the next packet for transmittion and confirm that it is set
to false.</P>

<P><A NAME="eirxd"></A><B>ei_RXD:</B> This flag is set to TRUE if the data
in the Receive buffer should be processed. This is the only system variable
that the programmer should modify. Once the packet has been processed, the
programmer should clear this flag, otherwise no further packets will be
transferred from the NIC to the receive buffer. After this flag is cleared,
the subroutine <TT>EIGETPACKET</TT> should be called to retreive the next
packet from the NIC should it exist. If you do not call the <TT>EIGETPACKET</TT>
routine after clearing the flag, any packets waiting in the NIC will not
retrieved until the next interrupt at which time only one packet will be
retreived.</P>

<P><A NAME="dmaing"></A><B>DMAING:</B> This value is set to TRUE if data
is being transferred to or from the NIC. DO NOT change the value of this
variable, otherwise unpredictable results may occur.</P>

<P><A NAME="nextpage"></A><B>Next_Page:</B> Holds the page location of the
next packet to be retreived from the NIC. <TABLE BORDER="1" BGCOLOR="#FF6633"
CELLSPACING="2" CELLPADDING="0">
<TR>
<TD BGCOLOR="#ff6600"><P ALIGN=CENTER><B><FONT COLOR="#FFFF00">DO NOT CHANGE THIS VARIABLE. Doing
so WILL cause packets to be lost within the NIC. It may even cause the NIC
to stop responding.</FONT></B></TD></TR>
</TABLE>
</P>

<P ALIGN=CENTER><HR><B>&lt;---------- SUBROUTINES ----------&gt;</B></P>

<P><A NAME="Int8390"></A><B>INT8390<BR>
</B><I>ON EXTRY:</I> NIL<BR>
<I>ON EXIT: </I>NIL<BR>
<I>DESTROYS: </I>NOTHING<BR>
As this code relies on an interrupt from the card to signal various states
of the card, a branch to INT8390 is required either at the INT0 or INT1
interrupt address of the card. This routine contains a RETI instruction,
so an LJMP or AJMP instruction is all that is required. The interrupt routine
performs the following functions:</P>

<OL>
  <LI>Saves the Program status register and changes the Microprocessor to
  use register bank 1
  <LI>Saves working registers
  <LI>Changes P2 to the value of the <TT>IOADDR</TT> byte
  <LI>Get the interrupt value from the NIC
  <LI>If the NIC signals that it has received a packet, and the <TT>EI_RXD</TT>
  flag is false, then the interrupt routine will call the <TT>EIGETPACKET
  </TT>subroutine to load a packet from the NIC into the <TT>RXBuffer</TT>.
  <LI>repeats steps 3 and 4 until all interrupts have been serviced
  <LI>restore working registers
  <LI>Restores PSW thereby returning selected register bank to pre-interrupt
  state
</OL>

<P>NOTE: Do not under any cercumstances atttempt to send a packet while
still in the interrupt routine. This will cause the NIC to stop. The only
way to overcome this is to use the reset button.</P>

<P><A NAME="Probe8390"></A><B>PROBE8390<BR>
</B><I>ON ENTRY: </I>NIL<BR>
<I>ON EXIT:</I> Carry flag reports status of the operation. if CF set, Accumulator
holds error value, otherwise Accumulator intederminate.<BR>
<I>DESTROYS:</I> R1, R2, R3, R4, P2<BR>
<I>FUNCTION:</I> To attempt to locate an 8390 compatible chipset NIC card
located on the IOADDR page boundary. If the operation is successful, the
CF is cleared, and the SAPROM contains valid information. If the search
for the card is unsuccessful, the CF bit is set, and the accumulator holds
the error code. Possible error codes are:</P>

<UL>
  <LI><I>NoCardFound</I> - Unable to locate, or communicate with a NIC. Chances
  are the IOADDR equate does not correspond to the page boundary that the
  NIC is on.
  <LI><I>NoResetAck</I> - Found a card, but did not get a return an acknowledgement
  to the reset function. Same symptons as for <I>NoCardFound</I>.
  <LI><I>NoIRQFound </I>- Found a card, can communicate with it, but no acknowlegement
  to an interrupt. Check to make sure that the IRQ number programmed into
  the NIC, and the line that you have attached to the microprocessor are
  the same. Also, make sure that the interrupt is active and enabled.
</UL>

<P><A NAME="NS8390_Init"></A><B>NS8390_INIT<BR>
</B><I>ON ENTRY: </I>The first 6 bytes of the SAPROM array MUST contain
a the bytes for the MAC address.<BR>
<I>ON EXIT: </I>No status, it is assumed that this will finish with out
error. MAKE SURE THAT PROBE8390 is executed before this for error detection,
as well as to get the MAC address from the NIC.<BR>
<I>DESTROYS:</I> P2, R1, R2, Accumulator, DPTR<BR>
<I>FUNCTION:</I> Initializes the card, and turns on the Transmit and Receive
buffers. When this call completes, packets can be sent and received. This
routine can be called at any time to reset the NIC.</P>

<P><A NAME="EIGetPacket"></A><B>EIGETPACKET<BR>
</B><I>ON ENTRY:</I> <TT>EI_RXD</TT> flag set accordingly (see below)<BR>
<I>ON EXIT:</I> <TT>EI_RXD</TT> flag, if cleared upon entry will be set
if a packet has been transferred from the NIC to the Receive buffer.<BR>
<I>DESTROYS:</I> P2<BR>
<I>FUNCTION:</I> To retrieve a packet from the NIC if one is waiting. If
<TT>EI_RXD</TT> is set upon entry to this routine, the routine will exit
as the receive buffer is flagged as containing valid data. If the <TT>EI_RXD</TT>
flag is clear upon entry to this routine and a packet is waiting in the
NIC for retrieval, then the packet is transferred to the ReceiveBuffer and
this flag set. The interrupt to the NIC is switched off during the data
transfer.</P>

<P><A NAME="SendPacket"></A><B>SENDPACKET<BR>
</B><I>ON ENTRY:</I> DPTR points to the data to be transmitted. R3/R4 contains
the length of the data to be transferred.<BR>
<I>ON EXIT: </I>No exit code. Assume success.<BR>
<I>DESTROYS:</I> CF, Accumulator, P2, R1<BR>
<I>FUNCTION:</I> To send a packet pointed to by DPTR onto the ethernet network.
No checks are performed on the data to confirm validity. To be a valid ethernet
packet, the minimum size if the packet shall be no less than 60 bytes or
greater than 1518 bytes. The NIC interrupt is turned off during the transmit
to prevent any extraneous errors. <TABLE BORDER="1" BGCOLOR="#FF6633" CELLSPACING=
"2" CELLPADDING="0">
<TR>
<TD BGCOLOR="#ff6600"><P ALIGN=CENTER><B><FONT COLOR="#FFFF00">DO NOT call this routine from within
an interrupt routine. Doing so will stop the network card.</FONT></B></TD></TR>
</TABLE>
</P>

<P ALIGN=CENTER><A HREF="index.phtml">Home</A></TD></TR>
</TABLE>
</BODY>
<HR>
<CENTER><FONT SIZE=1>
(C) Copyright 1997 - 2001 by <A HREF="http://www.vaultbbs.com">Vault Information Services</A>.  All Rights Reserved.<BR>
Information provided "as-is" without warranty.  Please <A HREF="../disclaim.htm">see details</A>.<BR>
<A HREF="../contact.htm">Contact us</A> for usage and copy permission.<BR>
</H6></CENTER><BR>
</TD></TR></TABLE>
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>


	
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -