1 /******************************************************************************
5 * Definition of routine to set the MAC address.
7 * Revision information:
9 * 28AUG2004 kb_admin initial creation
12 * No warranty, expressed or implied, is included with this software. It is
13 * provided "AS IS" and no warranty of any kind including statutory or aspects
14 * relating to merchantability or fitness for any purpose is provided. All
15 * intellectual property rights of others is maintained with the respective
16 * owners. This software is not copyrighted and is intended for reference
21 *****************************************************************************/
27 extern void EMAC_SetMACAddress(unsigned char addr[6]);
28 extern void SetServerIPAddress(unsigned address);
29 extern void SetLocalIPAddress(unsigned address);
30 extern void EMAC_Init(void);
31 extern void TFTP_Download(unsigned address, char *filename);
33 #define MAX_RX_PACKETS 8
34 #define RX_PACKET_SIZE 1536
35 #define RX_BUFFER_START 0x21000000
36 #define RX_DATA_START (RX_BUFFER_START + (8 * MAX_RX_PACKETS))
38 #define ARP_REQUEST 0x0001
39 #define ARP_REPLY 0x0002
40 #define PROTOCOL_ARP 0x0806
41 #define PROTOCOL_IP 0x0800
42 #define PROTOCOL_UDP 0x11
44 #define SWAP16(x) ((((x) & 0xff) << 8) | ((x) >> 8))
49 } receive_descriptor_t;
53 unsigned char dest_mac[6];
55 unsigned char src_mac[6];
57 unsigned short frame_type;
58 unsigned short hard_type;
59 unsigned short prot_type;
60 unsigned char hard_size;
61 unsigned char prot_size;
63 unsigned short operation;
65 unsigned char sender_mac[6];
66 unsigned char sender_ip[4];
68 unsigned char target_mac[6];
69 unsigned char target_ip[4];
71 } __attribute__((__packed__)) arp_header_t;
74 unsigned char ip_v_hl;
76 unsigned short ip_len;
78 unsigned short ip_off;
81 unsigned short ip_sum;
82 unsigned char ip_src[4];
83 unsigned char ip_dst[4];
84 } __attribute__((__packed__)) ip_header_t;
87 unsigned char dest_mac[6];
88 unsigned char src_mac[6];
89 unsigned short proto_mac;
90 unsigned short packet_length;
92 } __attribute__((__packed__)) transmit_header_t;
95 unsigned short src_port;
96 unsigned short dst_port;
97 unsigned short udp_len;
98 unsigned short udp_cksum;
99 } __attribute__((__packed__)) udp_header_t;
102 unsigned short opcode;
103 unsigned short block_num;
104 unsigned char data[512];
105 } __attribute__((__packed__)) tftp_header_t;
108 #define TFTP_RRQ_OPCODE 0x0100
109 #define TFTP_WRQ_OPCODE 0x0200
110 #define TFTP_DATA_OPCODE 0x0300
111 #define TFTP_ACK_OPCODE 0x0400
112 #define TFTP_ERROR_OPCODE 0x0500
114 /* MII registers definition */
115 #define MII_STS_REG 0x01
116 #define MII_STS_LINK_STAT 0x04
117 #if defined(BOOT_KB920X) || defined(BOOT_CENTIPAD)
118 #define MII_STS2_REG 0x11
119 #define MII_STS2_LINK 0x400
120 #define MII_STS2_100TX 0x4000
121 #define MII_STS2_FDX 0x200
123 #define MII_SPEC_STS_REG 0x11
124 #define MII_SSTS_100FDX 0x8000
125 #define MII_SSTS_100HDX 0x4000
126 #define MII_SSTS_10FDX 0x2000
127 #define MII_SSTS_10HDX 0x1000
130 extern unsigned char localMACAddr[6];
131 extern unsigned localMAClow, localMAChigh;
132 extern unsigned localMACSet;
135 #endif /* _EMAC_H_ */