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

📄 pci_bus_cvlink.c

📁 linux-2.4.29操作系统的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
					GFP_KERNEL);		if (widget_sysdata <= 0)			BUG(); /* Cannot afford to run out of memory */		widget_sysdata->vhdl = pci_bus_to_vertex(pci_bus->number);		pci_bus->sysdata = (void *)widget_sysdata;	}	/* 	 * set the root start and end so that drivers calling check_region()	 * won't see a conflict	 */	ioport_resource.start  = 0xc000000000000000;	ioport_resource.end =    0xcfffffffffffffff;	/*	 * Set the root start and end for Mem Resource.	 */	iomem_resource.start = 0;	iomem_resource.end = 0xffffffffffffffff;	/*	 * Initialize the device vertex in the pci_dev struct.	 */	pci_for_each_dev(device_dev) {		unsigned int irq;		int idx;		u16 cmd;		vertex_hdl_t vhdl;		unsigned long size;		extern int bit_pos_to_irq(int);		/* Set the device vertex */		device_sysdata = kmalloc(sizeof(struct sn_device_sysdata),					GFP_KERNEL);		if (device_sysdata <= 0)			BUG(); /* Cannot afford to run out of memory */		device_sysdata->vhdl = devfn_to_vertex(device_dev->bus->number, device_dev->devfn);		device_sysdata->isa64 = 0;		device_dev->sysdata = (void *) device_sysdata;		set_sn_pci64(device_dev);		set_isPIC(device_sysdata);		pci_read_config_word(device_dev, PCI_COMMAND, &cmd);		/*		 * Set the resources address correctly.  The assumption here 		 * is that the addresses in the resource structure has been		 * read from the card and it was set in the card by our		 * Infrastructure ..		 */		vhdl = device_sysdata->vhdl;		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {			size = 0;			size = device_dev->resource[idx].end -				device_dev->resource[idx].start;			if (size) {				device_dev->resource[idx].start = (unsigned long)pciio_pio_addr(vhdl, 0, PCIIO_SPACE_WIN(idx), 0, size, 0, 0);				device_dev->resource[idx].start |= __IA64_UNCACHED_OFFSET;			}			else				continue;			device_dev->resource[idx].end = 				device_dev->resource[idx].start + size;			if (device_dev->resource[idx].flags & IORESOURCE_IO)				cmd |= PCI_COMMAND_IO;			if (device_dev->resource[idx].flags & IORESOURCE_MEM)				cmd |= PCI_COMMAND_MEMORY;		}#if 0	/*	 * Software WAR for a Software BUG.	 * This is only temporary.	 * See PV 872791	 */		/*		 * Now handle the ROM resource ..		 */		size = device_dev->resource[PCI_ROM_RESOURCE].end -			device_dev->resource[PCI_ROM_RESOURCE].start;		if (size) {			device_dev->resource[PCI_ROM_RESOURCE].start =			(unsigned long) pciio_pio_addr(vhdl, 0, PCIIO_SPACE_ROM, 0, 				size, 0, 0);			device_dev->resource[PCI_ROM_RESOURCE].start |= __IA64_UNCACHED_OFFSET;			device_dev->resource[PCI_ROM_RESOURCE].end =			device_dev->resource[PCI_ROM_RESOURCE].start + size;		}#endif		/*		 * Update the Command Word on the Card.		 */		cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */					   /* bit gets dropped .. no harm */		pci_write_config_word(device_dev, PCI_COMMAND, cmd);		pci_read_config_byte(device_dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines);		device_sysdata = (struct sn_device_sysdata *)device_dev->sysdata;		device_vertex = device_sysdata->vhdl; 		irqpdaindr->current = device_dev;		intr_handle = pciio_intr_alloc(device_vertex, NULL, lines, device_vertex);		irq = intr_handle->pi_irq;		irqpdaindr->device_dev[irq] = device_dev;		cpuid = intr_handle->pi_cpu;		pciio_intr_connect(intr_handle, (intr_func_t)0, (intr_arg_t)0);		device_dev->irq = irq;		register_pcibr_intr(irq, (pcibr_intr_t)intr_handle);		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {			int ibits = ((pcibr_intr_t)intr_handle)->bi_ibits;			int i;			size = device_dev->resource[idx].end -				device_dev->resource[idx].start;			if (size == 0) continue;			for (i=0; i<8; i++) {				if (ibits & (1 << i) ) {					sn_dma_flush_init(device_dev->resource[idx].start, 							device_dev->resource[idx].end,							idx,							i,							PCI_SLOT(device_dev->devfn));				}			}		}	}#ifdef ajmtestintr		{			int slot = PCI_SLOT(device_dev->devfn);			static int timer_set = 0;			pcibr_intr_t	pcibr_intr = (pcibr_intr_t)intr_handle;			pcibr_soft_t	pcibr_soft = pcibr_intr->bi_soft;			extern void intr_test_handle_intr(int, void*, struct pt_regs *);			if (!timer_set) {				intr_test_set_timer();				timer_set = 1;			}			intr_test_register_irq(irq, pcibr_soft, slot);			request_irq(irq, intr_test_handle_intr,0,NULL, NULL);		}#endif}/* * linux_bus_cvlink() Creates a link between the Linux PCI Bus number  *	to the actual hardware component that it represents: *	/dev/hw/linux/busnum/0 -> ../../../hw/module/001c01/slab/0/Ibrick/xtalk/15/pci * *	The bus vertex, when called to devfs_generate_path() returns: *		hw/module/001c01/slab/0/Ibrick/xtalk/15/pci *		hw/module/001c01/slab/1/Pbrick/xtalk/12/pci-x/0 *		hw/module/001c01/slab/1/Pbrick/xtalk/12/pci-x/1 */voidlinux_bus_cvlink(void){	char name[8];	int index;		for (index=0; index < MAX_PCI_XWIDGET; index++) {		if (!busnum_to_pcibr_vhdl[index])			continue;		sprintf(name, "%x", index);		(void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index], 				name);	}}/* * pci_bus_map_create() - Called by pci_bus_to_hcl_cvlink() to finish the job. * *	Linux PCI Bus numbers are assigned from lowest module_id numbers *	(rack/slot etc.) starting from HUB_WIDGET_ID_MAX down to  *	HUB_WIDGET_ID_MIN: *		widgetnum 15 gets lower Bus Number than widgetnum 14 etc. * *	Given 2 modules 001c01 and 001c02 we get the following mappings: *		001c01, widgetnum 15 = Bus number 0 *		001c01, widgetnum 14 = Bus number 1 *		001c02, widgetnum 15 = Bus number 3 *		001c02, widgetnum 14 = Bus number 4 *		etc. * * The rational for starting Bus Number 0 with Widget number 15 is because  * the system boot disks are always connected via Widget 15 Slot 0 of the  * I-brick.  Linux creates /dev/sd* devices(naming) strating from Bus Number 0  * Therefore, /dev/sda1 will be the first disk, on Widget 15 of the lowest  * module id(Master Cnode) of the system. *	 */static int pci_bus_map_create(vertex_hdl_t xtalk, int brick_type, char * io_moduleid){	vertex_hdl_t xwidget = NULL;	vertex_hdl_t pci_bus = NULL;	xwidgetnum_t widgetnum;	char pathname[128];	graph_error_t rv;	int bus;	int basebus_num;	extern void ioconfig_get_busnum(char *, int *);	int bus_number;	/*	 * PCIX devices	 * We number busses differently for PCI-X devices.	 * We start from Lowest Widget on up ..	 */        (void) ioconfig_get_busnum((char *)io_moduleid, &basebus_num);	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {		/* Do both buses */		for ( bus = 0; bus < 2; bus++ ) {			sprintf(pathname, "%d", widgetnum);			xwidget = NULL;						/*			 * Example - /hw/module/001c16/Pbrick/xtalk/8 is the xwidget			 *	     /hw/module/001c16/Pbrick/xtalk/8/pci-x/0 is the bus			 *	     /hw/module/001c16/Pbrick/xtalk/8/pci-x/0/1 is device			 */			rv = hwgraph_traverse(xtalk, pathname, &xwidget);			if ( (rv != GRAPH_SUCCESS) ) {				if (!xwidget) {					continue;				}			}				if ( bus == 0 )				sprintf(pathname, "%d/"EDGE_LBL_PCIX_0, widgetnum);			else				sprintf(pathname, "%d/"EDGE_LBL_PCIX_1, widgetnum);			pci_bus = NULL;			if (hwgraph_traverse(xtalk, pathname, &pci_bus) != GRAPH_SUCCESS)				if (!pci_bus) {					continue;				}				/*			 * Assign the correct bus number and also the nasid of this 			 * pci Xwidget.			 * 			 * Should not be any race here ...			 */			bus_number = basebus_num + bus + io_brick_map_widget(brick_type, widgetnum);#ifdef DEBUG			printk("bus_number %d basebus_num %d bus %d io %d pci_bus 0x%x brick_type %d \n", 				bus_number, basebus_num, bus, 				io_brick_map_widget(brick_type, widgetnum), pci_bus, brick_type);#endif			busnum_to_pcibr_vhdl[bus_number] = pci_bus;				/*			 * Pre assign DMA maps needed for 32 Bits Page Map DMA.			 */			busnum_to_atedmamaps[bus_number] = (void *) kmalloc(				sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS, GFP_KERNEL);			if (busnum_to_atedmamaps[bus_number] <= 0)				BUG(); /* Cannot afford to run out of memory. */				memset(busnum_to_atedmamaps[bus_number], 0x0, 				sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS);		}	}	/* AGP/CGbrick */	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {		/* Do both buses */		for ( bus = 0; bus < 2; bus++ ) {			sprintf(pathname, "%d", widgetnum);			xwidget = NULL;						/*			 * Example - /hw/module/001c16/slab/0/CGbrick/xtalk/15 is the xwidget			 *	     /hw/module/001c16/slab/0/CGbrick/xtalk/15/agp/0 is the bus			 *	     /hw/module/001c16/slab/0/CGbrick/xtalk/15/agp/0/1a is device			 */			rv = hwgraph_traverse(xtalk, pathname, &xwidget);			if ( (rv != GRAPH_SUCCESS) ) {				if (!xwidget) {					continue;				}			}				if ( bus == 0 )				sprintf(pathname, "%d/"EDGE_LBL_AGP_0, widgetnum);			else				sprintf(pathname, "%d/"EDGE_LBL_AGP_1, widgetnum);			pci_bus = NULL;			if (hwgraph_traverse(xtalk, pathname, &pci_bus) != GRAPH_SUCCESS)				if (!pci_bus) {					continue;				}				/*			 * Assign the correct bus number and also the nasid of this 			 * pci Xwidget.			 * 			 * Should not be any race here ...			 */			bus_number = basebus_num + bus + io_brick_map_widget(brick_type, widgetnum);#ifdef DEBUG			printk("bus_number %d basebus_num %d bus %d io %d pci_bus 0x%x\n", 				bus_number, basebus_num, bus, 				io_brick_map_widget(brick_type, widgetnum), pci_bus);#endif			busnum_to_pcibr_vhdl[bus_number] = pci_bus;			/*			 * Pre assign DMA maps needed for 32 Bits Page Map DMA.			 */			busnum_to_atedmamaps[bus_number] = (void *) kmalloc(				sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS, GFP_KERNEL);			if (busnum_to_atedmamaps[bus_number] <= 0)				BUG(); /* Cannot afford to run out of memory */				memset(busnum_to_atedmamaps[bus_number], 0x0, 				sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS);		}	}        return(0);}/* * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure    *      initialization has completed to set up the mappings between Xbridge *      and logical pci bus numbers.  We also set up the NASID for each of these *      xbridges. * *      Must be called before pci_init() is invoked. */intpci_bus_to_hcl_cvlink(void) {	vertex_hdl_t devfs_hdl = NULL;	vertex_hdl_t xtalk = NULL;	int rv = 0;	char *name;	char *tmp_name;	int i, ii, j;	char *brick_name;	extern void ioconfig_bus_new_entries(void);	extern int iobrick_type_get_nasid(nasid_t);	name = kmalloc(256, GFP_KERNEL);	if (!name)		BUG();	tmp_name = kmalloc(256, GFP_KERNEL);	if (!name)		 BUG();	/*	 * Figure out which IO Brick is connected to the Compute Bricks.	 */	for (i = 0; i < nummodules; i++) {		extern int iomoduleid_get(nasid_t);		moduleid_t iobrick_id;		nasid_t nasid = -1;		int n = 0;		for ( n = 0; n <= MAX_SLABS; n++ ) {			if (modules[i]->nodes[n] == -1)				continue; /* node is not alive in module */			nasid = cnodeid_to_nasid(modules[i]->nodes[n]);			iobrick_id = iomoduleid_get(nasid);			if ((int)iobrick_id > 0) { /* Valid module id */				char name[12];				memset(name, 0, 12);				format_module_id((char *)&(modules[i]->io[n].moduleid), iobrick_id, MODULE_FORMAT_BRIEF);				modules[i]->io[n].iobrick_type = (uint64_t)iobrick_type_get_nasid(nasid);			}		}	}					devfs_hdl = hwgraph_path_to_vertex("hw/module");	for (i = 0; i < nummodules ; i++) {	    for ( j = 0; j < 4; j++ ) {		if ( j == 0 )			brick_name = EDGE_LBL_IXBRICK;		else if ( j == 1 )			brick_name = EDGE_LBL_PXBRICK;		else if ( j == 2 )			brick_name = EDGE_LBL_OPUSBRICK;		else	/* 3 */			brick_name = EDGE_LBL_CGBRICK;		for ( ii = 0; ii <= MAX_SLABS ; ii++ ) {			if (modules[i]->nodes[ii] == -1)				continue; /* Missing slab */			memset(name, 0, 256);			memset(tmp_name, 0, 256);			format_module_id(name, modules[i]->id, MODULE_FORMAT_BRIEF);			sprintf(tmp_name, "/slab/%d/%s/xtalk", geo_slab(modules[i]->geoid[ii]), brick_name);			strcat(name, tmp_name);			xtalk = NULL;			rv = hwgraph_edge_get(devfs_hdl, name, &xtalk);			if ( rv == 0 ) 				pci_bus_map_create(xtalk, (int)modules[i]->io[ii].iobrick_type, (char *)&(modules[i]->io[ii].moduleid));		}	    }	}	kfree(name);	kfree(tmp_name);	/*	 * Create the Linux PCI bus number vertex link.	 */	(void)linux_bus_cvlink();	(void)ioconfig_bus_new_entries();	return(0);}

⌨️ 快捷键说明

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