mac.h


1
/******************************************************************************
2
 * Company:        
3
 *
4
 * Project:        
5
 *
6
 * Target:         
7
 *
8
 * Type:           
9
 *
10
 * Description:    
11
 *
12
 * Compiler:       
13
 *
14
 * Filename:       
15
 *
16
 * Version:        
17
 *
18
 * Author:         
19
 *
20
 * Creation-Date:  
21
 ******************************************************************************
22
 *****************************************************************************/
23
24
#ifndef __MAC_H__
25
#define __MAC_H__
26
27
/******************************************************************************
28
 * INCLUDE FILES
29
 *****************************************************************************/
30
31
#include "base_def.h"
32
33
/******************************************************************************
34
 * CONSTANT DEFINITIONS
35
 *****************************************************************************/
36
37
#define MAC_ADDRESS6 0x00 /* unique mac address */
38
#define MAC_ADDRESS5 0x16
39
#define MAC_ADDRESS4 0x35
40
#define MAC_ADDRESS3 0xAC
41
#define MAC_ADDRESS2 0x4B
42
#define MAC_ADDRESS1 0xAE
43
44
#define MAX_FRAME 1536 /* maximum frame length */
45
#define CLRT_DEFAULT 0x0000370F /* default collision window / retry */
46
#define IPGR_DEFAULT 0x00000C12 /* default back-to-back inter packet gap */
47
48
#define PHY_BCR 0 /* basic control register */
49
#define PHY_STATUS 1 /* status register */
50
#define PHY_ID1 2 /* phy identifier 1 */
51
#define PHY_ID2 3 /* phy identifier 2 */
52
#define PHY_ANA 4 /* auto-negotiation advertisement register */
53
#define PHY_ANLPA 5 /* auto-negotiation link partner ability register */
54
#define PHY_ANE 6 /* auto-negotiation expansion register */
55
#define PHY_ANNP 7 /* auto-negotiation next page register */
56
#define PHY_LPNPA 8 /* link partner next page ability */
57
#define PHY_RXER 0x15 /* RXER counter */
58
#define PHY_ICS 0x1b /* interrupt control/status register */
59
#define PHY_LCS 0x1d /* LinkMD control/status register */
60
#define PHY_CTL 0x1e /* PHY control register */
61
#define PHY_100BTX 0x1f /* 100BASE-TX PHY control register */
62
63
#define KSZ8001_ID 0x00221610 /* PHY identifier of micrel KSZ8001L */
64
65
#define MAC_RX_FRAGMENTS 128
66
#define MAC_TX_FRAGMENTS 128
67
68
/******************************************************************************
69
 * OTHER DEFINITIONS (MACROS ETC)
70
 *****************************************************************************/
71
72
#define ETH_FRAG_SIZE 1536 /* must be a multiple of 4 */
73
#define RX_DESC_BASE 0x7FE00000
74
#define TX_DESC_BASE (RX_DESC_BASE + (MAC_RX_FRAGMENTS * 16))
75
76
//#define TX_PACKET_DESC(i) (TX_DESC_BASE + (i * 8))
77
//#define TX_CONTROL_DESC(i) (TX_DESC_BASE + (i * 8) + 4)
78
//#define TX_STATUS_DESC(i) (TxStatus + (i * 4));
79
80
#define TxPacketDescriptor(i) (*(tpDWord)(TX_DESC_BASE + (i * 8)))
81
#define TxControlDescriptor(i) (*(tpDWord)(TX_DESC_BASE + (i * 8) + 4))
82
#define TxStatusDescriptor(i) (*(tpDWord)(TxStatus + (i * 4)))
83
84
#define RxPacketDescriptor(i) (*(tpDWord)(RX_DESC_BASE + (i * 8)))
85
#define RxControlDescriptor(i) (*(tpDWord)(RX_DESC_BASE + (i * 8) + 4))
86
#define RxStatusDescriptor(i) (*(tpDWord)(RX_DESC_BASE + (MAC_RX_FRAGMENTS * 8) + (i * 8)))
87
#define RxStatusHash(i) (*(tpDWord)(RX_DESC_BASE + (MAC_RX_FRAGMENTS * 8) + (i * 8) + 4))
88
89
/******************************************************************************
90
 * TYPE DEFINITIONS
91
 *****************************************************************************/
92
93
/******************************************************************************
94
 * FUNCTION PROTOTYPES (PUBLIC)
95
 *****************************************************************************/
96
97
tenBool MAC_fInitMAC(void);
98
99
tenBool MAC_fGetLinkStatus(void);
100
101
tenBool MAC_fSendPacket(tpByte pData, tDWord dwSize);
102
103
tDWord MAC_fReceivePacket(tpByte pData);
104
105
tAddress MAC_fCreatePacket(void);
106
107
/******************************************************************************
108
 * END OF CODE
109
 *****************************************************************************/
110
111
#endif