Ignore:
Timestamp:
2011-01-06T20:16:24Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c2f3e0b
Parents:
196ef08 (diff), e0854e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge of a huge refactoring of the original NE2000 driver

  • coding style changes
  • removal of all the unnecessary and unused stuff from the original MINIX driver
  • improved interrupt handling
  • removal of several additional buffering layers

The TCP/IP stack is still not 100 % functional (spurious packet losses, duplicate frames, etc.), but it is being debugged on a real netowkr now (QEMU/KVM connected via TAP bridge into a LAN). It is possible to ping the virtual machine with HelenOS from the LAN and even ping machines on the public Internet from HelenOS.

The cleanup of the original NE2000 driver should allow a faster debugging pace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/netif/dp8390/dp8390_port.h

    r196ef08 rb1d15e7  
    4444#include <sys/types.h>
    4545
    46 /** Macro for difining functions.
    47  *  @param[in] function The function type and name definition.
    48  *  @param[in] params The function parameters definition.
    49  */
    50 #define _PROTOTYPE(function, params) function params
    51 
    52 /** Success error code.
    53  */
    54 #define OK      EOK
    55 
    56 /** Type definition of the unsigned byte.
    57  */
    58 typedef uint8_t u8_t;
    59 
    60 /** Type definition of the unsigned short.
    61  */
    62 typedef uint16_t u16_t;
    63 
    6446/** Compares two memory blocks.
    6547 *  @param[in] first The first memory block.
     
    7052 *  @returns 1 if the second is greater than the first.
    7153 */
    72 #define memcmp(first, second, size)     bcmp((char *) (first), (char *) (second), (size))
     54#define memcmp(first, second, size)  bcmp((char *) (first), (char *) (second), (size))
    7355
    7456/** Reads 1 byte.
     
    7658 *  @returns The read value.
    7759 */
    78 #define inb(port)       pio_read_8((ioport8_t *) (port))
     60#define inb(port)  pio_read_8((ioport8_t *) (port))
    7961
    8062/** Reads 1 word (2 bytes).
     
    8264 *  @returns The read value.
    8365 */
    84 #define inw(port)       pio_read_16((ioport16_t *) (port))
     66#define inw(port)  pio_read_16((ioport16_t *) (port))
    8567
    8668/** Writes 1 byte.
     
    8870 *  @param[in] value The value to be written.
    8971 */
    90 #define outb(port, value)       pio_write_8((ioport8_t *) (port), (value))
     72#define outb(port, value)  pio_write_8((ioport8_t *) (port), (value))
    9173
    9274/** Writes 1 word (2 bytes).
     
    9476 *  @param[in] value The value to be written.
    9577 */
    96 #define outw(port, value)       pio_write_16((ioport16_t *) (port), (value))
     78#define outw(port, value)  pio_write_16((ioport16_t *) (port), (value))
    9779
    98 /** Prints out the driver critical error.
    99  *  Does not call the system panic().
    100  */
    101 #define panic(...)      printf("%s%s%d", __VA_ARGS__)
     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
    10285
    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  */
    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  */
    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  */
    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  */
    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  */
    145 #define do_vir_outsw(port, proc, src, bytes)    outsw((port), (void *)(src), (bytes))
    146 
    147 /* com.h */
    148 /* Bits in 'DL_MODE' field of DL requests. */
    149 #  define DL_NOMODE             0x0
    150 #  define DL_PROMISC_REQ        0x2
    151 #  define DL_MULTI_REQ          0x4
    152 #  define DL_BROAD_REQ          0x8
    153 
    154 /* const.h */
    155 /** True value.
    156  */
    157 #define TRUE               1    /* used for turning integers into Booleans */
    158 
    159 /** False value.
    160  */
    161 #define FALSE              0    /* used for turning integers into Booleans */
    162 
    163 /** No number value.
    164  */
    165 #define NO_NUM        0x8000    /* used as numerical argument to panic() */
    166 
    167 /* devio.h */
    168 //typedef u16_t port_t;
    16986/** Type definition of a port.
    17087 */
    17188typedef long port_t;
    17289
    173 /* dl_eth.h */
    17490/** Ethernet statistics.
    17591 */
    176 typedef struct eth_stat
    177 {
     92typedef struct eth_stat {
    17893        /** Number of receive errors.
    17994         */
     
    226141} eth_stat_t;
    227142
    228 /* errno.h */
    229 /** Generic error.
    230  */
    231 #define EGENERIC     EINVAL
    232 
    233 /* ether.h */
    234143/** Minimum Ethernet packet size in bytes.
    235144 */
    236 #define ETH_MIN_PACK_SIZE                 60
     145#define ETH_MIN_PACK_SIZE  60
    237146
    238147/** Maximum Ethernet packet size in bytes.
    239148 */
    240 #define ETH_MAX_PACK_SIZE_TAGGED        1518
     149#define ETH_MAX_PACK_SIZE_TAGGED  1518
    241150
    242151/** Ethernet address type definition.
    243152 */
    244 typedef struct ether_addr
    245 {
     153typedef struct ether_addr {
    246154        /** Address data.
    247155         */
    248         u8_t ea_addr[6];
     156        uint8_t ea_addr[6];
    249157} ether_addr_t;
    250 
    251 /* type.h */
    252 /** Type definition of the physical addresses and lengths in bytes.
    253  */
    254 typedef unsigned long phys_bytes;
    255 
    256 /** Type definition of the virtual addresses and lengths in bytes.
    257  */
    258 typedef unsigned long vir_bytes;
    259 
    260 /** Type definition of the input/output vector.
    261  */
    262 typedef struct {
    263         /** Address of an I/O buffer.
    264          */
    265         vir_bytes iov_addr;
    266         /** Sizeof an I/O buffer.
    267          */
    268         vir_bytes iov_size;
    269 } iovec_t;
    270158
    271159#endif
Note: See TracChangeset for help on using the changeset viewer.