Retro Rocket Kernel BASIC-Powered Operating System

Data Structures | Macros | Functions | Variables
e1000.h File Reference
`#include "kernel.h"`

## Data Structures
struct | e1000_rx_desc
struct | e1000_tx_desc

## Macros
#define | INTEL_VEND 0x8086
#define | E1000_DEV 0x100E
#define | E1000_I217 0x153A
#define | E1000_82577LM 0x10EA
#define | REG_CTRL 0x0000
#define | REG_STATUS 0x0008
#define | REG_EEPROM 0x0014
#define | REG_CTRL_EXT 0x0018
#define | REG_IMASK 0x00D0
#define | REG_RCTRL 0x0100
#define | REG_RXDESCLO 0x2800
#define | REG_RXDESCHI 0x2804
#define | REG_RXDESCLEN 0x2808
#define | REG_RXDESCHEAD 0x2810
#define | REG_RXDESCTAIL 0x2818
#define | REG_TCTRL 0x0400
#define | REG_TXDESCLO 0x3800
#define | REG_TXDESCHI 0x3804
#define | REG_TXDESCLEN 0x3808
#define | REG_TXDESCHEAD 0x3810
#define | REG_TXDESCTAIL 0x3818
#define | REG_RDTR 0x2820
#define | REG_RXDCTL 0x3828
#define | REG_RADV 0x282C
#define | REG_RSRPD 0x2C00
#define | REG_TIPG 0x0410
#define | ECTRL_SLU 0x40
#define | RCTL_EN (1 << 1)
#define | RCTL_SBP (1 << 2)
#define | RCTL_UPE (1 << 3)
#define | RCTL_MPE (1 << 4)
#define | RCTL_LPE (1 << 5)
#define | RCTL_LBM_NONE (0 << 6)
#define | RCTL_LBM_PHY (3 << 6)
#define | RTCL_RDMTS_HALF (0 << 8)
#define | RTCL_RDMTS_QUARTER (1 << 8)
#define | RTCL_RDMTS_EIGHTH (2 << 8)
#define | RCTL_MO_36 (0 << 12)
#define | RCTL_MO_35 (1 << 12)
#define | RCTL_MO_34 (2 << 12)
#define | RCTL_MO_32 (3 << 12)
#define | RCTL_BAM (1 << 15)
#define | RCTL_VFE (1 << 18)
#define | RCTL_CFIEN (1 << 19)
#define | RCTL_CFI (1 << 20)
#define | RCTL_DPF (1 << 22)
#define | RCTL_PMCF (1 << 23)
#define | RCTL_SECRC (1 << 26)
#define | RCTL_BSIZE_256 (3 << 16)
#define | RCTL_BSIZE_512 (2 << 16)
#define | RCTL_BSIZE_1024 (1 << 16)
#define | RCTL_BSIZE_2048 (0 << 16)
#define | RCTL_BSIZE_4096 ((3 << 16) | (1 << 25))
#define | RCTL_BSIZE_8192 ((2 << 16) | (1 << 25))
#define | RCTL_BSIZE_16384 ((1 << 16) | (1 << 25))
#define | RXD_STAT_DD 0x01 /* Descriptor Done */
#define | RXD_STAT_EOP 0x02 /* End of Packet */
#define | CMD_EOP (1 << 0)
#define | CMD_IFCS (1 << 1)
#define | CMD_IC (1 << 2)
#define | CMD_RS (1 << 3)
#define | CMD_RPS (1 << 4)
#define | CMD_VLE (1 << 6)
#define | CMD_IDE (1 << 7)
#define | TCTL_EN (1 << 1)
#define | TCTL_PSP (1 << 3)
#define | TCTL_CT_SHIFT 4
#define | TCTL_COLD_SHIFT 12
#define | TCTL_SWXOFF (1 << 22)
#define | TCTL_RTLC (1 << 24)
#define | TSTA_DD (1 << 0)
#define | TSTA_EC (1 << 1)
#define | TSTA_LC (1 << 2)
#define | LSTA_TU (1 << 3)
#define | E1000_NUM_RX_DESC 32
#define | E1000_NUM_TX_DESC 8

## Functions
struct e1000_rx_desc | __attribute__ ((packed)) e1000_rx_desc_t
void | e1000_get_mac_addr (uint8_t *src_mac_addr)
int | e1000_send_packet (const void *p_data, uint16_t p_len)
bool | init_e1000 ()

## Variables
volatile uint64_t | addr
volatile uint16_t | length
volatile uint16_t | checksum
volatile uint8_t | status
volatile uint8_t | errors
volatile uint16_t | special
volatile uint8_t | cso
volatile uint8_t | cmd
volatile uint8_t | css

## Detailed Description

Author
  Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Copyright
  Copyright (c) 2012-2023

## Macro Definition Documentation

## ◆ CMD_EOP

#define CMD_EOP (1 << 0)

## ◆ CMD_IC

#define CMD_IC (1 << 2)

## ◆ CMD_IDE

#define CMD_IDE (1 << 7)

## ◆ CMD_IFCS

#define CMD_IFCS (1 << 1)

## ◆ CMD_RPS

#define CMD_RPS (1 << 4)

## ◆ CMD_RS

#define CMD_RS (1 << 3)

## ◆ CMD_VLE

#define CMD_VLE (1 << 6)

## ◆ E1000_82577LM

#define E1000_82577LM 0x10EA

## ◆ E1000_DEV

#define E1000_DEV 0x100E

## ◆ E1000_I217

#define E1000_I217 0x153A

## ◆ E1000_NUM_RX_DESC

#define E1000_NUM_RX_DESC 32

## ◆ E1000_NUM_TX_DESC

#define E1000_NUM_TX_DESC 8

## ◆ ECTRL_SLU

#define ECTRL_SLU 0x40

## ◆ INTEL_VEND

#define INTEL_VEND 0x8086

## ◆ LSTA_TU

#define LSTA_TU (1 << 3)

## ◆ RCTL_BAM

#define RCTL_BAM (1 << 15)

## ◆ RCTL_BSIZE_1024

#define RCTL_BSIZE_1024 (1 << 16)

## ◆ RCTL_BSIZE_16384

#define RCTL_BSIZE_16384 ((1 << 16) | (1 << 25))

## ◆ RCTL_BSIZE_2048

#define RCTL_BSIZE_2048 (0 << 16)

## ◆ RCTL_BSIZE_256

#define RCTL_BSIZE_256 (3 << 16)

## ◆ RCTL_BSIZE_4096

#define RCTL_BSIZE_4096 ((3 << 16) | (1 << 25))

## ◆ RCTL_BSIZE_512

#define RCTL_BSIZE_512 (2 << 16)

## ◆ RCTL_BSIZE_8192

#define RCTL_BSIZE_8192 ((2 << 16) | (1 << 25))

## ◆ RCTL_CFI

#define RCTL_CFI (1 << 20)

## ◆ RCTL_CFIEN

#define RCTL_CFIEN (1 << 19)

## ◆ RCTL_DPF

#define RCTL_DPF (1 << 22)

## ◆ RCTL_EN

#define RCTL_EN (1 << 1)

## ◆ RCTL_LBM_NONE

#define RCTL_LBM_NONE (0 << 6)

## ◆ RCTL_LBM_PHY

#define RCTL_LBM_PHY (3 << 6)

## ◆ RCTL_LPE

#define RCTL_LPE (1 << 5)

## ◆ RCTL_MO_32

#define RCTL_MO_32 (3 << 12)

## ◆ RCTL_MO_34

#define RCTL_MO_34 (2 << 12)

## ◆ RCTL_MO_35

#define RCTL_MO_35 (1 << 12)

## ◆ RCTL_MO_36

#define RCTL_MO_36 (0 << 12)

## ◆ RCTL_MPE

#define RCTL_MPE (1 << 4)

## ◆ RCTL_PMCF

#define RCTL_PMCF (1 << 23)

## ◆ RCTL_SBP

#define RCTL_SBP (1 << 2)

## ◆ RCTL_SECRC

#define RCTL_SECRC (1 << 26)

## ◆ RCTL_UPE

#define RCTL_UPE (1 << 3)

## ◆ RCTL_VFE

#define RCTL_VFE (1 << 18)

## ◆ REG_CTRL

#define REG_CTRL 0x0000

## ◆ REG_CTRL_EXT

#define REG_CTRL_EXT 0x0018

## ◆ REG_EEPROM

#define REG_EEPROM 0x0014

## ◆ REG_IMASK

#define REG_IMASK 0x00D0

## ◆ REG_RADV

#define REG_RADV 0x282C

## ◆ REG_RCTRL

#define REG_RCTRL 0x0100

## ◆ REG_RDTR

#define REG_RDTR 0x2820

## ◆ REG_RSRPD

#define REG_RSRPD 0x2C00

## ◆ REG_RXDCTL

#define REG_RXDCTL 0x3828

## ◆ REG_RXDESCHEAD

#define REG_RXDESCHEAD 0x2810

## ◆ REG_RXDESCHI

#define REG_RXDESCHI 0x2804

## ◆ REG_RXDESCLEN

#define REG_RXDESCLEN 0x2808

## ◆ REG_RXDESCLO

#define REG_RXDESCLO 0x2800

## ◆ REG_RXDESCTAIL

#define REG_RXDESCTAIL 0x2818

## ◆ REG_STATUS

#define REG_STATUS 0x0008

## ◆ REG_TCTRL

#define REG_TCTRL 0x0400

## ◆ REG_TIPG

#define REG_TIPG 0x0410

## ◆ REG_TXDESCHEAD

#define REG_TXDESCHEAD 0x3810

## ◆ REG_TXDESCHI

#define REG_TXDESCHI 0x3804

## ◆ REG_TXDESCLEN

#define REG_TXDESCLEN 0x3808

## ◆ REG_TXDESCLO

#define REG_TXDESCLO 0x3800

## ◆ REG_TXDESCTAIL

#define REG_TXDESCTAIL 0x3818

## ◆ RTCL_RDMTS_EIGHTH

#define RTCL_RDMTS_EIGHTH (2 << 8)

## ◆ RTCL_RDMTS_HALF

#define RTCL_RDMTS_HALF (0 << 8)

## ◆ RTCL_RDMTS_QUARTER

#define RTCL_RDMTS_QUARTER (1 << 8)

## ◆ RXD_STAT_DD

#define RXD_STAT_DD 0x01 /* Descriptor Done */

## ◆ RXD_STAT_EOP

#define RXD_STAT_EOP 0x02 /* End of Packet */

## ◆ TCTL_COLD_SHIFT

#define TCTL_COLD_SHIFT 12

## ◆ TCTL_CT_SHIFT

#define TCTL_CT_SHIFT 4

## ◆ TCTL_EN

#define TCTL_EN (1 << 1)

## ◆ TCTL_PSP

#define TCTL_PSP (1 << 3)

## ◆ TCTL_RTLC

#define TCTL_RTLC (1 << 24)

## ◆ TCTL_SWXOFF

#define TCTL_SWXOFF (1 << 22)

## ◆ TSTA_DD

#define TSTA_DD (1 << 0)

## ◆ TSTA_EC

#define TSTA_EC (1 << 1)

## ◆ TSTA_LC

#define TSTA_LC (1 << 2)

## Function Documentation

## ◆ __attribute__()

struct e1000_rx_desc __attribute__ | ( | (packed) |  | ) |

## ◆ e1000_get_mac_addr()

void e1000_get_mac_addr | ( | uint8_t * | src_mac_addr | ) |

## ◆ e1000_send_packet()

int e1000_send_packet | ( | const void * | p_data,
|  | uint16_t | p_len
| ) |  |

## ◆ init_e1000()

bool init_e1000 | ( |  | ) |

## Variable Documentation

## ◆ addr

volatile uint64_t addr

## ◆ checksum

volatile uint16_t checksum

## ◆ cmd

volatile uint8_t cmd

## ◆ cso

volatile uint8_t cso

## ◆ css

volatile uint8_t css

## ◆ errors

volatile uint8_t errors

## ◆ length

volatile uint16_t length

## ◆ special

volatile uint16_t special

## ◆ status

volatile uint8_t status