亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pci.c

?? linux下的pci接口驅動程序
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* *	$Id: pci.c,v 1.91 1999/01/21 13:34:01 davem Exp $ * *	PCI Bus Services, see include/linux/pci.h for further explanation. * *	Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter, *	David Mosberger-Tang * *	Copyright 1997 -- 2000 Martin Mares <mj@ucw.cz> */#include <linux/config.h>#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/pci.h>#include <linux/string.h>#include <linux/init.h>#include <linux/slab.h>#include <linux/ioport.h>#include <linux/spinlock.h>#include <linux/pm.h>#include <linux/kmod.h>		/* for hotplug_path */#include <linux/bitops.h>#include <linux/delay.h>#include <linux/cache.h>#include <asm/page.h>#include <asm/dma.h>	/* isa_dma_bridge_buggy */#undef DEBUG#ifdef DEBUG#define DBG(x...) printk(x)#else#define DBG(x...)#endifLIST_HEAD(pci_root_buses);LIST_HEAD(pci_devices);/** * pci_find_slot - locate PCI device from a given PCI slot * @bus: number of PCI bus on which desired PCI device resides * @devfn: encodes number of PCI slot in which the desired PCI  * device resides and the logical device number within that slot  * in case of multi-function devices. * * Given a PCI bus and slot/function number, the desired PCI device  * is located in system global list of PCI devices.  If the device * is found, a pointer to its data structure is returned.  If no  * device is found, %NULL is returned. */struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn){	struct pci_dev *dev;	pci_for_each_dev(dev) {		if (dev->bus->number == bus && dev->devfn == devfn)			return dev;	}	return NULL;}/** * pci_find_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids * @ss_vendor: PCI subsystem vendor id to match, or %PCI_ANY_ID to match all vendor ids * @ss_device: PCI subsystem device id to match, or %PCI_ANY_ID to match all device ids * @from: Previous PCI device found in search, or %NULL for new search. * * Iterates through the list of known PCI devices.  If a PCI device is * found with a matching @vendor, @device, @ss_vendor and @ss_device, a pointer to its * device structure is returned.  Otherwise, %NULL is returned. * A new search is initiated by passing %NULL to the @from argument. * Otherwise if @from is not %NULL, searches continue from next device on the global list. */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 list_head *n = from ? from->global_list.next : pci_devices.next;	while (n != &pci_devices) {		struct pci_dev *dev = pci_dev_g(n);		if ((vendor == PCI_ANY_ID || dev->vendor == vendor) &&		    (device == PCI_ANY_ID || dev->device == device) &&		    (ss_vendor == PCI_ANY_ID || dev->subsystem_vendor == ss_vendor) &&		    (ss_device == PCI_ANY_ID || dev->subsystem_device == ss_device))			return dev;		n = n->next;	}	return NULL;}/** * pci_find_device - begin or continue searching for a PCI device by vendor/device id * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids * @from: Previous PCI device found in search, or %NULL for new search. * * Iterates through the list of known PCI devices.  If a PCI device is * found with a matching @vendor and @device, a pointer to its device structure is * returned.  Otherwise, %NULL is returned. * A new search is initiated by passing %NULL to the @from argument. * Otherwise if @from is not %NULL, searches continue from next device on the global list. */struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from){	return pci_find_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);}/** * pci_find_class - begin or continue searching for a PCI device by class * @class: search for a PCI device with this class designation * @from: Previous PCI device found in search, or %NULL for new search. * * Iterates through the list of known PCI devices.  If a PCI device is * found with a matching @class, a pointer to its device structure is * returned.  Otherwise, %NULL is returned. * A new search is initiated by passing %NULL to the @from argument. * Otherwise if @from is not %NULL, searches continue from next device * on the global list. */struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from){	struct list_head *n = from ? from->global_list.next : pci_devices.next;	while (n != &pci_devices) {		struct pci_dev *dev = pci_dev_g(n);		if (dev->class == class)			return dev;		n = n->next;	}	return NULL;}/** * pci_find_capability - query for devices' capabilities  * @dev: PCI device to query * @cap: capability code * * Tell if a device supports a given PCI capability. * Returns the address of the requested capability structure within the * device's PCI configuration space or 0 in case the device does not * support it.  Possible values for @cap: * *  %PCI_CAP_ID_PM           Power Management  * *  %PCI_CAP_ID_AGP          Accelerated Graphics Port  * *  %PCI_CAP_ID_VPD          Vital Product Data  * *  %PCI_CAP_ID_SLOTID       Slot Identification  * *  %PCI_CAP_ID_MSI          Message Signalled Interrupts * *  %PCI_CAP_ID_CHSWP        CompactPCI HotSwap  */intpci_find_capability(struct pci_dev *dev, int cap){	u16 status;	u8 pos, id;	int ttl = 48;	pci_read_config_word(dev, PCI_STATUS, &status);	if (!(status & PCI_STATUS_CAP_LIST))		return 0;	switch (dev->hdr_type) {	case PCI_HEADER_TYPE_NORMAL:	case PCI_HEADER_TYPE_BRIDGE:		pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);		break;	case PCI_HEADER_TYPE_CARDBUS:		pci_read_config_byte(dev, PCI_CB_CAPABILITY_LIST, &pos);		break;	default:		return 0;	}	while (ttl-- && pos >= 0x40) {		pos &= ~3;		pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);		if (id == 0xff)			break;		if (id == cap)			return pos;		pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);	}	return 0;}/** * pci_find_parent_resource - return resource region of parent bus of given region * @dev: PCI device structure contains resources to be searched * @res: child resource record for which parent is sought * *  For given resource region of given device, return the resource *  region of parent bus the given region is contained in or where *  it should be allocated from. */struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res){	const struct pci_bus *bus = dev->bus;	int i;	struct resource *best = NULL;	for(i=0; i<4; i++) {		struct resource *r = bus->resource[i];		if (!r)			continue;		if (res->start && !(res->start >= r->start && res->end <= r->end))			continue;	/* Not contained */		if ((res->flags ^ r->flags) & (IORESOURCE_IO | IORESOURCE_MEM))			continue;	/* Wrong type */		if (!((res->flags ^ r->flags) & IORESOURCE_PREFETCH))			return r;	/* Exact match */		if ((res->flags & IORESOURCE_PREFETCH) && !(r->flags & IORESOURCE_PREFETCH))			best = r;	/* Approximating prefetchable by non-prefetchable */	}	return best;}/** * pci_set_power_state - Set the power state of a PCI device * @dev: PCI device to be suspended * @state: Power state we're entering * * Transition a device to a new power state, using the Power Management  * Capabilities in the device's config space. * * RETURN VALUE:  * -EINVAL if trying to enter a lower state than we're already in. * 0 if we're already in the requested state. * -EIO if device does not support PCI PM. * 0 if we can successfully change the power state. */intpci_set_power_state(struct pci_dev *dev, int state){	int pm;	u16 pmcsr;	/* bound the state we're entering */	if (state > 3) state = 3;	/* Validate current state:	 * Can enter D0 from any state, but if we can only go deeper 	 * to sleep if we're already in a low power state	 */	if (state > 0 && dev->current_state > state)		return -EINVAL;	else if (dev->current_state == state) 		return 0;        /* we're already there */	/* find PCI PM capability in list */	pm = pci_find_capability(dev, PCI_CAP_ID_PM);		/* abort if the device doesn't support PM capabilities */	if (!pm) return -EIO; 	/* check if this device supports the desired state */	if (state == 1 || state == 2) {		u16 pmc;		pci_read_config_word(dev,pm + PCI_PM_PMC,&pmc);		if (state == 1 && !(pmc & PCI_PM_CAP_D1)) return -EIO;		else if (state == 2 && !(pmc & PCI_PM_CAP_D2)) return -EIO;	}	/* If we're in D3, force entire word to 0.	 * This doesn't affect PME_Status, disables PME_En, and	 * sets PowerState to 0.	 */	if (dev->current_state >= 3)		pmcsr = 0;	else {		pci_read_config_word(dev, pm + PCI_PM_CTRL, &pmcsr);		pmcsr &= ~PCI_PM_CTRL_STATE_MASK;		pmcsr |= state;	}	/* enter specified state */	pci_write_config_word(dev, pm + PCI_PM_CTRL, pmcsr);	/* Mandatory power management transition delays */	/* see PCI PM 1.1 5.6.1 table 18 */	if(state == 3 || dev->current_state == 3)	{		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(HZ/100);	}	else if(state == 2 || dev->current_state == 2)		udelay(200);	dev->current_state = state;	return 0;}/** * pci_save_state - save the PCI configuration space of a device before suspending * @dev: - PCI device that we're dealing with * @buffer: - buffer to hold config space context * * @buffer must be large enough to hold the entire PCI 2.2 config space  * (>= 64 bytes). */intpci_save_state(struct pci_dev *dev, u32 *buffer){	int i;	if (buffer) {		/* XXX: 100% dword access ok here? */		for (i = 0; i < 16; i++)			pci_read_config_dword(dev, i * 4,&buffer[i]);	}	return 0;}/**  * pci_restore_state - Restore the saved state of a PCI device * @dev: - PCI device that we're dealing with * @buffer: - saved PCI config space * */int pci_restore_state(struct pci_dev *dev, u32 *buffer){	int i;	if (buffer) {		for (i = 0; i < 16; i++)			pci_write_config_dword(dev,i * 4, buffer[i]);	}	/*	 * otherwise, write the context information we know from bootup.	 * This works around a problem where warm-booting from Windows	 * combined with a D3(hot)->D0 transition causes PCI config	 * header data to be forgotten.	 */		else {		for (i = 0; i < 6; i ++)			pci_write_config_dword(dev,					       PCI_BASE_ADDRESS_0 + (i * 4),					       dev->resource[i].start);		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);	}	return 0;}int pci_compare_state(struct pci_dev *dev, u32 *buffer){	int i;	unsigned int temp;	if (buffer) {		for (i = 0; i < 16; i++) {			pci_read_config_dword(dev,i*4,&temp);			if (temp!=buffer[i])				return 1;		}	}	return 0;}int pci_generic_suspend_save(struct pci_dev *pdev, u32 state){	if (pdev)		pci_save_state(pdev,pdev->saved_state);	return 0;}int pci_generic_resume_restore(struct pci_dev *pdev){	if (pdev)		pci_restore_state(pdev,pdev->saved_state);	return 0;		}int pci_generic_resume_compare(struct pci_dev *pdev){	int retval=0;	if (pdev)		retval = pci_compare_state(pdev,pdev->saved_state);	return retval;		}EXPORT_SYMBOL(pci_generic_suspend_save);EXPORT_SYMBOL(pci_generic_resume_restore);EXPORT_SYMBOL(pci_generic_resume_compare);/** * pci_enable_device - Initialize device before it's used by a driver. * @dev: PCI device to be initialized * *  Initialize device before it's used by a driver. Ask low-level code *  to enable I/O and memory. Wake up the device if it was suspended. *  Beware, this function can fail. */intpci_enable_device(struct pci_dev *dev){	int err;	pci_set_power_state(dev, 0);	if ((err = pcibios_enable_device(dev)) < 0)		return err;	return 0;}/** * pci_disable_device - Disable PCI device after use * @dev: PCI device to be disabled * * Signal to the system that the PCI device is not in use by the system * anymore.  This only involves disabling PCI bus-mastering, if active. */voidpci_disable_device(struct pci_dev *dev){	u16 pci_command;	pci_read_config_word(dev, PCI_COMMAND, &pci_command);	if (pci_command & PCI_COMMAND_MASTER) {		pci_command &= ~PCI_COMMAND_MASTER;		pci_write_config_word(dev, PCI_COMMAND, pci_command);	}}/** * pci_enable_wake - enable device to generate PME# when suspended * @dev: - PCI device to operate on * @state: - Current state of device. * @enable: - Flag to enable or disable generation *  * Set the bits in the device's PM Capabilities to generate PME# when * the system is suspended.  * * -EIO is returned if device doesn't have PM Capabilities.  * -EINVAL is returned if device supports it, but can't generate wake events. * 0 if operation is successful. *  */int pci_enable_wake(struct pci_dev *dev, u32 state, int enable){	int pm;	u16 value;	/* find PCI PM capability in list */	pm = pci_find_capability(dev, PCI_CAP_ID_PM);	/* If device doesn't support PM Capabilities, but request is to disable	 * wake events, it's a nop; otherwise fail */	if (!pm) 		return enable ? -EIO : 0; 	/* Check device's ability to generate PME# */	pci_read_config_word(dev,pm+PCI_PM_PMC,&value);	value &= PCI_PM_CAP_PME_MASK;	value >>= ffs(value);   /* First bit of mask */	/* Check if it can generate PME# from requested state. */	if (!value || !(value & (1 << state))) 		return enable ? -EINVAL : 0;	pci_read_config_word(dev, pm + PCI_PM_CTRL, &value);	/* Clear PME_Status by writing 1 to it and enable PME# */	value |= PCI_PM_CTRL_PME_STATUS | PCI_PM_CTRL_PME_ENABLE;	if (!enable)		value &= ~PCI_PM_CTRL_PME_ENABLE;	pci_write_config_word(dev, pm + PCI_PM_CTRL, value);		return 0;}intpci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge){	u8 pin;	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);	if (!pin)		return -1;	pin--;	while (dev->bus->self) {		pin = (pin + PCI_SLOT(dev->devfn)) % 4;		dev = dev->bus->self;	}	*bridge = dev;	return pin;}/** *	pci_release_regions - Release reserved PCI I/O and memory resources *	@pdev: PCI device whose resources were previously reserved by pci_request_regions * *	Releases all PCI I/O and memory resources previously reserved by a *	successful call to pci_request_regions.  Call this function only *	after all use of the PCI regions has ceased. */void pci_release_regions(struct pci_dev *pdev){	int i;		for (i = 0; i < 6; i++) {		if (pci_resource_len(pdev, i) == 0)			continue;		if (pci_resource_flags(pdev, i) & IORESOURCE_IO)			release_region(pci_resource_start(pdev, i),				       pci_resource_len(pdev, i));		else if (pci_resource_flags(pdev, i) & IORESOURCE_MEM)			release_mem_region(pci_resource_start(pdev, i),					   pci_resource_len(pdev, i));	}}/** *	pci_request_regions - Reserved PCI I/O and memory resources *	@pdev: PCI device whose resources are to be reserved *	@res_name: Name to be associated with resource. * *	Mark all PCI regions associated with PCI device @pdev as *	being reserved by owner @res_name.  Do not access any *	address inside the PCI regions unless this call returns *	successfully. * *	Returns 0 on success, or %EBUSY on error.  A warning *	message is also printed on failure. */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区蜜桃网| 欧美成va人片在线观看| 国产精品灌醉下药二区| 成人性视频免费网站| 国产精品国产自产拍在线| 91香蕉国产在线观看软件| 亚洲精品高清在线| 欧美日韩黄视频| 久久精品国产亚洲一区二区三区| 日韩欧美综合一区| 国产精品一区在线| 亚洲婷婷综合久久一本伊一区| 91黄色在线观看| 丝袜a∨在线一区二区三区不卡| 欧美精品国产精品| 国产剧情一区在线| 一区二区三区日韩欧美| 91.com在线观看| 国产精品影视在线| 亚洲综合一二区| 日韩视频一区二区在线观看| 高清成人在线观看| 亚洲伊人色欲综合网| 精品卡一卡二卡三卡四在线| 成人午夜精品一区二区三区| 亚洲一区二区美女| 久久久精品国产99久久精品芒果| 99久久精品情趣| 日韩电影免费在线看| 国产清纯白嫩初高生在线观看91 | 蜜桃av一区二区| 久久精品视频在线看| 色婷婷av一区二区三区软件| 麻豆91在线播放免费| 中文字幕一区二区三区四区不卡| 在线成人av影院| 粉嫩av亚洲一区二区图片| 天堂在线亚洲视频| 中文字幕一区二区三区乱码在线| 精品视频1区2区3区| 国产美女一区二区| 五月婷婷欧美视频| 国产精品美女久久久久aⅴ| 91麻豆精品91久久久久久清纯| 成人激情开心网| 蜜乳av一区二区| 亚洲成人中文在线| 一区在线观看免费| 精品国产sm最大网站| 欧美日韩高清在线播放| 91女人视频在线观看| 国产sm精品调教视频网站| 日本不卡一二三| 亚洲综合色丁香婷婷六月图片| 久久精品亚洲一区二区三区浴池| 欧美精品久久天天躁| 色综合久久综合网| 国产99精品在线观看| 激情五月激情综合网| 日韩和欧美的一区| 亚洲丰满少妇videoshd| 亚洲日本欧美天堂| 中文字幕亚洲视频| 国产欧美日韩三级| 国产午夜亚洲精品羞羞网站| 日韩欧美国产成人一区二区| 欧美精品在线观看播放| 色老汉一区二区三区| 色综合久久久久综合99| 99久久免费视频.com| 成人黄色av网站在线| 国产成人免费高清| 国产不卡视频在线观看| 国产91在线|亚洲| 国产风韵犹存在线视精品| 久久99精品国产.久久久久| 久久精品国产久精国产爱| 日韩电影在线免费观看| 石原莉奈在线亚洲二区| 日韩精品电影在线观看| 日日夜夜免费精品视频| 蜜臀精品一区二区三区在线观看| 日本成人在线不卡视频| 裸体一区二区三区| 久久99久久精品| 国产精品亚洲一区二区三区在线| 国产成人久久精品77777最新版本| 国产乱色国产精品免费视频| 国产成人精品一区二区三区四区| 大白屁股一区二区视频| 99久久精品国产麻豆演员表| 91小宝寻花一区二区三区| 欧美亚一区二区| 欧美肥胖老妇做爰| 欧美大肚乱孕交hd孕妇| 国产清纯白嫩初高生在线观看91 | 精品久久久久一区二区国产| 欧美大黄免费观看| 国产日产欧美一区| 亚洲精品国产精华液| 日本成人在线电影网| 色综合久久久久久久久| 69久久夜色精品国产69蝌蚪网| 日韩免费观看高清完整版| 国产视频一区二区在线| 亚洲欧美欧美一区二区三区| 亚洲成人动漫在线观看| 精油按摩中文字幕久久| 国产不卡在线一区| 欧美视频自拍偷拍| 久久综合色之久久综合| 亚洲同性同志一二三专区| 丝袜亚洲另类丝袜在线| 国产成人午夜精品影院观看视频| 91黄色激情网站| 精品少妇一区二区三区在线视频 | 成人手机电影网| 欧美三区在线视频| 久久影院午夜论| 亚洲第一狼人社区| 国产黄人亚洲片| 欧美日韩一区二区在线观看视频| 久久久夜色精品亚洲| 一区二区免费看| 国产寡妇亲子伦一区二区| 欧美日精品一区视频| 国产三级一区二区| 日本一道高清亚洲日美韩| 成人网男人的天堂| 日韩欧美在线观看一区二区三区| 中文字幕日韩精品一区| 久草在线在线精品观看| 欧美在线视频全部完| 国产清纯在线一区二区www| 青娱乐精品视频| 色八戒一区二区三区| 久久久久久久久一| 日韩高清中文字幕一区| 91蝌蚪porny九色| 久久丝袜美腿综合| 日本v片在线高清不卡在线观看| 日本精品免费观看高清观看| 久久久久亚洲综合| 美女在线一区二区| 欧美视频自拍偷拍| 国产美女视频一区| 日韩一区二区中文字幕| 亚洲国产欧美日韩另类综合| www.欧美精品一二区| 久久亚洲影视婷婷| 麻豆91在线看| 欧美精品v日韩精品v韩国精品v| 亚洲精品免费在线播放| fc2成人免费人成在线观看播放| 精品国产3级a| 捆绑紧缚一区二区三区视频| 欧美精品乱码久久久久久| 亚洲一区二区三区在线| 色域天天综合网| 亚洲少妇最新在线视频| www.在线成人| 一色桃子久久精品亚洲| 99久久精品国产网站| 亚洲四区在线观看| 成a人片亚洲日本久久| 国产精品人妖ts系列视频| 国产91在线|亚洲| 国产精品伦一区二区三级视频| 国产成人亚洲综合a∨婷婷| 国产日韩av一区| 成人av午夜电影| 亚洲人精品午夜| 色先锋资源久久综合| 一区二区三区色| 欧美日韩国产三级| 日日噜噜夜夜狠狠视频欧美人 | 欧美日韩另类一区| 亚洲成人在线免费| 5月丁香婷婷综合| 久久国产人妖系列| 久久综合视频网| 成人avav在线| 亚洲夂夂婷婷色拍ww47| 欧美日韩久久久久久| 日韩国产高清影视| 久久久久久久久蜜桃| www.亚洲免费av| 亚洲国产一区视频| 337p亚洲精品色噜噜狠狠| 久久狠狠亚洲综合| 国产日韩欧美一区二区三区乱码 | 91麻豆精品视频| 亚洲高清免费在线| 欧美成人vps| 成人午夜伦理影院| 亚洲成a人v欧美综合天堂下载 | 久久久久九九视频| av在线不卡免费看| 视频在线观看一区| 国产欧美日韩中文久久|