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

📄 io_init.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * This file is subject to the terms and conditions of the GNU General Public * License.  See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved. */#include <linux/bootmem.h>#include <linux/nodemask.h>#include <asm/sn/types.h>#include <asm/sn/addrs.h>#include <asm/sn/geo.h>#include <asm/sn/io.h>#include <asm/sn/pcibr_provider.h>#include <asm/sn/pcibus_provider_defs.h>#include <asm/sn/pcidev.h>#include <asm/sn/simulator.h>#include <asm/sn/sn_sal.h>#include <asm/sn/tioca_provider.h>#include <asm/sn/tioce_provider.h>#include "xtalk/hubdev.h"#include "xtalk/xwidgetdev.h"static struct list_head sn_sysdata_list;/* sysdata list struct */struct sysdata_el {	struct list_head entry;	void *sysdata;};struct slab_info {	struct hubdev_info hubdev;};struct brick {	moduleid_t id;		/* Module ID of this module        */	struct slab_info slab_info[MAX_SLABS + 1];};int sn_ioif_inited = 0;		/* SN I/O infrastructure initialized? */struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES];	/* indexed by asic type */static int max_segment_number = 0; /* Default highest segment number */static int max_pcibus_number = 255; /* Default highest pci bus number *//* * Hooks and struct for unsupported pci providers */static dma_addr_tsn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size){	return 0;}static voidsn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction){	return;}static void *sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller){	return NULL;}static struct sn_pcibus_provider sn_pci_default_provider = {	.dma_map = sn_default_pci_map,	.dma_map_consistent = sn_default_pci_map,	.dma_unmap = sn_default_pci_unmap,	.bus_fixup = sn_default_pci_bus_fixup,};/* * Retrieve the DMA Flush List given nasid.  This list is needed  * to implement the WAR - Flush DMA data on PIO Reads. */static inline uint64_tsal_get_widget_dmaflush_list(u64 nasid, u64 widget_num, u64 address){	struct ia64_sal_retval ret_stuff;	ret_stuff.status = 0;	ret_stuff.v0 = 0;	SAL_CALL_NOLOCK(ret_stuff,			(u64) SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,			(u64) nasid, (u64) widget_num, (u64) address, 0, 0, 0,			0);	return ret_stuff.v0;}/* * Retrieve the hub device info structure for the given nasid. */static inline uint64_t sal_get_hubdev_info(u64 handle, u64 address){	struct ia64_sal_retval ret_stuff;	ret_stuff.status = 0;	ret_stuff.v0 = 0;	SAL_CALL_NOLOCK(ret_stuff,			(u64) SN_SAL_IOIF_GET_HUBDEV_INFO,			(u64) handle, (u64) address, 0, 0, 0, 0, 0);	return ret_stuff.v0;}/* * Retrieve the pci bus information given the bus number. */static inline uint64_t sal_get_pcibus_info(u64 segment, u64 busnum, u64 address){	struct ia64_sal_retval ret_stuff;	ret_stuff.status = 0;	ret_stuff.v0 = 0;	SAL_CALL_NOLOCK(ret_stuff,			(u64) SN_SAL_IOIF_GET_PCIBUS_INFO,			(u64) segment, (u64) busnum, (u64) address, 0, 0, 0, 0);	return ret_stuff.v0;}/* * Retrieve the pci device information given the bus and device|function number. */static inline uint64_tsal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev, 			u64 sn_irq_info){	struct ia64_sal_retval ret_stuff;	ret_stuff.status = 0;	ret_stuff.v0 = 0;	SAL_CALL_NOLOCK(ret_stuff,			(u64) SN_SAL_IOIF_GET_PCIDEV_INFO,			(u64) segment, (u64) bus_number, (u64) devfn, 			(u64) pci_dev,			sn_irq_info, 0, 0);	return ret_stuff.v0;}/* * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified *			  device. */inline struct pcidev_info *sn_pcidev_info_get(struct pci_dev *dev){	struct pcidev_info *pcidev;	list_for_each_entry(pcidev,			    &(SN_PCI_CONTROLLER(dev)->pcidev_info), pdi_list) {		if (pcidev->pdi_linux_pcidev == dev) {			return pcidev;		}	}	return NULL;}/* * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for  *	each node in the system. */static void sn_fixup_ionodes(void){	struct sn_flush_device_list *sn_flush_device_list;	struct hubdev_info *hubdev;	uint64_t status;	uint64_t nasid;	int i, widget;	/*	 * Get SGI Specific HUB chipset information.	 * Inform Prom that this kernel can support domain bus numbering.	 */	for (i = 0; i < num_cnodes; i++) {		hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);		nasid = cnodeid_to_nasid(i);		hubdev->max_segment_number = 0xffffffff;		hubdev->max_pcibus_number = 0xff;		status = sal_get_hubdev_info(nasid, (uint64_t) __pa(hubdev));		if (status)			continue;		/* Save the largest Domain and pcibus numbers found. */		if (hubdev->max_segment_number) {			/*			 * Dealing with a Prom that supports segments.			 */			max_segment_number = hubdev->max_segment_number;			max_pcibus_number = hubdev->max_pcibus_number;		}		/* Attach the error interrupt handlers */		if (nasid & 1)			ice_error_init(hubdev);		else			hub_error_init(hubdev);		for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)			hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;		if (!hubdev->hdi_flush_nasid_list.widget_p)			continue;		hubdev->hdi_flush_nasid_list.widget_p =		    kmalloc((HUB_WIDGET_ID_MAX + 1) *			    sizeof(struct sn_flush_device_list *), GFP_KERNEL);		memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,		       (HUB_WIDGET_ID_MAX + 1) *		       sizeof(struct sn_flush_device_list *));		for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {			sn_flush_device_list = kmalloc(DEV_PER_WIDGET *						       sizeof(struct							      sn_flush_device_list),						       GFP_KERNEL);			memset(sn_flush_device_list, 0x0,			       DEV_PER_WIDGET *			       sizeof(struct sn_flush_device_list));			status =			    sal_get_widget_dmaflush_list(nasid, widget,							 (uint64_t)							 __pa							 (sn_flush_device_list));			if (status) {				kfree(sn_flush_device_list);				continue;			}			spin_lock_init(&sn_flush_device_list->sfdl_flush_lock);			hubdev->hdi_flush_nasid_list.widget_p[widget] =			    sn_flush_device_list;		}	}}/* * sn_pci_window_fixup() - Create a pci_window for each device resource. *			   Until ACPI support is added, we need this code *			   to setup pci_windows for use by *			   pcibios_bus_to_resource(), *			   pcibios_resource_to_bus(), etc. */static voidsn_pci_window_fixup(struct pci_dev *dev, unsigned int count,		    int64_t * pci_addrs){	struct pci_controller *controller = PCI_CONTROLLER(dev->bus);	unsigned int i;	unsigned int idx;	unsigned int new_count;	struct pci_window *new_window;	if (count == 0)		return;	idx = controller->windows;	new_count = controller->windows + count;	new_window = kcalloc(new_count, sizeof(struct pci_window), GFP_KERNEL);	if (new_window == NULL)		BUG();	if (controller->window) {		memcpy(new_window, controller->window,		       sizeof(struct pci_window) * controller->windows);		kfree(controller->window);	}	/* Setup a pci_window for each device resource. */	for (i = 0; i <= PCI_ROM_RESOURCE; i++) {		if (pci_addrs[i] == -1)			continue;		new_window[idx].offset = dev->resource[i].start - pci_addrs[i];		new_window[idx].resource = dev->resource[i];		idx++;	}	controller->windows = new_count;	controller->window = new_window;}void sn_pci_unfixup_slot(struct pci_dev *dev){	struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;	sn_irq_unfixup(dev);	pci_dev_put(host_pci_dev);	pci_dev_put(dev);}/* * sn_pci_fixup_slot() - This routine sets up a slot's resources * consistent with the Linux PCI abstraction layer.  Resources acquired * from our PCI provider include PIO maps to BAR space and interrupt * objects. */void sn_pci_fixup_slot(struct pci_dev *dev){	unsigned int count = 0;	int idx;	int segment = pci_domain_nr(dev->bus);	int status = 0;	struct pcibus_bussoft *bs; 	struct pci_bus *host_pci_bus; 	struct pci_dev *host_pci_dev;	struct pcidev_info *pcidev_info;	int64_t pci_addrs[PCI_ROM_RESOURCE + 1]; 	struct sn_irq_info *sn_irq_info; 	unsigned long size; 	unsigned int bus_no, devfn;	pci_dev_get(dev); /* for the sysdata pointer */	pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);	if (pcidev_info <= 0)		BUG();		/* Cannot afford to run out of memory */	sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL);	if (sn_irq_info <= 0)		BUG();		/* Cannot afford to run out of memory */	memset(sn_irq_info, 0, sizeof(struct sn_irq_info));	/* Call to retrieve pci device information needed by kernel. */	status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 

⌨️ 快捷键说明

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