mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Cleaning up printouts for debugging of uIP
This commit is contained in:
@@ -1,267 +0,0 @@
|
|||||||
1 ;--------------------------------------------------------
|
|
||||||
2 ; File Created by SDCC : free open source ANSI-C Compiler
|
|
||||||
3 ; Version 4.2.0 #13081 (Linux)
|
|
||||||
4 ;--------------------------------------------------------
|
|
||||||
5 .module hello_world
|
|
||||||
6 .optsdcc -mmcs51 --model-small
|
|
||||||
7
|
|
||||||
8 ;--------------------------------------------------------
|
|
||||||
9 ; Public variables in this module
|
|
||||||
10 ;--------------------------------------------------------
|
|
||||||
11 .globl _uip_listen
|
|
||||||
12 .globl _psock_readto
|
|
||||||
13 .globl _psock_init
|
|
||||||
14 .globl _strtox
|
|
||||||
15 .globl _write_char
|
|
||||||
16 .globl _hello_world_init
|
|
||||||
17 .globl _hello_world_appcall
|
|
||||||
18 ;--------------------------------------------------------
|
|
||||||
19 ; special function registers
|
|
||||||
20 ;--------------------------------------------------------
|
|
||||||
21 .area RSEG (ABS,DATA)
|
|
||||||
000000 22 .org 0x0000
|
|
||||||
23 ;--------------------------------------------------------
|
|
||||||
24 ; special function bits
|
|
||||||
25 ;--------------------------------------------------------
|
|
||||||
26 .area RSEG (ABS,DATA)
|
|
||||||
000000 27 .org 0x0000
|
|
||||||
28 ;--------------------------------------------------------
|
|
||||||
29 ; overlayable register banks
|
|
||||||
30 ;--------------------------------------------------------
|
|
||||||
31 .area REG_BANK_0 (REL,OVR,DATA)
|
|
||||||
000000 32 .ds 8
|
|
||||||
33 ;--------------------------------------------------------
|
|
||||||
34 ; internal ram data
|
|
||||||
35 ;--------------------------------------------------------
|
|
||||||
36 .area DSEG (DATA)
|
|
||||||
37 ;--------------------------------------------------------
|
|
||||||
38 ; overlayable items in internal ram
|
|
||||||
39 ;--------------------------------------------------------
|
|
||||||
40 ;--------------------------------------------------------
|
|
||||||
41 ; indirectly addressable internal ram data
|
|
||||||
42 ;--------------------------------------------------------
|
|
||||||
43 .area ISEG (DATA)
|
|
||||||
44 ;--------------------------------------------------------
|
|
||||||
45 ; absolute internal ram data
|
|
||||||
46 ;--------------------------------------------------------
|
|
||||||
47 .area IABS (ABS,DATA)
|
|
||||||
48 .area IABS (ABS,DATA)
|
|
||||||
49 ;--------------------------------------------------------
|
|
||||||
50 ; bit data
|
|
||||||
51 ;--------------------------------------------------------
|
|
||||||
52 .area BSEG (BIT)
|
|
||||||
53 ;--------------------------------------------------------
|
|
||||||
54 ; paged external ram data
|
|
||||||
55 ;--------------------------------------------------------
|
|
||||||
56 .area PSEG (PAG,XDATA)
|
|
||||||
57 ;--------------------------------------------------------
|
|
||||||
58 ; external ram data
|
|
||||||
59 ;--------------------------------------------------------
|
|
||||||
60 .area XSEG (XDATA)
|
|
||||||
001B2D 61 _handle_connection_buf_65536_59:
|
|
||||||
001B2D 62 .ds 100
|
|
||||||
63 ;--------------------------------------------------------
|
|
||||||
64 ; absolute external ram data
|
|
||||||
65 ;--------------------------------------------------------
|
|
||||||
66 .area XABS (ABS,XDATA)
|
|
||||||
67 ;--------------------------------------------------------
|
|
||||||
68 ; external initialized ram data
|
|
||||||
69 ;--------------------------------------------------------
|
|
||||||
70 .area XISEG (XDATA)
|
|
||||||
71 .area HOME (CODE)
|
|
||||||
72 .area GSINIT0 (CODE)
|
|
||||||
73 .area GSINIT1 (CODE)
|
|
||||||
74 .area GSINIT2 (CODE)
|
|
||||||
75 .area GSINIT3 (CODE)
|
|
||||||
76 .area GSINIT4 (CODE)
|
|
||||||
77 .area GSINIT5 (CODE)
|
|
||||||
78 .area GSINIT (CODE)
|
|
||||||
79 .area GSFINAL (CODE)
|
|
||||||
80 .area CSEG (CODE)
|
|
||||||
81 ;--------------------------------------------------------
|
|
||||||
82 ; global & static initialisations
|
|
||||||
83 ;--------------------------------------------------------
|
|
||||||
84 .area HOME (CODE)
|
|
||||||
85 .area GSINIT (CODE)
|
|
||||||
86 .area GSFINAL (CODE)
|
|
||||||
87 .area GSINIT (CODE)
|
|
||||||
88 ;--------------------------------------------------------
|
|
||||||
89 ; Home
|
|
||||||
90 ;--------------------------------------------------------
|
|
||||||
91 .area HOME (CODE)
|
|
||||||
92 .area HOME (CODE)
|
|
||||||
93 ;--------------------------------------------------------
|
|
||||||
94 ; code
|
|
||||||
95 ;--------------------------------------------------------
|
|
||||||
96 .area BANK1 (CODE)
|
|
||||||
97 ;------------------------------------------------------------
|
|
||||||
98 ;Allocation info for local variables in function 'hello_world_init'
|
|
||||||
99 ;------------------------------------------------------------
|
|
||||||
100 ; hello-world.c:43: hello_world_init(void)
|
|
||||||
101 ; -----------------------------------------
|
|
||||||
102 ; function hello_world_init
|
|
||||||
103 ; -----------------------------------------
|
|
||||||
01A00D 104 _hello_world_init:
|
|
||||||
000007 105 ar7 = 0x07
|
|
||||||
000006 106 ar6 = 0x06
|
|
||||||
000005 107 ar5 = 0x05
|
|
||||||
000004 108 ar4 = 0x04
|
|
||||||
000003 109 ar3 = 0x03
|
|
||||||
000002 110 ar2 = 0x02
|
|
||||||
000001 111 ar1 = 0x01
|
|
||||||
000000 112 ar0 = 0x00
|
|
||||||
113 ; hello-world.c:46: uip_listen(HTONS(1000));
|
|
||||||
01A00D 90 E8 03 [24] 114 mov dptr,#0xe803
|
|
||||||
115 ; hello-world.c:47: }
|
|
||||||
01A010 02 7F C7 [24] 116 ljmp _uip_listen
|
|
||||||
117 ;------------------------------------------------------------
|
|
||||||
118 ;Allocation info for local variables in function 'hello_world_appcall'
|
|
||||||
119 ;------------------------------------------------------------
|
|
||||||
120 ;s Allocated to registers r6 r7
|
|
||||||
121 ;------------------------------------------------------------
|
|
||||||
122 ; hello-world.c:57: hello_world_appcall(void)
|
|
||||||
123 ; -----------------------------------------
|
|
||||||
124 ; function hello_world_appcall
|
|
||||||
125 ; -----------------------------------------
|
|
||||||
01A013 126 _hello_world_appcall:
|
|
||||||
127 ; hello-world.c:64: __xdata struct hello_world_state *s = &(uip_conn->appstate);
|
|
||||||
01A013 74 1C [12] 128 mov a,#0x1c
|
|
||||||
01A015 25 50 [12] 129 add a,_uip_conn
|
|
||||||
01A017 FE [12] 130 mov r6,a
|
|
||||||
01A018 E4 [12] 131 clr a
|
|
||||||
01A019 35 51 [12] 132 addc a,(_uip_conn + 1)
|
|
||||||
01A01B FF [12] 133 mov r7,a
|
|
||||||
134 ; hello-world.c:70: if(uip_connected()) {
|
|
||||||
01A01C 90 0A C8 [24] 135 mov dptr,#_uip_flags
|
|
||||||
01A01F E0 [24] 136 movx a,@dptr
|
|
||||||
01A020 30 E6 1E [24] 137 jnb acc.6,00102$
|
|
||||||
138 ; hello-world.c:71: PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
|
|
||||||
01A023 74 15 [12] 139 mov a,#0x15
|
|
||||||
01A025 2E [12] 140 add a,r6
|
|
||||||
01A026 F5 66 [12] 141 mov _psock_init_PARM_2,a
|
|
||||||
01A028 E4 [12] 142 clr a
|
|
||||||
01A029 3F [12] 143 addc a,r7
|
|
||||||
01A02A F5 67 [12] 144 mov (_psock_init_PARM_2 + 1),a
|
|
||||||
01A02C 75 68 0A [24] 145 mov _psock_init_PARM_3,#0x0a
|
|
||||||
01A02F 75 69 00 [24] 146 mov (_psock_init_PARM_3 + 1),#0x00
|
|
||||||
01A032 8E 82 [24] 147 mov dpl,r6
|
|
||||||
01A034 8F 83 [24] 148 mov dph,r7
|
|
||||||
01A036 C0 07 [24] 149 push ar7
|
|
||||||
01A038 C0 06 [24] 150 push ar6
|
|
||||||
01A03A 12 70 C4 [24] 151 lcall _psock_init
|
|
||||||
01A03D D0 06 [24] 152 pop ar6
|
|
||||||
01A03F D0 07 [24] 153 pop ar7
|
|
||||||
01A041 154 00102$:
|
|
||||||
155 ; hello-world.c:79: write_char('A');
|
|
||||||
01A041 75 82 41 [24] 156 mov dpl,#0x41
|
|
||||||
01A044 C0 07 [24] 157 push ar7
|
|
||||||
01A046 C0 06 [24] 158 push ar6
|
|
||||||
01A048 12 01 D8 [24] 159 lcall _write_char
|
|
||||||
01A04B D0 06 [24] 160 pop ar6
|
|
||||||
01A04D D0 07 [24] 161 pop ar7
|
|
||||||
162 ; hello-world.c:80: handle_connection(s);
|
|
||||||
01A04F 8E 82 [24] 163 mov dpl,r6
|
|
||||||
01A051 8F 83 [24] 164 mov dph,r7
|
|
||||||
165 ; hello-world.c:81: }
|
|
||||||
01A053 02 A0 56 [24] 166 ljmp _handle_connection
|
|
||||||
167 ;------------------------------------------------------------
|
|
||||||
168 ;Allocation info for local variables in function 'handle_connection'
|
|
||||||
169 ;------------------------------------------------------------
|
|
||||||
170 ;s Allocated to registers r6 r7
|
|
||||||
171 ;PT_YIELD_FLAG Allocated to registers
|
|
||||||
172 ;buf Allocated with name '_handle_connection_buf_65536_59'
|
|
||||||
173 ;------------------------------------------------------------
|
|
||||||
174 ; hello-world.c:90: handle_connection(__xdata struct hello_world_state *s)
|
|
||||||
175 ; -----------------------------------------
|
|
||||||
176 ; function handle_connection
|
|
||||||
177 ; -----------------------------------------
|
|
||||||
01A056 178 _handle_connection:
|
|
||||||
179 ; hello-world.c:94: PSOCK_BEGIN(&s->p);
|
|
||||||
01A056 AE 82 [24] 180 mov r6,dpl
|
|
||||||
01A058 AF 83 [24] 181 mov r7,dph
|
|
||||||
01A05A E0 [24] 182 movx a,@dptr
|
|
||||||
01A05B FC [12] 183 mov r4,a
|
|
||||||
01A05C A3 [24] 184 inc dptr
|
|
||||||
01A05D E0 [24] 185 movx a,@dptr
|
|
||||||
01A05E FD [12] 186 mov r5,a
|
|
||||||
01A05F BC 00 05 [24] 187 cjne r4,#0x00,00123$
|
|
||||||
01A062 BD 00 02 [24] 188 cjne r5,#0x00,00123$
|
|
||||||
01A065 80 08 [24] 189 sjmp 00101$
|
|
||||||
01A067 190 00123$:
|
|
||||||
01A067 BC 63 56 [24] 191 cjne r4,#0x63,00108$
|
|
||||||
01A06A BD 00 53 [24] 192 cjne r5,#0x00,00108$
|
|
||||||
01A06D 80 1E [24] 193 sjmp 00102$
|
|
||||||
01A06F 194 00101$:
|
|
||||||
195 ; hello-world.c:96: strtox(buf, "Hello. What is your name?\n");
|
|
||||||
01A06F 75 66 9E [24] 196 mov _strtox_PARM_2,#___str_0
|
|
||||||
01A072 75 67 2C [24] 197 mov (_strtox_PARM_2 + 1),#(___str_0 >> 8)
|
|
||||||
01A075 90 1B 2D [24] 198 mov dptr,#_handle_connection_buf_65536_59
|
|
||||||
01A078 C0 07 [24] 199 push ar7
|
|
||||||
01A07A C0 06 [24] 200 push ar6
|
|
||||||
01A07C 12 02 A6 [24] 201 lcall _strtox
|
|
||||||
01A07F D0 06 [24] 202 pop ar6
|
|
||||||
01A081 D0 07 [24] 203 pop ar7
|
|
||||||
204 ; hello-world.c:99: PSOCK_READTO(&s->p, '\n');
|
|
||||||
01A083 8E 82 [24] 205 mov dpl,r6
|
|
||||||
01A085 8F 83 [24] 206 mov dph,r7
|
|
||||||
01A087 74 63 [12] 207 mov a,#0x63
|
|
||||||
01A089 F0 [24] 208 movx @dptr,a
|
|
||||||
01A08A E4 [12] 209 clr a
|
|
||||||
01A08B A3 [24] 210 inc dptr
|
|
||||||
01A08C F0 [24] 211 movx @dptr,a
|
|
||||||
01A08D 212 00102$:
|
|
||||||
01A08D 75 26 0A [24] 213 mov _psock_readto_PARM_2,#0x0a
|
|
||||||
01A090 8E 82 [24] 214 mov dpl,r6
|
|
||||||
01A092 8F 83 [24] 215 mov dph,r7
|
|
||||||
01A094 C0 07 [24] 216 push ar7
|
|
||||||
01A096 C0 06 [24] 217 push ar6
|
|
||||||
01A098 12 6A 24 [24] 218 lcall _psock_readto
|
|
||||||
01A09B E5 82 [12] 219 mov a,dpl
|
|
||||||
01A09D D0 06 [24] 220 pop ar6
|
|
||||||
01A09F D0 07 [24] 221 pop ar7
|
|
||||||
01A0A1 70 03 [24] 222 jnz 00106$
|
|
||||||
01A0A3 F5 82 [12] 223 mov dpl,a
|
|
||||||
01A0A5 22 [24] 224 ret
|
|
||||||
01A0A6 225 00106$:
|
|
||||||
226 ; hello-world.c:101: strtox(buf, "Name: ");
|
|
||||||
01A0A6 75 66 B9 [24] 227 mov _strtox_PARM_2,#___str_1
|
|
||||||
01A0A9 75 67 2C [24] 228 mov (_strtox_PARM_2 + 1),#(___str_1 >> 8)
|
|
||||||
01A0AC 90 1B 2D [24] 229 mov dptr,#_handle_connection_buf_65536_59
|
|
||||||
01A0AF C0 07 [24] 230 push ar7
|
|
||||||
01A0B1 C0 06 [24] 231 push ar6
|
|
||||||
01A0B3 12 02 A6 [24] 232 lcall _strtox
|
|
||||||
01A0B6 D0 06 [24] 233 pop ar6
|
|
||||||
01A0B8 D0 07 [24] 234 pop ar7
|
|
||||||
235 ; hello-world.c:104: PSOCK_CLOSE(&s->p);
|
|
||||||
01A0BA 90 0A C8 [24] 236 mov dptr,#_uip_flags
|
|
||||||
01A0BD 74 10 [12] 237 mov a,#0x10
|
|
||||||
01A0BF F0 [24] 238 movx @dptr,a
|
|
||||||
239 ; hello-world.c:106: PSOCK_END(&s->p);
|
|
||||||
01A0C0 240 00108$:
|
|
||||||
01A0C0 8E 82 [24] 241 mov dpl,r6
|
|
||||||
01A0C2 8F 83 [24] 242 mov dph,r7
|
|
||||||
01A0C4 E4 [12] 243 clr a
|
|
||||||
01A0C5 F0 [24] 244 movx @dptr,a
|
|
||||||
01A0C6 A3 [24] 245 inc dptr
|
|
||||||
01A0C7 F0 [24] 246 movx @dptr,a
|
|
||||||
01A0C8 75 82 02 [24] 247 mov dpl,#0x02
|
|
||||||
248 ; hello-world.c:107: }
|
|
||||||
01A0CB 22 [24] 249 ret
|
|
||||||
250 .area BANK1 (CODE)
|
|
||||||
251 .area CONST (CODE)
|
|
||||||
252 .area CONST (CODE)
|
|
||||||
002C9E 253 ___str_0:
|
|
||||||
002C9E 48 65 6C 6C 6F 2E 20 254 .ascii "Hello. What is your name?"
|
|
||||||
57 68 61 74 20 69 73
|
|
||||||
20 79 6F 75 72 20 6E
|
|
||||||
61 6D 65 3F
|
|
||||||
002CB7 0A 255 .db 0x0a
|
|
||||||
002CB8 00 256 .db 0x00
|
|
||||||
257 .area BANK1 (CODE)
|
|
||||||
258 .area CONST (CODE)
|
|
||||||
002CB9 259 ___str_1:
|
|
||||||
002CB9 4E 61 6D 65 3A 20 260 .ascii "Name: "
|
|
||||||
002CBF 00 261 .db 0x00
|
|
||||||
262 .area BANK1 (CODE)
|
|
||||||
263 .area XINIT (CODE)
|
|
||||||
264 .area CABS (ABS,CODE)
|
|
||||||
+10
-22
@@ -442,7 +442,6 @@ void nic_tx_packet(uint16_t ring_ptr)
|
|||||||
SFR_NIC_RING_L = ring_ptr;
|
SFR_NIC_RING_L = ring_ptr;
|
||||||
SFR_NIC_RING_H = ring_ptr >> 8;
|
SFR_NIC_RING_H = ring_ptr >> 8;
|
||||||
uint16_t len =(((uint16_t)uip_buf[VLAN_TAG_SIZE + 5]) << 8) | uip_buf[VLAN_TAG_SIZE + 4];
|
uint16_t len =(((uint16_t)uip_buf[VLAN_TAG_SIZE + 5]) << 8) | uip_buf[VLAN_TAG_SIZE + 4];
|
||||||
print_string("\n>> "); write_char('['); print_short(len); write_char(']'); write_char(' ');
|
|
||||||
len += 0xf;
|
len += 0xf;
|
||||||
len >>= 3;
|
len >>= 3;
|
||||||
SFR_NIC_CTRL = len;
|
SFR_NIC_CTRL = len;
|
||||||
@@ -772,7 +771,6 @@ uint8_t sfp_read_reg(uint8_t reg)
|
|||||||
*/
|
*/
|
||||||
void tcpip_output(void)
|
void tcpip_output(void)
|
||||||
{
|
{
|
||||||
print_string("\n>> "); write_char('('); print_short(uip_len); write_char(')'); write_char(' ');
|
|
||||||
__xdata uint8_t *ptr = &uip_buf[0];
|
__xdata uint8_t *ptr = &uip_buf[0];
|
||||||
// Add RTL-TAG
|
// Add RTL-TAG
|
||||||
uip_buf[VLAN_TAG_SIZE] = tx_seq++;
|
uip_buf[VLAN_TAG_SIZE] = tx_seq++;
|
||||||
@@ -785,21 +783,18 @@ void tcpip_output(void)
|
|||||||
reg_read_m(0x7890);
|
reg_read_m(0x7890);
|
||||||
uint16_t ring_ptr = ((uint16_t)sfr_data[2]) << 8;
|
uint16_t ring_ptr = ((uint16_t)sfr_data[2]) << 8;
|
||||||
ring_ptr |= sfr_data[3];
|
ring_ptr |= sfr_data[3];
|
||||||
print_string("\nring_ptr: "); print_short(ring_ptr);
|
/*
|
||||||
for (uint8_t i = 0; i < 120; i++) {
|
for (uint8_t i = 0; i < 120; i++) {
|
||||||
print_byte(*ptr++);
|
print_byte(*ptr++);
|
||||||
write_char(' ');
|
write_char(' ');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
nic_tx_packet(ring_ptr);
|
nic_tx_packet(ring_ptr);
|
||||||
|
|
||||||
reg_read_m(0x7884);
|
reg_read_m(0x7884);
|
||||||
print_string("\nring_ptr now: "); print_short(ring_ptr);
|
|
||||||
|
|
||||||
sfr_data[0] = sfr_data[1] = sfr_data[2] = 0;
|
sfr_data[0] = sfr_data[1] = sfr_data[2] = 0;
|
||||||
sfr_data[3] = 0x1;
|
sfr_data[3] = 0x1;
|
||||||
reg_write_m(0x7850);
|
reg_write_m(0x7850);
|
||||||
print_string("done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -813,40 +808,39 @@ void handle_rx(void)
|
|||||||
ring_ptr <<= 3;
|
ring_ptr <<= 3;
|
||||||
nic_rx_header(ring_ptr);
|
nic_rx_header(ring_ptr);
|
||||||
__xdata uint8_t *ptr = rx_headers;
|
__xdata uint8_t *ptr = rx_headers;
|
||||||
|
/*
|
||||||
print_string("RX on port "); print_byte(rx_headers[3] & 0xf);
|
print_string("RX on port "); print_byte(rx_headers[3] & 0xf);
|
||||||
print_string(": ");
|
print_string(": ");
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
print_byte(*ptr++);
|
print_byte(*ptr++);
|
||||||
write_char(' ');
|
write_char(' ');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
nic_rx_packet((uint16_t) &uip_buf[0], ring_ptr + 8);
|
nic_rx_packet((uint16_t) &uip_buf[0], ring_ptr + 8);
|
||||||
|
|
||||||
print_string("\n<< ");
|
/* print_string("\n<< ");
|
||||||
ptr = &uip_buf[0];
|
ptr = &uip_buf[0];
|
||||||
for (uint8_t i = 0; i < 80; i++) {
|
for (uint8_t i = 0; i < 80; i++) {
|
||||||
print_byte(*ptr++);
|
print_byte(*ptr++);
|
||||||
write_char(' ');
|
write_char(' ');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
sfr_data[0] = sfr_data[1] = sfr_data[2] = 0;
|
sfr_data[0] = sfr_data[1] = sfr_data[2] = 0;
|
||||||
sfr_data[3] = 0x1;
|
sfr_data[3] = 0x1;
|
||||||
reg_write_m(RTL837X_REG_RX_DONE);
|
reg_write_m(RTL837X_REG_RX_DONE);
|
||||||
uip_len = (((uint16_t)rx_headers[5]) << 8) | rx_headers[4];
|
uip_len = (((uint16_t)rx_headers[5]) << 8) | rx_headers[4];
|
||||||
write_char('>'); print_byte(uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE]); write_char('<');
|
// write_char('>'); print_byte(uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE]); write_char('<');
|
||||||
write_char('>'); print_byte(uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE]); write_char('<');
|
// write_char('>'); print_byte(uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE]); write_char('<');
|
||||||
|
// Check for ARP packet
|
||||||
if (uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x08 && uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x06) {
|
if (uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x08 && uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x06) {
|
||||||
uip_arp_arpin();
|
uip_arp_arpin();
|
||||||
if (uip_len) {
|
if (uip_len) {
|
||||||
print_string("UIP-ARP returned packet for TX, size "); print_short(uip_len); write_char('\n');
|
|
||||||
tcpip_output();
|
tcpip_output();
|
||||||
}
|
}
|
||||||
} else if (uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x08 && uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x00) {
|
} else if (uip_buf[12 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x08 && uip_buf[13 + VLAN_TAG_SIZE + RTL_TAG_SIZE] == 0x00) {
|
||||||
uip_arp_ipin();
|
uip_arp_ipin();
|
||||||
uip_input();
|
uip_input();
|
||||||
if (uip_len) {
|
if (uip_len) {
|
||||||
print_string("UIP returned packet for TX, size "); print_short(uip_len); write_char('\n');
|
|
||||||
// Add ethernet frame
|
// Add ethernet frame
|
||||||
uip_arp_out();
|
uip_arp_out();
|
||||||
tcpip_output();
|
tcpip_output();
|
||||||
@@ -861,16 +855,13 @@ void handle_tx(void)
|
|||||||
for(uint8_t i = 0; i < UIP_CONNS; i++) {
|
for(uint8_t i = 0; i < UIP_CONNS; i++) {
|
||||||
uip_periodic(i);
|
uip_periodic(i);
|
||||||
if(uip_len > 0) {
|
if(uip_len > 0) {
|
||||||
print_string("UIP periodic send packet for "); print_byte(i);
|
|
||||||
uip_arp_out();
|
uip_arp_out();
|
||||||
tcpip_output();
|
tcpip_output();
|
||||||
print_string("Transmit done\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void handle_sfp(void)
|
void handle_sfp(void)
|
||||||
{
|
{
|
||||||
reg_read_m(RTL837X_REG_GPIO_B);
|
reg_read_m(RTL837X_REG_GPIO_B);
|
||||||
@@ -1593,13 +1584,10 @@ void bootloader(void)
|
|||||||
|
|
||||||
print_string("A\n");
|
print_string("A\n");
|
||||||
REG_SET(0x7f94, 0x0); // BUG: Only for testing, otherwise: clear bits 0-3
|
REG_SET(0x7f94, 0x0); // BUG: Only for testing, otherwise: clear bits 0-3
|
||||||
print_string("B\n");
|
|
||||||
nic_setup();
|
nic_setup();
|
||||||
print_string("C\n");
|
|
||||||
vlan_setup();
|
vlan_setup();
|
||||||
print_string("D\n");
|
uip_init();
|
||||||
uip_arp_init();
|
uip_arp_init();
|
||||||
print_string("E\n");
|
|
||||||
|
|
||||||
was_offline = 1;
|
was_offline = 1;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -94,7 +94,6 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, __xdata struct uip_neighbor_addr *addr)
|
|||||||
printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
addr->addr.addr[0], addr->addr.addr[1], addr->addr.addr[2], addr->addr.addr[3],
|
addr->addr.addr[0], addr->addr.addr[1], addr->addr.addr[2], addr->addr.addr[3],
|
||||||
addr->addr.addr[4], addr->addr.addr[5]);
|
addr->addr.addr[4], addr->addr.addr[5]);
|
||||||
*/
|
|
||||||
print_string("Adding neighbor with link address ");
|
print_string("Adding neighbor with link address ");
|
||||||
print_byte(addr->addr.addr[0]); write_char(':');
|
print_byte(addr->addr.addr[0]); write_char(':');
|
||||||
print_byte(addr->addr.addr[1]); write_char(':');
|
print_byte(addr->addr.addr[1]); write_char(':');
|
||||||
@@ -103,6 +102,7 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, __xdata struct uip_neighbor_addr *addr)
|
|||||||
print_byte(addr->addr.addr[4]); write_char(':');
|
print_byte(addr->addr.addr[4]); write_char(':');
|
||||||
print_byte(addr->addr.addr[5]); write_char(':');
|
print_byte(addr->addr.addr[5]); write_char(':');
|
||||||
write_char('\n');
|
write_char('\n');
|
||||||
|
*/
|
||||||
|
|
||||||
/* Find the first unused entry or the oldest used entry. */
|
/* Find the first unused entry or the oldest used entry. */
|
||||||
oldest_time = 0;
|
oldest_time = 0;
|
||||||
|
|||||||
@@ -368,8 +368,9 @@ uip_udpchksum(void)
|
|||||||
#endif /* UIP_ARCH_CHKSUM */
|
#endif /* UIP_ARCH_CHKSUM */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_init(void)
|
uip_init(void) __banked
|
||||||
{
|
{
|
||||||
|
uint8_t c;
|
||||||
for(c = 0; c < UIP_LISTENPORTS; ++c) {
|
for(c = 0; c < UIP_LISTENPORTS; ++c) {
|
||||||
uip_listenports[c] = 0;
|
uip_listenports[c] = 0;
|
||||||
}
|
}
|
||||||
@@ -801,6 +802,7 @@ uip_process(u8_t flag) __banked
|
|||||||
}
|
}
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UIP_UDP
|
#if UIP_UDP
|
||||||
if(flag == UIP_UDP_TIMER) {
|
if(flag == UIP_UDP_TIMER) {
|
||||||
if(uip_udp_conn->lport != 0) {
|
if(uip_udp_conn->lport != 0) {
|
||||||
@@ -816,7 +818,6 @@ uip_process(u8_t flag) __banked
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
print_string("R1\n");
|
|
||||||
/* This is where the input processing starts. */
|
/* This is where the input processing starts. */
|
||||||
UIP_STAT(++uip_stat.ip.recv);
|
UIP_STAT(++uip_stat.ip.recv);
|
||||||
|
|
||||||
@@ -832,7 +833,6 @@ uip_process(u8_t flag) __banked
|
|||||||
}
|
}
|
||||||
#else /* UIP_CONF_IPV6 */
|
#else /* UIP_CONF_IPV6 */
|
||||||
/* Check validity of the IP header. */
|
/* Check validity of the IP header. */
|
||||||
print_string("R2: "); print_byte(BUF->vhl); write_char('\n');
|
|
||||||
if(BUF->vhl != 0x45) { /* IP version and header length. */
|
if(BUF->vhl != 0x45) { /* IP version and header length. */
|
||||||
UIP_STAT(++uip_stat.ip.drop);
|
UIP_STAT(++uip_stat.ip.drop);
|
||||||
UIP_STAT(++uip_stat.ip.vhlerr);
|
UIP_STAT(++uip_stat.ip.vhlerr);
|
||||||
@@ -840,7 +840,6 @@ uip_process(u8_t flag) __banked
|
|||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
print_string("R2a\n");
|
|
||||||
/* Check the size of the packet. If the size reported to us in
|
/* Check the size of the packet. If the size reported to us in
|
||||||
uip_len is smaller the size reported in the IP header, we assume
|
uip_len is smaller the size reported in the IP header, we assume
|
||||||
that the packet has been corrupted in transit. If the size of
|
that the packet has been corrupted in transit. If the size of
|
||||||
@@ -849,7 +848,6 @@ uip_process(u8_t flag) __banked
|
|||||||
value.. */
|
value.. */
|
||||||
|
|
||||||
if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
|
if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
|
||||||
print_string("R2b\n");
|
|
||||||
uip_len = (BUF->len[0] << 8) + BUF->len[1];
|
uip_len = (BUF->len[0] << 8) + BUF->len[1];
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
uip_len += 40; /* The length reported in the IPv6 header is the
|
uip_len += 40; /* The length reported in the IPv6 header is the
|
||||||
@@ -885,7 +883,6 @@ uip_process(u8_t flag) __banked
|
|||||||
}
|
}
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
print_string("R2b\n");
|
|
||||||
if(uip_ipaddr_cmpc(uip_hostaddr, all_zeroes_addr)) {
|
if(uip_ipaddr_cmpc(uip_hostaddr, all_zeroes_addr)) {
|
||||||
/* If we are configured to use ping IP address configuration and
|
/* If we are configured to use ping IP address configuration and
|
||||||
hasn't been assigned an IP address yet, we accept all ICMP
|
hasn't been assigned an IP address yet, we accept all ICMP
|
||||||
@@ -980,7 +977,6 @@ uip_process(u8_t flag) __banked
|
|||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_string("IS ICMP\n");
|
|
||||||
/* If we are configured to use ping IP address assignment, we use
|
/* If we are configured to use ping IP address assignment, we use
|
||||||
the destination IP address of this ping packet and assign it to
|
the destination IP address of this ping packet and assign it to
|
||||||
ourself. */
|
ourself. */
|
||||||
@@ -1867,7 +1863,6 @@ uip_process(u8_t flag) __banked
|
|||||||
/* Return and let the caller do the actual transmission. */
|
/* Return and let the caller do the actual transmission. */
|
||||||
uip_flags = 0;
|
uip_flags = 0;
|
||||||
|
|
||||||
print_string("uip_process done");
|
|
||||||
return;
|
return;
|
||||||
drop:
|
drop:
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||||||
* This function should be called at boot up to initilize the uIP
|
* This function should be called at boot up to initilize the uIP
|
||||||
* TCP/IP stack.
|
* TCP/IP stack.
|
||||||
*/
|
*/
|
||||||
void uip_init(void);
|
void uip_init(void) __banked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uIP initialization function.
|
* uIP initialization function.
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
|||||||
/* Check if the source IP address of the incoming packet matches
|
/* Check if the source IP address of the incoming packet matches
|
||||||
the IP address in this ARP table entry. */
|
the IP address in this ARP table entry. */
|
||||||
if(ipaddr[0] == arp_table[i].ipaddr[0] && ipaddr[1] == arp_table[i].ipaddr[1]) {
|
if(ipaddr[0] == arp_table[i].ipaddr[0] && ipaddr[1] == arp_table[i].ipaddr[1]) {
|
||||||
print_string("Updating: "); print_short(ipaddr[0]); print_short(ipaddr[1]); write_char('\n');
|
|
||||||
/* An old entry found, update this and return. */
|
/* An old entry found, update this and return. */
|
||||||
memcpy(arp_table[i].ethaddr.addr, ethaddr->addr, 6);
|
memcpy(arp_table[i].ethaddr.addr, ethaddr->addr, 6);
|
||||||
arp_table[i].time = arptime;
|
arp_table[i].time = arptime;
|
||||||
@@ -198,7 +197,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
|||||||
/* If we get here, no existing ARP table entry was found, so we
|
/* If we get here, no existing ARP table entry was found, so we
|
||||||
create one. */
|
create one. */
|
||||||
|
|
||||||
print_string("No entry yet for: "); print_short(ipaddr[1]); write_char('\n');
|
|
||||||
/* First, we try to find an unused entry in the ARP table. */
|
/* First, we try to find an unused entry in the ARP table. */
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
if(arp_table[i].ipaddr[0] == 0 && arp_table[i].ipaddr[1] == 0)
|
if(arp_table[i].ipaddr[0] == 0 && arp_table[i].ipaddr[1] == 0)
|
||||||
@@ -219,8 +217,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
|||||||
i = c;
|
i = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_string("Setting entry "); print_short(ipaddr[0]); print_short(ipaddr[1]); write_char('>');
|
|
||||||
print_byte(arp_table[i].ethaddr.addr[0]); write_char(':'); print_byte(arp_table[i].ethaddr.addr[1]);
|
|
||||||
/* Now, i is the ARP table entry which we will fill with the new
|
/* Now, i is the ARP table entry which we will fill with the new
|
||||||
information. */
|
information. */
|
||||||
memcpy(arp_table[i].ipaddr, ipaddr, 4);
|
memcpy(arp_table[i].ipaddr, ipaddr, 4);
|
||||||
@@ -289,25 +285,14 @@ void
|
|||||||
uip_arp_arpin(void) __banked
|
uip_arp_arpin(void) __banked
|
||||||
{
|
{
|
||||||
|
|
||||||
print_string("uip_arp_arpin called");
|
|
||||||
if(uip_len < sizeof(struct arp_hdr_i)) {
|
if(uip_len < sizeof(struct arp_hdr_i)) {
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
|
|
||||||
print_string("ARP opcode: ");
|
|
||||||
print_short((uint16_t)(&BUF->opcode)); write_char(' '); print_short((uint16_t)(&BUF->protolen)); write_char(' '); print_short((uint16_t)(&uip_buf[0]));write_char(' ');
|
|
||||||
print_short((uint16_t)(&(BUF->shwaddr.addr[0]))); write_char(' ');
|
|
||||||
print_short(BUF->hwtype); write_char(' ');
|
|
||||||
print_short(BUF->protocol); write_char(' ');
|
|
||||||
print_byte(BUF->hwlen); write_char(' ');
|
|
||||||
print_byte(BUF->protolen); write_char(' ');
|
|
||||||
print_short(BUF->opcode); write_char(' ');
|
|
||||||
print_byte(BUF->shwaddr.addr[0]); write_char('\n');
|
|
||||||
switch(BUF->opcode) {
|
switch(BUF->opcode) {
|
||||||
case HTONS(ARP_REQUEST):
|
case HTONS(ARP_REQUEST):
|
||||||
print_string("Is ARP_REQUEST\n");
|
|
||||||
/* ARP request. If it asked for our address, we send out a
|
/* ARP request. If it asked for our address, we send out a
|
||||||
reply. */
|
reply. */
|
||||||
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
||||||
@@ -334,7 +319,6 @@ uip_arp_arpin(void) __banked
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTONS(ARP_REPLY):
|
case HTONS(ARP_REPLY):
|
||||||
print_string("Is ARP_REPLY\n");
|
|
||||||
/* ARP reply. We insert or update the ARP table if it was meant
|
/* ARP reply. We insert or update the ARP table if it was meant
|
||||||
for us. */
|
for us. */
|
||||||
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
||||||
@@ -379,7 +363,6 @@ uip_arp_out(void) __banked
|
|||||||
__xdata struct arp_entry *tabptr;
|
__xdata struct arp_entry *tabptr;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
print_string("uip_arp_arout called, dest "); print_short(IPBUF->destipaddr[0]); print_short(IPBUF->destipaddr[1]); write_char('\n');
|
|
||||||
/* Find the destination IP address in the ARP table and construct
|
/* Find the destination IP address in the ARP table and construct
|
||||||
the Ethernet header. If the destination IP addres isn't on the
|
the Ethernet header. If the destination IP addres isn't on the
|
||||||
local network, we use the default router's IP address instead.
|
local network, we use the default router's IP address instead.
|
||||||
@@ -389,24 +372,19 @@ uip_arp_out(void) __banked
|
|||||||
|
|
||||||
/* First check if destination is a local broadcast. */
|
/* First check if destination is a local broadcast. */
|
||||||
if(uip_ipaddr_cmpc(IPBUF->destipaddr, broadcast_ipaddr)) {
|
if(uip_ipaddr_cmpc(IPBUF->destipaddr, broadcast_ipaddr)) {
|
||||||
print_string("local broadcast\n");
|
|
||||||
memcpyc(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
memcpyc(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||||
} else {
|
} else {
|
||||||
write_char('S');
|
|
||||||
/* Check if the destination address is on the local network. */
|
/* Check if the destination address is on the local network. */
|
||||||
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
||||||
write_char('T');
|
|
||||||
/* Destination address was not on the local network, so we need to
|
/* Destination address was not on the local network, so we need to
|
||||||
use the default router's IP address instead of the destination
|
use the default router's IP address instead of the destination
|
||||||
address when determining the MAC address. */
|
address when determining the MAC address. */
|
||||||
uip_ipaddr_copy(ipaddr, uip_draddr);
|
uip_ipaddr_copy(ipaddr, uip_draddr);
|
||||||
} else {
|
} else {
|
||||||
write_char('U');
|
|
||||||
/* Else, we use the destination IP address. */
|
/* Else, we use the destination IP address. */
|
||||||
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_char('V');
|
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
if(uip_ipaddr_cmpx(ipaddr, tabptr->ipaddr)) {
|
if(uip_ipaddr_cmpx(ipaddr, tabptr->ipaddr)) {
|
||||||
@@ -415,7 +393,6 @@ uip_arp_out(void) __banked
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(i == UIP_ARPTAB_SIZE) {
|
if(i == UIP_ARPTAB_SIZE) {
|
||||||
write_char('W');
|
|
||||||
/* The destination address was not in our ARP table, so we
|
/* The destination address was not in our ARP table, so we
|
||||||
overwrite the IP packet with an ARP request. */
|
overwrite the IP packet with an ARP request. */
|
||||||
|
|
||||||
@@ -441,13 +418,11 @@ uip_arp_out(void) __banked
|
|||||||
|
|
||||||
/* Build an ethernet header. */
|
/* Build an ethernet header. */
|
||||||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||||
write_char('X');
|
|
||||||
}
|
}
|
||||||
memcpyc(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
memcpyc(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||||
|
|
||||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||||
|
|
||||||
write_char('Y');
|
|
||||||
uip_len += sizeof(struct uip_eth_hdr);
|
uip_len += sizeof(struct uip_eth_hdr);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user