📄 pci.h
字号:
#define PCI_PREFMEM_LIMIT_MSK (MSK(16) << PCI_PREFMEM_LIMIT_SHF)/************************************************************************ * PCI configuration cycle AD bus definition ************************************************************************//* Type 0 */#define PCI_CFG_TYPE0_REG_SHF 0#define PCI_CFG_TYPE0_REG_MSK (MSK(6) << 2)#define PCI_CFG_TYPE0_FUNC_SHF 8#define PCI_CFG_TYPE0_FUNC_MSK (MSK(3) << PCI_CFG_TYPE0_FUNC_SHF)/* Type 1 */#define PCI_CFG_TYPE1_REG_SHF 0#define PCI_CFG_TYPE1_REG_MSK (MSK(6) << 2)#define PCI_CFG_TYPE1_FUNC_SHF 8#define PCI_CFG_TYPE1_FUNC_MSK (MSK(3) << PCI_CFG_TYPE0_FUNC_SHF)#define PCI_CFG_TYPE1_DEV_SHF 11#define PCI_CFG_TYPE1_DEV_MSK (MSK(5) << PCI_CFG_TYPE1_DEV_SHF)#define PCI_CFG_TYPE1_BUS_SHF 16#define PCI_CFG_TYPE1_BUS_MSK (MSK(8) << PCI_CFG_TYPE1_BUS_SHF)#ifndef _ASSEMBLER_/* Structures and function prototypes used locally in implementation * of PCI configuration. *//* Known device */typedef struct{ UINT16 vendorid; /* Vendor ID */ UINT16 devid; /* Device ID */ UINT8 function; /* Function number */ UINT8 intline; /* Interrupt line used by device */ char *vendor; /* String holding vendor name */ char *device; /* String holding device name */}t_known_dev;/* Fixed request for BAR setup */typedef struct{ UINT16 vendorid; /* Vendor ID */ UINT16 devid; /* Device ID */ UINT8 function; /* Function number */ t_pci_bar bar; /* Requirements for BAR */}t_pci_bar_req;/************************************************************************ * Public functions ************************************************************************//************************************************************************ * * pci_config * Description : * ------------- * * Autodetect and autoconfigure PCI * * Return values : * --------------- * * 0 = OK, otherwise error * ************************************************************************/UINT32pci_config( void );/************************************************************************ * * arch_pci_config_controller * Description : * ------------- * * Configure system controller regarding PCI. * * Return values : * --------------- * * OK or ERROR_PCI_STRUCTURE (should never happen) * ************************************************************************/UINT32arch_pci_config_controller( t_pci_bar_req *bar_req, /* Array for fixed bar requests */ UINT32 *bar_count, /* Current number of fixed bar req. */ UINT32 max_bar_count, /* Max fixed bar requests */ UINT8 intline, /* Interrupt line for controller */ t_known_dev *controller ); /* Controller data to be filled out *//************************************************************************ * * arch_pci_config_access * Description : * ------------- * * PCI configuration cycle (read or write) * * Return values : * --------------- * * OK : If no error. * ERROR_PCI_ABORT : If master abort (no target) or target abort. * ************************************************************************/UINT32arch_pci_config_access( UINT32 busnum, /* PCI bus number (0 = local bus) */ UINT32 devnum, /* PCI device number */ UINT32 func, /* Function number of device */ UINT32 reg, /* Device register */ bool write, /* TRUE -> Config write, else read */ UINT8 size, /* Sizeof data (1/2/4 bytes) */ void *data ); /* write or read data *//************************************************************************ * * arch_pci_system_slot * Description : * ------------- * * Determine whether board is located in Compact PCI system slot. * Platforms that don't have a compact PCI connector will always * return FALSE. * * Return values : * --------------- * * TRUE -> In Compact PCI system slot * FALSE -> Not in system slot. * ************************************************************************/boolarch_pci_system_slot( void );/************************************************************************ * * arch_pci_slot * Description : * ------------- * * Determine whether a device number corresponds to a PCI slot * * Return values : * --------------- * * TRUE -> PCI slot * FALSE -> Not PCI slot * ************************************************************************/boolarch_pci_slot( UINT8 dev, /* PCI device number */ UINT8 *number ); /* OUT : PCI slot number *//************************************************************************ * * arch_pci_slot_intline * Description : * ------------- * * Determine the interrupt line (for interrupt controller) used for * PCI slot identified by PCI device number. * * Return values : * --------------- * * Interrupt line * ************************************************************************/UINT8arch_pci_slot_intline( UINT8 dev, /* PCI device number of slot */ UINT8 intpin ); /* Int. pin (A/B/C/D) used by device *//************************************************************************ * * arch_pci_remote_intline * Description : * ------------- * * Determine the interrupt line (for interrupt controller) used for * PCI interrupt pin on Compact PCI connector * * Return values : * --------------- * * Interrupt line * ************************************************************************/UINT8arch_pci_remote_intline( UINT8 intpin ); /* Int. pin (A/B/C/D) used by device *//************************************************************************ * * arch_pci_lattim * Description : * ------------- * * Latency timer value to be written to PCI device (Max_Lat) * * Return values : * --------------- * * Value to be written to Max_Lat. * ************************************************************************/UINT8arch_pci_lattim( t_pci_cfg_dev *dev ); /* PCI device structure *//************************************************************************ * * arch_pci_multi * Description : * ------------- * * Extrace multi field from PCI configuration word 0xc * (Word holding Bist/Header Type/Latency Timer/Cache Line Size) * * Return values : * --------------- * * multi field * ************************************************************************/UINT8arch_pci_multi( t_pci_cfg_dev *dev, UINT32 bhlc );/************************************************************************ * * pci_autoconfig * Description : * ------------- * * Configure PCI based on platform requirements. * * Return values : * --------------- * * 0: no pci error, else error * ************************************************************************/UINT32pci_autoconfig( t_pci_bar_req *bar_req, /* Special BAR requirements */ UINT32 bar_req_count, /* Number of special BARs */ t_known_dev *known_dev, /* Array of known devices */ UINT32 known_dev_count ); /* Count of known devices *//************************************************************************ * * pci_check_range * Description : * ------------- * * Validate PCI memory range * * Return values : * --------------- * * OK : Range OK * ERROR_PCI_RANGE : Range not OK * ************************************************************************/UINT32pci_check_range( UINT32 addr, /* Start of range */ UINT32 size, /* Size of range */ UINT32 *mask ); /* Mask corresponding to range */#endif /* #ifndef _ASSEMBLER_ */#endif /* #ifndef PCI_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -