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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [eth/] [v2_0/] [include/] [eth_drv.h] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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