OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [eth/] [current/] [include/] [eth_drv.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/cyg/io/eth/eth_drv.h
4
//
5
//      High level networking driver interfaces
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    gthomas
43
// Contributors: gthomas
44
// Date:         2000-01-10
45
// Purpose:      
46
// Description:  High level networking driver interfaces
47
//              
48
//
49
//####DESCRIPTIONEND####
50
//
51
//==========================================================================
52
 
53
// Ethernet driver structure
54
 
55
#ifndef _ETH_DRV_H_
56
#define _ETH_DRV_H_
57
 
58
#include <pkgconf/system.h>
59
#include <pkgconf/io_eth_drivers.h>
60
 
61
#ifdef CYGPKG_NET
62
#include <sys/param.h>
63
#include <sys/socket.h>
64
 
65
#include <net/if.h>
66
 
67
#ifdef INET
68
#include <netinet/in.h>
69
#include <netinet/in_systm.h>
70
#include <netinet/in_var.h>
71
#include <netinet/ip.h>
72
#include <netinet/if_ether.h>
73
#endif
74
 
75
#ifndef NBPFILTER
76
#define NBPFILTER 0
77
#endif
78
 
79
#if NBPFILTER > 0
80
#include <net/bpf.h>
81
#include <net/bpfdesc.h>
82
#endif
83
 
84
#else // !CYGPKG_NET
85
#include <cyg/hal/drv_api.h>
86
#endif
87
#ifdef CYGPKG_NET_LWIP
88
#include "lwip/netif.h"
89
#endif
90
 
91
struct eth_drv_sg {
92
    CYG_ADDRESS  buf;
93
    CYG_ADDRWORD len;
94
};
95
 
96
#define MAX_ETH_DRV_SG CYGNUM_IO_ETH_DRIVERS_SG_LIST_SIZE
97
 
98
struct eth_drv_sc;
99
 
100
struct eth_drv_funs {
101
    // Logical driver - initialization
102
    void (*init)(struct eth_drv_sc *sc,
103
                 unsigned char *enaddr);
104
    // Logical driver - incoming packet notifier
105
    void (*recv)(struct eth_drv_sc *sc,
106
                 int total_len);
107
    // Logical driver - outgoing packet notifier
108
    void (*tx_done)(struct eth_drv_sc *sc,
109
                    CYG_ADDRESS key,
110
                    int status);
111
};
112
 
113
struct eth_hwr_funs {
114
    // Initialize hardware (including startup)
115
    void (*start)(struct eth_drv_sc *sc,
116
                  unsigned char *enaddr,
117
                  int flags);
118
    // Shut down hardware
119
    void (*stop)(struct eth_drv_sc *sc);
120
    // Device control (ioctl pass-thru)
121
    int  (*control)(struct eth_drv_sc *sc,
122
                    unsigned long key,
123
                    void *data,
124
                    int   data_length);
125
    // Query - can a packet be sent?
126
    int  (*can_send)(struct eth_drv_sc *sc);
127
    // Send a packet of data
128
    void (*send)(struct eth_drv_sc *sc,
129
                 struct eth_drv_sg *sg_list,
130
                 int sg_len,
131
                 int total_len,
132
                 unsigned long key);
133
    // Receive [unload] a packet of data
134
    void (*recv)(struct eth_drv_sc *sc,
135
                 struct eth_drv_sg *sg_list,
136
                 int sg_len);
137
    // Deliver data to/from device from/to stack memory space
138
    // (moves lots of memcpy()s out of DSRs into thread)
139
    void (*deliver)(struct eth_drv_sc *sc);
140
    // Poll for interrupts/device service
141
    void (*poll)(struct eth_drv_sc *sc);
142
    // Get interrupt information from hardware driver
143
    int (*int_vector)(struct eth_drv_sc *sc);
144
    // Logical driver interface
145
    struct eth_drv_funs *eth_drv, *eth_drv_old;
146
};
147
 
148
#ifdef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
149
struct arpcom {
150
    unsigned char esa[6];
151
};
152
#endif
153
 
154
#ifdef CYGPKG_NET_LWIP
155
struct arpcom {
156
    struct netif ac_if;
157
# ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
158
    cyg_sem_t send_sem;
159
# endif
160
};
161
#endif
162
 
163
struct eth_drv_sc {
164
    struct eth_hwr_funs *funs;
165
    void                *driver_private;
166
    const char          *dev_name;
167
    int                  state;
168
    struct arpcom        sc_arpcom; /* ethernet common */
169
};
170
 
171
#define ETH_DRV_SC(sc,priv,name,start,stop,control,can_send,send,recv,deliver,poll,int_vector) \
172
static void start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags); \
173
static void stop(struct eth_drv_sc *sc); \
174
static int  control(struct eth_drv_sc *sc, unsigned long key, void *data, int data_length); \
175
static int  can_send(struct eth_drv_sc *sc); \
176
static void send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, int total, unsigned long key); \
177
static void recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len); \
178
static void deliver(struct eth_drv_sc *sc); \
179
static void poll(struct eth_drv_sc *sc); \
180
static int  int_vector(struct eth_drv_sc *sc); \
181
static struct eth_hwr_funs sc##_funs = {        \
182
    start,                                      \
