????? ?????? ??? ??????? ??????? ?????? ???? PCI

?????? ????????? ?????? ?????????
???? ???????: 253232 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

??????

???? ??? ??????? ??? ???? ?????? ??? ??????? ???? ??????? (??? BusNumber DeviceNumber ???? ????) ?? ?????? ???????? ????? (PCI) ?? ?????? ????? ??? ?? ?????? ????? ?????? ????? ????? ??? ????? ?? ??????? ?????? ???????.

??????? ????

??? Windows NT 4.0 ????? ??????? ?????? ??? ??? ????????? ?? ???? ??? ?????? ??????? HalGetBusData ? APIs HalGetBusDataByOffset. ?? Windows 2000 ?????? ?? ????? ????? Windows ? ??? ?????? ????? ??????? ?????? ????? ????? ?????? ?????? ??? ????? ?? ?????? HAL. ????? APIs Hal ???????? ?????? ????????? ??? ????? ?????? ???? ????? ?? Windows 2000 ?????? ??????? Windows ??????.

?? Windows 2000 ?????? ?? ????? ????? Windows ? ?? ????? ?????? ????? ????????? ?? ???? ????? ?? ???????. ???? ?????? ??????? ??????? ?? ????? ??????? ???????? (PnP) ?? ??? IRP_MN_START_DEVICE ????? ??. ???? ???? ?????? ????? well-written ?? ?? ????? ?? ?? ??? ????????? ???? ????. ??? ??? ???? ????? ?????? ??????? ??? ?????????, ????? ????? ????????? ???????? ??????? ????? ?????? ??? ???????. ??? ?? ???? ?????? ??????? ??? ?? ???? ?????? ????? ?????? ???? ????? ?????? ?????? ?????? ??????? (PDO) ?? ?????? ?????? ??? PnP.

???? ????? ????????? ???????? ?????? ????? ?????? ??? ??????? ???????:
NTSTATUS
ReadWriteConfigSpace(
    IN PDEVICE_OBJECT DeviceObject,
    IN ULONG	      ReadOrWrite, // 0 for read 1 for write
    IN PVOID	      Buffer,
    IN ULONG	      Offset,
    IN ULONG	      Length
    )
{
    KEVENT event;
    NTSTATUS status;
    PIRP irp;
    IO_STATUS_BLOCK ioStatusBlock;
    PIO_STACK_LOCATION irpStack;
    PDEVICE_OBJECT targetObject;

    PAGED_CODE();

    KeInitializeEvent( &event, NotificationEvent, FALSE );

    targetObject = IoGetAttachedDeviceReference( DeviceObject );

    irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
                                        targetObject,
                                        NULL,
                                        0,
                                        NULL,
                                        &event,
                                        &ioStatusBlock );

    if (irp == NULL) {
        status = STATUS_INSUFFICIENT_RESOURCES;
        goto End;
    }

    irpStack = IoGetNextIrpStackLocation( irp );

    if (ReadOrWrite == 0) {
        irpStack->MinorFunction = IRP_MN_READ_CONFIG;
    }else {
        irpStack->MinorFunction = IRP_MN_WRITE_CONFIG;
    }

    irpStack->Parameters.ReadWriteConfig.WhichSpace = PCI_WHICHSPACE_CONFIG;
    irpStack->Parameters.ReadWriteConfig.Buffer = Buffer;
    irpStack->Parameters.ReadWriteConfig.Offset = Offset;
    irpStack->Parameters.ReadWriteConfig.Length = Length;

    // 
    // Initialize the status to error in case the bus driver does not 
    // set it correctly.
    // 

    irp->IoStatus.Status = STATUS_NOT_SUPPORTED ;

    status = IoCallDriver( targetObject, irp );

    if (status == STATUS_PENDING) {

        KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
        status = ioStatusBlock.Status;
    }

End:
    // 
    // Done with reference
    // 
    ObDereferenceObject( targetObject );

    return status;

}
				
??? ????? ??? ????? PnP I/O ??? ??? (??????) ?? PASSIVE_LEVEL ? ?? ????? ??????? ???? ????? ?????? ??? ??????? ??????? ?? DISPATCH_LEVEL.

