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

📄 tmpnp.c

📁 PNX系列设备驱动 PNX系列设备驱动
💻 C
字号:
/*---------------------------------------------------------------------------- 
COPYRIGHT (c) 1995 by Philips Semiconductors

THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED AND COPIED IN 
ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH A LICENSE AND WITH THE 
INCLUSION OF THE THIS COPY RIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES 
OF THIS SOFTWARE MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
PERSON. THE OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED. 

THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT ANY PRIOR NOTICE
AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY Philips Semiconductor. 

PHILIPS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE
ON PLATFORMS OTHER THAN THE ONE ON WHICH THIS SOFTWARE IS FURNISHED.
----------------------------------------------------------------------------*/
/*
	HISTORY
	#define	TR	Tilakraj Roy
	960325	Tilakraj Roy 	Created
	960325	Tilakraj Roy 	Due to the PnP bug in TM-CTC we use the PCI Bios
							rather than	Win95 for retrieving PnP Settings.
	960326	Tilakraj Roy	Added conditional code for USE_CM
	960404	Tilakraj Roy	Added code for handling configuration
	960620	Tilakraj Roy	Added comments and remomed TMPNP_OBJECT 
							dependency on TM_CONFIG
	980520	Volker Schildwach	Ported to WinCE User Mode DLL
	981021	Tilakraj Roy	Changes for integrating into common source base

*/

/*----------------------------------------------------------------------------
          SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
#include <windows.h>
#include "ceddk.h"

/*----------------------------------------------------------------------------
          DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "tmmanapi.h"
#include "tmmanlib.h"
#include "platform.h"

#define SDRAM_LENGTH	(8 * 1024 * 1024)
#define MMIO_LENGTH		(2 * 1024 * 1024)

/*----------------------------------------------------------------------------
          GENERIC PNP FUNCTIONS
----------------------------------------------------------------------------*/

BOOLEAN	pnpOnConfigStart ( 	
	IN ULONG BusNumber, 
	IN PCI_SLOT_NUMBER SlotNumber,
    PCI_COMMON_CONFIG	PciData );

BOOLEAN	pnpFindPCIDevices ( 
	IN USHORT wVendor, 
	IN USHORT wDevice )
{
    ULONG				n;
    BOOLEAN				fNotDone;
    PCI_COMMON_CONFIG	PciData;
    NTSTATUS			Status = STATUS_UNSUCCESSFUL;
    ULONG				i = 0, j = 0, Idx;
    ULONG				ulTmp;
	ULONG				BusNumber = 0;
	PCI_SLOT_NUMBER		SlotNumber;

	BusNumber = 0;
	SlotNumber.u.bits.DeviceNumber = 0;
	SlotNumber.u.bits.FunctionNumber = 0;
	SlotNumber.u.bits.Reserved = 0;

    for (BusNumber = 0, fNotDone = TRUE; fNotDone ; BusNumber++) 
	{

        for ( i = 0 ; i < PCI_MAX_DEVICES  &&  fNotDone ; i++ ) 
		{
            for ( j = 0 ; j < PCI_MAX_FUNCTION ; j++) 
			{
				SlotNumber.u.bits.DeviceNumber = i;
				SlotNumber.u.bits.FunctionNumber = j;

                n = HalGetBusData (
                    PCIConfiguration,
                    BusNumber,
                    SlotNumber.u.AsULONG,
                    &PciData,
                    PCI_COMMON_HDR_LENGTH
                    );

				/*
				DPF (1, 
					("pnpFindPCIDevices:[Bus:%x][Dev:%x][Func:%x][Vendor:%x][Device:%x]\n",
					BusNumber, i, j, PciData.VendorID, PciData.DeviceID ));
				*/


                if (n == 0) 
				{
					OutputDebugString( TEXT("tmman:pnpFindPCIDevices:Out of Busses\n") );    
                    // out of buses
                    fNotDone = FALSE;
                    break;
                }

                if (PciData.VendorID == PCI_INVALID_VENDORID) 
				{
                    // Nothing in this slot, skip to next slot
                    break;
                }

				DPF ( 1, ("[Bus:%x][Dev:%x][Func:%x][Vendor:%x][Device:%x][IntrPin:%x][IntrLine:%x]\n",
					BusNumber, i, j, PciData.VendorID, PciData.DeviceID,
					PciData.u.type0.InterruptPin,
					PciData.u.type0.InterruptLine ));


                if ( ( PciData.VendorID == wVendor ) &&  ( PciData.DeviceID == wDevice ) ) 
				{
					DPF (1,("[pnpFindPCIDevices:PCI CONFIG SPACE DUMP]\n" ));
					
					DPF (1,("[Bus:%x][Dev:%x][Func:%x][Vendor:%x][Device:%x]\n",
						BusNumber, i, j, PciData.VendorID, PciData.DeviceID ));

					DPF (1,("[Cmd:%x][Sts:%x][BaseCls:%x][SubCls:%x][ProgIf:%x][RevID:%x]\n",
						PciData.Command,                    // Device control
						PciData.Status,
						PciData.BaseClass,                 // (ro)
						PciData.SubClass,                     // (ro)
						PciData.ProgIf,                   // (ro)
						PciData.RevisionID ));

					DPF (1,("[BIST:%x][HeaderType:%x][LatencyTimer:%x][CacheLineSize:%x]\n",
						PciData.BIST,                    // Device control
						PciData.HeaderType,
						PciData.LatencyTimer,                 // (ro)
						PciData.CacheLineSize ));                     // (ro)

					for ( Idx = 0 ; Idx < PCI_TYPE0_ADDRESSES ; Idx++ )
					{
						DPF (1,("[BaseAddresses:%x]\n",
							PciData.u.type0.BaseAddresses[Idx] ));
					}

					DPF (1,("[MaximumLatency:%x][MinimumGrant:%x][InterruptPin:%x][InterruptLine:%x]\n",
						PciData.u.type0.MaximumLatency,
						PciData.u.type0.MinimumGrant,
						PciData.u.type0.InterruptPin,
						PciData.u.type0.InterruptLine ));

					// found device node
                    pnpOnConfigStart ( BusNumber, SlotNumber, PciData );
				}
			}
		}
	}
 	return FALSE;
}