183
    stop,                                       \
184
    control,                                    \
185
    can_send,                                   \
186
    send,                                       \
187
    recv,                                       \
188
    deliver,                                    \
189
    poll,                                       \
190
    int_vector,                                 \
191
    &eth_drv_funs,                              \
192
    (struct eth_drv_funs *)0 };                 \
193
struct eth_drv_sc sc = {&sc##_funs, priv, name};
194
 
195
#define ETH_DRV_STATE_ACTIVE   0x0001
196
#define ETH_DRV_NEEDS_DELIVERY 0x0002
197
#define ETH_DRV_STATE_DEBUG    0x1000
198
 
199
// Register this as your DSR within your driver: it will cause your deliver
200
// routine to be called from the network thread.  The "data" parameter
201
// *must* be your own "struct eth_drv_sc *sc" pointer.
202
extern void eth_drv_dsr(cyg_vector_t vector,
203
                        cyg_ucount32 count,
204
                        cyg_addrword_t data);
205
 
206
extern struct eth_drv_funs eth_drv_funs;
207
 
208
#ifdef CYGPKG_IO_PCMCIA
209
#ifdef CYGPKG_NET
210
#include <cyg/io/eth/netdev.h>
211
cyg_netdevtab_entry_t *eth_drv_netdev(char *name);
212
#endif
213
#endif // CYGPKG_IO_PCMCIA
214
 
215
// Control 'key's
216
#define ETH_DRV_SET_MAC_ADDRESS 0x0100
217
 
218
#ifdef CYGPKG_NET
219
#define ETH_DRV_GET_IF_STATS_UD 0x0101
220
#define ETH_DRV_GET_IF_STATS    0x0102
221
#include <cyg/io/eth/eth_drv_stats.h> // The struct * for these ops.
222
#endif
223
 
224
#ifndef ETHER_ADDR_LEN
225
#define ETHER_ADDR_LEN 6
226
#endif
227
 
228
#define ETH_DRV_SET_MC_LIST     0x0110   // Set multicast list
229
#define ETH_DRV_SET_MC_ALL      0x0111   // Set multicast all mode
230
#define ETH_DRV_MAX_MC 8
231
struct eth_drv_mc_list {
232
    int len;
233
    unsigned char addrs[ETH_DRV_MAX_MC][ETHER_ADDR_LEN];
234
};
235
 
236
#ifndef CYGPKG_NET
237
extern void eth_drv_buffers_init(void);
238
extern int  eth_drv_read(char *eth_hdr, char *buf, int len);
239
extern void eth_drv_write(char *eth_hdr, char *buf, int len);
240
extern int  eth_drv_int_vector(void);
241
extern void eth_drv_stop(void);
242
extern unsigned char __local_enet_addr[];
243
extern struct eth_drv_sc *__local_enet_sc;
244
#endif
245
 
246
#endif // _ETH_DRV_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.