intel.h revision a734c64bff58bda2fa48c2795453e092167b0ff7
#ifndef _INTEL_H
#define _INTEL_H
/** @file
*
* Intel 10/100/1000 network card driver
*
*/
#include <stdint.h>
#include <ipxe/if_ether.h>
/** Intel BAR size */
/** A packet descriptor */
struct intel_descriptor {
/** Buffer address */
/** Length */
/** Reserved */
/** Command */
/** Status */
/** Errors */
/** Reserved */
} __attribute__ (( packed ));
/** Packet descriptor command bits */
enum intel_descriptor_command {
/** Report status */
INTEL_DESC_CMD_RS = 0x08,
/** Insert frame checksum (CRC) */
INTEL_DESC_CMD_IFCS = 0x02,
/** End of packet */
INTEL_DESC_CMD_EOP = 0x01,
};
/** Packet descriptor status bits */
enum intel_descriptor_status {
/** Descriptor done */
INTEL_DESC_STATUS_DD = 0x01,
};
/** Device Control Register */
#define INTEL_CTRL 0x00000UL
/** Time to delay for device reset, in milliseconds */
#define INTEL_RESET_DELAY_MS 20
/** Device Status Register */
#define INTEL_STATUS 0x00008UL
/** EEPROM Read Register */
#define INTEL_EERD 0x00014UL
/** Maximum time to wait for EEPROM read, in milliseconds */
#define INTEL_EEPROM_MAX_WAIT_MS 100
/** EEPROM word length */
#define INTEL_EEPROM_WORD_LEN_LOG2 1
/** Minimum EEPROM size, in words */
#define INTEL_EEPROM_MIN_SIZE_WORDS 64
/** Offset of MAC address within EEPROM */
#define INTEL_EEPROM_MAC 0x00
/** Interrupt Cause Read Register */
#define INTEL_ICR 0x000c0UL
#define INTEL_IMS 0x000d0UL
/** Interrupt Mask Clear Register */
#define INTEL_IMC 0x000d8UL
/** Receive Control Register */
#define INTEL_RCTL 0x00100UL
#define INTEL_RCTL_BSIZE_2048 INTEL_RCTL_BSIZE_BSEX ( 0, 0 )
/** Transmit Control Register */
#define INTEL_TCTL 0x00400UL
/** Packet Buffer Allocation */
#define INTEL_PBA 0x01000UL
/** Packet Buffer Size */
#define INTEL_PBS 0x01008UL
/** Receive Descriptor register block */
#define INTEL_RD 0x02800UL
/** Number of receive descriptors
*
* Minimum value is 8, since the descriptor ring length must be a
* multiple of 128.
*/
#define INTEL_NUM_RX_DESC 8
/** Receive descriptor ring fill level */
#define INTEL_RX_FILL 4
/** Receive buffer length */
#define INTEL_RX_MAX_LEN 2048
/** Transmit Descriptor register block */
#define INTEL_TD 0x03800UL
/** Number of transmit descriptors
*
* Descriptor ring length must be a multiple of 16. ICH8/9/10
* requires a minimum of 16 TX descriptors.
*/
#define INTEL_NUM_TX_DESC 16
#define INTEL_xDBAL 0x00
#define INTEL_xDBAH 0x04
#define INTEL_xDLEN 0x08
#define INTEL_xDH 0x10
#define INTEL_xDT 0x18
/** Receive Descriptor Head */
/** Receive Descriptor Tail */
/** Transmit Descriptor Head */
/** Transmit Descriptor Tail */
/** Receive Address Low */
#define INTEL_RAL0 0x05400UL
/** Receive Address High */
#define INTEL_RAH0 0x05404UL
/** Receive address */
union intel_receive_address {
struct {
};
/** An Intel descriptor ring */
struct intel_ring {
/** Descriptors */
struct intel_descriptor *desc;
/** Producer index */
unsigned int prod;
/** Consumer index */
unsigned int cons;
/** Register block */
unsigned int reg;
/** Length (in bytes) */
};
/**
* Initialise descriptor ring
*
* @v ring Descriptor ring
* @v count Number of descriptors
* @v reg Descriptor register block
*/
static inline __attribute__ (( always_inline)) void
unsigned int reg ) {
}
/** An Intel network card */
struct intel_nic {
/** Registers */
void *regs;
/** Port number (for multi-port devices) */
unsigned int port;
/** EEPROM */
struct nvs_device eeprom;
/** EEPROM done flag */
/** EEPROM address shift */
unsigned int eerd_addr_shift;
/** Transmit descriptor ring */
struct intel_ring tx;
/** Receive descriptor ring */
struct intel_ring rx;
/** Receive I/O buffers */
};
#endif /* _INTEL_H */