Exemplo n.º 1
0
//
//The following routine scans all devices on one system bus,and inserts them into
//system bus's device list.
//
static VOID PciScanDevices(__SYSTEM_BUS* lpSysBus)
{
	DWORD                           dwConfigReg   = 0x80000000;
	DWORD                           dwLoop        = 0;
	DWORD                           dwTmp         = 0;

	if(NULL == lpSysBus) //Parameter check.
		return;

	dwTmp =  lpSysBus->dwBusNum;
	dwTmp &= 0x000000FF;    //Only reserve the lowest 7 bits.
	dwConfigReg += (dwTmp << 16);  //Now,dwConfigReg value countains the bus number.

	//
	//The following code scans all devices and functions in one PCI bus,if there is
	//a device or function,it calles PciAddDevice routine to initialize it and add it
	//to system bus's device list.
	//
	for(dwLoop = 0;dwLoop < 0x100;dwLoop ++)  //For every devices and functions.
	{
		dwConfigReg &= 0xFFFF0000;
		dwConfigReg += (dwLoop << 8);  //Now,dwConfigReg countains the bus number,device number,
		                               //and function number.

		__outd(CONFIG_REGISTER,dwConfigReg);
		dwTmp = __ind(DATA_REGISTER);

		if(0xFFFFFFFF == dwTmp)        //The device or function does not exist.
			continue;
		/*
		//
		//Now,find one PCI device,first,we check if it is a multi-function device,
		//if so,enumerate all sub-functions of this physical device,and add them to
		//system bus,otherwise,add the current physical device to system bus,and
		//increment 7 to dwLoop to skip all functions bound to this physical device.
		//
		dwConfigReg += PCI_CONFIG_OFFSET_CACHELINESZ;
		__outd(CONFIG_REGISTER,dwConfigReg);
		dwTmp = __ind(DATA_REGISTER);        //Read one double word countaining the header
		                                     //type segment.
		dwConfigReg -= PCI_CONFIG_OFFSET_CACHELINESZ;
		if(dwTmp & 0x00800000)               //This is a multiple function device.
		{
			PciAddDevice(dwConfigReg,lpSysBus);
		}
		else                                 //This is a single function device.
		{
			PciAddDevice(dwConfigReg,lpSysBus);
			dwLoop += 7;                     //Skip all other functions of current device.
		}*/
		PciAddDevice(dwConfigReg,lpSysBus);  //Add to system device.
	}
	return;
}
Exemplo n.º 2
0
/*
 * Scans all devices on one system bus,and inserts them into
 * system bus's device list.
 */
static VOID PciScanDevices(__SYSTEM_BUS* lpSysBus)
{
	DWORD dwConfigReg = 0x80000000;
	DWORD dwLoop = 0, dwTmp = 0;

	if (NULL == lpSysBus)
	{
		return;
	}

	dwTmp =  lpSysBus->dwBusNum;
	dwTmp &= 0x000000FF;    //Only reserve the lowest 7 bits.
	dwConfigReg += (dwTmp << 16);  //Now,dwConfigReg value countains the bus number.

	/*
	 * The following code scans all devices and functions in one PCI bus,if there is
	 * a device or function,it calles PciAddDevice routine to initialize it and add it
	 * to system bus's device list.
	 */
	for(dwLoop = 0;dwLoop < 0x100;dwLoop ++)
	{
		dwConfigReg &= 0xFFFF0000;
		/* Now,dwConfigReg countains the bus number,device number, and function number. */
		dwConfigReg += (dwLoop << 8);

		__outd(CONFIG_REGISTER,dwConfigReg);
		dwTmp = __ind(DATA_REGISTER);

		/* The device or function does not exist. */
		if (0xFFFFFFFF == dwTmp)
		{
			continue;
		}
		/* Add the probed device into system. */
		PciAddDevice(dwConfigReg,lpSysBus);
	}
	return;
}