📄 ioctl.c
字号:
ntStatus = t1394_IsochAllocateBandwidth( DeviceObject,
Irp,
IsochAllocateBandwidth->nMaxBytesPerFrameRequested,
IsochAllocateBandwidth->fulSpeed,
&IsochAllocateBandwidth->hBandwidth,
&IsochAllocateBandwidth->BytesPerFrameAvailable,
&IsochAllocateBandwidth->SpeedSelected
);
if (NT_SUCCESS(ntStatus))
Irp->IoStatus.Information = outputBufferLength;
}
}
break; // IOCTL_ISOCH_ALLOCATE_BANDWIDTH
case IOCTL_ISOCH_ALLOCATE_CHANNEL:
{
PISOCH_ALLOCATE_CHANNEL IsochAllocateChannel;
TRACE(TL_TRACE, ("IOCTL_ISOCH_ALLOCATE_CHANNEL\n"));
if ((inputBufferLength < sizeof(ISOCH_ALLOCATE_CHANNEL)) ||
(outputBufferLength < sizeof(ISOCH_ALLOCATE_CHANNEL))) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
IsochAllocateChannel = (PISOCH_ALLOCATE_CHANNEL)ioBuffer;
ntStatus = t1394_IsochAllocateChannel( DeviceObject,
Irp,
IsochAllocateChannel->nRequestedChannel,
&IsochAllocateChannel->Channel,
&IsochAllocateChannel->ChannelsAvailable
);
if (NT_SUCCESS(ntStatus))
Irp->IoStatus.Information = outputBufferLength;
}
}
break; // IOCTL_ISOCH_ALLOCATE_CHANNEL
case IOCTL_ISOCH_ALLOCATE_RESOURCES:
{
PISOCH_ALLOCATE_RESOURCES IsochAllocateResources;
TRACE(TL_TRACE, ("IOCTL_ISOCH_ALLOCATE_RESOURCES\n"));
if ((inputBufferLength < sizeof(ISOCH_ALLOCATE_RESOURCES)) ||
(outputBufferLength < sizeof(ISOCH_ALLOCATE_RESOURCES))) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
IsochAllocateResources = (PISOCH_ALLOCATE_RESOURCES)ioBuffer;
ntStatus = t1394_IsochAllocateResources( DeviceObject,
Irp,
IsochAllocateResources->fulSpeed,
IsochAllocateResources->fulFlags,
IsochAllocateResources->nChannel,
IsochAllocateResources->nMaxBytesPerFrame,
IsochAllocateResources->nNumberOfBuffers,
IsochAllocateResources->nMaxBufferSize,
IsochAllocateResources->nQuadletsToStrip,
&IsochAllocateResources->hResource
);
if (NT_SUCCESS(ntStatus))
Irp->IoStatus.Information = outputBufferLength;
}
}
break; // IOCTL_ISOCH_ALLOCATE_RESOURCES
case IOCTL_ISOCH_ATTACH_BUFFERS:
{
PISOCH_ATTACH_BUFFERS IsochAttachBuffers = NULL;
PRING3_ISOCH_DESCRIPTOR pTempR3Desc = NULL;
ULONG ulBuffSize = 0;
ULONG i = 0;
TRACE(TL_TRACE, ("IOCTL_ISOCH_ATTACH_BUFFERS\n"));
if (inputBufferLength < (sizeof(ISOCH_ATTACH_BUFFERS))) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
// verify the passed in buffer is large enough to hold each r3 descriptor
// plus the data portion
IsochAttachBuffers = (PISOCH_ATTACH_BUFFERS)ioBuffer;
pTempR3Desc = &(IsochAttachBuffers->R3_IsochDescriptor[0]);
ulBuffSize = sizeof (ISOCH_ATTACH_BUFFERS) - sizeof (RING3_ISOCH_DESCRIPTOR);
for (i = 0; i < IsochAttachBuffers->nNumberOfDescriptors; i++)
{
// check the alignment on the pTempR3Desc
if ((ULONG_PTR)pTempR3Desc & 0x3)
{
// this is a situation of a descriptor not on a 4 byte alignment, just break
TRACE(TL_WARNING, ("Incorrect alignment detected, pTempR3Desc = 0x%p\n", pTempR3Desc));
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
// verify the buffer is large enough to hold this R3 Isoch Descriptor
// but first make sure we won't overflow
if ((ulBuffSize + sizeof (RING3_ISOCH_DESCRIPTOR)) < ulBuffSize)
{
// this is an overflow situation, just set an error code and break
TRACE(TL_WARNING, ("Overflow of ulBuffSize, sizeof (RING3_ISOCH_DESCRIPTOR) too large\n"));
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ulBuffSize += sizeof (RING3_ISOCH_DESCRIPTOR);
if (inputBufferLength < ulBuffSize)
{
TRACE(TL_WARNING, ("Isoch Attach buffer request too small\n"));
ntStatus = STATUS_BUFFER_TOO_SMALL;
break;
}
// now verify the buffer is large enough to hold the data indicated
// by the last R3 Isoch Descriptor, but first make sure we won't overflow
if ((ulBuffSize + pTempR3Desc->ulLength) < ulBuffSize)
{
// this is an overflow situation, just set an error code and break
TRACE(TL_WARNING, ("Overflow of ulBuffSize, R3->length too large = 0x%x\n", pTempR3Desc->ulLength));
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ulBuffSize += pTempR3Desc->ulLength;
if (inputBufferLength < ulBuffSize)
{
TRACE(TL_WARNING, ("Isoch Attach buffer request too small\n"));
ntStatus = STATUS_BUFFER_TOO_SMALL;
break;
}
// now increment our temp R3 descriptor so the next time through this for loop
// we are pointing at the correct data
pTempR3Desc = (PRING3_ISOCH_DESCRIPTOR)((ULONG_PTR)pTempR3Desc +
pTempR3Desc->ulLength +
sizeof(RING3_ISOCH_DESCRIPTOR));
}
// make sure we didn't fail up above
if (NT_SUCCESS(ntStatus))
{
ntStatus = t1394_IsochAttachBuffers( DeviceObject,
Irp,
outputBufferLength,
IsochAttachBuffers->hResource,
IsochAttachBuffers->nNumberOfDescriptors,
(PISOCH_DESCRIPTOR)IsochAttachBuffers->pIsochDescriptor,
(PRING3_ISOCH_DESCRIPTOR)&IsochAttachBuffers->R3_IsochDescriptor
);
if (STATUS_PENDING == ntStatus)
{
goto t1394VDev_IoControlExit;
}
}
}
}
break; // IOCTL_ISOCH_ATTACH_BUFFERS
case IOCTL_ISOCH_DETACH_BUFFERS:
{
PISOCH_DETACH_BUFFERS IsochDetachBuffers;
TRACE(TL_TRACE, ("IOCTL_ISOCH_DETACH_BUFFERS\n"));
if (inputBufferLength < sizeof(ISOCH_DETACH_BUFFERS)) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
IsochDetachBuffers = (PISOCH_DETACH_BUFFERS)ioBuffer;
ntStatus = t1394_IsochDetachBuffers( DeviceObject,
Irp,
IsochDetachBuffers->hResource,
IsochDetachBuffers->nNumberOfDescriptors,
(PISOCH_DESCRIPTOR)IsochDetachBuffers->pIsochDescriptor
);
}
}
break; // IOCTL_ISOCH_DETACH_BUFFERS
case IOCTL_ISOCH_FREE_BANDWIDTH:
{
TRACE(TL_TRACE, ("IOCTL_ISOCH_FREE_BANDWIDTH\n"));
if (inputBufferLength < sizeof(HANDLE)) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
ntStatus = t1394_IsochFreeBandwidth( DeviceObject,
Irp,
*(PHANDLE)ioBuffer
);
}
}
break; // IOCTL_ISOCH_FREE_BANDWIDTH
case IOCTL_ISOCH_FREE_CHANNEL:
{
TRACE(TL_TRACE, ("IOCTL_ISOCH_FREE_CHANNEL\n"));
if (inputBufferLength < sizeof(ULONG)) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
ntStatus = t1394_IsochFreeChannel( DeviceObject,
Irp,
*(PULONG)ioBuffer
);
}
}
break; // IOCTL_ISOCH_FREE_CHANNEL
case IOCTL_ISOCH_FREE_RESOURCES:
{
TRACE(TL_TRACE, ("IOCTL_ISOCH_FREE_RESOURCES\n"));
if (inputBufferLength < sizeof(HANDLE)) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
ntStatus = t1394_IsochFreeResources( DeviceObject,
Irp,
*(PHANDLE)ioBuffer
);
}
}
break; // IOCTL_ISOCH_FREE_RESOURCES
case IOCTL_ISOCH_LISTEN:
{
PISOCH_LISTEN IsochListen;
TRACE(TL_TRACE, ("IOCTL_ISOCH_LISTEN\n"));
if (inputBufferLength < sizeof(ISOCH_LISTEN)) {
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
else {
IsochListen = (PISOCH_LISTEN)ioBuffer;
ntStatus = t1394_IsochListen( DeviceObject,
Irp,
IsochListen->hResource,
IsochListen->fulFlags,
IsochListen->StartTime
);
}
}
break; // IOCTL_ISOCH_LISTEN
case IOCTL_ISOCH_QUERY_CURRENT_CYCLE_TIME:
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -