source: umon/ports/csb740/etherdev.c @ 87db514

Last change on this file since 87db514 was 87db514, checked in by Amar Takhar <amar@…>, on 04/16/15 at 19:26:21

Initial commit of the umon repository.

Prior to this three changes were made:

  • Remove umon_ prefix from parent directories.
  • Collapse main/target/ into main/
  • Remove ports/template/flashtest.scr.ucon script.
  • Property mode set to 100755
File size: 4.9 KB
Line 
1//=============================================================================
2//
3//      etherdev.c
4//
5//      Ethernet Abstraction Layer for Micro Monitor
6//
7// Author(s):    Michael Kelly, Cogent Computer Systems, Inc.
8// Contributors: Luis Torrico, Cogent Computer Systems, Inc.
9// Date:         05-26-2002
10// Modified:     06-26-2007
11// Description:  This file contains the interface layer between Micro Monitor
12//               and the Ethernet driver for the LAN921x on the CSB733.
13//
14//=============================================================================
15
16#include "config.h"
17#include "cpuio.h"
18#include "genlib.h"
19#include "stddefs.h"
20#include "ether.h"
21
22extern void smsc911x_reset(void);
23extern ushort smsc911x_rx(uchar *pktbuf);
24extern int smsc911x_init(void);
25extern ulong smsc911x_tx(ulong txbuf, ulong length);
26extern void smsc911x_enable_promiscuous_reception(void);
27extern void smsc911x_disable_promiscuous_reception(void);
28extern void smsc911x_enable_multicast_reception(void);
29extern void smsc911x_disable_multicast_reception(void);
30extern void smsc911x_enable_broadcast_reception(void);
31extern void smsc911x_disable_broadcast_reception(void);
32
33ulong tx_buf[400];
34
35#if INCLUDE_ETHERNET
36
37/*
38 * enreset():
39 *      Reset the PHY and MAC.
40 */
41void
42enreset(void)
43{
44        smsc911x_reset();
45}
46
47/*
48 * eninit():
49 * This would include establishing buffer descriptor tables and
50 * all the support code that will be used by the ethernet device.
51 *
52 * It can be assumed at this point that the array uchar BinEnetAddr[6]
53 * contains the 6-byte MAC address.
54 *
55 * Return 0 if successful; else -1.
56 */
57int
58eninit(void)
59{
60        return smsc911x_init();
61
62}
63
64int
65EtherdevStartup(int verbose)
66{
67        /* Initialize local device error counts (if any) here. */
68        /* OPT_ADD_CODE_HERE */
69
70        /* Put ethernet controller in reset: */
71        enreset();
72
73        /* Initialize controller: */
74        eninit();
75
76        return(0);
77}
78
79/* disablePromiscuousReception():
80 * Provide the code that disables promiscuous reception.
81 */
82void
83disablePromiscuousReception(void)
84{
85        smsc911x_disable_promiscuous_reception();
86}
87
88/* enablePromiscuousReception():
89 * Provide the code that enables promiscuous reception.
90 */
91void
92enablePromiscuousReception(void)
93{
94        smsc911x_enable_promiscuous_reception();
95}
96
97/* disableBroadcastReception():
98 * Provide the code that disables broadcast reception.
99 */
100void
101disableBroadcastReception(void)
102{
103        smsc911x_disable_broadcast_reception();
104}
105
106/* enableBroadcastReception():
107 * Provide the code that enables broadcast reception.
108 */
109void
110enableBroadcastReception(void)
111{
112        smsc911x_enable_broadcast_reception();
113}
114
115void
116disableMulticastReception(void)
117{
118        smsc911x_disable_multicast_reception();
119}
120
121void
122enableMulticastReception(void)
123{
124        smsc911x_enable_multicast_reception();
125}
126
127
128/*
129 * enselftest():
130 *      Run a self test of the ethernet device(s).  This can be stubbed
131 *      with a return(1).
132 *      Return 1 if success; else -1 if failure.
133 */
134int
135enselftest(int verbose)
136{
137        return(1);
138}
139
140/* ShowEtherdevStats():
141 * This function is used to display device-specific stats (error counts
142 * usually).
143 */
144void
145ShowEtherdevStats(void)
146{
147        /* OPT_ADD_CODE_HERE */
148}
149
150/* getXmitBuffer():
151 * Return a pointer to the buffer that is to be used for transmission of
152 * the next packet.  Since the monitor's driver is EXTREMELY basic,
153 * there will only be one packet ever being transmitted.  No need to queue
154 * up transmit packets.
155 */
156uchar *
157getXmitBuffer(void)
158{
159        return((uchar *) tx_buf);
160}
161
162/* sendBuffer():
163 * Send out the packet assumed to be built in the buffer returned by the
164 * previous call to getXmitBuffer() above.
165 */
166int
167sendBuffer(int length)
168{
169        ulong temp32;
170
171    if (length < 64)
172        length = 64;
173
174        if (EtherVerbose &  SHOW_OUTGOING)
175                printPkt((struct ether_header *)tx_buf,length,ETHER_OUTGOING);
176
177        // tell the cs8900a to send the tx buffer pointed to by tx_buf
178        temp32 = smsc911x_tx((ulong)tx_buf, (ulong)length);
179
180        EtherXFRAMECnt++;
181        if (temp32) {
182                return -1;
183        }
184        else {
185                return 0;
186        }
187}
188
189/* DisableEtherdev():
190 * Fine as it is...
191 */
192void
193DisableEtherdev(void)
194{
195        enreset();
196}
197
198/* extGetIpAdd():
199 * If there was some external mechanism (other than just using the
200 * IPADD shell variable established in the monrc file) for retrieval of
201 * the board's IP address, then do it here...
202 */
203char *
204extGetIpAdd(void)
205{
206        return((char *)0);
207}
208
209/* extGetEtherAdd():
210 * If there was some external mechanism (other than just using the
211 * ETHERADD shell variable established in the monrc file) for retrieval of
212 * the board's MAC address, then do it here...
213 */
214char *
215extGetEtherAdd(void)
216{
217        return((char *)0);
218}
219
220/*
221 * polletherdev():
222 * Called continuously by the monitor (ethernet.c) to determine if there
223 * is any incoming ethernet packets.
224 */
225int
226polletherdev(void)
227{
228        ulong pktbuf[RBUFSIZE/4];
229        int     pktlen, pktcnt = 0;
230
231        pktlen = smsc911x_rx((uchar *)pktbuf);
232
233        if(pktlen) {
234                pktcnt = 1;
235                EtherRFRAMECnt++;
236                processPACKET((struct ether_header *)pktbuf, pktlen);
237        }
238        return(pktcnt);
239}
240
241#endif
Note: See TracBrowser for help on using the repository browser.