source: mainline/uspace/srv/hw/netif/dp8390/dp8390_port.h@ 122b753

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 122b753 was 122b753, checked in by Martin Decky <martin@…>, 15 years ago

more declutter

  • Property mode set to 100644
File size: 5.8 KB
Line 
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/** Reads a memory block byte by byte.
81 * @param[in] port The address to be written.
82 * @param[in] dst The destination address.
83 * @param[in] bytes The block size in bytes.
84 */
85#define do_vir_insb(port, dst, bytes) insb((port), (void *)(dst), (bytes))
86
87/** Reads a memory block word by word (2 bytes).
88 * @param[in] port The address to be written.
89 * @param[in] dst The destination address.
90 * @param[in] bytes The block size in bytes.
91 */
92#define do_vir_insw(port, dst, bytes) insw((port), (void *)(dst), (bytes))
93
94/** Writes a memory block byte by byte.
95 * @param[in] port The address to be written.
96 * @param[in] src The source address.
97 * @param[in] bytes The block size in bytes.
98 */
99#define do_vir_outsb(port, src, bytes) outsb((port), (void *)(src), (bytes))
100
101/** Writes a memory block word by word (2 bytes).
102 * @param[in] port The address to be written.
103 * @param[in] src The source address.
104 * @param[in] bytes The block size in bytes.
105 */
106#define do_vir_outsw(port, src, bytes) outsw((port), (void *)(src), (bytes))
107
108/* Bits in 'DL_MODE' field of DL requests. */
109#define DL_NOMODE 0x0
110#define DL_PROMISC_REQ 0x2
111#define DL_MULTI_REQ 0x4
112#define DL_BROAD_REQ 0x8
113
114/** Type definition of a port.
115 */
116typedef long port_t;
117
118/** Ethernet statistics.
119 */
120typedef struct eth_stat {
121 /** Number of receive errors.
122 */
123 unsigned long ets_recvErr;
124 /** Number of send error.
125 */
126 unsigned long ets_sendErr;
127 /** Number of buffer overwrite warnings.
128 */
129 unsigned long ets_OVW;
130 /** Number of crc errors of read.
131 */
132 unsigned long ets_CRCerr;
133 /** Number of frames not alligned (number of bits % 8 != 0).
134 */
135 unsigned long ets_frameAll;
136 /** Number of packets missed due to slow processing.
137 */
138 unsigned long ets_missedP;
139 /** Number of packets received.
140 */
141 unsigned long ets_packetR;
142 /** Number of packets transmitted.
143 */
144 unsigned long ets_packetT;
145 /** Number of transmission defered (Tx was busy).
146 */
147 unsigned long ets_transDef;
148 /** Number of collissions.
149 */
150 unsigned long ets_collision;
151 /** Number of Tx aborted due to excess collisions.
152 */
153 unsigned long ets_transAb;
154 /** Number of carrier sense lost.
155 */
156 unsigned long ets_carrSense;
157 /** Number of FIFO underruns (processor too busy).
158 */
159 unsigned long ets_fifoUnder;
160 /** Number of FIFO overruns (processor too busy).
161 */
162 unsigned long ets_fifoOver;
163 /** Number of times unable to transmit collision sig.
164 */
165 unsigned long ets_CDheartbeat;
166 /** Number of times out of window collision.
167 */
168 unsigned long ets_OWC;
169} eth_stat_t;
170
171/* ether.h */
172/** Minimum Ethernet packet size in bytes.
173 */
174#define ETH_MIN_PACK_SIZE 60
175
176/** Maximum Ethernet packet size in bytes.
177 */
178#define ETH_MAX_PACK_SIZE_TAGGED 1518
179
180/** Ethernet address type definition.
181 */
182typedef struct ether_addr {
183 /** Address data.
184 */
185 uint8_t ea_addr[6];
186} ether_addr_t;
187
188/** Type definition of the input/output vector.
189 */
190typedef struct {
191 /** Address of an I/O buffer.
192 */
193 void *iov_addr;
194
195 /** Size of an I/O buffer.
196 */
197 size_t iov_size;
198} iovec_t;
199
200#endif
201
202/** @}
203 */
Note: See TracBrowser for help on using the repository browser.