e100b.h

来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C头文件 代码 · 共 671 行 · 第 1/2 页

H
671
字号
/*++

Copyright (c) 2004, Intel Corporation                                                         
All rights reserved. This program and the accompanying materials                          
are licensed and made available under the terms and conditions of the BSD License         
which accompanies this distribution.  The full text of the license may be found at        
http://opensource.org/licenses/bsd-license.php                                            
                                                                                          
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             

Module Name:

  E100B.H

Abstract:


Revision History

--*/
// pci config offsets:

#define RX_BUFFER_COUNT 32
#define TX_BUFFER_COUNT 32

#define PCI_VENDOR_ID_INTEL 0x8086
#define PCI_DEVICE_ID_INTEL_82557 0x1229
#define D100_VENDOR_ID   0x8086
#define D100_DEVICE_ID   0x1229
#define D102_DEVICE_ID   0x2449

#define ICH3_DEVICE_ID_1   0x1031
#define ICH3_DEVICE_ID_2   0x1032
#define ICH3_DEVICE_ID_3   0x1033
#define ICH3_DEVICE_ID_4   0x1034
#define ICH3_DEVICE_ID_5   0x1035
#define ICH3_DEVICE_ID_6   0x1036
#define ICH3_DEVICE_ID_7   0x1037
#define ICH3_DEVICE_ID_8   0x1038

#define SPEEDO_DEVICE_ID   0x1227
#define SPLASH1_DEVICE_ID   0x1226


// bit fields for the command
#define PCI_COMMAND_MASTER  0x04  // bit 2
#define PCI_COMMAND_IO    0x01  // bit 0
#define PCI_COMMAND  0x04
#define PCI_LATENCY_TIMER  0x0D

#define ETHER_MAC_ADDR_LEN 6
#ifdef AVL_XXX
#define ETHER_HEADER_LEN 14
// media interface type
// #define INTERFACE_TYPE "

// Hardware type values
#define HW_ETHER_TYPE    1
#define HW_EXPERIMENTAL_ETHER_TYPE 2
#define HW_IEEE_TYPE    6
#define HW_ARCNET_TYPE     7

#endif  // AVL_XXX

#define MAX_ETHERNET_PKT_SIZE 1514  // including eth header
#define RX_BUFFER_SIZE 1536  // including crc and padding
#define TX_BUFFER_SIZE 64
#define ETH_MTU 1500  // does not include ethernet header length

#define SPEEDO3_TOTAL_SIZE 0x20

#pragma pack(1)

typedef struct eth {
  UINT8 dest_addr[PXE_HWADDR_LEN_ETHER];
  UINT8 src_addr[PXE_HWADDR_LEN_ETHER];
  UINT16 type;
} EtherHeader;

#pragma pack(1)
typedef struct CONFIG_HEADER {
  UINT16 VendorID;
  UINT16 DeviceID;
  UINT16 Command;
  UINT16 Status;
  UINT16 RevID;
  UINT16 ClassID;
  UINT8  CacheLineSize;
  UINT8  LatencyTimer;
  UINT8  HeaderType;    // must be zero to impose this structure...
  UINT8  BIST;  // built-in self test
  UINT32 BaseAddressReg_0;  // memory mapped address
  UINT32 BaseAddressReg_1;  //io mapped address, Base IO address
  UINT32 BaseAddressReg_2;  // option rom address
  UINT32 BaseAddressReg_3;
  UINT32 BaseAddressReg_4;
  UINT32 BaseAddressReg_5;
  UINT32 CardBusCISPtr;
  UINT16 SubVendorID;
  UINT16 SubSystemID;
  UINT32 ExpansionROMBaseAddr;
  UINT8 CapabilitiesPtr;
  UINT8 reserved1;
  UINT16 Reserved2;
  UINT32 Reserved3;
  UINT8 int_line;
  UINT8 int_pin;
  UINT8 Min_gnt;
  UINT8 Max_lat;
} PCI_CONFIG_HEADER;
#pragma pack()