/*
	pnpOnConfigStart

	This function retrieves the allocated logical configuration for 
	the enumerated PCI device. It populates the config structure.
	It can either retrieve the configuration from the BIOS or from the
	Config Manager.

*/

BOOLEAN	pnpOnConfigStart ( 	
	IN ULONG BusNumber, 
	IN PCI_SLOT_NUMBER SlotNumber,
    PCI_COMMON_CONFIG	PciData )
{
	NTSTATUS Status;

	halParameters	Config;
	PCI_COMMON_CONFIG PCIConfig;
	PVOID				AllocatedDevice;

	//ULONG SlotInfo = (ULONG)SlotNumber;

	Config.BusNumber			    = BusNumber;
    Config.SlotNumber               = SlotNumber;
	Config.InterruptLevel		    = PciData.u.type0.InterruptLine;
	Config.InterruptVector		    = 0;
	Config.InterruptAffinity	    = 0;
	Config.SDRAMAddrPhysical.LowPart= PciData.u.type0.BaseAddresses[0]; 	
    Config.SDRAMLength			    = SDRAM_LENGTH;
	Config.MMIOAddrPhysical.LowPart = PciData.u.type0.BaseAddresses[1]; 
    Config.MMIOLength               = MMIO_LENGTH;

	// read the hardware revision ID
	HalGetBusData(
		PCIConfiguration,
		BusNumber,
		SlotNumber.u.AsULONG,
		&PCIConfig,
		sizeof ( PCI_COMMON_CONFIG ) );

    ((PUSHORT)&Config.TMDeviceVendorID)[0] =  PCIConfig.VendorID;
	((PUSHORT)&Config.TMDeviceVendorID)[1] =  PCIConfig.VendorID;

    ((PULONG)&Config.TMClassRevisionID)[0] =  PCIConfig.RevisionID;
	((PULONG)&Config.TMClassRevisionID)[1] =  PCIConfig.ProgIf;
    ((PULONG)&Config.TMClassRevisionID)[2] =  PCIConfig.SubClass;
	((PULONG)&Config.TMClassRevisionID)[3] =  PCIConfig.BaseClass;

    ((PUSHORT)&Config.TMSubsystemID)[0] =  PCIConfig.u.type0.SubVendorID;
	((PUSHORT)&Config.TMSubsystemID)[1] =  PCIConfig.u.type0.SubSystemID;

	// we haven't GOne MAD yet.
    Config.BridgeDeviceVendorID = 0;
	Config.BridgeSubsystemID = 0;
	Config.BridgeClassRevisionID = 0;
	
	HalGetBusData (
		PCIConfiguration,
		BusNumber,
		SlotNumber.u.AsULONG,
		Config.PCIRegisters,
		sizeof ( ULONG ) * constTMMANPCIRegisters );

    if ( ( AllocatedDevice = tmmanInit ( 
		TMManGlobal->DeviceCount , &Config ) ) == NULL )
	{
		return FALSE;
	}
	// insert the device we have just created into the global device list for this driver
	TMManGlobal->DeviceList[TMManGlobal->DeviceCount] = AllocatedDevice;
	TMManGlobal->DeviceCount++;

	return TRUE;
}	

⌨️ 快捷键说明

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