Subversion Repositories HelenOS

Rev

Rev 4743 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4743 Rev 4756
Line 29... Line 29...
29
/** @addtogroup dp8390
29
/** @addtogroup dp8390
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  \todo
34
 *  DP8390 network interface types and structures ports.
35
 */
35
 */
36
 
36
 
37
#ifndef __NET_NETIF_DP8390_PORT_H__
37
#ifndef __NET_NETIF_DP8390_PORT_H__
38
#define __NET_NETIF_DP8390_PORT_H__
38
#define __NET_NETIF_DP8390_PORT_H__
39
 
39
 
Line 41... Line 41...
41
#include <mem.h>
41
#include <mem.h>
42
#include <stdio.h>
42
#include <stdio.h>
43
#include <libarch/ddi.h>
43
#include <libarch/ddi.h>
44
#include <sys/types.h>
44
#include <sys/types.h>
45
 
45
 
-
 
46
/** Macro for difining functions.
-
 
47
 *  @param[in] function The function type and name definition.
-
 
48
 *  @param[in] params The function parameters definition.
-
 
49
 */
46
#define _PROTOTYPE( function, params ) function params
50
#define _PROTOTYPE( function, params ) function params
47
 
51
 
-
 
52
/** Success error code.
-
 
53
 */
48
#define OK  EOK
54
#define OK  EOK
49
 
55
 
-
 
56
/** Type definition of the unsigned byte.
-
 
57
 */
50
typedef uint8_t u8_t;
58
typedef uint8_t u8_t;
-
 
59
 
-
 
60
/** Type definition of the unsigned short.
-
 
61
 */
51
typedef uint16_t u16_t;
62
typedef uint16_t u16_t;
52
 
63
 
-
 
64
/** Compares two memory blocks.
-
 
65
 *  @param[in] first The first memory block.
-
 
66
 *  @param[in] second The second memory block.
-
 
67
 *  @param[in] size The blocks size in bytes.
-
 
68
 *  @returns 0 if equeal.
-
 
69
 *  @returns -1 if the first is greater than the second.
-
 
70
 *  @returns 1 if the second is greater than the first.
-
 
71
 */
53
#define memcmp( first, second, size )   bcmp(( char * ) ( first ), ( char * ) ( second ), ( size ))
72
#define memcmp( first, second, size )   bcmp(( char * ) ( first ), ( char * ) ( second ), ( size ))
54
 
73
 
-
 
74
/** Reads 1 byte.
-
 
75
 *  @param[in] port The address to be read.
-
 
76
 *  @returns The read value.
-
 
77
 */
55
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
78
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
-
 
79
 
-
 
80
/** Reads 1 word (2 bytes).
-
 
81
 *  @param[in] port The address to be read.
-
 
82
 *  @returns The read value.
-
 
83
 */
56
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
84
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
-
 
85
 
-
 
86
/** Writes 1 byte.
-
 
87
 *  @param[in] port The address to be written.
-
 
88
 *  @param[in] value The value to be written.
-
 
89
 */
57
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
90
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
-
 
91
 
-
 
92
/** Writes 1 word (2 bytes).
-
 
93
 *  @param[in] port The address to be written.
-
 
94
 *  @param[in] value The value to be written.
-
 
95
 */
58
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
96
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
59
 
97
 
-
 
98
/** Prints out the driver critical error.
-
 
99
 *  Does not call the system panic().
-
 
100
 */
60
#define panic( ... )    printf( "%s%s%d", __VA_ARGS__ )
101
#define panic( ... )    printf( "%s%s%d", __VA_ARGS__ )
61
 
102
 
-
 
103
/** Copies a memory block.
-
 
104
 *  @param proc The source process. Ignored parameter.
-
 
105
 *  @param src_s Ignored parameter.
-
 
106
 *  @param[in] src The source address.
-
 
107
 *  @param me The current proces. Ignored parameter.
-
 
108
 *  @param dst_s Ignored parameter.
-
 
109
 *  @param[in] dst The destination address.
-
 
110
 *  @param[in] bytes The block size in bytes.
-
 
111
 *  @returns EOK.
-
 
112
 */
62
#define sys_vircopy( proc, src_s, src, me, dst_s, dst, bytes )  ({ memcpy(( void * )( dst ), ( void * )( src ), ( bytes )); EOK; })
113
#define sys_vircopy( proc, src_s, src, me, dst_s, dst, bytes )  ({ memcpy(( void * )( dst ), ( void * )( src ), ( bytes )); EOK; })
-
 
114
 
-
 
115
/** Reads a memory block byte by byte.
-
 
116
 *  @param[in] port The address to be written.
-
 
117
 *  @param proc The source process. Ignored parameter.
-
 
118
 *  @param[in] dst The destination address.
-
 
119
 *  @param[in] bytes The block size in bytes.
-
 
120
 */
63
#define do_vir_insb( port, proc, src, bytes )   insb(( port ), ( void * )( src ), ( bytes ))
121
#define do_vir_insb( port, proc, dst, bytes )   insb(( port ), ( void * )( dst ), ( bytes ))
-
 
122
 
-
 
123
/** Reads a memory block word by word (2 bytes).
-
 
124
 *  @param[in] port The address to be written.
-
 
125
 *  @param proc The source process. Ignored parameter.
-
 
126
 *  @param[in] dst The destination address.
-
 
127
 *  @param[in] bytes The block size in bytes.
-
 
128
 */
64
#define do_vir_insw( port, proc, src, bytes )   insw(( port ), ( void * )( src ), ( bytes ))
129
#define do_vir_insw( port, proc, dst, bytes )   insw(( port ), ( void * )( dst ), ( bytes ))
-
 
130
 
-
 
131
/** Writes a memory block byte by byte.
-
 
132
 *  @param[in] port The address to be written.
-
 
133
 *  @param proc The source process. Ignored parameter.
-
 
134
 *  @param[in] src The source address.
-
 
135
 *  @param[in] bytes The block size in bytes.
-
 
136
 */
65
#define do_vir_outsb( port, proc, src, bytes )  outsb(( port ), ( void * )( src ), ( bytes ))
137
#define do_vir_outsb( port, proc, src, bytes )  outsb(( port ), ( void * )( src ), ( bytes ))
-
 
138
 
-
 
139
/** Writes a memory block word by word (2 bytes).
-
 
140
 *  @param[in] port The address to be written.
-
 
141
 *  @param proc The source process. Ignored parameter.
-
 
142
 *  @param[in] src The source address.
-
 
143
 *  @param[in] bytes The block size in bytes.
-
 
144
 */
66
#define do_vir_outsw( port, proc, src, bytes )  outsw(( port ), ( void * )( src ), ( bytes ))
145
#define do_vir_outsw( port, proc, src, bytes )  outsw(( port ), ( void * )( src ), ( bytes ))
67
 
146
 
68
/* com.h */
147
/* com.h */
69
/* Bits in 'DL_MODE' field of DL requests. */
148
/* Bits in 'DL_MODE' field of DL requests. */
70
#  define DL_NOMODE     0x0
149
#  define DL_NOMODE     0x0
71
#  define DL_PROMISC_REQ    0x2
150
#  define DL_PROMISC_REQ    0x2
72
#  define DL_MULTI_REQ      0x4
151
#  define DL_MULTI_REQ      0x4
73
#  define DL_BROAD_REQ      0x8
152
#  define DL_BROAD_REQ      0x8
74
 
153
 
75
/* const.h */
154
/* const.h */
-
 
155
/** True value.
-
 
156
 */
76
#define TRUE               1    /* used for turning integers into Booleans */
157
#define TRUE               1    /* used for turning integers into Booleans */
-
 
158
 
-
 
159
/** False value.
-
 
160
 */
77
#define FALSE              0    /* used for turning integers into Booleans */
161
#define FALSE              0    /* used for turning integers into Booleans */
-
 
162
 
-
 
163
/** No number value.
-
 
164
 */
78
#define NO_NUM        0x8000    /* used as numerical argument to panic() */
165
#define NO_NUM        0x8000    /* used as numerical argument to panic() */
79
 
166
 
80
/* devio.h */
167
/* devio.h */
81
//typedef u16_t port_t;
168
//typedef u16_t port_t;
-
 
169
/** Type definition of a port.
-
 
170
 */
82
typedef int port_t;
171
typedef int port_t;
83
 
172
 
84
/* dl_eth.h */
173
/* dl_eth.h */
-
 
174
/** Ethernet statistics.
-
 
175
 */
85
typedef struct eth_stat
176
typedef struct eth_stat
86
{
177
{
-
 
178
    /** Number of receive errors.
-
 
179
     */
87
  unsigned long ets_recvErr,    /* # receive errors */
180
    unsigned long ets_recvErr;
88
    ets_sendErr,        /* # send error */
181
    /** Number of send error.
-
 
182
     */
-
 
183
    unsigned long ets_sendErr;
89
    ets_OVW,        /* # buffer overwrite warnings */
184
    /** Number of buffer overwrite warnings.
-
 
185
     */
-
 
186
    unsigned long ets_OVW;
90
    ets_CRCerr,     /* # crc errors of read */
187
    /** Number of crc errors of read.
-
 
188
     */
-
 
189
    unsigned long ets_CRCerr;
91
    ets_frameAll,       /* # frames not alligned (# bits % 8 != 0) */
190
    /** Number of frames not alligned (number of bits % 8 != 0).
-
 
191
     */
-
 
192
    unsigned long ets_frameAll;
92
    ets_missedP,        /* # packets missed due to slow processing */
193
    /** Number of packets missed due to slow processing.
-
 
194
     */
-
 
195
    unsigned long ets_missedP;
93
    ets_packetR,        /* # packets received */
196
    /** Number of packets received.
-
 
197
     */
-
 
198
    unsigned long ets_packetR;
94
    ets_packetT,        /* # packets transmitted */
199
    /** Number of packets transmitted.
-
 
200
     */
-
 
201
    unsigned long ets_packetT;
95
    ets_transDef,       /* # transmission defered (Tx was busy) */
202
    /** Number of transmission defered (Tx was busy).
-
 
203
     */
-
 
204
    unsigned long ets_transDef;
96
    ets_collision,      /* # collissions */
205
    /** Number of collissions.
-
 
206
     */
-
 
207
    unsigned long ets_collision;
97
    ets_transAb,        /* # Tx aborted due to excess collisions */
208
    /** Number of Tx aborted due to excess collisions.
-
 
209
     */
-
 
210
    unsigned long ets_transAb;
98
    ets_carrSense,      /* # carrier sense lost */
211
    /** Number of carrier sense lost.
-
 
212
     */
-
 
213
    unsigned long ets_carrSense;
99
    ets_fifoUnder,      /* # FIFO underruns (processor too busy) */
214
    /** Number of FIFO underruns (processor too busy).
-
 
215
     */
-
 
216
    unsigned long ets_fifoUnder;
100
    ets_fifoOver,       /* # FIFO overruns (processor too busy) */
217
    /** Number of FIFO overruns (processor too busy).
-
 
218
     */
-
 
219
    unsigned long ets_fifoOver;
101
    ets_CDheartbeat,    /* # times unable to transmit collision sig*/
220
    /** Number of times unable to transmit collision sig.
-
 
221
     */
-
 
222
    unsigned long ets_CDheartbeat;
102
    ets_OWC;        /* # times out of window collision */
223
    /** Number of times out of window collision.
-
 
224
     */
-
 
225
    unsigned long ets_OWC;
103
} eth_stat_t;
226
} eth_stat_t;
104
 
227
 
105
/* errno.h */
228
/* errno.h */
-
 
229
/** Generic error.
-
 
230
 */
106
#define EGENERIC     EINVAL
231
#define EGENERIC     EINVAL
107
 
232
 
108
/* ether.h */
233
/* ether.h */
-
 
234
/** Minimum Ethernet packet size in bytes.
-
 
235
 */
109
#define ETH_MIN_PACK_SIZE         60
236
#define ETH_MIN_PACK_SIZE         60
-
 
237
 
-
 
238
/** Maximum Ethernet packet size in bytes.
-
 
239
 */
110
#define ETH_MAX_PACK_SIZE_TAGGED    1518
240
#define ETH_MAX_PACK_SIZE_TAGGED    1518
111
 
241
 
-
 
242
/** Ethernet address type definition.
-
 
243
 */
112
typedef struct ether_addr
244
typedef struct ether_addr
113
{
245
{
-
 
246
    /** Address data.
-
 
247
     */
114
    u8_t ea_addr[6];
248
    u8_t ea_addr[6];
115
} ether_addr_t;
249
} ether_addr_t;
116
 
250
 
117
/* type.h */
251
/* type.h */
118
typedef unsigned long phys_bytes;   /* physical addr/length in bytes */
252
/** Type definition of the physical addresses and lengths in bytes.
-
 
253
 */
-
 
254
typedef unsigned long phys_bytes;
-
 
255
 
119
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
256
/** Type definition of the virtual addresses and lengths in bytes.
-
 
257
 */
-
 
258
typedef unsigned int vir_bytes;
120
 
259
 
-
 
260
/** Type definition of the input/output vector.
-
 
261
 */
121
typedef struct {
262
typedef struct {
122
  vir_bytes iov_addr;       /* address of an I/O buffer */
263
    /** Address of an I/O buffer.
-
 
264
     */
-
 
265
    vir_bytes iov_addr;
123
  vir_bytes iov_size;       /* sizeof an I/O buffer */
266
    /** Sizeof an I/O buffer.
-
 
267
     */
-
 
268
    vir_bytes iov_size;
124
} iovec_t;
269
} iovec_t;
125
 
270
 
126
#endif
271
#endif
127
 
272
 
128
/** @}
273
/** @}