📄 test_luojincdriv01.cpp
字号:
printf("Example:\n");
printf(" Test_LuojincDriv01 r 32 w 32\n");
printf(" read 32 bytes, then write 32 bytes\n");
Exit(1);
}
#define IOCTL_INBUF_SIZE 512
#define IOCTL_OUTBUF_SIZE 512
//=== Parameterized IOCTL Example ===
//void Test_IOCTL_PARAMETERIZED(int nVal, ULONG dwVal)
//{
// Function body same as other IOCTL handlers, with command line
// parameters 'nVal' and 'dwVal' available as input.
//}
////////////////////////////////////////////////////////////////////////
// Test_ReadMemConfigReg
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_ReadMemConfigReg(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (ReadMemConfigReg) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
ReadMemConfigReg,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_ReadIoConfigReg
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_ReadIoConfigReg(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (ReadIoConfigReg) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
ReadIoConfigReg,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_WriteMemConfigReg
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_WriteMemConfigReg(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (WriteMemConfigReg) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
WriteMemConfigReg,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_WriteIoConfigReg
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_WriteIoConfigReg(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (WriteIoConfigReg) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
WriteIoConfigReg,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_ReadLocalSpace0
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_ReadLocalSpace0(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (ReadLocalSpace0) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
ReadLocalSpace0,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_ReadLocalSpace1
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_ReadLocalSpace1(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (ReadLocalSpace1) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
ReadLocalSpace1,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_WriteLocalSpace0
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_WriteLocalSpace0(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (WriteLocalSpace0) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
WriteLocalSpace0,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_WriteLocalSpace1
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_WriteLocalSpace1(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (WriteLocalSpace1) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
WriteLocalSpace1,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_GetDriverInfo
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_GetDriverInfo(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (GetDriverInfo) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
GetDriverInfo,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_SetDriverInfo
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_SetDriverInfo(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (SetDriverInfo) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
SetDriverInfo,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// ShowIoctlValues
//
// Print list of IO Control Code values for usage display
//
void ShowIoctlValues(void)
{
int i;
for (i=0; i<N_IOCODES; i++)
{
if (i==0)
printf( " IO control code index\n");
printf( " %d is code %s [%x]\n", i, IOnames[i], IOcodes[i]);
//=== Parameterized IOCTL Example ===
// if (IOcodes[i] == IOCTL_PARAMETERIZED)
// {
// printf( " and has two arguments: <arg1 desc.> <arg1 desc.>\n");
// printf( " Example: i %d <IOCTL index> <ex. arg1> <ex. arg2>\n", i);
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -