/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** @addtogroup dp8390
* @{
*/
#ifndef __NET_NETIF_DP8390_PORT_H__
#define __NET_NETIF_DP8390_PORT_H__
#include <errno.h>
#include <stdio.h>
#include <libarch/ddi.h>
#include <sys/types.h>
#define _PROTOTYPE( function, params ) function params
#define OK EOK
typedef uint8_t u8_t;
typedef uint16_t u16_t;
static inline int memcmp( const void * first, const void * second, size_t length ){
uint8_t * f;
uint8_t * s;
if( ! first ){
return second ? 1 : 0;
}
if( ! second ) return -1;
f = ( uint8_t * ) first;
s = ( uint8_t * ) second;
while(( length > 0 ) && (( * f ) == ( * s ))){
-- length;
++ f;
++ s;
}
return length ? ((( * f ) < ( * s )) ? 1 : -1 ): 0;
}
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
#define panic( ... ) { printf( __VA_ARGS__ ); return; }
/* com.h */
/* Bits in 'DL_MODE' field of DL requests. */
# define DL_NOMODE 0x0
# define DL_PROMISC_REQ 0x2
# define DL_MULTI_REQ 0x4
# define DL_BROAD_REQ 0x8
/* const.h */
#define TRUE 1 /* used for turning integers into Booleans */
#define FALSE 0 /* used for turning integers into Booleans */
#define NO_NUM 0x8000 /* used as numerical argument to panic() */
/* devio.h */
typedef u16_t port_t;
/* dl_eth.h */
typedef struct eth_stat
{
unsigned long ets_recvErr, /* # receive errors */
ets_sendErr, /* # send error */
ets_OVW, /* # buffer overwrite warnings */
ets_CRCerr, /* # crc errors of read */
ets_frameAll, /* # frames not alligned (# bits % 8 != 0) */
ets_missedP, /* # packets missed due to slow processing */
ets_packetR, /* # packets received */
ets_packetT, /* # packets transmitted */
ets_transDef, /* # transmission defered (Tx was busy) */
ets_collision, /* # collissions */
ets_transAb, /* # Tx aborted due to excess collisions */
ets_carrSense, /* # carrier sense lost */
ets_fifoUnder, /* # FIFO underruns (processor too busy) */
ets_fifoOver, /* # FIFO overruns (processor too busy) */
ets_CDheartbeat, /* # times unable to transmit collision sig*/
ets_OWC; /* # times out of window collision */
} eth_stat_t;
/* errno.h */
#define EGENERIC EINVAL
/* ether.h */
#define ETH_MIN_PACK_SIZE 60
#define ETH_MAX_PACK_SIZE_TAGGED 1518
typedef struct ether_addr
{
u8_t ea_addr[6];
} ether_addr_t;
/* type.h */
//TODO platform dependent types
typedef unsigned long phys_bytes; /* physical addr/length in bytes */
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
typedef struct {
vir_bytes iov_addr; /* address of an I/O buffer */
vir_bytes iov_size; /* sizeof an I/O buffer */
} iovec_t;
#endif
/** @}
*/