source: umon/ports/beagleboneblack/etherdev.c @ 976c170

Last change on this file since 976c170 was 976c170, checked in by Jarielle Catbagan <jcatbagan93@…>, on 08/07/15 at 18:04:18

BBB: Clean up *.c and *.h files using 'astyle --unpad-paren --align-pointer=name --lineend=linux --add-brackets --convert-tabs -A4 <file>'

Note: <file> is the file being formatted

  • Property mode set to 100644
File size: 5.0 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
175    if(EtherVerbose &  SHOW_OUTGOING) {
176        printPkt((struct ether_header *)tx_buf,length,ETHER_OUTGOING);
177    }
178
179    // tell the cs8900a to send the tx buffer pointed to by tx_buf
180    temp32 = smsc911x_tx((ulong)tx_buf, (ulong)length);
181
182    EtherXFRAMECnt++;
183    if(temp32) {
184        return -1;
185    } else {
186        return 0;
187    }
188}
189
190/* DisableEtherdev():
191 * Fine as it is...
192 */
193void
194DisableEtherdev(void)
195{
196    enreset();
197}
198
199/* extGetIpAdd():
200 * If there was some external mechanism (other than just using the
201 * IPADD shell variable established in the monrc file) for retrieval of
202 * the board's IP address, then do it here...
203 */
204char *
205extGetIpAdd(void)
206{
207    return((char *)0);
208}
209
210/* extGetEtherAdd():
211 * If there was some external mechanism (other than just using the
212 * ETHERADD shell variable established in the monrc file) for retrieval of
213 * the board's MAC address, then do it here...
214 */
215char *
216extGetEtherAdd(void)
217{
218    return((char *)0);
219}
220
221/*
222 * polletherdev():
223 * Called continuously by the monitor (ethernet.c) to determine if there
224 * is any incoming ethernet packets.
225 */
226int
227polletherdev(void)
228{
229    ulong pktbuf[RBUFSIZE/4];
230    int pktlen, pktcnt = 0;
231
232    pktlen = smsc911x_rx((uchar *)pktbuf);
233
234    if(pktlen) {
235        pktcnt = 1;
236        EtherRFRAMECnt++;
237        processPACKET((struct ether_header *)pktbuf, pktlen);
238    }
239    return(pktcnt);
240}
241
242#endif
Note: See TracBrowser for help on using the repository browser.