????? ????? ??????? ??????? ?????? ??? ????? ????? ?? DISPATCH_LEVEL:
  1. ????? IRP_MN_QUERY_INTERFACE ?? PASSIVE_LEVEL ?????? ??? ???? ????? ??????? ???????? (BUS_INTERFACE_STANDARD) ?? ?????? ????? ???? PCI. ??? ????? ?? ????? ???? ??? ???? ??? ????? (????? ?? DevcieExtension) ".
  2. ??????? SetBusData ? GetBusData ?????? ??? ????? ????? ?? DISPATCH_LEVEL.
  3. ?????? ????? ???? PCI ???? ??? ???? ??????? ??? ?? ???? ?????? ??? ??? ?? dereference ??????? ??? ??? ??????.
  4. ?????? ?????? ??????? ?????? ??? BUS_INTERFACE_STANDARD ?? PASSIVE_LEVEL:
    NTSTATUS
    GetPCIBusInterfaceStandard(
        IN  PDEVICE_OBJECT DeviceObject,
        OUT PBUS_INTERFACE_STANDARD	BusInterfaceStandard
        )
    /*++
    
    Routine Description:
    
        This routine gets the bus interface standard information from the PDO.
    
    Arguments:
    
        DeviceObject - Device object to query for this information.
    
        BusInterface - Supplies a pointer to the retrieved information.
    
    Return Value:
    
        NT status.
    
    --*/ 
    {
        KEVENT event;
        NTSTATUS status;
        PIRP irp;
        IO_STATUS_BLOCK ioStatusBlock;
        PIO_STACK_LOCATION irpStack;
        PDEVICE_OBJECT targetObject;
    
        Bus_KdPrint(("GetPciBusInterfaceStandard entered.\n"));
    
        KeInitializeEvent( &event, NotificationEvent, FALSE );
    
        targetObject = IoGetAttachedDeviceReference( DeviceObject );
    
        irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
                                            targetObject,
                                            NULL,
                                            0,
                                            NULL,
                                            &event,
                                            &ioStatusBlock );
    
        if (irp == NULL) {
            status = STATUS_INSUFFICIENT_RESOURCES;
            goto End;
        }
    
        irpStack = IoGetNextIrpStackLocation( irp );
        irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
        irpStack->Parameters.QueryInterface.InterfaceType = 
                            (LPGUID) &GUID_BUS_INTERFACE_STANDARD ;
        irpStack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
        irpStack->Parameters.QueryInterface.Version = 1;
        irpStack->Parameters.QueryInterface.Interface = (PINTERFACE)
    BusInterfaceStandard;
        irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
    
        // 
        // Initialize the status to error in case the bus driver does not 
        // set it correctly.
        // 
    
        irp->IoStatus.Status = STATUS_NOT_SUPPORTED ;
    
        status = IoCallDriver( targetObject, irp );
    
        if (status == STATUS_PENDING) {
    
            KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
            status = ioStatusBlock.Status;
        }
    
    End:
        // 
        // Done with reference
        // 
        ObDereferenceObject( targetObject );
    
        return status;
    
    }
    					
????? ???????? ???????? ??????? ??? ????? ??????? ?????? ???????? ??????? ????? ?????? ??? ???????? ??????.
    bytes = busInterfaceStandard.GetBusData(<BR/>
                    busInterfaceStandard.Context,
                    PCI_WHICHSPACE_CONFIG,
                    Buffer
                    Offset,
                    Length);
				
??? ?? ??? ?? ???? ??????? ??????? ????????? ???????? ??????? ??? dereference ??????? ?? ????????? ???????? ???????. ?? ??????? ?? ??????? ????? ??? dereference ???????.
    (busInterfaceStandard.InterfaceDereference)(
                (PVOID)busInterfaceStandard.Context);
				
??????? ?????? IoGetDeviceProperty ??? PDO ?????? ????? ?????? ??? ????? ?????? ? ???? ??????? ??? ???:
    ULONG   propertyAddress, length;
    USHORT  FunctionNumber; DeviceNumber;
    
    // 
    // Get the BusNumber. Please read the warning to follow.
    // 

    IoGetDeviceProperty(PhysicalDeviceObject,
                        DevicePropertyBusNumber,
                        sizeof(ULONG),
                        (PVOID)&BusNumber,
                        &length);

    // 
    // Get the DevicePropertyAddress
    // 
    IoGetDeviceProperty(PhysicalDeviceObject,
                     DevicePropertyAddress,
                     sizeof(ULONG),
                     (PVOID)&propertyAddress,
                     &length);
    // 
    // For PCI, the DevicePropertyAddress has device number 
    // in the high word and the function number in the low word. 
    // 
    FunctionNumber = (USHORT)((propertyAddress) & 0x0000FFFF);
    DeviceNumber = (USHORT)(((propertyAddress) >> 16) & 0x0000FFFF);

				
????? ???? PCI ??? ?? ???? ??????? ?????? ?? ?? ????. ????? ?? ??? ???? ????? ??? ??? ?????? ?? ??????? ??? ????????? ?????? ??? ????? PCI ?????? ??. ?? ???? ??? ??? ??? ??????.

???????

???? ???????: 253232 - ????? ??? ??????: 04/?????/1426 - ??????: 2.1
????? ???
  • Microsoft Win32 Device Driver Kit ?? Windows 2000
  • Microsoft Windows XP Driver Development Kit
  • Microsoft Windows Server 2003 Driver Development Kit (DDK)
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Professional
  • Microsoft Windows Server 2003 Service Pack 1
????? ??????: 
kbmt kbhowto kbwdm KB253232 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????253232

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com