Subversion Repositories HelenOS

Rev

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