quinn-os/i825xx.h
2022-07-19 11:40:37 +10:00

50 lines
1.1 KiB
C

#ifndef __I825XX_H
#define __I825XX_H
#include "ether.h"
#define NUM_RX_DESCRIPTORS 768
#define NUM_TX_DESCRIPTORS 768
#define CTRL_FD (1 << 0)
#define CTRL_ASDE (1 << 5)
#define CTRL_SLU (1 << 6)
// RX and TX descriptor structures
struct i825xx_rx_desc_t {
uint64_t address;
uint16_t length;
uint16_t checksum;
uint8_t status;
uint8_t error;
uint16_t special;
} __attribute__((packed));
struct i825xx_tx_desc_t {
uint64_t address;
uint16_t length;
uint8_t cso;
uint8_t cmd;
uint8_t sta;
uint8_t css;
uint16_t special;
} __attribute__((packed));
// Device-specific structure
struct i825xx_device_t {
uint32_t mmio_address;
uint8_t bar_type;
uint8_t have_eeprom;
uint32_t io_address;
uint8_t *rx_desc_virt_base, *rx_desc_phys_base;
uint8_t *tx_desc_virt_base, *tx_desc_phys_base;
struct i825xx_rx_desc_t *rx_descs;
struct i825xx_tx_desc_t *tx_descs;
struct ether_t *ether;
};
extern struct ether_t *init_i825xx(int count);
extern int i825xx_send(struct i825xx_device_t *i825xx_device, char *packet, int len);
extern void i825xx_enable(struct ether_t *ether);
#endif