亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
色婷婷综合五月| 国产精品午夜在线| 国产精品高潮呻吟久久| 日本欧美久久久久免费播放网| 国产资源精品在线观看| 欧美区在线观看| 一区二区三区四区av| 国产成人午夜99999| 欧美一区二区三区成人| 中文字幕欧美一区| 国产盗摄精品一区二区三区在线 | 亚洲国产中文字幕在线视频综合 | 日韩1区2区3区| 色综合天天综合狠狠| 久久亚洲精品国产精品紫薇| 婷婷开心激情综合| 色综合色综合色综合| 欧美韩国日本不卡| 国产老肥熟一区二区三区| 日韩一区二区在线看| 婷婷中文字幕一区三区| 欧美少妇bbb| 亚洲黄色av一区| 色婷婷久久久综合中文字幕| 国产精品乱码人人做人人爱 | 欧美三级电影一区| 亚洲蜜臀av乱码久久精品蜜桃| 粉嫩一区二区三区在线看| 2020国产精品| 韩国精品一区二区| 国产午夜精品一区二区三区四区| 麻豆一区二区三区| 欧美草草影院在线视频| 美女视频黄免费的久久| 欧美本精品男人aⅴ天堂| 蜜臀av一级做a爰片久久| 91精品国产综合久久精品图片| 香蕉乱码成人久久天堂爱免费| 欧美午夜一区二区三区| 亚洲成a人v欧美综合天堂下载| 欧美日韩一级大片网址| 日精品一区二区三区| 精品国产一区二区三区久久影院 | 欧美精品九九99久久| 日韩精品福利网| 精品裸体舞一区二区三区| 国产一区二区三区免费播放| 国产午夜亚洲精品理论片色戒 | 1区2区3区国产精品| 色综合久久天天| 天天操天天色综合| 久久久精品tv| 91福利社在线观看| 欧美aaaaa成人免费观看视频| 日韩欧美国产麻豆| a级精品国产片在线观看| 一区二区激情视频| 91精品国产综合久久香蕉的特点| 国产一区二区视频在线播放| 中文字幕欧美一| 欧美日韩亚洲高清一区二区| 精品亚洲欧美一区| |精品福利一区二区三区| 欧美午夜理伦三级在线观看| 老司机精品视频一区二区三区| 日本一区免费视频| 欧美日韩五月天| 成人一区二区三区在线观看 | 国产九色sp调教91| 亚洲自拍偷拍麻豆| 国产亚洲精品超碰| 91福利精品视频| 国产精品综合一区二区三区| 亚洲最大成人综合| 国产无遮挡一区二区三区毛片日本| 不卡一卡二卡三乱码免费网站| 日韩主播视频在线| 中文字幕在线播放不卡一区| 欧美一级高清片在线观看| 99re视频精品| 国产成人精品影院| 免费人成在线不卡| 亚洲成人三级小说| 国产精品毛片久久久久久| 日韩你懂的电影在线观看| 色嗨嗨av一区二区三区| 成人激情免费视频| 激情伊人五月天久久综合| 亚洲综合丝袜美腿| ...xxx性欧美| 国产婷婷色一区二区三区在线| 欧美一三区三区四区免费在线看| 99国产精品久久久久久久久久 | 精品一区精品二区高清| 亚洲一区二区三区国产| 日韩美女视频一区二区| 国产午夜精品一区二区| 2欧美一区二区三区在线观看视频| 在线观看免费成人| 91天堂素人约啪| 99久久国产综合精品女不卡 | 国模少妇一区二区三区| 蜜臀久久久久久久| 免费人成在线不卡| 视频在线观看一区| 视频一区二区中文字幕| 亚洲成人av一区| 亚洲成人精品一区| 亚洲va欧美va国产va天堂影院| 一区二区激情小说| 亚洲一区影音先锋| 午夜精品久久久久久久99水蜜桃| 亚洲国产一区二区视频| 亚洲一区影音先锋| 丝袜a∨在线一区二区三区不卡| 午夜视频一区在线观看| 无码av免费一区二区三区试看| 亚洲成人手机在线| 日本va欧美va精品| 蜜乳av一区二区| 国产一区二区三区不卡在线观看| 激情成人综合网| 高清av一区二区| 99久久久久免费精品国产| 91麻豆高清视频| 欧洲国产伦久久久久久久| 日本精品一级二级| 91精品国产一区二区三区| 日韩欧美一区二区久久婷婷| 精品国产伦一区二区三区观看方式| 日韩视频一区二区在线观看| 欧美不卡一区二区三区| 欧美极品少妇xxxxⅹ高跟鞋| 1区2区3区欧美| 亚洲不卡av一区二区三区| 久久99这里只有精品| 成人性生交大合| 在线观看不卡一区| 日韩片之四级片| 中文字幕乱码日本亚洲一区二区| 亚洲私人黄色宅男| 偷拍亚洲欧洲综合| 国产91在线看| 欧美亚洲一区二区三区四区| 欧美电视剧在线看免费| 中文字幕在线一区二区三区| 亚洲超碰精品一区二区| 国产精品亚洲视频| 欧美日韩在线三级| 日本一区二区免费在线观看视频 | 高清beeg欧美| 欧美色精品天天在线观看视频| 日韩免费视频一区| 亚洲丝袜精品丝袜在线| 久久精品久久久精品美女| 波多野结衣在线一区| 91精品国产综合久久福利| 国产精品网友自拍| 麻豆91在线播放| 在线免费观看日本欧美| 26uuu国产电影一区二区| 亚洲一区二区三区四区的| 国产馆精品极品| 日韩一区二区影院| 一区二区三区**美女毛片| 成人午夜激情视频| 欧美成人综合网站| 亚洲精品久久7777| 成人中文字幕电影| 欧美大尺度电影在线| 丝瓜av网站精品一区二区| 91丨porny丨在线| 国产日韩欧美一区二区三区综合| 日本中文字幕一区二区有限公司| fc2成人免费人成在线观看播放| 日韩你懂的在线播放| 午夜亚洲福利老司机| 色素色在线综合| 国产精品家庭影院| 国产很黄免费观看久久| 精品国产一区久久| 老司机精品视频在线| 日韩一级视频免费观看在线| 亚洲自拍另类综合| 色嗨嗨av一区二区三区| 1024国产精品| 91麻豆精品视频| 中文字幕视频一区| 91麻豆高清视频| 亚洲黄一区二区三区| 色av综合在线| 一区二区三区四区中文字幕| 不卡av电影在线播放| 中文字幕一区二区三区乱码在线| 国产馆精品极品| 国产精品成人一区二区三区夜夜夜 | 国产精品一区2区| 欧美xfplay| 国产精品1区2区3区在线观看| 久久网站最新地址|