Subversion Repositories HelenOS

Rev

Rev 4192 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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. #ifndef __NET_NETIF_DP8390_PORT_H__
  34. #define __NET_NETIF_DP8390_PORT_H__
  35.  
  36. #include <errno.h>
  37. #include <stdio.h>
  38. #include <libarch/ddi.h>
  39. #include <sys/types.h>
  40.  
  41. #define _PROTOTYPE( function, params ) function params
  42.  
  43. #define OK  EOK
  44.  
  45. typedef uint8_t u8_t;
  46. typedef uint16_t u16_t;
  47.  
  48. static inline int memcmp( const void * first, const void * second, size_t length ){
  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.  
  66. #define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
  67. #define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
  68. #define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
  69. #define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
  70.  
  71. #define panic( ... )    { printf( __VA_ARGS__ ); return; }
  72.  
  73. /* com.h */
  74. /* Bits in 'DL_MODE' field of DL requests. */
  75. #  define DL_NOMODE     0x0
  76. #  define DL_PROMISC_REQ    0x2
  77. #  define DL_MULTI_REQ      0x4
  78. #  define DL_BROAD_REQ      0x8
  79.  
  80. /* const.h */
  81. #define TRUE               1    /* used for turning integers into Booleans */
  82. #define FALSE              0    /* used for turning integers into Booleans */
  83. #define NO_NUM        0x8000    /* used as numerical argument to panic() */
  84.  
  85. /* devio.h */
  86. typedef u16_t port_t;
  87.  
  88. /* dl_eth.h */
  89. typedef struct eth_stat
  90. {
  91.   unsigned long ets_recvErr,    /* # receive errors */
  92.     ets_sendErr,        /* # send error */
  93.     ets_OVW,        /* # buffer overwrite warnings */
  94.     ets_CRCerr,     /* # crc errors of read */
  95.     ets_frameAll,       /* # frames not alligned (# bits % 8 != 0) */
  96.     ets_missedP,        /* # packets missed due to slow processing */
  97.     ets_packetR,        /* # packets received */
  98.     ets_packetT,        /* # packets transmitted */
  99.     ets_transDef,       /* # transmission defered (Tx was busy) */
  100.     ets_collision,      /* # collissions */
  101.     ets_transAb,        /* # Tx aborted due to excess collisions */
  102.     ets_carrSense,      /* # carrier sense lost */
  103.     ets_fifoUnder,      /* # FIFO underruns (processor too busy) */
  104.     ets_fifoOver,       /* # FIFO overruns (processor too busy) */
  105.     ets_CDheartbeat,    /* # times unable to transmit collision sig*/
  106.     ets_OWC;        /* # times out of window collision */
  107. } eth_stat_t;
  108.  
  109. /* errno.h */
  110. #define EGENERIC     EINVAL
  111.  
  112. /* ether.h */
  113. #define ETH_MIN_PACK_SIZE         60
  114. #define ETH_MAX_PACK_SIZE_TAGGED    1518
  115.  
  116. typedef struct ether_addr
  117. {
  118.     u8_t ea_addr[6];
  119. } ether_addr_t;
  120.  
  121. /* type.h */
  122. //TODO platform dependent types
  123. typedef unsigned long phys_bytes;   /* physical addr/length in bytes */
  124. typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
  125.  
  126. typedef struct {
  127.   vir_bytes iov_addr;       /* address of an I/O buffer */
  128.   vir_bytes iov_size;       /* sizeof an I/O buffer */
  129. } iovec_t;
  130.  
  131. #endif
  132.  
  133. /** @}
  134.  */
  135.