2005-03-08 18:53:11 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NIC_H
|
|
|
|
#define NIC_H
|
|
|
|
|
2005-04-21 18:18:29 +00:00
|
|
|
#include "dev.h"
|
|
|
|
#include "byteswap.h"
|
|
|
|
#include "dhcp.h"
|
|
|
|
|
2005-03-08 18:53:11 +00:00
|
|
|
typedef enum {
|
|
|
|
DISABLE = 0,
|
|
|
|
ENABLE,
|
|
|
|
FORCE
|
|
|
|
} irq_action_t;
|
|
|
|
|
2005-04-13 00:16:42 +00:00
|
|
|
typedef enum duplex {
|
|
|
|
HALF_DUPLEX = 1,
|
|
|
|
FULL_DUPLEX
|
|
|
|
} duplex_t;
|
|
|
|
|
2005-03-08 18:53:11 +00:00
|
|
|
/*
|
|
|
|
* Structure returned from eth_probe and passed to other driver
|
|
|
|
* functions.
|
|
|
|
*/
|
2005-04-12 16:54:09 +00:00
|
|
|
struct nic {
|
2005-04-21 18:18:29 +00:00
|
|
|
struct nic_operations *nic_op;
|
|
|
|
int flags; /* driver specific flags */
|
|
|
|
unsigned char *node_addr;
|
|
|
|
unsigned char *packet;
|
|
|
|
unsigned int packetlen;
|
|
|
|
unsigned int ioaddr;
|
|
|
|
unsigned char irqno;
|
|
|
|
unsigned int mbps;
|
|
|
|
duplex_t duplex;
|
|
|
|
struct dhcp_dev_id dhcp_dev_id;
|
|
|
|
void *priv_data; /* driver private data */
|
2005-03-08 18:53:11 +00:00
|
|
|
};
|
|
|
|
|
2005-04-12 16:54:09 +00:00
|
|
|
struct nic_operations {
|
|
|
|
int ( *connect ) ( struct nic * );
|
|
|
|
int ( *poll ) ( struct nic *, int retrieve );
|
|
|
|
void ( *transmit ) ( struct nic *, const char *,
|
|
|
|
unsigned int, unsigned int, const char * );
|
|
|
|
void ( *irq ) ( struct nic *, irq_action_t );
|
|
|
|
};
|
|
|
|
|
2005-04-21 18:18:29 +00:00
|
|
|
extern struct type_driver nic_driver;
|
|
|
|
|
2005-04-12 16:54:09 +00:00
|
|
|
/*
|
|
|
|
* Function prototypes
|
|
|
|
*
|
|
|
|
*/
|
2005-04-12 19:11:13 +00:00
|
|
|
extern int dummy_connect ( struct nic *nic );
|
2005-04-13 01:28:43 +00:00
|
|
|
extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
|
2005-04-21 18:18:29 +00:00
|
|
|
extern void nic_disable ( struct nic *nic );
|
2005-04-12 16:54:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions that implicitly operate on the current boot device
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-04-21 18:18:29 +00:00
|
|
|
extern struct nic nic;
|
2005-04-12 16:54:09 +00:00
|
|
|
|
|
|
|
static inline int eth_connect ( void ) {
|
2005-04-21 18:18:29 +00:00
|
|
|
return nic.nic_op->connect ( &nic );
|
2005-04-12 16:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int eth_poll ( int retrieve ) {
|
2005-04-21 18:18:29 +00:00
|
|
|
return nic.nic_op->poll ( &nic, retrieve );
|
2005-04-12 16:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void eth_transmit ( const char *dest, unsigned int type,
|
|
|
|
unsigned int size, const void *packet ) {
|
2005-04-21 18:18:29 +00:00
|
|
|
nic.nic_op->transmit ( &nic, dest, type, size, packet );
|
2005-04-12 16:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void eth_irq ( irq_action_t action ) {
|
2005-04-21 18:18:29 +00:00
|
|
|
nic.nic_op->irq ( &nic, action );
|
2005-04-12 16:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Should be using disable() rather than eth_disable() */
|
2005-04-21 18:18:29 +00:00
|
|
|
extern void eth_disable ( void ) __attribute__ (( deprecated ));
|
2005-04-12 18:15:12 +00:00
|
|
|
|
2005-03-08 18:53:11 +00:00
|
|
|
#endif /* NIC_H */
|