📄 1394api.c
字号:
/*++
Copyright (c) 1998 Microsoft Corporation
Module Name:
1394api.c
Abstract
Author:
Peter Binder (pbinder) 5/07/98
Revision History:
Date Who What
-------- --------- ------------------------------------------------------------
5/07/98 pbinder birth
--*/
// todo:
// t1394Diag_Control
// t1394Diag_GetMaxSpeedBetweenDevices
// t1394Diag_GetConfigurationInformation
// t1394Diag_SendPhyConfigurationPacket
// t1394Diag_GetSpeedTopologyMaps
// t1394Diag_BusResetNotification
#include "pch.h"
NTSTATUS
t1394Diag_GetLocalHostInformation(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN ULONG nLevel,
IN OUT PULONG UserStatus,
IN OUT PVOID Information
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
PIRB pIrb;
GET_LOCAL_HOST_INFO6 LocalHostInfo6;
ENTER("t1394Diag_GetLocalHostInformation");
TRACE(TL_TRACE, ("nLevel = 0x%x\n", nLevel));
TRACE(TL_TRACE, ("Information = 0x%x\n", Information));
pIrb = ExAllocatePool(NonPagedPool, sizeof(IRB));
if (!pIrb) {
TRACE(TL_ERROR, ("Failed to allocate pIrb!\n"));
TRAP;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto Exit_GetLocalHostInformation;
} // if
pIrb->FunctionNumber = REQUEST_GET_LOCAL_HOST_INFO;
pIrb->Flags = 0;
pIrb->u.GetLocalHostInformation.nLevel = nLevel;
// in the case of nLevel = 5 or 6, we need to reset Information,
// because we have a variable sized data buffer being passed in
// from user mode.
if (nLevel == 6) {
LocalHostInfo6 = *(PGET_LOCAL_HOST_INFO6)Information;
LocalHostInfo6.CsrDataBuffer = &((PGET_LOCAL_HOST_INFO6)Information)->CsrDataBuffer;
pIrb->u.GetLocalHostInformation.Information = &LocalHostInfo6;
TRACE(TL_TRACE, ("CsrBaseAddress.Off_High = 0x%x\n", LocalHostInfo6.CsrBaseAddress.Off_High));
TRACE(TL_TRACE, ("CsrBaseAddress.Off_Low = 0x%x\n", LocalHostInfo6.CsrBaseAddress.Off_Low));
TRACE(TL_TRACE, ("CsrDataLength = 0x%x\n", LocalHostInfo6.CsrDataLength));
TRACE(TL_TRACE, ("CsrDataBuffer = 0x%x\n", LocalHostInfo6.CsrDataBuffer));
}
else {
pIrb->u.GetLocalHostInformation.Information = Information;
}
ntStatus = t1394Diag_SubmitIrpSynch(deviceExtension->StackDeviceObject, Irp, pIrb);
if (!NT_SUCCESS(ntStatus)) {
if (ntStatus == STATUS_INVALID_BUFFER_SIZE) {
// we have to set status=success, otherwise, we don't get
// the size value passed up to ring 3.
ntStatus = STATUS_SUCCESS;
*UserStatus = 122;
TRACE(TL_WARNING, ("Invalid Buffer Size. nLevel = 0x%x\n", nLevel));
// see if it's a config rom request or a csr request
if (nLevel == 5) {
PGET_LOCAL_HOST_INFO5 LocalHostInfo5;
// it is, lets print out the size
LocalHostInfo5 = (PGET_LOCAL_HOST_INFO5)Information;
TRACE(TL_TRACE, ("ConfigRomLength = 0x%x\n", LocalHostInfo5->ConfigRomLength));
}
else if (nLevel == 6) {
// csr, print out size
TRACE(TL_TRACE, ("CsrDataLength needed = 0x%x\n", LocalHostInfo6.CsrDataLength));
// need to set this in the information struct we were passed down
*(PGET_LOCAL_HOST_INFO6)Information = LocalHostInfo6;
}
}
else {
TRACE(TL_ERROR, ("SubmitIrpSync failed = 0x%x\n", ntStatus));
TRAP;
}
}
else {
*UserStatus = 0;
if (nLevel == 1) {
PGET_LOCAL_HOST_INFO1 LocalHostInfo1;
LocalHostInfo1 = (PGET_LOCAL_HOST_INFO1)Information;
TRACE(TL_TRACE, ("UniqueId.LowPart = 0x%x\n", LocalHostInfo1->UniqueId.LowPart));
TRACE(TL_TRACE, ("UniqueId.HighPart = 0x%x\n", LocalHostInfo1->UniqueId.HighPart));
}
else if (nLevel == 2) {
PGET_LOCAL_HOST_INFO2 LocalHostInfo2;
LocalHostInfo2 = (PGET_LOCAL_HOST_INFO2)Information;
TRACE(TL_TRACE, ("HostCapabilities = 0x%x\n", LocalHostInfo2->HostCapabilities));
TRACE(TL_TRACE, ("MaxAsyncReadRequest = 0x%x\n", LocalHostInfo2->MaxAsyncReadRequest));
TRACE(TL_TRACE, ("MaxAsyncWriteRequest = 0x%x\n", LocalHostInfo2->MaxAsyncWriteRequest));
}
else if (nLevel == 3) {
PGET_LOCAL_HOST_INFO3 LocalHostInfo3;
LocalHostInfo3 = (PGET_LOCAL_HOST_INFO3)Information;
TRACE(TL_TRACE, ("deciWattsSupplied = 0x%x\n", LocalHostInfo3->deciWattsSupplied));
TRACE(TL_TRACE, ("Voltage = 0x%x\n", LocalHostInfo3->Voltage));
}
else if (nLevel == 4) {
PGET_LOCAL_HOST_INFO4 LocalHostInfo4;
LocalHostInfo4 = (PGET_LOCAL_HOST_INFO4)Information;
TRACE(TL_TRACE, ("Context = 0x%x\n", LocalHostInfo4->Context));
}
else if (nLevel == 5) {
PGET_LOCAL_HOST_INFO5 LocalHostInfo5;
LocalHostInfo5 = (PGET_LOCAL_HOST_INFO5)Information;
TRACE(TL_TRACE, ("ConfigRomLength = 0x%x\n", LocalHostInfo5->ConfigRomLength));
// IDEAIDEA: add some debug spew for whatever we are getting...
}
else if (nLevel == 6) {
// IDEAIDEA: add some debug spew for whatever we are getting...
}
else {
TRACE(TL_WARNING, ("Returned success on invalid nLevel = 0x%x\n", nLevel));
}
}
if (pIrb)
ExFreePool(pIrb);
Exit_GetLocalHostInformation:
EXIT("t1394Diag_GetLocalHostInformation", ntStatus);
return(ntStatus);
} // t1394Diag_GetLocalHostInformation
NTSTATUS
t1394Diag_Get1394AddressFromDeviceObject(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN ULONG fulFlags,
OUT PNODE_ADDRESS pNodeAddress
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
PIRB pIrb;
ENTER("t1394Diag_Get1394AddressFromDeviceObject");
TRACE(TL_TRACE, ("fulFlags = 0x%x\n", fulFlags));
pIrb = ExAllocatePool(NonPagedPool, sizeof(IRB));
if (!pIrb) {
TRACE(TL_ERROR, ("Failed to allocate pIrb!\n"));
TRAP;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto Exit_Get1394AddressFromDeviceObject;
} // if
pIrb->FunctionNumber = REQUEST_GET_ADDR_FROM_DEVICE_OBJECT;
pIrb->Flags = 0;
pIrb->u.Get1394AddressFromDeviceObject.fulFlags = fulFlags;
ntStatus = t1394Diag_SubmitIrpSynch(deviceExtension->StackDeviceObject, Irp, pIrb);
if (NT_SUCCESS(ntStatus)) {
*pNodeAddress = pIrb->u.Get1394AddressFromDeviceObject.NodeAddress;
TRACE(TL_TRACE, ("NodeAddres.NA_Node_Number = 0x%x\n", pNodeAddress->NA_Node_Number));
TRACE(TL_TRACE, ("NodeAddres.NA_Bus_Number = 0x%x\n", pNodeAddress->NA_Bus_Number));
}
else {
TRACE(TL_ERROR, ("SubmitIrpSync failed = 0x%x\n", ntStatus));
TRAP;
}
ExFreePool(pIrb);
Exit_Get1394AddressFromDeviceObject:
EXIT("t1394Diag_Get1394AddressFromDeviceObject", ntStatus);
return(ntStatus);
} // t1394Diag_Get1394AddressFromDeviceObject
NTSTATUS
t1394Diag_Control(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
ENTER("t1394Diag_Control");
ntStatus = STATUS_NOT_IMPLEMENTED;
EXIT("t1394Diag_Control", ntStatus);
return(ntStatus);
} // t1394Diag_Control
NTSTATUS
t1394Diag_GetMaxSpeedBetweenDevices(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN ULONG fulFlags,
IN ULONG ulNumberOfDestinations,
IN PDEVICE_OBJECT hDestinationDeviceObjects[64],
OUT PULONG fulSpeed
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
PIRB pIrb;
ULONG i;
ENTER("t1394Diag_GetMaxSpeedBetweenDevices");
TRACE(TL_TRACE, ("DeviceObject = 0x%x\n", DeviceObject));
TRACE(TL_TRACE, ("Irp = 0x%x\n", Irp));
TRACE(TL_TRACE, ("fulFlags = 0x%x\n", fulFlags));
TRACE(TL_TRACE, ("ulNumberOfDestinations = 0x%x\n", ulNumberOfDestinations));
for (i=0; i<ulNumberOfDestinations; i++) {
TRACE(TL_TRACE, ("hDestinationDeviceObjects[%d] = 0x%x\n", i, hDestinationDeviceObjects[i]));
}
pIrb = ExAllocatePool(NonPagedPool, sizeof(IRB));
if (!pIrb) {
TRACE(TL_ERROR, ("Failed to allocate pIrb!\n"));
TRAP;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto Exit_GetMaxSpeedBetweenDevices;
} // if
pIrb->FunctionNumber = REQUEST_GET_SPEED_BETWEEN_DEVICES;
pIrb->Flags = 0;
pIrb->u.GetMaxSpeedBetweenDevices.fulFlags = fulFlags;
pIrb->u.GetMaxSpeedBetweenDevices.ulNumberOfDestinations = ulNumberOfDestinations;
for (i=0; i<ulNumberOfDestinations; i++) {
pIrb->u.GetMaxSpeedBetweenDevices.hDestinationDeviceObjects[i] = hDestinationDeviceObjects[i];
}
ntStatus = t1394Diag_SubmitIrpSynch(deviceExtension->StackDeviceObject, Irp, pIrb);
if (NT_SUCCESS(ntStatus)) {
*fulSpeed = pIrb->u.GetMaxSpeedBetweenDevices.fulSpeed;
TRACE(TL_TRACE, ("fulSpeed = 0x%x\n", *fulSpeed));
}
else {
TRACE(TL_ERROR, ("SubmitIrpSync failed = 0x%x\n", ntStatus));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -