mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 17:01:28 +00:00
added timer test routines
svn path=/trunk/; revision=80
This commit is contained in:
parent
8b29e69d3d
commit
a3fbbaa42d
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include <in.h>
|
#include <in.h>
|
||||||
|
|
||||||
|
#define IDE_SECTOR_SZ 512
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
static KEVENT event = {};
|
static KEVENT event = {};
|
||||||
|
@ -217,20 +219,21 @@ typedef struct _ROOT_DIR_ENTRY {
|
||||||
void TstIDERead(void)
|
void TstIDERead(void)
|
||||||
{
|
{
|
||||||
BOOLEAN TestFailed;
|
BOOLEAN TestFailed;
|
||||||
int Entry, i, j;
|
int Entry, i, j, BufferSize;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
LARGE_INTEGER BlockOffset;
|
LARGE_INTEGER BlockOffset;
|
||||||
ANSI_STRING AnsiDeviceName;
|
ANSI_STRING AnsiDeviceName;
|
||||||
UNICODE_STRING UnicodeDeviceName;
|
UNICODE_STRING UnicodeDeviceName;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
// static char SectorBuffer2[512 ];
|
char *SectorBuffer;
|
||||||
static char SectorBuffer[512 * 10];
|
|
||||||
PBOOT_BLOCK BootBlock;
|
PBOOT_BLOCK BootBlock;
|
||||||
ROOT_DIR_ENTRY DirectoryBlock[ENTRIES_PER_BLOCK];
|
ROOT_DIR_ENTRY DirectoryBlock[ENTRIES_PER_BLOCK];
|
||||||
|
|
||||||
DbgPrint("IDE Read Test\n");
|
DbgPrint("IDE Read Test\n");
|
||||||
TestFailed = FALSE;
|
TestFailed = FALSE;
|
||||||
|
BufferSize = IDE_SECTOR_SZ * 300;
|
||||||
|
SectorBuffer = ExAllocatePool(NonPagedPool, BufferSize);
|
||||||
|
|
||||||
/* open the first partition */
|
/* open the first partition */
|
||||||
DbgPrint("Opening Partition1\n");
|
DbgPrint("Opening Partition1\n");
|
||||||
|
@ -241,7 +244,12 @@ static char SectorBuffer[512 * 10];
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
Status = ZwOpenFile(&FileHandle, 0, &ObjectAttributes, NULL, 0, 0);
|
Status = ZwOpenFile(&FileHandle,
|
||||||
|
FILE_ALL_ACCESS,
|
||||||
|
&ObjectAttributes,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
FILE_SYNCHRONOUS_IO_ALERT);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to open partition1\n");
|
DbgPrint("Failed to open partition1\n");
|
||||||
|
@ -374,55 +382,58 @@ static char SectorBuffer[512 * 10];
|
||||||
if (!TestFailed)
|
if (!TestFailed)
|
||||||
{
|
{
|
||||||
DbgPrint("Reading data from blocks 10000-4 from Partition1\n");
|
DbgPrint("Reading data from blocks 10000-4 from Partition1\n");
|
||||||
RtlFillMemory(SectorBuffer, sizeof(SectorBuffer), 0xea);
|
RtlFillMemory(SectorBuffer, BufferSize, 0xea);
|
||||||
BlockOffset.HighPart = 0;
|
BlockOffset.HighPart = 0;
|
||||||
BlockOffset.LowPart = 10000 * 512;
|
BlockOffset.LowPart = 10000 * IDE_SECTOR_SZ;
|
||||||
Status = ZwReadFile(FileHandle,
|
Status = ZwReadFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
SectorBuffer,
|
SectorBuffer,
|
||||||
512 * 5,
|
BufferSize,
|
||||||
&BlockOffset,
|
&BlockOffset,
|
||||||
0);
|
0);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to read blocks 10000-4 from partition1 status:%x\n",
|
DbgPrint("Failed to read %d bytes of data to offset 10000 from partition1 status:%x\n",
|
||||||
|
BufferSize,
|
||||||
Status);
|
Status);
|
||||||
TestFailed = TRUE;
|
TestFailed = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (j = 0; j < 10; j++)
|
DbgPrint("%d bytes read from offset 10000 of partition1\n", BufferSize);
|
||||||
|
for (j = 0; j < BufferSize; j += IDE_SECTOR_SZ)
|
||||||
{
|
{
|
||||||
DbgPrint("%04x: ", j * 256);
|
DbgPrint("%02x", (unsigned char)SectorBuffer[j]);
|
||||||
for (i = 0; i < 16; i++)
|
SectorBuffer[j]++;
|
||||||
|
if (((j / IDE_SECTOR_SZ + 1) % 30) == 0)
|
||||||
{
|
{
|
||||||
DbgPrint("%02x ", (unsigned char)SectorBuffer[j * 256 + i]);
|
DbgPrint("\n");
|
||||||
SectorBuffer[j * 256 + i]++;
|
|
||||||
}
|
}
|
||||||
DbgPrint("\n");
|
|
||||||
}
|
}
|
||||||
//for(;;);
|
DbgPrint("\n");
|
||||||
|
//RtlZeroMemory(SectorBuffer, BufferSize);
|
||||||
Status = ZwWriteFile(FileHandle,
|
Status = ZwWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
SectorBuffer,
|
SectorBuffer,
|
||||||
512 * 5,
|
BufferSize,
|
||||||
&BlockOffset,
|
&BlockOffset,
|
||||||
0);
|
0);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to write blocks 10000-4 to partition1 status:%x\n",
|
DbgPrint("Failed to write %d bytes of data to offset 10000 of partition1 status:%x\n",
|
||||||
|
BufferSize,
|
||||||
Status);
|
Status);
|
||||||
TestFailed = TRUE;
|
TestFailed = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("Block written\n");
|
DbgPrint("%d bytes written\n", BufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,6 +492,44 @@ TstKeyboard(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int TTcnt = 0;
|
||||||
|
|
||||||
|
VOID TstTimerDpc(struct _KDPC* Dpc,
|
||||||
|
PVOID DeferredContext,
|
||||||
|
PVOID SystemArgument1,
|
||||||
|
PVOID SystemArgument2)
|
||||||
|
{
|
||||||
|
TTcnt++;
|
||||||
|
|
||||||
|
DPRINT("Timer DPC cnt:%d\n", TTcnt);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TstTimer(void)
|
||||||
|
{
|
||||||
|
PIO_TIMER Timer = ExAllocatePool(NonPagedPool,sizeof(IO_TIMER));
|
||||||
|
long long int lli = -10000000;
|
||||||
|
LARGE_INTEGER li = *(LARGE_INTEGER *)&lli;
|
||||||
|
|
||||||
|
CHECKPOINT;
|
||||||
|
KeInitializeTimer(&Timer->timer);
|
||||||
|
CHECKPOINT;
|
||||||
|
KeInitializeDpc(&Timer->dpc, TstTimerDpc, NULL);
|
||||||
|
CHECKPOINT;
|
||||||
|
KeSetTimerEx(&Timer->timer,
|
||||||
|
li,
|
||||||
|
1000,
|
||||||
|
&Timer->dpc);
|
||||||
|
CHECKPOINT;
|
||||||
|
while (TTcnt < 100)
|
||||||
|
;
|
||||||
|
CHECKPOINT;
|
||||||
|
KeCancelTimer(&Timer->timer);
|
||||||
|
CHECKPOINT;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TstBegin()
|
void TstBegin()
|
||||||
{
|
{
|
||||||
ExExecuteShell();
|
ExExecuteShell();
|
||||||
|
@ -491,5 +540,6 @@ void TstBegin()
|
||||||
// TstIDERead();
|
// TstIDERead();
|
||||||
// TstKeyboardRead();
|
// TstKeyboardRead();
|
||||||
// TstShell();
|
// TstShell();
|
||||||
|
// TstTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue