Модель обмена данными по шине MIL-STD-1553B микропроцессорных устройств
Построение рабочей системы в виде готового программного продукта, с отражением результатов его тестирования. Ознакомление с интерфейсом между приложением и драйвером режима ядра. Рассмотрение процесса выбора и обоснования метода установки драйвера.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 20.12.2017 |
Размер файла | 956,2 K |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
VIRTUAL1553B_VALIDATE_TERMINAL_OWNER(VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TERMINAL_MODE(
RemoteTerminalMode, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TRANSFER_DIRECTION(
InBuffer->Direction, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_SUBADDRESS(
InBuffer->Subaddress, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_DATA_WORD_COUNT(
InBuffer->WordCountToRead, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
switch (InBuffer->Direction)
{
caseDirectionReceive:
RtlCopyMemory(OutBuffer->Buffer,
GetReceiveBuffer(VirtualTerminal->RemoteTerminal, InBuffer->Subaddress),
InBuffer->WordCountToRead * sizeof(USHORT));
break;
caseDirectionTransmit:
RtlCopyMemory(OutBuffer->Buffer,
GetTransmitBuffer(VirtualTerminal->RemoteTerminal, InBuffer->Subaddress),
InBuffer->WordCountToRead * sizeof(USHORT));
break;
}
OutBuffer->WordCountRead = InBuffer->WordCountToRead;
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_SUCCESS_RETURN(OutBuffer, OutBufferSize, Irp);
}
NTSTATUSVirtualRT_GetTransferResult(
INPVIRTUAL1553B_EXTENSIONExtension,
INULONGInputBufferLength,
INULONGOutputBufferLength,
INPIRPIrp)
{
Virtual1553B_DbgPrintEntry();
ULONGInBufferSize = sizeof(INPUT_RT_GET_TRANSFER_RESULT);
VIRTUAL1553B_VALIDATE_INPUT_BUFFER_LENGTH(InputBufferLength, InBufferSize, Irp);
PINPUT_RT_GET_TRANSFER_RESULTInBuffer =
(PINPUT_RT_GET_TRANSFER_RESULT)(Irp->AssociatedIrp.SystemBuffer);
ULONGOutBufferSize = sizeof(OUTPUT_RT_GET_TRANSFER_RESULT);
VIRTUAL1553B_VALIDATE_OUTPUT_BUFFER_LENGTH(OutputBufferLength, OutBufferSize, Irp);
POUTPUT_RT_GET_TRANSFER_RESULTOutBuffer =
(POUTPUT_RT_GET_TRANSFER_RESULT)(Irp->AssociatedIrp.SystemBuffer);
LONG_PTRTerminalIndex = (LONG_PTR)(InBuffer->TerminalHandle);
VIRTUAL1553B_VALIDATE_TERMINAL_INDEX(TerminalIndex, OutBuffer, OutBufferSize, Irp);
PVIRTUAL_TERMINALVirtualTerminal = &Extension->VirtualTerminal[TerminalIndex];
AcquireVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_VALIDATE_TERMINAL_OWNER(VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TERMINAL_MODE(
RemoteTerminalMode, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
if (RemoteTerminal->Head == RemoteTerminal->Tail)
{
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_TRANSFER_RESULT_BUFFER_IS_EMPTY_RETURN(OutBuffer, OutBufferSize, Irp);
}
OutBuffer->TransferResult = RemoteTerminal->TransferResultBuffer[RemoteTerminal->Tail];
RemoteTerminal->Tail = (RemoteTerminal->Tail + 1) % TRANSFER_RESULT_BUFFER_LENGTH;
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_SUCCESS_RETURN(OutBuffer, OutBufferSize, Irp);
}
NTSTATUSVirtualBM_GetCurrentBase(
INPVIRTUAL1553B_EXTENSIONExtension,
INULONGInputBufferLength,
INULONGOutputBufferLength,
INPIRPIrp)
{
Virtual1553B_DbgPrintEntry();
ULONGInBufferSize = sizeof(INPUT_BM_GET_CURRENT_BASE);
VIRTUAL1553B_VALIDATE_INPUT_BUFFER_LENGTH(InputBufferLength, InBufferSize, Irp);
PINPUT_BM_GET_CURRENT_BASEInBuffer =
(PINPUT_BM_GET_CURRENT_BASE)(Irp->AssociatedIrp.SystemBuffer);
ULONGOutBufferSize = sizeof(OUTPUT_BM_GET_CURRENT_BASE);
VIRTUAL1553B_VALIDATE_OUTPUT_BUFFER_LENGTH(OutputBufferLength, OutBufferSize, Irp);
POUTPUT_BM_GET_CURRENT_BASEOutBuffer =
(POUTPUT_BM_GET_CURRENT_BASE)(Irp->AssociatedIrp.SystemBuffer);
LONG_PTRTerminalIndex = (LONG_PTR)(InBuffer->TerminalHandle);
VIRTUAL1553B_VALIDATE_TERMINAL_INDEX(TerminalIndex, OutBuffer, OutBufferSize, Irp);
PVIRTUAL_TERMINALVirtualTerminal = &Extension->VirtualTerminal[TerminalIndex];
AcquireVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_VALIDATE_TERMINAL_OWNER(VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TERMINAL_MODE(
BusMonitorMode, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
OutBuffer->CurrentBase = VirtualTerminal->BusMonitor->CurrentBase;
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_SUCCESS_RETURN(OutBuffer, OutBufferSize, Irp);
}
NTSTATUSVirtualBM_GetBaseCount(
INPVIRTUAL1553B_EXTENSIONExtension,
INULONGInputBufferLength,
INULONGOutputBufferLength,
INPIRPIrp)
{
Virtual1553B_DbgPrintEntry();
ULONGInBufferSize = sizeof(INPUT_BM_GET_BASE_COUNT);
VIRTUAL1553B_VALIDATE_INPUT_BUFFER_LENGTH(InputBufferLength, InBufferSize, Irp);
PINPUT_BM_GET_BASE_COUNTInBuffer = (PINPUT_BM_GET_BASE_COUNT)(Irp->AssociatedIrp.SystemBuffer);
ULONGOutBufferSize = sizeof(OUTPUT_BM_GET_BASE_COUNT);
VIRTUAL1553B_VALIDATE_OUTPUT_BUFFER_LENGTH(OutputBufferLength, OutBufferSize, Irp);
POUTPUT_BM_GET_BASE_COUNTOutBuffer =
(POUTPUT_BM_GET_BASE_COUNT)(Irp->AssociatedIrp.SystemBuffer);
LONG_PTRTerminalIndex = (LONG_PTR)(InBuffer->TerminalHandle);
VIRTUAL1553B_VALIDATE_TERMINAL_INDEX(TerminalIndex, OutBuffer, OutBufferSize, Irp);
PVIRTUAL_TERMINALVirtualTerminal = &Extension->VirtualTerminal[TerminalIndex];
AcquireVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_VALIDATE_TERMINAL_OWNER(VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TERMINAL_MODE(
BusMonitorMode, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
OutBuffer->BaseCount = TRANSFER_RECORD_BUFFER_LENGTH;
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_SUCCESS_RETURN(OutBuffer, OutBufferSize, Irp);
}
NTSTATUSVirtualBM_GetTransferRecord(
INPVIRTUAL1553B_EXTENSIONExtension,
INULONGInputBufferLength,
INULONGOutputBufferLength,
INPIRPIrp)
{
Virtual1553B_DbgPrintEntry();
ULONGInBufferSize = sizeof(INPUT_BM_GET_TRANSFER_RECORD);
VIRTUAL1553B_VALIDATE_INPUT_BUFFER_LENGTH(InputBufferLength, InBufferSize, Irp);
PINPUT_BM_GET_TRANSFER_RECORDInBuffer =
(PINPUT_BM_GET_TRANSFER_RECORD)(Irp->AssociatedIrp.SystemBuffer);
ULONGOutBufferSize = sizeof(OUTPUT_BM_GET_TRANSFER_RECORD);
VIRTUAL1553B_VALIDATE_OUTPUT_BUFFER_LENGTH(OutputBufferLength, OutBufferSize, Irp);
POUTPUT_BM_GET_TRANSFER_RECORDOutBuffer =
(POUTPUT_BM_GET_TRANSFER_RECORD)(Irp->AssociatedIrp.SystemBuffer);
LONG_PTRTerminalIndex = (LONG_PTR)(InBuffer->TerminalHandle);
VIRTUAL1553B_VALIDATE_TERMINAL_INDEX(TerminalIndex, OutBuffer, OutBufferSize, Irp);
PVIRTUAL_TERMINALVirtualTerminal = &Extension->VirtualTerminal[TerminalIndex];
AcquireVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_VALIDATE_TERMINAL_OWNER(VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_TERMINAL_MODE(
BusMonitorMode, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
VIRTUAL1553B_VALIDATE_BUS_MONITOR_BASE(
InBuffer->TargetBase, VirtualTerminal, OutBuffer, OutBufferSize, Irp);
OutBuffer->TransferRecord =
VirtualTerminal->BusMonitor->TransferRecordBuffer[InBuffer->TargetBase];
ReleaseVirtualTerminal(VirtualTerminal);
VIRTUAL1553B_SUCCESS_RETURN(OutBuffer, OutBufferSize, Irp);
}
/************************************************************************/
/* WorkerThreads.cpp */
/************************************************************************/
#include"stdafx.h"
#include"WorkerThreads.h"
BOOLEANVirtual1553B_CreateWorkerThreads(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_DATA_BUSBus,
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL1553B_WORKER_ROUTINEWorkerRoutine)
{
Virtual1553B_DbgPrintEntry();
PKEVENTStartEvent = (PKEVENT)ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), 0);
if (!StartEvent)
{
Virtual1553B_DbgPrintExit_0("ExAllocatePoolWithTag() failed.");
returnFALSE;
}
PKEVENTTerminateEvent = (PKEVENT)ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), 0);
if (!TerminateEvent)
{
ExFreePoolWithTag(StartEvent, 0);
Virtual1553B_DbgPrintExit_0("ExAllocatePoolWithTag() failed.");
returnFALSE;
}
PVIRTUAL1553B_WORKER_THREADWorkerThread = (PVIRTUAL1553B_WORKER_THREAD)ExAllocatePoolWithTag(
NonPagedPool, sizeof(VIRTUAL1553B_WORKER_THREAD) * TransferLineNumber, 0);
if (!WorkerThread)
{
ExFreePoolWithTag(TerminateEvent, 0);
ExFreePoolWithTag(StartEvent, 0);
Virtual1553B_DbgPrintExit_0("ExAllocatePoolWithTag() failed.");
returnFALSE;
}
RtlZeroMemory(StartEvent, sizeof(KEVENT));
RtlZeroMemory(TerminateEvent, sizeof(KEVENT));
RtlZeroMemory(WorkerThread, sizeof(VIRTUAL1553B_WORKER_THREAD) * TransferLineNumber);
KeInitializeEvent(StartEvent, NotificationEvent, FALSE);
KeInitializeEvent(TerminateEvent, NotificationEvent, FALSE);
VirtualTerminal->StartEvent = StartEvent;
VirtualTerminal->TerminateEvent = TerminateEvent;
VirtualTerminal->WorkerThread = WorkerThread;
for (USHORTj = 0; j<TransferLineNumber; ++j)
{
WorkerThread[j].Context.VirtualTerminal = VirtualTerminal;
WorkerThread[j].Context.Line = &Bus->Line[j];
WorkerThread[j].Context.TerminalMap = TerminalMap;
KeInitializeEvent(&WorkerThread[j].Context.InitiateTransferEvent, NotificationEvent, FALSE);
NTSTATUSStatus = STATUS_SUCCESS;
HANDLEThreadHandle = NULL;
Status = PsCreateSystemThread(
&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
(PKSTART_ROUTINE)(WorkerRoutine),
&WorkerThread[j].Context);
PKTHREADThreadObject = NULL;
if (!NT_SUCCESS(Status))
{
KeSetEvent(TerminateEvent, IO_NO_INCREMENT, FALSE);
for (USHORTi = 0; i<j; ++i)
{
ThreadObject = (PKTHREAD)InterlockedExchangePointer(
&WorkerThread[i].ThreadObject, NULL);
KeWaitForSingleObject(ThreadObject, Executive, KernelMode, FALSE, NULL);
ObDereferenceObject(ThreadObject);
}
VirtualTerminal->WorkerThread = NULL;
VirtualTerminal->TerminateEvent = NULL;
VirtualTerminal->StartEvent = NULL;
ExFreePoolWithTag(WorkerThread, 0);
ExFreePoolWithTag(TerminateEvent, 0);
ExFreePoolWithTag(StartEvent, 0);
Virtual1553B_DbgPrintExit_1("PsCreateSystemThread() failed. Error: %08X.", Status);
returnFALSE;
}
ObReferenceObjectByHandle(
ThreadHandle,
THREAD_ALL_ACCESS,
*PsThreadType,
KernelMode,
(PVOID *)(&ThreadObject),
NULL);
ZwClose(ThreadHandle);
WorkerThread[j].ThreadObject = ThreadObject;
}
KeSetEvent(VirtualTerminal->StartEvent, IO_NO_INCREMENT, FALSE);
Virtual1553B_DbgPrintExit_0("Success.");
returnTRUE;
}
VOIDVirtual1553B_CloseWorkerThreads(
INPVIRTUAL_TERMINALVirtualTerminal)
{
Virtual1553B_DbgPrintEntry();
KeSetEvent(VirtualTerminal->TerminateEvent, IO_NO_INCREMENT, FALSE);
PVOIDThreadObject = NULL;
for (USHORTi = 0; i<TransferLineNumber; ++i)
{
ThreadObject = InterlockedExchangePointer(
&VirtualTerminal->WorkerThread[i].ThreadObject, NULL);
KeWaitForSingleObject(ThreadObject, Executive, KernelMode, FALSE, NULL);
ObDereferenceObject(ThreadObject);
}
PVOIDWorkerThread = InterlockedExchangePointer(&VirtualTerminal->WorkerThread, NULL);
PVOIDTerminateEvent = InterlockedExchangePointer(&VirtualTerminal->TerminateEvent, NULL);
PVOIDStartEvent = InterlockedExchangePointer(&VirtualTerminal->StartEvent, NULL);
ExFreePoolWithTag(WorkerThread, 0);
ExFreePoolWithTag(TerminateEvent, 0);
ExFreePoolWithTag(StartEvent, 0);
Virtual1553B_DbgPrintExit();
}
inlinestaticVOIDMapRemoteTerminal(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal,
INULONGIndex)
{
TerminalMap->RemoteTerminal[Index] = VirtualTerminal;
BitTestAndSet((LONG *)(&TerminalMap->RemoteTerminalBitmap), (LONG)(Index));
VirtualTerminal->BitmapIndex = Index;
}
inlinestaticVOIDUnmapRemoteTerminal(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal)
{
TerminalMap->RemoteTerminal[VirtualTerminal->BitmapIndex] = NULL;
BitTestAndReset((LONG *)(&TerminalMap->RemoteTerminalBitmap),
(LONG)(VirtualTerminal->BitmapIndex));
VirtualTerminal->BitmapIndex = (ULONG)(-1);
}
inlinestaticVOIDMapBusMonitor(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal,
INULONGIndex)
{
TerminalMap->BusMonitor[Index] = VirtualTerminal;
BitTestAndSet((LONG *)(&TerminalMap->BusMonitorBitmap), (LONG)(Index));
VirtualTerminal->BitmapIndex = Index;
}
inlinestaticVOIDUnmapBusMonitor(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal)
{
TerminalMap->BusMonitor[VirtualTerminal->BitmapIndex] = NULL;
BitTestAndReset((LONG *)(&TerminalMap->BusMonitorBitmap), (LONG)(VirtualTerminal->BitmapIndex));
VirtualTerminal->BitmapIndex = (ULONG)(-1);
}
BOOLEANVirtual1553B_RegisterRemoteTerminal(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal,
INUSHORTAddress,
INBOOLEANRemap)
{
Virtual1553B_DbgPrintEntry();
if ((Address<REMOTE_TERMINAL_ADDRESS_MINIMUM) || (Address>REMOTE_TERMINAL_ADDRESS_MAXIMUM))
{
Virtual1553B_DbgPrintExit_0("Failure: Invalid remote terminal address.");
returnFALSE;
}
AcquireTerminalMap(TerminalMap);
if (TerminalMap->RemoteTerminal[Address])
{
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit_0("Failure: Remote terminal address is already used.");
returnFALSE;
}
if (Remap)
{
UnmapRemoteTerminal(TerminalMap, VirtualTerminal);
}
MapRemoteTerminal(TerminalMap, VirtualTerminal, Address);
VirtualTerminal->RemoteTerminal->Address = Address;
VirtualTerminal->RemoteTerminal->StatusWord.RemoteTerminalAddress = Address;
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit_0("Success.");
returnTRUE;
}
VOIDVirtual1553B_RevokeRemoteTerminal(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal)
{
Virtual1553B_DbgPrintEntry();
AcquireTerminalMap(TerminalMap);
UnmapRemoteTerminal(TerminalMap, VirtualTerminal);
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit();
}
BOOLEANVirtual1553B_RegisterBusMonitor(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal)
{
Virtual1553B_DbgPrintEntry();
AcquireTerminalMap(TerminalMap);
ULONGInvertedBitmap = ~TerminalMap->BusMonitorBitmap;
ULONGIndex = (ULONG)(-1);
if (BitScanForward(&Index, InvertedBitmap))
{
MapBusMonitor(TerminalMap, VirtualTerminal, Index);
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit_0("Success.");
returnTRUE;
}
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit_0("Failure.");
returnFALSE;
}
VOIDVirtual1553B_RevokeBusMonitor(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL_TERMINALVirtualTerminal)
{
Virtual1553B_DbgPrintEntry();
AcquireTerminalMap(TerminalMap);
UnmapBusMonitor(TerminalMap, VirtualTerminal);
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit();
}
VOIDVirtual1553B_VisitRemoteTerminal(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL1553B_TRANSFER_LINELine,
INPVIRTUAL1553B_VISITORRemoteTerminalVisitor,
INUSHORTAddress)
{
Virtual1553B_DbgPrintEntry();
AcquireTerminalMap(TerminalMap);
if (Address == BROADCAST_REMOTE_TERMINAL_ADDRESS)
{
ULONGBitmap = TerminalMap->RemoteTerminalBitmap;
ULONGIndex = (ULONG)(-1);
while (Bitmap&&BitScanForward(&Index, Bitmap))
{
RemoteTerminalVisitor(TerminalMap->RemoteTerminal[Index], Line);
BitTestAndReset((LONG *)(&Bitmap), (LONG)(Index));
}
}
else
{
if (TerminalMap->RemoteTerminal[Address])
{
RemoteTerminalVisitor(TerminalMap->RemoteTerminal[Address], Line);
}
}
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit();
}
VOIDVirtual1553B_VisitBusMonitors(
INPVIRTUAL_TERMINAL_MAPTerminalMap,
INPVIRTUAL1553B_TRANSFER_LINELine,
INPVIRTUAL1553B_VISITORBusMonitorVisitor)
{
Virtual1553B_DbgPrintEntry();
AcquireTerminalMap(TerminalMap);
ULONGBitmap = TerminalMap->BusMonitorBitmap;
ULONGIndex = (ULONG)(-1);
while (Bitmap&&BitScanForward(&Index, Bitmap))
{
BusMonitorVisitor(TerminalMap->BusMonitor[Index], Line);
BitTestAndReset((LONG *)(&Bitmap), (LONG)(Index));
}
ReleaseTerminalMap(TerminalMap);
Virtual1553B_DbgPrintExit();
}
VOIDVirtualBC_WorkerThread(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
KeSetPriorityThread(KeGetCurrentThread(), LOW_REALTIME_PRIORITY);
NTSTATUSStatus = STATUS_SUCCESS;
PVIRTUAL_TERMINALVirtualTerminal = Context->VirtualTerminal;
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
PVOIDWaitObjects[MaximumEventObject] = { 0 };
WaitObjects[SynqEventObject] = VirtualTerminal->StartEvent;
WaitObjects[TerminateEventObject] = VirtualTerminal->TerminateEvent;
KWAIT_BLOCKWaitBlockArray[MaximumEventObject] = { 0 };
Status = KeWaitForMultipleObjects(
MaximumEventObject,
WaitObjects,
WaitAny,
Executive,
KernelMode,
FALSE,
NULL,
WaitBlockArray);
switch (Status)
{
caseSynqEventObject:
break;
default:
Virtual1553B_UnlockTransferLine(Line, VirtualTerminal);
Virtual1553B_DbgPrintExit();
PsTerminateSystemThread(STATUS_SUCCESS);
}
PBC_TRANSFER_RESULTTransferResult = &VirtualTerminal->BusController->TransferResult;
WaitObjects[SynqEventObject] = &Context->InitiateTransferEvent;
for ( ; ; )
{
Status = KeWaitForMultipleObjects(
MaximumEventObject,
WaitObjects,
WaitAny,
Executive,
KernelMode,
FALSE,
NULL,
WaitBlockArray);
switch (Status)
{
caseSynqEventObject:
if (!KeResetEvent(&Context->InitiateTransferEvent))
{
continue;
}
break;
default:
Virtual1553B_UnlockTransferLine(Line, VirtualTerminal);
Virtual1553B_DbgPrintExit();
PsTerminateSystemThread(STATUS_SUCCESS);
}
switch (Line->Format)
{
caseTransferBCRT:
VirtualBC_TransferBCRT(Context);
break;
caseTransferBCRTBroadcast:
VirtualBC_TransferBCRTBroadcast(Context);
break;
caseTransferRTBC:
VirtualBC_TransferRTBC(Context);
break;
caseTransferRTRT:
VirtualBC_TransferRTRT(Context);
break;
caseTransferRTRTBroadcast:
VirtualBC_TransferRTRTBroadcast(Context);
break;
caseModeCommandWithoutData:
VirtualBC_ModeCommandWithoutData(Context);
break;
caseModeCommandWithoutDataBroadcast:
VirtualBC_ModeCommandWithoutDataBroadcast(Context);
break;
caseModeCommandWithDataReceive:
VirtualBC_ModeCommandWithDataReceive(Context);
break;
caseModeCommandWithDataReceiveBroadcast:
VirtualBC_ModeCommandWithDataReceiveBroadcast(Context);
break;
caseModeCommandWithDataTransmit:
VirtualBC_ModeCommandWithDataTransmit(Context);
break;
default:
Virtual1553B_DbgPrint_1("Unknown message format: %hu.", Line->Format);
break;
}
TransferResult->Time = Line->Time;
TransferResult->Error = Line->Error;
TransferResult->SW1 = Line->SW1;
TransferResult->SW2 = Line->SW2;
RtlCopyMemory(TransferResult->Data, Line->Data, DATA_WORD_COUNT_MAXIMUM * sizeof(USHORT));
Virtual1553B_VisitBusMonitors(Context->TerminalMap, Line, VirtualBM_SaveTransferResult);
Virtual1553B_UnlockTransferLine(Line, VirtualTerminal);
Virtual1553B_RaiseInterrupt(VirtualTerminal);
}
}
VOIDVirtualBC_TransferBCRT(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_TRANSFER_BC_RT_COMMAND(GET_DATA_WORD_COUNT(Line->CW1.Raw)));
Virtual1553B_VisitRemoteTerminal(
Context->TerminalMap, Line, VirtualRT_TransferBCRT, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
if (Line->SW1.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(INTERVAL_TRANSFER_BC_RT_RESPONSE);
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_TransferBCRTBroadcast(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(
INTERVAL_TRANSFER_BC_RT_BROADCAST_COMMAND(GET_DATA_WORD_COUNT(Line->CW1.Raw)));
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferBCRTBroadcast, Line->CW1.RemoteTerminalAddress);
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
Virtual1553B_DbgPrintExit_0("Success.");
}
VOIDVirtualBC_TransferRTBC(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_TRANSFER_RT_BC_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferRTBC, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
if (Line->SW1.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(
INTERVAL_TRANSFER_RT_BC_RESPONSE(GET_DATA_WORD_COUNT(Line->CW1.Raw)));
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_TransferRTRT(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_TRANSFER_RT_RT_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferRTRTFirst, Line->CW2.RemoteTerminalAddress);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferRTRTSecond, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
if (Line->SW1.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error in the first response.");
return;
}
else
{
KeStallExecutionProcessor(
INTERVAL_TRANSFER_RT_RT_RESPONSE_1(GET_DATA_WORD_COUNT(Line->CW2.Raw)));
}
if (Line->SW2.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_SECOND_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No second response.");
return;
}
if (Line->SW2.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error in the second response.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(INTERVAL_TRANSFER_RT_RT_RESPONSE_2);
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_TransferRTRTBroadcast(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_TRANSFER_RT_RT_BROADCAST_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferRTRTBroadcastFirst, Line->CW2.RemoteTerminalAddress);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_TransferRTRTBroadcastSecond, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
if (Line->SW1.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error in the first response.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(
INTERVAL_TRANSFER_RT_RT_BROADCAST_RESPONSE(GET_DATA_WORD_COUNT(Line->CW2.Raw)));
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_ModeCommandWithoutData(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITHOUT_DATA_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_ModeCommandWithoutData, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
USHORTModeCommand = GET_MODE_COMMAND(Line->CW1.Raw);
if (Line->SW1.MessageError&& (ModeCommand != CommandTransmitStatusWord))
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITHOUT_DATA_RESPONSE);
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_ModeCommandWithoutDataBroadcast(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITHOUT_DATA_BROADCAST_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_ModeCommandWithoutDataBroadcast, Line->CW1.RemoteTerminalAddress);
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
Virtual1553B_DbgPrintExit_0("Success.");
}
VOIDVirtualBC_ModeCommandWithDataReceive(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITH_DATA_RECEIVE_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_ModeCommandWithDataReceive, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
if (Line->SW1.MessageError)
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITH_DATA_RECEIVE_RESPONSE);
Virtual1553B_DbgPrintExit_0("Success.");
}
}
VOIDVirtualBC_ModeCommandWithDataReceiveBroadcast(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITH_DATA_RECEIVE_BROADCAST_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_ModeCommandWithDataReceiveBroadcast, Line->CW1.RemoteTerminalAddress);
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
Virtual1553B_DbgPrintExit_0("Success.");
}
VOIDVirtualBC_ModeCommandWithDataTransmit(INPVIRTUAL1553B_CONTEXTContext)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL1553B_TRANSFER_LINELine = Context->Line;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITH_DATA_TRANSMIT_COMMAND);
Virtual1553B_VisitRemoteTerminal(Context->TerminalMap, Line,
VirtualRT_ModeCommandWithDataTransmit, Line->CW1.RemoteTerminalAddress);
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
Line->Error = VIRTUAL1553B_ERROR_NO_FIRST_RESPONSE;
Virtual1553B_DbgPrintExit_0("Failure: No first response.");
return;
}
USHORTModeCommand = GET_MODE_COMMAND(Line->CW1.Raw);
if (Line->SW1.MessageError&& (ModeCommand != CommandTransmitLastCommandWord))
{
Line->Error = VIRTUAL1553B_ERROR_MESSAGE_ERROR;
KeStallExecutionProcessor(INTERVAL_STATUS_WORD);
Virtual1553B_DbgPrintExit_0("Failure: Message error.");
}
else
{
Line->Error = VIRTUAL1553B_ERROR_SUCCESS;
KeStallExecutionProcessor(INTERVAL_MODE_COMMAND_WITH_DATA_TRANSMIT_RESPONSE);
Virtual1553B_DbgPrintExit_0("Success.");
}
}
inlinestaticVOIDValidMessageReceived(
INPVIRTUAL_REMOTE_TERMINALRemoteTerminal,
INCOMMAND_WORDCommandWord,
INBOOLEANBroadcastCommandReceived)
{
RemoteTerminal->StatusWord.MessageError = 0;
RemoteTerminal->StatusWord.BroadcastCommandReceived = BroadcastCommandReceived;
RemoteTerminal->LastCommandWord = CommandWord;
}
inlinestaticVOIDInvalidMessageReceived(
INPVIRTUAL_REMOTE_TERMINALRemoteTerminal,
INCOMMAND_WORDCommandWord)
{
RemoteTerminal->StatusWord.MessageError = 1;
RemoteTerminal->StatusWord.BroadcastCommandReceived = 0;
RemoteTerminal->LastCommandWord = CommandWord;
}
inlinestaticVOIDSubmitTransferResult(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine,
INUSHORTError,
INCOMMAND_WORDCW)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
PRT_TRANSFER_RESULTTransferResult =
&RemoteTerminal->TransferResultBuffer[RemoteTerminal->Head];
TransferResult->Time = Line->Time;
TransferResult->Error = Error;
TransferResult->Format = Line->Format;
TransferResult->CW = CW;
RtlCopyMemory(TransferResult->Data, Line->Data, DATA_WORD_COUNT_MAXIMUM * sizeof(USHORT));
RemoteTerminal->Head = (RemoteTerminal->Head + 1) % TRANSFER_RESULT_BUFFER_LENGTH;
Virtual1553B_RaiseInterrupt(VirtualTerminal);
Virtual1553B_DbgPrintExit_2("The transfer result was saved. Head: %hu, Tail: %hu.",
RemoteTerminal->Head, RemoteTerminal->Tail);
}
VOIDVirtualRT_TransferBCRT(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_BC_RT(Line->CW1.Raw))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW1.Raw);
RtlCopyMemory(GetReceiveBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
if (Line->CW1.Subaddress == SUBADDRESS_MAXIMUM)
{
RtlCopyMemory(GetTransmitBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer BC-RT.");
}
}
VOIDVirtualRT_TransferBCRTBroadcast(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != BROADCAST_REMOTE_TERMINAL_ADDRESS)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_BC_RT_BROADCAST(Line->CW1.Raw))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, TRUE);
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW1.Raw);
RtlCopyMemory(GetReceiveBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
if (Line->CW1.Subaddress == SUBADDRESS_MAXIMUM)
{
RtlCopyMemory(GetTransmitBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer BC-RT Broadcast.");
}
}
VOIDVirtualRT_TransferRTBC(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_RT_BC(Line->CW1.Raw))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW1.Raw);
RtlCopyMemory(Line->Data, GetTransmitBuffer(RemoteTerminal, Line->CW1.Subaddress),
DataWordCount * sizeof(USHORT));
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer RT-BC.");
}
}
VOIDVirtualRT_TransferRTRTFirst(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW2.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_RT_RT(Line->CW1.Raw, Line->CW2.Raw))
{
ValidMessageReceived(RemoteTerminal, Line->CW2, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW2.Raw);
RtlCopyMemory(Line->Data, GetTransmitBuffer(RemoteTerminal, Line->CW2.Subaddress),
DataWordCount * sizeof(USHORT));
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW2);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW2);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW2);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer RT-RT.");
}
}
VOIDVirtualRT_TransferRTRTSecond(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW2.RemoteTerminalAddress == RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_RT_RT(Line->CW1.Raw, Line->CW2.Raw))
{
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0(
"Failure: No response from the transmitting remote terminal.");
return;
}
if (Line->SW1.MessageError)
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0(
"Failure: Message error in the response from the transmitting remote terminal.");
return;
}
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW2 = RemoteTerminal->StatusWord;
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW1.Raw);
RtlCopyMemory(GetReceiveBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
if (Line->CW1.Subaddress == SUBADDRESS_MAXIMUM)
{
RtlCopyMemory(GetTransmitBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer RT-RT.");
}
}
VOIDVirtualRT_TransferRTRTBroadcastFirst(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW2.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_RT_RT_BROADCAST(Line->CW1.Raw, Line->CW2.Raw))
{
ValidMessageReceived(RemoteTerminal, Line->CW2, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW2.Raw);
RtlCopyMemory(Line->Data, GetTransmitBuffer(RemoteTerminal, Line->CW2.Subaddress),
DataWordCount * sizeof(USHORT));
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW2);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW2);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW2);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer RT-RT Broadcast.");
}
}
VOIDVirtualRT_TransferRTRTBroadcastSecond(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW2.RemoteTerminalAddress == RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (Line->CW1.RemoteTerminalAddress != BROADCAST_REMOTE_TERMINAL_ADDRESS)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_TRANSFER_RT_RT_BROADCAST(Line->CW1.Raw, Line->CW2.Raw))
{
if (Line->SW1.Raw == INVALID_STATUS_WORD)
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0(
"Failure: No response from the transmitting remote terminal.");
return;
}
if (Line->SW1.MessageError)
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0(
"Failure: Message error in the response from the transmitting remote terminal.");
return;
}
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
USHORTDataWordCount = GET_DATA_WORD_COUNT(Line->CW1.Raw);
RtlCopyMemory(GetReceiveBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
if (Line->CW1.Subaddress == SUBADDRESS_MAXIMUM)
{
RtlCopyMemory(GetTransmitBuffer(RemoteTerminal, Line->CW1.Subaddress), Line->Data,
DataWordCount * sizeof(USHORT));
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Transfer RT-RT Broadcast.");
}
}
VOIDVirtualRT_ModeCommandWithoutData(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_MODE_COMMAND_WITHOUT_DATA(Line->CW1.Raw))
{
USHORTModeCode = GET_MODE_CODE(Line->CW1.Raw);
switch (ModeCode)
{
caseCodeDynamicBusControl:
caseCodeSynchronize:
caseCodeInitiateSelfTest:
caseCodeTransmitterShutdown:
caseCodeOverrideTransmitterShutdown:
caseCodeInhibitTerminalFlagBit:
caseCodeOverrideInhibitTerminalFlagBit:
caseCodeResetRemoteTerminal:
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
break;
caseCodeTransmitStatusWord:
RemoteTerminal->LastCommandWord = Line->CW1;
Line->SW1 = RemoteTerminal->StatusWord;
break;
default:
if ((ModeCode>= CODE_RESERVED_WITHOUT_DATA_MINIMUM) &&
(ModeCode<= CODE_RESERVED_WITHOUT_DATA_MAXIMUM))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Invalid Mode Code.");
return;
}
break;
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Mode Command Without Data.");
}
}
VOIDVirtualRT_ModeCommandWithoutDataBroadcast(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != BROADCAST_REMOTE_TERMINAL_ADDRESS)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_MODE_COMMAND_WITHOUT_DATA_BROADCAST(Line->CW1.Raw))
{
USHORTModeCode = GET_MODE_CODE(Line->CW1.Raw);
switch (ModeCode)
{
caseCodeSynchronize:
caseCodeInitiateSelfTest:
caseCodeTransmitterShutdown:
caseCodeOverrideTransmitterShutdown:
caseCodeInhibitTerminalFlagBit:
caseCodeOverrideInhibitTerminalFlagBit:
caseCodeResetRemoteTerminal:
ValidMessageReceived(RemoteTerminal, Line->CW1, TRUE);
break;
default:
if ((ModeCode>= CODE_RESERVED_WITHOUT_DATA_MINIMUM) &&
(ModeCode<= CODE_RESERVED_WITHOUT_DATA_MAXIMUM))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, TRUE);
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Invalid Mode Code.");
return;
}
break;
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Mode Command Without Data Broadcast.");
}
}
VOIDVirtualRT_ModeCommandWithDataReceive(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_MODE_COMMAND_WITH_DATA_RECEIVE(Line->CW1.Raw))
{
USHORTModeCode = GET_MODE_CODE(Line->CW1.Raw);
switch (ModeCode)
{
caseCodeSynchronizeWithDataWord:
caseCodeSelectedTransmitterShutdown:
caseCodeOverrideSelectedTransmitterShutdown:
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
break;
default:
if ((ModeCode>= CODE_RESERVED_WITH_DATA_MINIMUM) &&
(ModeCode<= CODE_RESERVED_WITH_DATA_MAXIMUM))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Invalid Mode Code.");
return;
}
break;
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Mode Command With Data Receive.");
}
}
VOIDVirtualRT_ModeCommandWithDataReceiveBroadcast(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != BROADCAST_REMOTE_TERMINAL_ADDRESS)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_MODE_COMMAND_WITH_DATA_RECEIVE_BROADCAST(Line->CW1.Raw))
{
USHORTModeCode = GET_MODE_CODE(Line->CW1.Raw);
switch (ModeCode)
{
caseCodeSynchronizeWithDataWord:
caseCodeSelectedTransmitterShutdown:
caseCodeOverrideSelectedTransmitterShutdown:
ValidMessageReceived(RemoteTerminal, Line->CW1, TRUE);
break;
default:
if ((ModeCode>= CODE_RESERVED_WITH_DATA_MINIMUM) &&
(ModeCode<= CODE_RESERVED_WITH_DATA_MAXIMUM))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, TRUE);
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Invalid Mode Code.");
return;
}
break;
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Mode Command With Data Receive Broadcast.");
}
}
VOIDVirtualRT_ModeCommandWithDataTransmit(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_REMOTE_TERMINALRemoteTerminal = VirtualTerminal->RemoteTerminal;
Virtual1553B_DbgPrint_1("Remote terminal address: %hu.", RemoteTerminal->Address);
if (Line->CW1.RemoteTerminalAddress != RemoteTerminal->Address)
{
Virtual1553B_DbgPrintExit();
return;
}
if (VALIDATE_MODE_COMMAND_WITH_DATA_TRANSMIT(Line->CW1.Raw))
{
USHORTModeCode = GET_MODE_CODE(Line->CW1.Raw);
switch (ModeCode)
{
caseCodeTransmitVectorWord:
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
Line->Data[0] = RemoteTerminal->VectorWord;
break;
caseCodeTransmitLastCommandWord:
Line->SW1 = RemoteTerminal->StatusWord;
Line->Data[0] = RemoteTerminal->LastCommandWord.Raw;
break;
caseCodeTransmitBuiltInTestWord:
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
Line->Data[0] = RemoteTerminal->BuiltInTestWord;
break;
default:
if ((ModeCode>= CODE_RESERVED_WITH_DATA_MINIMUM) &&
(ModeCode<= CODE_RESERVED_WITH_DATA_MAXIMUM))
{
ValidMessageReceived(RemoteTerminal, Line->CW1, FALSE);
Line->SW1 = RemoteTerminal->StatusWord;
Line->Data[0] = 0;
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line,
VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Invalid Mode Code.");
return;
}
break;
}
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_SUCCESS, Line->CW1);
Virtual1553B_DbgPrintExit_0("Success.");
}
else
{
InvalidMessageReceived(RemoteTerminal, Line->CW1);
Line->SW1 = RemoteTerminal->StatusWord;
SubmitTransferResult(VirtualTerminal, Line, VIRTUAL1553B_ERROR_MESSAGE_ERROR, Line->CW1);
Virtual1553B_DbgPrintExit_0("Failure: Validate Mode Command With Data Transmit.");
}
}
VOIDVirtualBM_SaveTransferResult(
INPVIRTUAL_TERMINALVirtualTerminal,
INPVIRTUAL1553B_TRANSFER_LINELine)
{
Virtual1553B_DbgPrintEntry();
PVIRTUAL_BUS_MONITORBusMonitor = VirtualTerminal->BusMonitor;
PTRANSFER_RECORDTransferRecord = &BusMonitor->TransferRecordBuffer[BusMonitor->CurrentBase];
TransferRecord->Time = Line->Time;
TransferRecord->Error = Line->Error;
TransferRecord->TransferLine = Line->TransferLine;
TransferRecord->Format = Line->Format;
TransferRecord->CW1 = Line->CW1;
TransferRecord->CW2 = Line->CW2;
TransferRecord->SW1 = Line->SW1;
TransferRecord->SW2 = Line->SW2;
RtlCopyMemory(TransferRecord->Data, Line->Data, DATA_WORD_COUNT_MAXIMUM * sizeof(USHORT));
BusMonitor->CurrentBase = (BusMonitor->CurrentBase + 1) % TRANSFER_RECORD_BUFFER_LENGTH;
Virtual1553B_RaiseInterrupt(VirtualTerminal);
Virtual1553B_DbgPrintExit_1("The transfer result was saved. Current base: %hu.",
BusMonitor->CurrentBase);
}
Приложение Б
Листингкодадрайвера
пользовательскогорежима
/************************************************************************/
/* VirtualTerminalDriver.cpp */
/************************************************************************/
#include"stdafx.h"
#include"VirtualTerminalDriver.h"
#include"..\Virtual1553B\IoControlCode.h"
#include"SynqLocker.h"
HANDLEhDriverVirtual1553B;
HANDLEhSynqVirtual1553B;
LONGnReferenceCount;
VIRTUAL_TERMINAL_DRIVER_APIBOOL__stdcallVirtual1553B_DriverOpen(VOID)
{
SYNQLOCKER(hSynqVirtual1553B);
if (hDriverVirtual1553B)
{
InterlockedIncrement(&nReferenceCount);
returnTRUE;
}
HANDLEhDriver = CreateFile(
TEXT("\\\\.\\Virtual1553B0"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hDriver == INVALID_HANDLE_VALUE)
{
returnFALSE;
}
hDriverVirtual1553B = hDriver;
InterlockedIncrement(&nReferenceCount);
returnTRUE;
}
VIRTUAL_TERMINAL_DRIVER_APIBOOL__stdcallVirtual1553B_DriverClose(VOID)
{
SYNQLOCKER(hSynqVirtual1553B);
if (hDriverVirtual1553B)
{
if (!InterlockedDecrement(&nReferenceCount))
{
HANDLEhDriver = InterlockedExchangePointer(&hDriverVirtual1553B, NULL);
CloseHandle(hDriver);
}
returnTRUE;
}
returnFALSE;
}
#defineVIRTUAL1553B_VERIFY_DRIVER_IS_OPEN(hDriverVirtual1553B) \
{ \
if (!(hDriverVirtual1553B)) \
{ \
returnVIRTUAL1553B_STATUS_DRIVER_HANDLE_IS_NOT_OPENED; \
} \
}
VIRTUAL_TERMINAL_DRIVER_APIVIRTUAL1553B_STATUS__stdcallVirtual1553B_AllocTerminal(
__outPTERMINAL_HANDLEpTerminalHandle)
{
SYNQLOCKER(hSynqVirtual1553B);
*pTerminalHandle = INVALID_TERMINAL_HANDLE;
VIRTUAL1553B_VERIFY_DRIVER_IS_OPEN(hDriverVirtual1553B);
OUTPUT_ALLOC_TERMINALoutBuffer = { 0 };
DWORDcbBytesReturned = 0;
BOOLbResult = DeviceIoControl(
hDriverVirtual1553B,
IOCTL_VIRTUAL1553B_ALLOC_TERMINAL,
NULL, 0,
&outBuffer, sizeof(outBuffer),
&cbBytesReturned,
NULL);
if (bResult&& (cbBytesReturned == sizeof(outBuffer)))
{
if (VIRTUAL1553B_SUCCESS(outBuffer.Status))
{
*pTerminalHandle = outBuffer.TerminalHandle;
}
returnoutBuffer.Status;
}
returnVIRTUAL1553B_STATUS_DEVICE_IO_CONTROL_FAILED;
}
#defineVIRTUAL1553B_VERIFY_TERMINAL_HANDLE(TerminalHandle) \
{ \
if ((TerminalHandle) == INVALID_TERMINAL_HANDLE) \
{ \
returnVIRTUAL1553B_STATUS_INVALID_TERMINAL_HANDLE; \
} \
}
VIRTUAL_TERMINAL_DRIVER_APIVIRTUAL1553B_STATUS__stdcallVirtual1553B_FreeTerminal(
__inTERMINAL_HANDLETerminalHandle)
{
SYNQLOCKER(hSynqVirtual1553B);
VIRTUAL1553B_VERIFY_DRIVER_IS_OPEN(hDriverVirtual1553B);
VIRTUAL1553B_VERIFY_TERMINAL_HANDLE(TerminalHandle);
INPUT_FREE_TERMINALinBuffer = { 0 };
inBuffer.TerminalHandle = TerminalHandle;
OUTPUT_FREE_TERMINALoutBuffer = { 0 };
DWORDcbBytesReturned = 0;
BOOLbResult = DeviceIoControl(
hDriverVirtual1553B,
IOCTL_VIRTUAL1553B_FREE_TERMINAL,
&inBuffer, sizeof(inBuffer),
&outBuffer, sizeof(outBuffer),
&cbBytesReturned,
NULL);
if (bResult&& (cbBytesReturned == sizeof(outBuffer)))
{
returnoutBuffer.Status;
}
returnVIRTUAL1553B_STATUS_DEVICE_IO_CONTROL_FAILED;
Подобные документы
Описание исходных текстов программного продукта. Системные требования и установка программного продукта. Тестирование пользователя по двадцати вопросам указанной темы и сохранение результатов тестирования. Форма отображения результатов тестирования.
курсовая работа [2,8 M], добавлен 09.07.2013Характеристика основных методов и средств моделирования мультиагентных систем. Ознакомление с результатами экспериментального тестирования и отладки программного комплекса. Рассмотрение методов оценки качества разработанного программного продукта.
дипломная работа [3,1 M], добавлен 27.10.2017Операция обмена данными между прикладной программой и шиной USB путем передачи буферов памяти. Основные характеристики каналов. Аппаратная часть USB. Физическая топология шины. Конструкция кабелей и коннекторов. Способы питания устройств от сети.
контрольная работа [218,4 K], добавлен 27.01.2014Разработка драйверов ядра Windows. Драйвер виртуальных устройств Windows - компьютерная программа, с помощью которой другая программа получает доступ к аппаратному обеспечению стандартным образом. Доступ к драйверам из приложений пользовательского режима.
курсовая работа [436,1 K], добавлен 25.10.2012Использование драйвера режима ядра и управляющего приложения для создания системных потоков. Имитация обработки данных и организация задержек. Разработка драйвера на языке C++. Конфигурация тестового стенда. Точность изменения задержек и работы таймера.
курсовая работа [182,4 K], добавлен 24.06.2009Проектирование информационной системы для удобного ведения учета товара. Функциональная модель предметной области. Обоснование выбора языка программирования. Описание программы, руководство пользователя. Протокол тестирования программного продукта.
курсовая работа [537,6 K], добавлен 18.09.2014Разработка программного обеспечения для микропроцессорных систем МК51, интерфейсы в системах связи, основы асинхронной связи. Этапы решения задачи на ЭВМ, принципы тестирования программ и их отладка. Расчет затрат на разработку программного продукта.
дипломная работа [270,6 K], добавлен 19.06.2010Требования к создаваемому программному модулю. Разработка необходимых алгоритмов и интерфейсов. Описание протокола SPA-BUS. Выбор языка программирования. Тестирование и документирование программного продукта. Оценка экономической эффективности программы.
дипломная работа [722,4 K], добавлен 06.07.2012Механизмы взаимодействия драйвера режима ядра и пользовательского приложения: многослойная драйверная архитектура, алгоритм сокрытия данных, взаимодействие драйвера и приложения, пользовательский интерфейс программы фильтрации доступа к файлам.
курсовая работа [1023,3 K], добавлен 23.06.2009Автоматизация учета и управления, использование тиражных программных продуктов системы "1С: Предприятие". OLE - технология управления и обмена информацией между программным интерфейсом другими приложениями. Установка среды разработки, совместимой с 1С.
курсовая работа [558,9 K], добавлен 20.03.2013