//-------------------------------------------------------------------------
// Offsets to the various registers.
//   All accesses need not be longword aligned. 
//-------------------------------------------------------------------------
enum speedo_offsets {
  SCBStatus = 0, SCBCmd = 2,     // Rx/Command Unit command and status. 
  SCBPointer = 4,                // General purpose pointer. 
  SCBPort = 8,                   // Misc. commands and operands.  
  SCBflash = 12, SCBeeprom = 14, // EEPROM and flash memory control. 
  SCBCtrlMDI = 16,               // MDI interface control. 
  SCBEarlyRx = 20,               // Early receive byte count. 
  SCBEarlyRxInt = 24, SCBFlowCtrlReg = 25, SCBPmdr = 27,
  // offsets for general control registers (GCRs)
  SCBGenCtrl = 28, SCBGenStatus = 29, SCBGenCtrl2 = 30, SCBRsvd = 31,
};

#define GCR2_EEPROM_ACCESS_SEMAPHORE 0x80 // bit offset into the gcr2

//-------------------------------------------------------------------------
// Action commands - Commands that can be put in a command list entry. 
//-------------------------------------------------------------------------
enum commands {
  CmdNOp = 0, CmdIASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
  CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7,
  CmdSuspend = 0x4000,    /* Suspend after completion. */
  CmdIntr = 0x2000,      /* Interrupt after completion. */
  CmdTxFlex = 0x0008,      /* Use "Flexible mode" for CmdTx command. */
};

//-------------------------------------------------------------------------
// port commands
//-------------------------------------------------------------------------
#define PORT_RESET 0
#define PORT_SELF_TEST 1
#define POR_SELECTIVE_RESET 2
#define PORT_DUMP_POINTER 2

//-------------------------------------------------------------------------
// SCB Command Word bit definitions
//-------------------------------------------------------------------------
//- CUC fields
#define   CU_START    0x0010
#define   CU_RESUME    0x0020
#define   CU_STATSADDR  0x0040
#define   CU_SHOWSTATS  0x0050  /* Dump statistics counters. */
#define   CU_CMD_BASE  0x0060  /* Base address to add to add CU commands. */
#define   CU_DUMPSTATS  0x0070  /* Dump then reset stats counters. */

//- RUC fields
#define   RX_START  0x0001
#define   RX_RESUME  0x0002
#define   RX_ABORT  0x0004
#define   RX_ADDR_LOAD  0x0006  /* load ru_base_reg */
#define   RX_RESUMENR  0x0007

// Interrupt fields (assuming byte addressing)
#define INT_MASK  0x0100
#define DRVR_INT  0x0200    /* Driver generated interrupt. */

//- CB Status Word
#define CMD_STATUS_COMPLETE 0x8000
#define RX_STATUS_COMPLETE 0x8000
#define CMD_STATUS_MASK 0xF000

//-------------------------------------------------------------------------
//- SCB Status bits:
// Interrupts are ACKed by writing to the upper 6 interrupt bits
//-------------------------------------------------------------------------
#define SCB_STATUS_MASK        0xFC00 // bits 2-7 - STATUS/ACK Mask
#define SCB_STATUS_CX_TNO      0x8000 // BIT_15  - CX or TNO Interrupt
#define SCB_STATUS_FR          0x4000 // BIT_14 - FR Interrupt
#define SCB_STATUS_CNA         0x2000 // BIT_13 - CNA Interrupt
#define SCB_STATUS_RNR         0x1000 // BIT_12  - RNR Interrupt
#define SCB_STATUS_MDI         0x0800 // BIT_11  - MDI R/W Done Interrupt
#define SCB_STATUS_SWI         0x0400 // BIT_10  - SWI Interrupt

// CU STATUS: bits 6 & 7
#define SCB_STATUS_CU_MASK     0x00C0 // bits 6 & 7
#define SCB_STATUS_CU_IDLE     0x0000 // 00
#define SCB_STATUS_CU_SUSPEND  0x0040 // 01
#define SCB_STATUS_CU_ACTIVE   0x0080 // 10

// RU STATUS: bits 2-5
#define SCB_RUS_IDLE         0x0000
#define SCB_RUS_SUSPENDED    0x0004  // bit 2
#define SCB_RUS_NO_RESOURCES   0x0008 // bit 3
#define SCB_RUS_READY       0x0010 // bit 4

//-------------------------------------------------------------------------
// Bit Mask definitions
//-------------------------------------------------------------------------
#define BIT_0       0x0001
#define BIT_1       0x0002
#define BIT_2       0x0004
#define BIT_3       0x0008
#define BIT_4       0x0010
#define BIT_5       0x0020
#define BIT_6       0x0040
#define BIT_7       0x0080
#define BIT_8       0x0100
#define BIT_9       0x0200
#define BIT_10      0x0400
#define BIT_11      0x0800
#define BIT_12      0x1000
#define BIT_13      0x2000
#define BIT_14      0x4000
#define BIT_15      0x8000
#define BIT_24      0x01000000
#define BIT_28      0x10000000


//-------------------------------------------------------------------------
// MDI Control register bit definitions
//-------------------------------------------------------------------------
#define MDI_DATA_MASK           BIT_0_15        // MDI Data port
#define MDI_REG_ADDR            BIT_16_20       // which MDI register to read/write
#define MDI_PHY_ADDR            BIT_21_25       // which PHY to read/write
#define MDI_PHY_OPCODE          BIT_26_27       // which PHY to read/write
#define MDI_PHY_READY           BIT_28          // PHY is ready for another MDI cycle
#define MDI_PHY_INT_ENABLE      BIT_29          // Assert INT at MDI cycle completion

#define BIT_0_2     0x0007
#define BIT_0_3     0x000F
#define BIT_0_4     0x001F
#define BIT_0_5     0x003F
#define BIT_0_6     0x007F
#define BIT_0_7     0x00FF
#define BIT_0_8     0x01FF
#define BIT_0_13    0x3FFF
#define BIT_0_15    0xFFFF
#define BIT_1_2     0x0006
#define BIT_1_3     0x000E
#define BIT_2_5     0x003C
#define BIT_3_4     0x0018
#define BIT_4_5     0x0030
#define BIT_4_6     0x0070
#define BIT_4_7     0x00F0
#define BIT_5_7     0x00E0
#define BIT_5_9     0x03E0 
#define BIT_5_12    0x1FE0
#define BIT_5_15    0xFFE0
#define BIT_6_7     0x00c0
#define BIT_7_11    0x0F80
#define BIT_8_10    0x0700
#define BIT_9_13    0x3E00
#define BIT_12_15   0xF000

#define BIT_16_20   0x001F0000
#define BIT_21_25   0x03E00000
#define BIT_26_27   0x0C000000

//-------------------------------------------------------------------------
// MDI Control register opcode definitions
//-------------------------------------------------------------------------
#define MDI_WRITE               1               // Phy Write
#define MDI_READ                2               // Phy read

//-------------------------------------------------------------------------
// PHY 100 MDI Register/Bit Definitions
//-------------------------------------------------------------------------
// MDI register set
#define MDI_CONTROL_REG             0x00        // MDI control register
#define MDI_STATUS_REG              0x01        // MDI Status regiser
#define PHY_ID_REG_1                0x02        // Phy indentification reg (word 1)
#define PHY_ID_REG_2                0x03        // Phy indentification reg (word 2)
#define AUTO_NEG_ADVERTISE_REG      0x04        // Auto-negotiation advertisement
#define AUTO_NEG_LINK_PARTNER_REG   0x05        // Auto-negotiation link partner ability
#define AUTO_NEG_EXPANSION_REG      0x06        // Auto-negotiation expansion
#define AUTO_NEG_NEXT_PAGE_REG      0x07        // Auto-negotiation next page transmit
#define EXTENDED_REG_0              0x10        // Extended reg 0 (Phy 100 modes)
#define EXTENDED_REG_1              0x14        // Extended reg 1 (Phy 100 error indications)
#define NSC_CONG_CONTROL_REG        0x17        // National (TX) congestion control
#define NSC_SPEED_IND_REG           0x19        // National (TX) speed indication

// MDI Control register bit definitions
#define MDI_CR_COLL_TEST_ENABLE     BIT_7       // Collision test enable
#define MDI_CR_FULL_HALF            BIT_8       // FDX =1, half duplex =0
#define MDI_CR_RESTART_AUTO_NEG     BIT_9       // Restart auto negotiation
#define MDI_CR_ISOLATE              BIT_10      // Isolate PHY from MII
#define MDI_CR_POWER_DOWN           BIT_11      // Power down
#define MDI_CR_AUTO_SELECT          BIT_12      // Auto speed select enable
#define MDI_CR_10_100               BIT_13      // 0 = 10Mbs, 1 = 100Mbs
#define MDI_CR_LOOPBACK             BIT_14      // 0 = normal, 1 = loopback
#define MDI_CR_RESET                BIT_15      // 0 = normal, 1 = PHY reset

// MDI Status register bit definitions
#define MDI_SR_EXT_REG_CAPABLE      BIT_0       // Extended register capabilities
#define MDI_SR_JABBER_DETECT        BIT_1       // Jabber detected
#define MDI_SR_LINK_STATUS          BIT_2       // Link Status -- 1 = link
#define MDI_SR_AUTO_SELECT_CAPABLE  BIT_3       // Auto speed select capable
#define MDI_SR_REMOTE_FAULT_DETECT  BIT_4       // Remote fault detect
#define MDI_SR_AUTO_NEG_COMPLETE    BIT_5       // Auto negotiation complete
#define MDI_SR_10T_HALF_DPX         BIT_11      // 10BaseT Half Duplex capable
#define MDI_SR_10T_FULL_DPX         BIT_12      // 10BaseT full duplex capable
#define MDI_SR_TX_HALF_DPX          BIT_13      // TX Half Duplex capable
#define MDI_SR_TX_FULL_DPX          BIT_14      // TX full duplex capable
#define MDI_SR_T4_CAPABLE           BIT_15      // T4 capable

// Auto-Negotiation advertisement register bit definitions
#define NWAY_AD_SELCTOR_FIELD       BIT_0_4     // identifies supported protocol
#define NWAY_AD_ABILITY             BIT_5_12    // technologies that are supported
#define NWAY_AD_10T_HALF_DPX        BIT_5       // 10BaseT Half Duplex capable
#define NWAY_AD_10T_FULL_DPX        BIT_6       // 10BaseT full duplex capable
#define NWAY_AD_TX_HALF_DPX         BIT_7       // TX Half Duplex capable
#define NWAY_AD_TX_FULL_DPX         BIT_8       // TX full duplex capable
#define NWAY_AD_T4_CAPABLE          BIT_9       // T4 capable
#define NWAY_AD_REMOTE_FAULT        BIT_13      // indicates local remote fault
#define NWAY_AD_RESERVED            BIT_14      // reserved
#define NWAY_AD_NEXT_PAGE           BIT_15      // Next page (not supported)

// Auto-Negotiation link partner ability register bit definitions
#define NWAY_LP_SELCTOR_FIELD       BIT_0_4     // identifies supported protocol
#define NWAY_LP_ABILITY             BIT_5_9     // technologies that are supported
#define NWAY_LP_REMOTE_FAULT        BIT_13      // indicates partner remote fault
#define NWAY_LP_ACKNOWLEDGE         BIT_14      // acknowledge
#define NWAY_LP_NEXT_PAGE           BIT_15      // Next page (not supported)

// Auto-Negotiation expansion register bit definitions
#define NWAY_EX_LP_NWAY             BIT_0       // link partner is NWAY
#define NWAY_EX_PAGE_RECEIVED       BIT_1       // link code word received
#define NWAY_EX_NEXT_PAGE_ABLE      BIT_2       // local is next page able
#define NWAY_EX_LP_NEXT_PAGE_ABLE   BIT_3       // partner is next page able
#define NWAY_EX_PARALLEL_DET_FLT    BIT_4       // parallel detection fault

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?