⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pci.h

📁 嵌入式系统设计与实例开发源码
💻 H
📖 第 1 页 / 共 3 页
字号:
#define  PCI_SID_ESR_NSLOTS	0x1f	/* Number of expansion slots available */#define  PCI_SID_ESR_FIC	0x20	/* First In Chassis Flag */#define PCI_SID_CHASSIS_NR	3	/* Chassis Number *//* Message Signalled Interrupts registers */#define PCI_MSI_FLAGS		2	/* Various flags */#define  PCI_MSI_FLAGS_64BIT	0x80	/* 64-bit addresses allowed */#define  PCI_MSI_FLAGS_QSIZE	0x70	/* Message queue size configured */#define  PCI_MSI_FLAGS_QMASK	0x0e	/* Maximum queue size available */#define  PCI_MSI_FLAGS_ENABLE	0x01	/* MSI feature enabled */#define PCI_MSI_RFU		3	/* Rest of capability flags */#define PCI_MSI_ADDRESS_LO	4	/* Lower 32 bits */#define PCI_MSI_ADDRESS_HI	8	/* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */#define PCI_MSI_DATA_32		8	/* 16 bits of data for 32-bit devices */#define PCI_MSI_DATA_64		12	/* 16 bits of data for 64-bit devices *//* Include the ID list */#include <linux/pci_ids.h>/* * The PCI interface treats multi-function devices as independent * devices.  The slot/function address of each device is encoded * in a single byte as follows: * *	7:3 = slot *	2:0 = function */#define PCI_DEVFN(slot,func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))#define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)#define PCI_FUNC(devfn)		((devfn) & 0x07)/* Ioctls for /proc/bus/pci/X/Y nodes. */#define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)#define PCIIOC_CONTROLLER	(PCIIOC_BASE | 0x00)	/* Get controller for PCI device. */#define PCIIOC_MMAP_IS_IO	(PCIIOC_BASE | 0x01)	/* Set mmap state to I/O space. */#define PCIIOC_MMAP_IS_MEM	(PCIIOC_BASE | 0x02)	/* Set mmap state to MEM space. */#define PCIIOC_WRITE_COMBINE	(PCIIOC_BASE | 0x03)	/* Enable/disable write-combining. */#ifdef __KERNEL__#include <linux/types.h>#include <linux/config.h>#include <linux/ioport.h>#include <linux/list.h>#include <linux/errno.h>/* File state for mmap()s on /proc/bus/pci/X/Y */enum pci_mmap_state {	pci_mmap_io,	pci_mmap_mem};/* This defines the direction arg to the DMA mapping routines. */#define PCI_DMA_BIDIRECTIONAL	0#define PCI_DMA_TODEVICE	1#define PCI_DMA_FROMDEVICE	2#define PCI_DMA_NONE		3#define DEVICE_COUNT_COMPATIBLE	4#define DEVICE_COUNT_IRQ	2#define DEVICE_COUNT_DMA	2#define DEVICE_COUNT_RESOURCE	12#define PCI_ANY_ID (~0)#define pci_present pcibios_present#define pci_for_each_dev_reverse(dev) \	for(dev = pci_dev_g(pci_devices.prev); dev != pci_dev_g(&pci_devices); dev = pci_dev_g(dev->global_list.prev))#define pci_for_each_bus(bus) \for(bus = pci_bus_b(pci_root_buses.next); bus != pci_bus_b(&pci_root_buses); bus = pci_bus_b(bus->node.next))/* * The pci_dev structure is used to describe both PCI and ISAPnP devices. */struct pci_dev {	struct list_head global_list;	/* node in list of all PCI devices */	struct list_head bus_list;	/* node in per-bus list */	struct pci_bus	*bus;		/* bus this device is on */	struct pci_bus	*subordinate;	/* bus this device bridges to */	void		*sysdata;	/* hook for sys-specific extension */	struct proc_dir_entry *procent;	/* device entry in /proc/bus/pci */	unsigned int	devfn;		/* encoded device & function index */	unsigned short	vendor;	unsigned short	device;	unsigned short	subsystem_vendor;	unsigned short	subsystem_device;	unsigned int	class;		/* 3 bytes: (base,sub,prog-if) */	u8		hdr_type;	/* PCI header type (`multi' flag masked out) */	u8		rom_base_reg;	/* which config register controls the ROM */	struct pci_driver *driver;	/* which driver has allocated this device */	void		*driver_data;	/* data private to the driver */	u64		dma_mask;	/* Mask of the bits of bus address this					   device implements.  Normally this is					   0xffffffff.  You only need to change					   this if your device has broken DMA					   or supports 64-bit transfers.  */	u32             current_state;  /* Current operating state. In ACPI-speak,					   this is D0-D3, D0 being fully functional,					   and D3 being off. */	/* device is compatible with these IDs */	unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];	unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];	/*	 * Instead of touching interrupt line and base address registers	 * directly, use the values stored here. They might be different!	 */	unsigned int	irq;	struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */	struct resource dma_resource[DEVICE_COUNT_DMA];	struct resource irq_resource[DEVICE_COUNT_IRQ];	char		name[80];	/* device name */	char		slot_name[8];	/* slot name */	u32		saved_state[16]; /* for saving the config space before suspend */	int		active;		/* ISAPnP: device is active */	int		ro;		/* ISAPnP: read only */	unsigned short	regs;		/* ISAPnP: supported registers */	int (*prepare)(struct pci_dev *dev);	/* ISAPnP hooks */	int (*activate)(struct pci_dev *dev);	int (*deactivate)(struct pci_dev *dev);};#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)/* *  For PCI devices, the region numbers are assigned this way: * *	0-5	standard PCI regions *	6	expansion ROM *	7-10	bridges: address space assigned to buses behind the bridge */#define PCI_ROM_RESOURCE 6#define PCI_BRIDGE_RESOURCES 7#define PCI_NUM_RESOURCES 11  #define PCI_REGION_FLAG_MASK 0x0fU	/* These bits of resource flags tell us the PCI region flags */struct pci_bus {	struct list_head node;		/* node in list of buses */	struct pci_bus	*parent;	/* parent bus this bridge is on */	struct list_head children;	/* list of child buses */	struct list_head devices;	/* list of devices on this bus */	struct pci_dev	*self;		/* bridge device as seen by parent */	struct resource	*resource[4];	/* address space routed to this bus */	struct pci_ops	*ops;		/* configuration access functions */	void		*sysdata;	/* hook for sys-specific extension */	struct proc_dir_entry *procdir;	/* directory entry in /proc/bus/pci */	unsigned char	number;		/* bus number */	unsigned char	primary;	/* number of primary bridge */	unsigned char	secondary;	/* number of secondary bridge */	unsigned char	subordinate;	/* max number of subordinate buses */	char		name[48];	unsigned short	vendor;	unsigned short	device;	unsigned int	serial;		/* serial number */	unsigned char	pnpver;		/* Plug & Play version */	unsigned char	productver;	/* product version */	unsigned char	checksum;	/* if zero - checksum passed */	unsigned char	pad1;};#define pci_bus_b(n) list_entry(n, struct pci_bus, node)extern struct list_head pci_root_buses;	/* list of all known PCI buses */extern struct list_head pci_devices;	/* list of all devices *//* * Error values that may be returned by PCI functions. */#define PCIBIOS_SUCCESSFUL		0x00#define PCIBIOS_FUNC_NOT_SUPPORTED	0x81#define PCIBIOS_BAD_VENDOR_ID		0x83#define PCIBIOS_DEVICE_NOT_FOUND	0x86#define PCIBIOS_BAD_REGISTER_NUMBER	0x87#define PCIBIOS_SET_FAILED		0x88#define PCIBIOS_BUFFER_TOO_SMALL	0x89/* Low-level architecture-dependent routines */struct pci_ops {	int (*read_byte)(struct pci_dev *, int where, u8 *val);	int (*read_word)(struct pci_dev *, int where, u16 *val);	int (*read_dword)(struct pci_dev *, int where, u32 *val);	int (*write_byte)(struct pci_dev *, int where, u8 val);	int (*write_word)(struct pci_dev *, int where, u16 val);	int (*write_dword)(struct pci_dev *, int where, u32 val);};struct pbus_set_ranges_data{	int found_vga:1;	int prefetch_valid:1;	unsigned long io_start, io_end;	unsigned long mem_start, mem_end;	unsigned long prefetch_start, prefetch_end;};struct pci_device_id {	unsigned int vendor, device;		/* Vendor and device ID or PCI_ANY_ID */	unsigned int subvendor, subdevice;	/* Subsystem ID's or PCI_ANY_ID */	unsigned int class, class_mask;		/* (class,subclass,prog-if) triplet */	unsigned long driver_data;		/* Data private to the driver */};struct pci_driver {	struct list_head node;	char *name;	const struct pci_device_id *id_table;	/* NULL if wants all devices */	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */	int  (*save_state) (struct pci_dev *dev, u32 state);    /* Save Device Context */	int  (*suspend)(struct pci_dev *dev, u32 state);	/* Device suspended */	int  (*resume) (struct pci_dev *dev);	                /* Device woken up */	int  (*enable_wake) (struct pci_dev *dev, u32 state, int enable);   /* Enable wake event */};/* these external functions are only available when PCI support is enabled */#ifdef CONFIG_PCI#define pci_for_each_dev(dev) \	for(dev = pci_dev_g(pci_devices.next); dev != pci_dev_g(&pci_devices); dev = pci_dev_g(dev->global_list.next))void pcibios_init(void);void pcibios_fixup_bus(struct pci_bus *);int pcibios_enable_device(struct pci_dev *);char *pcibios_setup (char *str);/* Used only when drivers/pci/setup.c is used */void pcibios_align_resource(void *, struct resource *, unsigned long);void pcibios_update_resource(struct pci_dev *, struct resource *,			     struct resource *, int);void pcibios_update_irq(struct pci_dev *, int irq);void pcibios_fixup_pbus_ranges(struct pci_bus *, struct pbus_set_ranges_data *);/* Backward compatibility, don't use in new code! */int pcibios_present(void);int pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn,

⌨️ 快捷键说明

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