e1b005754e5e327bbaca938ee2dde29f7b721d8e
[tpg/acess2.git] / KernelLand / Modules / Network / PRO100 / pro100_hw.h
1 /*
2  * Acess2 PRO/100 Driver
3  * - By John Hodge (thePowersGang)
4  *
5  * pro100_hw.h
6  * - Hardware header
7  */
8 #ifndef _PRO100_HW_H_
9 #define _PRO100_HW_H_
10
11 // Want at least 5 TX Buffer slots (for TCP)
12 // - However, bounce buffers are annoying, so double that
13 #define MIN_LOCAL_TXBUFS        5*2
14 // - 16 bytes per TX header, plus 8 per buffer, want 16 byte alignment
15 // - need to round up to multiple of 2
16 #define NUM_LOCAL_TXBUFS        ((MIN_LOCAL_TXBUFS+1)&~(2-1))
17
18 enum ePro100_Regs {
19         REG_Status,
20         REG_Ack,
21         REG_Command,
22         REG_IntMask,
23         
24         REG_GenPtr = 4,
25         REG_Port = 8,
26         
27         REG_FlashCtrl = 12,
28         REG_EEPROMCtrl = 14,
29         
30         REG_MDICtrl = 16,
31         REG_RXDMACnt = 20,
32 };
33 struct sCSR
34 {
35         Uint16  Status;
36         Uint16  Command;
37         
38         Uint32  GenPtr;
39         Uint32  Port;
40         
41         Uint16  FlashCtrl;
42         Uint16  EEPROMCtrl;
43         
44         Uint32  MDICtrl;
45         Uint32  RXDMACount;
46 };
47
48 #define STATUS_RUS_MASK 0x003C  // Receive Unit Status
49 #define STATUS_CUS_MASK 0x00C0  // Comamnd Unit Status
50 #define ISR_FCP 0x01    // Flow Control Pause
51 #define ISR_ER  0x02    // Early Recieve
52 #define ISR_SWI 0x04    // Software Interrupt
53 #define ISR_MDI 0x08    // Management Data Interrupt
54 #define ISR_RNR 0x10    // Receive Not Ready
55 #define ISR_CNA 0x20    // Command Unit not active
56 #define ISR_FR  0x40    // Frame Recieved
57 #define ISR_CX  0x80    // Command Unit executed
58
59 #define CMD_RUC 0x0007
60 #define CMD_CUC 0x00F0
61 #define CMD_M   0x0100  // Interrupt Mask
62 #define CMD_SI  0x0200  // Software Interrupt
63
64 #define MDI_IE  (1 << 29)
65 #define MDI_RDY (1 << 28)
66
67 #define EEPROM_CTRL_SK  0x01    // 
68 #define EEPROM_CTRL_CS  0x02
69 #define EEPROM_CTRL_DI  0x04
70 #define EEPROM_CTRL_DO  0x08
71
72 #define EEPROM_OP_READ  0x06
73
74 enum ePortCommands {
75         PORT_SOFTWARERESET      = 0,
76         PORT_SELFTEST   = 1,
77         PORT_SELECTIVERESET     = 2,
78 };
79
80 enum eRXCommands {
81         RX_CMD_NOP,
82         RX_CMD_START,
83         RX_CMD_RESUME,
84         _RX_CMD_3,
85         RX_CMD_ABORT,
86         _RX_CMD_5,
87         RX_CMD_ADDR_LOAD,
88         RX_CMD_RESUMENR,
89 };
90 enum eCUCommands {
91         CU_CMD_NOP      = 0<<4,
92         CU_CMD_START    = 1<<4,
93         CU_CMD_RESUME   = 2<<4,
94         CU_CMD_BASE     = 6<<4,
95 };
96
97 enum eCommands {
98         CMD_Nop,
99         CMD_IAddrSetup,
100         CMD_Configure,
101         CMD_MulticastList,
102         CMD_Tx,
103 };
104
105 #define CMD_IOC (1 << 13)       // Interrupt on completion
106 #define CMD_Suspend     (1 << 14)       // Suspend upon completion
107 #define CMD_EL  (1 << 15)       // Stop upon completion
108
109 #define CU_Status_Complete      (1 << 15)
110
111 typedef struct sCommandUnit     tCommandUnit;
112
113 struct sCommandUnit
114 {
115         Uint16  Status;
116         Uint16  Command;
117         Uint32  Link;   // Relative to base
118 } ALIGN(4);
119
120 typedef struct sTXDescriptor    tTXDescriptor;
121 typedef struct sTXBufDesc       tTXBufDesc;
122 typedef struct sTXCommand       tTXCommand;
123
124 // - Core TX Descriptor
125 struct sTXDescriptor
126 {
127         tCommandUnit    CU;
128         
129         Uint32  TBDArrayAddr;
130         Uint16  TCBBytes;
131         Uint8   TXThreshold;
132         Uint8   TBDCount;
133 };
134
135 // - TX Buffer descriptor (pointed to by TBDArrayAddr, or following sTXDescriptor)
136 struct sTXBufDesc
137 {
138         Uint32  Addr;
139         Uint16  Len;
140         Uint16  EndOfList;
141 };
142
143 // - TX Command block (used by static allocation)
144 struct sTXCommand
145 {
146         tTXDescriptor   Desc;
147         tTXBufDesc      LocalBufs[NUM_LOCAL_TXBUFS];
148 };
149
150 typedef struct sRXBuffer        tRXBuffer;
151 struct sRXBuffer
152 {
153         // Status:
154         // - [1]: ???
155         tCommandUnit    CU;
156
157         Uint32  RXBufAddr;      // Unused according to qemu source
158         Uint16  Count;
159         Uint16  Size;
160 };
161
162 #endif
163

UCC git Repository :: git.ucc.asn.au