📄 eth1.lst
字号:
C51 COMPILER V7.09 ETH1 06/28/2007 11:17:08 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE ETH1
OBJECT MODULE PLACED IN ETH1.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE tcp\ETH1.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\ETH1.lst) OBJECT(ETH1.ob
-j)
line level source
1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2002 Jim Brady
3 // Do not use commercially without author's permission
4 // Last revised August 2002
5 // Net ETH.C
6 //
7 // This module is the Ethernet layer
8 //-----------------------------------------------------------------------------
9
10 #include <stdlib.h>
11 #include "net1.h"
12 #include "serial1.h"
13 #include "arp1.h"
14 #include "ip1.h"
15 #include "eth1.h"
16 #include "utils.h"
17 //#include "mac.h"
18
19
20 #define reg00 XBYTE[0x8000] //reg00- 10为isa网卡接口的寄存器地址300-310;
21 #define reg01 XBYTE[0x8001]
22 #define reg02 XBYTE[0x8002]
23 #define reg03 XBYTE[0x8003]
24 #define reg04 XBYTE[0x8004]
25 #define reg05 XBYTE[0x8005]
26 #define reg06 XBYTE[0x8006]
27 #define reg07 XBYTE[0x8007]
28 #define reg08 XBYTE[0x8008]
29 #define reg09 XBYTE[0x8009]
30 #define reg0a XBYTE[0x800a]
31 #define reg0b XBYTE[0x800b]
32 #define reg0c XBYTE[0x800c]
33 #define reg0d XBYTE[0x800d]
34 #define reg0e XBYTE[0x800e]
35 #define reg0f XBYTE[0x800f]
36 #define reg10 XBYTE[0x8010]
37
38 //bit txd_buffer_select=0; //选择网卡的发送缓冲区
39 extern UCHAR debug;
40 extern UCHAR arpbuf[];
41 extern UCHAR my_hwaddr[];
42
43 void Delay1ms(unsigned char T);
44
45 extern UCHAR rcve_buf_allocated;
46 extern uint volatile event_word;
47
48
49
50 #define Rtl8019ResetLow P5 &= ~(0x4); // P52
51 #define Rtl8019ResetHigh P5 |= 0x4; // P52
52
53 //------------------------------------------------------------------------
54 // Initialize the Cirrus Logic 8019 chip
C51 COMPILER V7.09 ETH1 06/28/2007 11:17:08 PAGE 2
55 //------------------------------------------------------------------------
56
57 void page(unsigned char pagenumber)
58 {
59 1
60 1 }
*** WARNING C280 IN LINE 57 OF TCP\ETH1.C: 'pagenumber': unreferenced local variable
61
62 void Rtl8019AS_Reset() //复位网卡
63 {
64 1
65 1 }
66
67 void ReadRtl8019NodeID(void)//读出网卡的物理地址存到my_ethernet_address.bytes[6]里
68 {
69 1 unsigned char i;
70 1 for (i=0;i<6;i++)
71 1 {
72 2 // my_hwaddr[i]=reg10;
73 2 // my_hwaddr[i]=reg10;
74 2 }
75 1 }
76
77 void WriteRtl8019NodeID()
78 {
79 1 }
80
81 void init_8019(void)
82 {
83 1
84 1 }
85
86 //------------------------------------------------------------------------
87 // This functions checks 8019 status then sends an ethernet
88 // frame to it by calling an assembler function.
89 //------------------------------------------------------------------------
90
91 void send_frame(UCHAR * outbuf, uint len)/*发送一个数据包的命令,长度最小为60字节,最大1514字节*/
92 {
93 1
94 1 // s3c44b0_eth_send(outbuf, len);
95 1 // printf("send packet\n");
96 1 }
*** WARNING C280 IN LINE 91 OF TCP\ETH1.C: 'outbuf': unreferenced local variable
*** WARNING C280 IN LINE 91 OF TCP\ETH1.C: 'len': unreferenced local variable
97
98 //------------------------------------------------------------------------
99 // This functions checks the 8019 receive event status
100 // word to see if an ethernet frame has arrived. If so,
101 // set EVENT_ETH_ARRIVED bit in global event_word
102 //------------------------------------------------------------------------
103 void query_8019(void)
104 {
105 1
106 1 }
107
108 //------------------------------------------------------------------------
109 // This function gets an incoming Ethernet frame from the 8019.
110 // There may be more than 1 waiting but just allocate memory for
111 // one and read one in. Use the 8019 to queue incoming packets.
112 //------------------------------------------------------------------------
113 UCHAR * rcve_frame()//如果收到一个有效的数据包,返回收到的数据,否则返回NULL
C51 COMPILER V7.09 ETH1 06/28/2007 11:17:08 PAGE 3
114 {
115 1 // UCHAR bnry,curr,next_page;
116 1 //
117 1 // uint len, ii;
118 1 // UCHAR temp;
119 1 // UCHAR * buf;
120 1 // if (buf_head!= buf_tail)
121 1
122 1 return NULL;
123 1 }
124
125
126 void eth_send1(UCHAR * outbuf, UCHAR * hwaddr, uint ptype, uint len)
127 {
128 1 ETH_HEADER * eth;
129 1
130 1 eth = (ETH_HEADER *)outbuf;
131 1
132 1 // Add 14 byte Ethernet header]
133 1 //Ethernet V2标准:14 = 目的MAC地址6 byte + 源MAC地址6 byte + 类型(2) = 14, 不包括LLC层
134 1 //现不支持: 802.3标准. MAC数据报文最小长度46 - 1500字节。小于46, 填充0;
135 1
136 1 memcpy((char*)eth->dest_hwaddr, hwaddr, 6); //目的MAC地址6 byte
137 1 memcpy((char*)eth->source_hwaddr, my_hwaddr, 6); //源MAC地址6 byte
138 1 eth->frame_type = ptype; //类型2 byte. 比如0x0800, 表示上层使用IP数据包. =0x8137,
-表示为Novell IPX发过来。
139 1 #ifdef __LITTLEENDIAN__
eth->frame_type = ntohs(eth->frame_type);
#endif
142 1
143 1 // We just added 14 bytes to length
144 1 send_frame(outbuf, len + 14);
145 1 }
146
147 //------------------------------------------------------------------------
148 // This is the handler for incoming Ethernet frames
149 // This is designed to handle standard Ethernet (RFC 893) frames
150 // See "TCP/IP Illustrated, Volume 1" Sect 2.2
151 //------------------------------------------------------------------------
152 void eth_rcve(uint Length, UCHAR* inbuf)
153 {
154 1 ETH_HEADER * eth;
155 1
156 1 eth = (ETH_HEADER *)inbuf;
157 1
158 1 #ifdef __LITTLEENDIAN__
eth->frame_type = ntohs(eth->frame_type);
#endif
161 1
162 1 // Reject frames in IEEE 802 format where Eth type field
163 1 // is used for length. Todo: Make it handle this format
164 1 if (eth->frame_type < 1520)
165 1 {
166 2 return;
167 2 }
168 1 //printf("frame_type %x", eth->frame_type);
169 1 // Figure out what type of frame it is from Eth header
170 1 // Call appropriate handler and supply address of buffer
171 1 switch (eth->frame_type)
172 1 {
173 2 case ARP_PACKET:
174 2 arp_rcve(inbuf);
C51 COMPILER V7.09 ETH1 06/28/2007 11:17:08 PAGE 4
175 2 break;
176 2
177 2 case IP_PACKET:
178 2 #ifdef __LITTLEENDIAN__
eth->frame_type = ntohs(eth->frame_type);
#endif
181 2 ip_rcve(inbuf);
182 2 break;
183 2
184 2 default:
185 2
186 2 break;
187 2 }
188 1 }
*** WARNING C280 IN LINE 152 OF TCP\ETH1.C: 'Length': unreferenced local variable
189
190
191
192
193
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 279 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 24
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 4 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -