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