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

📄 pci.h

📁 讲述linux的初始化过程
💻 H
📖 第 1 页 / 共 2 页
字号:
	 * 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 */	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 0x0f	/* 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;	unsigned long io_start, io_end;	unsigned long mem_start, mem_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) */	void (*suspend)(struct pci_dev *dev);	/* Device suspended */	void (*resume)(struct pci_dev *dev);	/* Device woken up */};/* these external functions are only available when PCI support is enabled */#ifdef CONFIG_PCIvoid 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,			      unsigned char where, unsigned char *val);int pcibios_read_config_word (unsigned char bus, unsigned char dev_fn,			      unsigned char where, unsigned short *val);int pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn,			       unsigned char where, unsigned int *val);int pcibios_write_config_byte (unsigned char bus, unsigned char dev_fn,			       unsigned char where, unsigned char val);int pcibios_write_config_word (unsigned char bus, unsigned char dev_fn,			       unsigned char where, unsigned short val);int pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn,				unsigned char where, unsigned int val);int pcibios_find_class (unsigned int class_code, unsigned short index, unsigned char *bus, unsigned char *dev_fn);int pcibios_find_device (unsigned short vendor, unsigned short dev_id,			 unsigned short index, unsigned char *bus,			 unsigned char *dev_fn);/* Generic PCI functions used internally */void pci_init(void);int pci_bus_exists(const struct list_head *list, int nr);struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);struct pci_bus *pci_alloc_primary_bus(int bus);struct pci_dev *pci_scan_slot(struct pci_dev *temp);int pci_proc_attach_device(struct pci_dev *dev);int pci_proc_detach_device(struct pci_dev *dev);void pci_name_device(struct pci_dev *dev);char *pci_class_name(u32 class);void pci_read_bridge_bases(struct pci_bus *child);struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);int pci_setup_device(struct pci_dev *dev);int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);/* Generic PCI functions exported to card drivers */struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from);struct pci_dev *pci_find_subsys (unsigned int vendor, unsigned int device,				 unsigned int ss_vendor, unsigned int ss_device,				 const struct pci_dev *from);struct pci_dev *pci_find_class (unsigned int class, const struct pci_dev *from);struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);int pci_find_capability (struct pci_dev *dev, int cap);int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val);int pci_read_config_word(struct pci_dev *dev, int where, u16 *val);int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val);int pci_write_config_byte(struct pci_dev *dev, int where, u8 val);int pci_write_config_word(struct pci_dev *dev, int where, u16 val);int pci_write_config_dword(struct pci_dev *dev, int where, u32 val);int pci_enable_device(struct pci_dev *dev);void pci_set_master(struct pci_dev *dev);int pci_set_power_state(struct pci_dev *dev, int state);int pci_assign_resource(struct pci_dev *dev, int i);/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */int pci_claim_resource(struct pci_dev *, int);void pci_assign_unassigned_resources(void);void pdev_enable_device(struct pci_dev *);void pdev_sort_resources(struct pci_dev *, struct resource_list *, u32);unsigned long pci_bridge_check_io(struct pci_dev *);void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),		    int (*)(struct pci_dev *, u8, u8));/* New-style probing supporting hot-pluggable devices */int pci_register_driver(struct pci_driver *);void pci_unregister_driver(struct pci_driver *);void pci_insert_device(struct pci_dev *, struct pci_bus *);void pci_remove_device(struct pci_dev *);struct pci_driver *pci_dev_driver(const struct pci_dev *);const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev);#endif /* CONFIG_PCI *//* Include architecture-dependent settings and functions */#include <asm/pci.h>/* *  If the system does not have PCI, clearly these return errors.  Define *  these as simple inline functions to avoid hair in drivers. */#ifndef CONFIG_PCIstatic inline int pcibios_present(void) { return 0; }static inline int pcibios_find_class (unsigned int class_code, unsigned short index, unsigned char *bus, unsigned char *dev_fn) { 	return PCIBIOS_DEVICE_NOT_FOUND; }#define _PCI_NOP(o,s,t) \	static inline int pcibios_##o##_config_##s## (u8 bus, u8 dfn, u8 where, t val) \		{ return PCIBIOS_FUNC_NOT_SUPPORTED; } \	static inline int pci_##o##_config_##s## (struct pci_dev *dev, int where, t val) \		{ return PCIBIOS_FUNC_NOT_SUPPORTED; }#define _PCI_NOP_ALL(o,x)	_PCI_NOP(o,byte,u8 x) \				_PCI_NOP(o,word,u16 x) \				_PCI_NOP(o,dword,u32 x)_PCI_NOP_ALL(read, *)_PCI_NOP_ALL(write,)static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from){ return NULL; }static inline struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from){ return NULL; }static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn){ return NULL; }static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device,unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from){ return NULL; }static inline void pci_set_master(struct pci_dev *dev) { }static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }static inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; }static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}static inline int pci_register_driver(struct pci_driver *drv) { return 0;}static inline void pci_unregister_driver(struct pci_driver *drv) { }static inline int scsi_to_pci_dma_dir(unsigned char scsi_dir) { return scsi_dir; }static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }#else/* * a helper function which helps ensure correct pci_driver * setup and cleanup for commonly-encountered hotplug/modular cases * * This MUST stay in a header, as it checks for -DMODULE */static inline int pci_module_init(struct pci_driver *drv){	int rc = pci_register_driver (drv);	if (rc > 0)		return 0;	/* iff CONFIG_HOTPLUG and built into kernel, we should	 * leave the driver around for future hotplug events.	 * For the module case, a hotplug daemon of some sort	 * should load a module in response to an insert event. */#if defined(CONFIG_HOTPLUG) && !defined(MODULE)	if (rc == 0)		return 0;#endif	/* if we get here, we need to clean up pci driver instance	 * and return some sort of error */	pci_unregister_driver (drv);		return -ENODEV;}#endif /* !CONFIG_PCI *//* these helpers provide future and backwards compatibility * for accessing popular PCI BAR info */#define pci_resource_start(dev,bar)   ((dev)->resource[(bar)].start)#define pci_resource_end(dev,bar)     ((dev)->resource[(bar)].end)#define pci_resource_flags(dev,bar)   ((dev)->resource[(bar)].flags)#define pci_resource_len(dev,bar) \	((pci_resource_start((dev),(bar)) == 0 &&	\	  pci_resource_end((dev),(bar)) ==		\	  pci_resource_start((dev),(bar))) ? 0 :	\	  						\	 (pci_resource_end((dev),(bar)) -		\	  pci_resource_start((dev),(bar)) + 1))/* Similar to the helpers above, these manipulate per-pci_dev * driver-specific data.  Currently stored as pci_dev::driver_data, * a void pointer, but it is not present on older kernels. */static inline void *pci_get_drvdata (struct pci_dev *pdev){	return pdev->driver_data;}static inline void pci_set_drvdata (struct pci_dev *pdev, void *data){	pdev->driver_data = data;}/* *  The world is not perfect and supplies us with broken PCI devices. *  For at least a part of these bugs we need a work-around, so both *  generic (drivers/pci/quirks.c) and per-architecture code can define *  fixup hooks to be called for particular buggy devices. */struct pci_fixup {	int pass;	u16 vendor, device;			/* You can use PCI_ANY_ID here of course */	void (*hook)(struct pci_dev *dev);};extern struct pci_fixup pcibios_fixups[];#define PCI_FIXUP_HEADER	1		/* Called immediately after reading configuration header */#define PCI_FIXUP_FINAL		2		/* Final phase of device fixups */void pci_fixup_device(int pass, struct pci_dev *dev);extern int pci_pci_problems;#define PCIPCI_FAIL		1#define PCIPCI_TRITON		2#define PCIPCI_NATOMA		4#define PCIPCI_VIAETBF		8#endif /* __KERNEL__ */#endif /* LINUX_PCI_H */

⌨️ 快捷键说明

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