summaryrefslogtreecommitdiff
path: root/general/PLX9x5x/test
diff options
context:
space:
mode:
authorkarlf <[email protected]>2016-08-11 13:28:13 -0700
committerkarlf <[email protected]>2016-08-11 13:28:13 -0700
commit96eb96dfb613e4c745db6bd1f53a92fe7e2290fc (patch)
treead5f3ede5cbcd6b598677ce41bcf8318471bdd92 /general/PLX9x5x/test
parent687b274aa38fd05c8c26e3068932121876d7f745 (diff)
Updated for "Windows 10 Anniversary Update" (Version 1607)
Diffstat (limited to 'general/PLX9x5x/test')
-rw-r--r--general/PLX9x5x/test/plx.cpp113
-rw-r--r--general/PLX9x5x/test/plx.hpp30
-rw-r--r--general/PLX9x5x/test/plx.vcxproj4
-rw-r--r--general/PLX9x5x/test/plx.vcxproj.Filters6
4 files changed, 112 insertions, 41 deletions
diff --git a/general/PLX9x5x/test/plx.cpp b/general/PLX9x5x/test/plx.cpp
index c5bae510..fb6681ea 100644
--- a/general/PLX9x5x/test/plx.cpp
+++ b/general/PLX9x5x/test/plx.cpp
@@ -332,47 +332,54 @@ void
PLX::Menu()
{
int menu = -1;
+ const char* menuItems[MENU_MAX];
+ BOOL status, toggle;
- while(menu != 0 && pDeviceInterfaceDetail) {
- printf("\n"
- " 1- Read from device\n"
- " 2- Write from device\n"
- " 3- Read/Write from device\n"
- " 4- Read/Write Thread Test\n"
- " 5- Select new device\n"
- " 6- Change Buffer Size\n"
- " 7- Compare Read/Write Buffers\n"
- " 8- Display Read/Write Buffers\n"
- " 9- Change Thread Lifetime\n"
- "10- Command Line Options\n"
- " 0- Quit\n");
+ menuItems[MENU_TEST] = "Quit";
+ menuItems[READ_TEST] = "Read from device";
+ menuItems[WRITE_TEST] = "Write to device";
+ menuItems[READ_WRITE_TEST] = "Read/Write from device";
+ menuItems[THREAD_TEST] = "Read/Write Thread Test";
+ menuItems[DEVICE_PATH] = "Select new device";
+ menuItems[SET_SIZE] = "Change Buffer Size";
+ menuItems[COMPARE_BUFFERS] = "Compare Read/Write Buffers";
+ menuItems[DISPLAY_BUFFERS] = "Display Read/Write Buffers";
+ menuItems[THREAD_TIME] = "Change Thread Lifetime";
+ menuItems[SINGLE_TRANSFER_TOGGLE] = "Toggle single transfer requirement";
+ menuItems[COMMAND_LINE] = "Command Line Options";
- if (scanf_s("%d", &menu) == 0) {
+ while(menu != MENU_TEST && pDeviceInterfaceDetail) {
+ for (int i = MENU_TEST + 1; i < MENU_MAX; i++) {
+ printf("\n%2x - %s", i, menuItems[i]);
+ }
+ printf("\n%2x - %s\n", MENU_TEST, menuItems[MENU_TEST]);
+
+ if (scanf_s("%x", &menu) == 0) {
break;
}
switch(menu) {
- case READ_TEST: // 1
+ case READ_TEST:
ReadTest();
break;
- case WRITE_TEST: // 2
+ case WRITE_TEST:
WriteTest();
break;
- case READ_WRITE_TEST: // 3
+ case READ_WRITE_TEST:
ReadWriteTest();
break;
- case THREAD_TEST: // 4
+ case THREAD_TEST:
ThreadedReadWriteTest();
break;
- case DEVICE_PATH: // 5
+ case DEVICE_PATH:
GetDevicePath();
break;
- case SET_SIZE: // 6
+ case SET_SIZE:
ULONG size;
printf("\nEnter new buffer size: ");
if (scanf_s("%u", &size) != 0) {
@@ -380,22 +387,34 @@ PLX::Menu()
}
break;
- case COMPARE_BUFFERS: // 7
+ case COMPARE_BUFFERS:
CompareReadWriteBuffers();
break;
- case DISPLAY_BUFFERS: // 8
+ case DISPLAY_BUFFERS:
DisplayReadWriteBuffers();
break;
- case THREAD_TIME: // 9
+ case THREAD_TIME:
printf("\nEnter new Thread Lifetime (ms): ");
if (scanf_s("%u", &ThreadTimer) == 0) {
break;
}
break;
- case COMMAND_LINE: // 10
+ case SINGLE_TRANSFER_TOGGLE:
+ status = SendSingleTransferIoctl(&toggle);
+ if (status) {
+ printf("Single transfer requirement is %s\n",
+ toggle ? "on" : "off");
+ }
+ else {
+ printf("Could not toggle the single transfer "
+ "requirement\n");
+ }
+ break;
+
+ case COMMAND_LINE:
printf("Command Line Options\n"
" Set Read Buffer Size: '/rb=xx'\n"
" Set Write Buffer Size: '/wb=xx'\n"
@@ -549,6 +568,13 @@ PLX::ThreadedReadWriteTest()
printf("WaitForMultipleObjects[%d] error %u\n", i, error);
}
}
+
+ if (!error) {
+ //
+ // Reset the TimeUp flag
+ //
+ g_TimeUp = 0;
+ }
}
if (Contexts) {
@@ -779,6 +805,44 @@ PLX::SetBufferSizes(ULONG size)
}
BOOL
+PLX::SendSingleTransferIoctl(BOOL* Toggle)
+{
+ BOOL status = TRUE;
+ UCHAR outBuffer = 0;
+ DWORD bytesReceived = 0;
+
+ if (hDevice == INVALID_HANDLE_VALUE) {
+ status = GetDeviceHandle();
+ if (status == FALSE) {
+ goto Done;
+ }
+ }
+
+ status = DeviceIoControl(hDevice,
+ IOCTL_PLX9X5X_TOGGLE_SINGLE_TRANSFER,
+ NULL,
+ 0,
+ &outBuffer,
+ sizeof(outBuffer),
+ &bytesReceived,
+ NULL);
+ if (status == FALSE || bytesReceived != sizeof(outBuffer)) {
+ printf("DeviceIoControl failed 0x%x\n", GetLastError());
+ goto Done;
+ }
+
+ *Toggle = outBuffer;
+
+Done:
+ if (hDevice != INVALID_HANDLE_VALUE) {
+ CloseHandle(hDevice);
+ hDevice = INVALID_HANDLE_VALUE;
+ }
+
+ return status;
+}
+
+BOOL
PLX::GetDevicePath()
{
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
@@ -1102,3 +1166,4 @@ PLX::SetThreadLifeTime(ULONG time)
ThreadTimer = time;
}
+
diff --git a/general/PLX9x5x/test/plx.hpp b/general/PLX9x5x/test/plx.hpp
index fe87fea1..10147df7 100644
--- a/general/PLX9x5x/test/plx.hpp
+++ b/general/PLX9x5x/test/plx.hpp
@@ -20,6 +20,7 @@ Environment:
#pragma once
#include <windows.h>
+#include <winioctl.h>
#include <setupapi.h>
#include <stdio.h>
@@ -52,19 +53,21 @@ typedef struct _THREAD_CONTEXT
} THREAD_CONTEXT, *PTHREAD_CONTEXT;
-typedef enum {
+enum {
- MENU_TEST = 0,
- READ_TEST = 1,
- WRITE_TEST = 2,
- READ_WRITE_TEST = 3,
- THREAD_TEST = 4,
- DEVICE_PATH = 5,
- SET_SIZE = 6,
- COMPARE_BUFFERS = 7,
- DISPLAY_BUFFERS = 8,
- THREAD_TIME = 9,
- COMMAND_LINE = 10,
+ MENU_TEST,
+ READ_TEST,
+ WRITE_TEST,
+ READ_WRITE_TEST,
+ THREAD_TEST,
+ DEVICE_PATH,
+ SET_SIZE,
+ COMPARE_BUFFERS,
+ DISPLAY_BUFFERS,
+ THREAD_TIME,
+ SINGLE_TRANSFER_TOGGLE,
+ COMMAND_LINE,
+ MENU_MAX
} COMMAND;
@@ -105,6 +108,9 @@ public:
BOOL
SetBufferSizes(ULONG size);
+ BOOL
+ SendSingleTransferIoctl(BOOL* Toggle);
+
void
DisplayReadWriteBuffers();
diff --git a/general/PLX9x5x/test/plx.vcxproj b/general/PLX9x5x/test/plx.vcxproj
index f5aee498..3c4519ff 100644
--- a/general/PLX9x5x/test/plx.vcxproj
+++ b/general/PLX9x5x/test/plx.vcxproj
@@ -19,11 +19,11 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{D12B451F-9593-4418-8E9D-3876568F0735}</ProjectGuid>
+ <ProjectGuid>{EFB89CBA-931F-426E-A7C0-50374FA9EA58}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{14470144-508A-4DC0-A4FB-05B235920C7D}</SampleGuid>
+ <SampleGuid>{C12C9771-61BE-4B27-83FF-C088E9B0307F}</SampleGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
diff --git a/general/PLX9x5x/test/plx.vcxproj.Filters b/general/PLX9x5x/test/plx.vcxproj.Filters
index 836927a3..808b6416 100644
--- a/general/PLX9x5x/test/plx.vcxproj.Filters
+++ b/general/PLX9x5x/test/plx.vcxproj.Filters
@@ -3,15 +3,15 @@
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{000E7888-9A7D-4186-A5B1-CD11AABC5214}</UniqueIdentifier>
+ <UniqueIdentifier>{297D236E-3E7C-4989-B3A0-0E9B4687ED03}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{C8A54ADD-C416-4801-951A-201A6C356E22}</UniqueIdentifier>
+ <UniqueIdentifier>{59B25362-CF9F-414A-ADBE-67FC03BEF70D}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{A98EC5F5-DB3F-4CFD-8487-F6901096E6D6}</UniqueIdentifier>
+ <UniqueIdentifier>{8C28172C-2543-4814-83C6-80CC3DDD1EE4}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>