Subversion Repositories HelenOS

Rev

Rev 4163 | Rev 4723 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4163 Rev 4192
1
/*
1
/*
2
 * Copyright (c) 2009 Lukas Mejdrech
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup dp8390
29
/** @addtogroup dp8390
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
#ifndef __NET_NETIF_DP8390_PORT_H__
33
#ifndef __NET_NETIF_DP8390_PORT_H__
34
#define __NET_NETIF_DP8390_PORT_H__
34
#define __NET_NETIF_DP8390_PORT_H__
35
 
35
 
36
#include <errno.h>
36
#include <errno.h>
-
 
37
#include <mem.h>
37
#include <stdio.h>
38
#include <stdio.h>
38
#include <libarch/ddi.h>
39
#include <libarch/ddi.h>
39
#include <sys/types.h>
40
#include <sys/types.h>
40
 
41
 
41
#define _PROTOTYPE( function, params ) function params
42
#define _PROTOTYPE( function, params ) function params
42
 
43
 
43
#define OK  EOK
44
#define OK  EOK
44
 
45
 
45
typedef uint8_t u8_t;
46
typedef uint8_t u8_t;
46
typedef uint16_t u16_t;
47
typedef uint16_t u16_t;
47
 
48
 
48
static inline int memcmp( const void * first, const void * second, size_t length ){
49
#define memcmp( first, second, size )   bcmp(( char * ) ( first ), ( char * ) ( second ), ( size ))
49
    uint8_t *   f;
-
 
50
    uint8_t *   s;
-
 
51
 
-
 
52
    if( ! first ){
-
 
53
        return second ? 1 : 0;
-
 
54
    }
-
 
55
    if( ! second ) return -1;
-
 
56
    f = ( uint8_t * ) first;
-
 
57
    s = ( uint8_t * ) second;
-
 
58
    while(( length > 0 ) && (( * f ) == ( * s ))){
-
 
59
        -- length;
-
 
60
        ++ f;
-
 
61
        ++ s;
-
 
62
    }
-
 
63
    return length ? ((( * f ) < ( * s )) ? 1 : -1 ): 0;
-
 
64
}
-
 
65
 
50
 
66
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
51
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
67
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
52
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
68
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
53
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
69
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
54
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
70
 
55
 
71
#define panic( ... )    { printf( __VA_ARGS__ ); return; }
56
#define panic( ... )    printf( "%s%s%d", __VA_ARGS__ )
-
 
57
 
-
 
58
#define sys_vircopy( proc, src_s, src, me, dst_s, dst, bytes )  ({ memcpy(( void * )( dst ), ( void * )( src ), ( bytes )); EOK; })
-
 
59
#define do_vir_insb( port, proc, src, bytes )   insb(( port ), ( void * )( src ), ( bytes ))
-
 
60
#define do_vir_insw( port, proc, src, bytes )   insw(( port ), ( void * )( src ), ( bytes ))
-
 
61
#define do_vir_outsb( port, proc, src, bytes )  outsb(( port ), ( void * )( src ), ( bytes ))
-
 
62
#define do_vir_outsw( port, proc, src, bytes )  outsw(( port ), ( void * )( src ), ( bytes ))
72
 
63
 
73
/* com.h */
64
/* com.h */
74
/* Bits in 'DL_MODE' field of DL requests. */
65
/* Bits in 'DL_MODE' field of DL requests. */
75
#  define DL_NOMODE     0x0
66
#  define DL_NOMODE     0x0
76
#  define DL_PROMISC_REQ    0x2
67
#  define DL_PROMISC_REQ    0x2
77
#  define DL_MULTI_REQ      0x4
68
#  define DL_MULTI_REQ      0x4
78
#  define DL_BROAD_REQ      0x8
69
#  define DL_BROAD_REQ      0x8
79
 
70
 
80
/* const.h */
71
/* const.h */
81
#define TRUE               1    /* used for turning integers into Booleans */
72
#define TRUE               1    /* used for turning integers into Booleans */
82
#define FALSE              0    /* used for turning integers into Booleans */
73
#define FALSE              0    /* used for turning integers into Booleans */
83
#define NO_NUM        0x8000    /* used as numerical argument to panic() */
74
#define NO_NUM        0x8000    /* used as numerical argument to panic() */
84
 
75
 
85
/* devio.h */
76
/* devio.h */
86
typedef u16_t port_t;
77
//typedef u16_t port_t;
-
 
78
typedef int port_t;
87
 
79
 
88
/* dl_eth.h */
80
/* dl_eth.h */
89
typedef struct eth_stat
81
typedef struct eth_stat
90
{
82
{
91
  unsigned long ets_recvErr,    /* # receive errors */
83
  unsigned long ets_recvErr,    /* # receive errors */
92
    ets_sendErr,        /* # send error */
84
    ets_sendErr,        /* # send error */
93
    ets_OVW,        /* # buffer overwrite warnings */
85
    ets_OVW,        /* # buffer overwrite warnings */
94
    ets_CRCerr,     /* # crc errors of read */
86
    ets_CRCerr,     /* # crc errors of read */
95
    ets_frameAll,       /* # frames not alligned (# bits % 8 != 0) */
87
    ets_frameAll,       /* # frames not alligned (# bits % 8 != 0) */
96
    ets_missedP,        /* # packets missed due to slow processing */
88
    ets_missedP,        /* # packets missed due to slow processing */
97
    ets_packetR,        /* # packets received */
89
    ets_packetR,        /* # packets received */
98
    ets_packetT,        /* # packets transmitted */
90
    ets_packetT,        /* # packets transmitted */
99
    ets_transDef,       /* # transmission defered (Tx was busy) */
91
    ets_transDef,       /* # transmission defered (Tx was busy) */
100
    ets_collision,      /* # collissions */
92
    ets_collision,      /* # collissions */
101
    ets_transAb,        /* # Tx aborted due to excess collisions */
93
    ets_transAb,        /* # Tx aborted due to excess collisions */
102
    ets_carrSense,      /* # carrier sense lost */
94
    ets_carrSense,      /* # carrier sense lost */
103
    ets_fifoUnder,      /* # FIFO underruns (processor too busy) */
95
    ets_fifoUnder,      /* # FIFO underruns (processor too busy) */
104
    ets_fifoOver,       /* # FIFO overruns (processor too busy) */
96
    ets_fifoOver,       /* # FIFO overruns (processor too busy) */
105
    ets_CDheartbeat,    /* # times unable to transmit collision sig*/
97
    ets_CDheartbeat,    /* # times unable to transmit collision sig*/
106
    ets_OWC;        /* # times out of window collision */
98
    ets_OWC;        /* # times out of window collision */
107
} eth_stat_t;
99
} eth_stat_t;
108
 
100
 
109
/* errno.h */
101
/* errno.h */
110
#define EGENERIC     EINVAL
102
#define EGENERIC     EINVAL
111
 
103
 
112
/* ether.h */
104
/* ether.h */
113
#define ETH_MIN_PACK_SIZE         60
105
#define ETH_MIN_PACK_SIZE         60
114
#define ETH_MAX_PACK_SIZE_TAGGED    1518
106
#define ETH_MAX_PACK_SIZE_TAGGED    1518
115
 
107
 
116
typedef struct ether_addr
108
typedef struct ether_addr
117
{
109
{
118
    u8_t ea_addr[6];
110
    u8_t ea_addr[6];
119
} ether_addr_t;
111
} ether_addr_t;
120
 
112
 
121
/* type.h */
113
/* type.h */
122
//TODO platform dependent types
114
//TODO platform dependent types
123
typedef unsigned long phys_bytes;   /* physical addr/length in bytes */
115
typedef unsigned long phys_bytes;   /* physical addr/length in bytes */
124
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
116
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
125
 
117
 
126
typedef struct {
118
typedef struct {
127
  vir_bytes iov_addr;       /* address of an I/O buffer */
119
  vir_bytes iov_addr;       /* address of an I/O buffer */
128
  vir_bytes iov_size;       /* sizeof an I/O buffer */
120
  vir_bytes iov_size;       /* sizeof an I/O buffer */
129
} iovec_t;
121
} iovec_t;
130
 
122
 
131
#endif
123
#endif
132
 
124
 
133
/** @}
125
/** @}
134
 */
126
 */
135
 
127