1 | /*
|
---|
2 | * Copyright (c) 2009 Lukas Mejdrech
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
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
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
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
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
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
|
---|
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
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup dp8390
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /** @file
|
---|
34 | * DP8390 network interface types and structures ports.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef __NET_NETIF_DP8390_PORT_H__
|
---|
38 | #define __NET_NETIF_DP8390_PORT_H__
|
---|
39 |
|
---|
40 | #include <errno.h>
|
---|
41 | #include <mem.h>
|
---|
42 | #include <stdio.h>
|
---|
43 | #include <libarch/ddi.h>
|
---|
44 | #include <sys/types.h>
|
---|
45 |
|
---|
46 | /** Compares two memory blocks.
|
---|
47 | * @param[in] first The first memory block.
|
---|
48 | * @param[in] second The second memory block.
|
---|
49 | * @param[in] size The blocks size in bytes.
|
---|
50 | * @returns 0 if equeal.
|
---|
51 | * @returns -1 if the first is greater than the second.
|
---|
52 | * @returns 1 if the second is greater than the first.
|
---|
53 | */
|
---|
54 | #define memcmp(first, second, size) bcmp((char *) (first), (char *) (second), (size))
|
---|
55 |
|
---|
56 | /** Reads 1 byte.
|
---|
57 | * @param[in] port The address to be read.
|
---|
58 | * @returns The read value.
|
---|
59 | */
|
---|
60 | #define inb(port) pio_read_8((ioport8_t *) (port))
|
---|
61 |
|
---|
62 | /** Reads 1 word (2 bytes).
|
---|
63 | * @param[in] port The address to be read.
|
---|
64 | * @returns The read value.
|
---|
65 | */
|
---|
66 | #define inw(port) pio_read_16((ioport16_t *) (port))
|
---|
67 |
|
---|
68 | /** Writes 1 byte.
|
---|
69 | * @param[in] port The address to be written.
|
---|
70 | * @param[in] value The value to be written.
|
---|
71 | */
|
---|
72 | #define outb(port, value) pio_write_8((ioport8_t *) (port), (value))
|
---|
73 |
|
---|
74 | /** Writes 1 word (2 bytes).
|
---|
75 | * @param[in] port The address to be written.
|
---|
76 | * @param[in] value The value to be written.
|
---|
77 | */
|
---|
78 | #define outw(port, value) pio_write_16((ioport16_t *) (port), (value))
|
---|
79 |
|
---|
80 | /* Bits in 'DL_MODE' field of DL requests. */
|
---|
81 | #define DL_NOMODE 0x0
|
---|
82 | #define DL_PROMISC_REQ 0x2
|
---|
83 | #define DL_MULTI_REQ 0x4
|
---|
84 | #define DL_BROAD_REQ 0x8
|
---|
85 |
|
---|
86 | /** Type definition of a port.
|
---|
87 | */
|
---|
88 | typedef long port_t;
|
---|
89 |
|
---|
90 | /** Ethernet statistics.
|
---|
91 | */
|
---|
92 | typedef struct eth_stat {
|
---|
93 | /** Number of receive errors.
|
---|
94 | */
|
---|
95 | unsigned long ets_recvErr;
|
---|
96 | /** Number of send error.
|
---|
97 | */
|
---|
98 | unsigned long ets_sendErr;
|
---|
99 | /** Number of buffer overwrite warnings.
|
---|
100 | */
|
---|
101 | unsigned long ets_OVW;
|
---|
102 | /** Number of crc errors of read.
|
---|
103 | */
|
---|
104 | unsigned long ets_CRCerr;
|
---|
105 | /** Number of frames not alligned (number of bits % 8 != 0).
|
---|
106 | */
|
---|
107 | unsigned long ets_frameAll;
|
---|
108 | /** Number of packets missed due to slow processing.
|
---|
109 | */
|
---|
110 | unsigned long ets_missedP;
|
---|
111 | /** Number of packets received.
|
---|
112 | */
|
---|
113 | unsigned long ets_packetR;
|
---|
114 | /** Number of packets transmitted.
|
---|
115 | */
|
---|
116 | unsigned long ets_packetT;
|
---|
117 | /** Number of transmission defered (Tx was busy).
|
---|
118 | */
|
---|
119 | unsigned long ets_transDef;
|
---|
120 | /** Number of collissions.
|
---|
121 | */
|
---|
122 | unsigned long ets_collision;
|
---|
123 | /** Number of Tx aborted due to excess collisions.
|
---|
124 | */
|
---|
125 | unsigned long ets_transAb;
|
---|
126 | /** Number of carrier sense lost.
|
---|
127 | */
|
---|
128 | unsigned long ets_carrSense;
|
---|
129 | /** Number of FIFO underruns (processor too busy).
|
---|
130 | */
|
---|
131 | unsigned long ets_fifoUnder;
|
---|
132 | /** Number of FIFO overruns (processor too busy).
|
---|
133 | */
|
---|
134 | unsigned long ets_fifoOver;
|
---|
135 | /** Number of times unable to transmit collision sig.
|
---|
136 | */
|
---|
137 | unsigned long ets_CDheartbeat;
|
---|
138 | /** Number of times out of window collision.
|
---|
139 | */
|
---|
140 | unsigned long ets_OWC;
|
---|
141 | } eth_stat_t;
|
---|
142 |
|
---|
143 | /** Minimum Ethernet packet size in bytes.
|
---|
144 | */
|
---|
145 | #define ETH_MIN_PACK_SIZE 60
|
---|
146 |
|
---|
147 | /** Maximum Ethernet packet size in bytes.
|
---|
148 | */
|
---|
149 | #define ETH_MAX_PACK_SIZE_TAGGED 1518
|
---|
150 |
|
---|
151 | /** Ethernet address type definition.
|
---|
152 | */
|
---|
153 | typedef struct ether_addr {
|
---|
154 | /** Address data.
|
---|
155 | */
|
---|
156 | uint8_t ea_addr[6];
|
---|
157 | } ether_addr_t;
|
---|
158 |
|
---|
159 | #endif
|
---|
160 |
|
---|
161 | /** @}
|
---|
162 | */
|
---|