mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
changes to support debugging of ide driver
svn path=/trunk/; revision=36
This commit is contained in:
parent
153b0ad928
commit
e8652909ce
1 changed files with 220 additions and 7 deletions
|
@ -25,14 +25,12 @@ static KEVENT event = {};
|
||||||
//static KEVENT event2;
|
//static KEVENT event2;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
/*
|
||||||
NTSTATUS TstPlaySound(void)
|
NTSTATUS TstPlaySound(void)
|
||||||
{
|
{
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
|
|
||||||
/*
|
// * Open the parallel port
|
||||||
* Open the parallel port
|
|
||||||
*/
|
|
||||||
printk("Opening Waveout\n");
|
printk("Opening Waveout\n");
|
||||||
// hfile = CreateFile("\\Device\\WaveOut",0,0,0,0,0,0);
|
// hfile = CreateFile("\\Device\\WaveOut",0,0,0,0,0,0);
|
||||||
if (hfile == NULL)
|
if (hfile == NULL)
|
||||||
|
@ -107,7 +105,7 @@ void TstGeneralWrite()
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void TstParallelPortWrite()
|
void TstParallelPortWrite()
|
||||||
{
|
{
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
|
@ -119,7 +117,7 @@ void TstParallelPortWrite()
|
||||||
DbgPrint("Failed to open parallel port\n");
|
DbgPrint("Failed to open parallel port\n");
|
||||||
}
|
}
|
||||||
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
|
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TstKeyboardRead()
|
void TstKeyboardRead()
|
||||||
{
|
{
|
||||||
|
@ -154,13 +152,228 @@ void TstKeyboardRead()
|
||||||
// DbgPrint("%c",key[1].AsciiChar);
|
// DbgPrint("%c",key[1].AsciiChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/* IDE TEST STUFF ***********************************************************/
|
||||||
|
|
||||||
|
typedef struct _BOOT_PARAMETERS {
|
||||||
|
WORD BytesBerSector;
|
||||||
|
BYTE SectorsPerAllocationUnit;
|
||||||
|
WORD ReservedSectorCount;
|
||||||
|
BYTE FATCount;
|
||||||
|
WORD RootDirEntryCount;
|
||||||
|
WORD TotalSectorCount;
|
||||||
|
BYTE MediaDescriptor;
|
||||||
|
WORD SectorsPerFAT;
|
||||||
|
WORD SectorsPerTrack;
|
||||||
|
WORD HeadCount;
|
||||||
|
DWORD HiddenSectorCount;
|
||||||
|
DWORD TotalSectorsInLogicalVolume;
|
||||||
|
} __attribute__ ((packed)) BOOT_PARAMETERS, __attribute__ ((packed)) *PBOOT_PARAMETERS;
|
||||||
|
|
||||||
|
typedef struct _BOOT_BLOCK {
|
||||||
|
char JumpInstruction[3];
|
||||||
|
char OEMName[8];
|
||||||
|
BOOT_PARAMETERS BootParameters;
|
||||||
|
BYTE DriveNumber;
|
||||||
|
BYTE Reserved1;
|
||||||
|
BYTE ExtBootSignatureRecord;
|
||||||
|
DWORD BinaryVolumeID;
|
||||||
|
char VolumeLabel[11];
|
||||||
|
char Reserved2[8];
|
||||||
|
char Bootstrap[512 - 61];
|
||||||
|
} __attribute__ ((packed)) BOOT_BLOCK, __attribute__ ((packed)) *PBOOT_BLOCK;
|
||||||
|
|
||||||
|
typedef struct _ROOT_DIR_ENTRY {
|
||||||
|
char Filename[8];
|
||||||
|
char Extension[3];
|
||||||
|
char FileAttribute;
|
||||||
|
char Reserved1[10];
|
||||||
|
WORD ModifiedTime;
|
||||||
|
WORD ModifiedDate;
|
||||||
|
WORD StartingCluster;
|
||||||
|
DWORD FileSize;
|
||||||
|
} __attribute__ ((packed)) ROOT_DIR_ENTRY;
|
||||||
|
|
||||||
|
#define ENTRIES_PER_BLOCK (512 / sizeof(ROOT_DIR_ENTRY))
|
||||||
|
|
||||||
|
void TstIDERead(void)
|
||||||
|
{
|
||||||
|
BOOLEAN TestFailed;
|
||||||
|
int Entry, i;
|
||||||
|
HANDLE FileHandle;
|
||||||
|
NTSTATUS Status;
|
||||||
|
LARGE_INTEGER BlockOffset;
|
||||||
|
ANSI_STRING AnsiDeviceName;
|
||||||
|
UNICODE_STRING UnicodeDeviceName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
char SectorBuffer[512];
|
||||||
|
PBOOT_BLOCK BootBlock;
|
||||||
|
ROOT_DIR_ENTRY DirectoryBlock[ENTRIES_PER_BLOCK];
|
||||||
|
|
||||||
|
DbgPrint("IDE Read Test\n");
|
||||||
|
TestFailed = FALSE;
|
||||||
|
|
||||||
|
/* open the first partition */
|
||||||
|
DbgPrint("Opening Partition1\n");
|
||||||
|
RtlInitAnsiString(&AnsiDeviceName, "\\Device\\HardDrive0\\Partition0");
|
||||||
|
RtlAnsiStringToUnicodeString(&UnicodeDeviceName, &AnsiDeviceName, TRUE);
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&UnicodeDeviceName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = ZwOpenFile(&FileHandle, 0, &ObjectAttributes, NULL, 0, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint("Failed to open partition1\n");
|
||||||
|
TestFailed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the boot block */
|
||||||
|
if (!TestFailed)
|
||||||
|
{
|
||||||
|
DbgPrint("Reading boot block from Partition1\n");
|
||||||
|
RtlZeroMemory(SectorBuffer, sizeof(SectorBuffer));
|
||||||
|
DbgPrint("addr %x\n", SectorBuffer);
|
||||||
|
Status = ZwReadFile(FileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
SectorBuffer,
|
||||||
|
sizeof(SectorBuffer),
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
if (Status != STATUS_SUCCESS /* !NT_SUCCESS(Status) */)
|
||||||
|
{
|
||||||
|
DbgPrint("Failed to read book block from partition1 status:%x\n", Status);
|
||||||
|
TestFailed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* %%% Check for valid boot block signature */
|
||||||
|
|
||||||
|
/* Spew info about boot block */
|
||||||
|
if (!TestFailed)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
if (!(i % 16))
|
||||||
|
{
|
||||||
|
DbgPrint("\n%04d: ", i);
|
||||||
|
}
|
||||||
|
DbgPrint("%02x ", (unsigned char)SectorBuffer[i]);
|
||||||
|
}
|
||||||
|
DbgPrint("\n");
|
||||||
|
|
||||||
|
BootBlock = (PBOOT_BLOCK) SectorBuffer;
|
||||||
|
DbgPrint("boot block on Partition1:\n");
|
||||||
|
DbgPrint(" OEM Name: %.8s Bytes/Sector:%d Sectors/Cluster:%d\n",
|
||||||
|
BootBlock->OEMName,
|
||||||
|
BootBlock->BootParameters.BytesBerSector,
|
||||||
|
BootBlock->BootParameters.SectorsPerAllocationUnit);
|
||||||
|
DbgPrint(" ReservedSectors:%d FATs:%d RootDirEntries:%d\n",
|
||||||
|
BootBlock->BootParameters.ReservedSectorCount,
|
||||||
|
BootBlock->BootParameters.FATCount,
|
||||||
|
BootBlock->BootParameters.RootDirEntryCount);
|
||||||
|
DbgPrint(" TotalSectors:%d MediaDescriptor:%d Sectors/FAT:%d\n",
|
||||||
|
BootBlock->BootParameters.TotalSectorCount,
|
||||||
|
BootBlock->BootParameters.MediaDescriptor,
|
||||||
|
BootBlock->BootParameters.SectorsPerFAT);
|
||||||
|
DbgPrint(" Sectors/Track:%d Heads:%d HiddenSectors:%d\n",
|
||||||
|
BootBlock->BootParameters.SectorsPerTrack,
|
||||||
|
BootBlock->BootParameters.HeadCount,
|
||||||
|
BootBlock->BootParameters.HiddenSectorCount);
|
||||||
|
DbgPrint(" VolumeLabel:%.11s\n", BootBlock->VolumeLabel);
|
||||||
|
}
|
||||||
|
for(;;);
|
||||||
|
|
||||||
|
/* Read the first root directory block */
|
||||||
|
if (!TestFailed)
|
||||||
|
{
|
||||||
|
DbgPrint("Reading rootdir block from Partition1\n");
|
||||||
|
BlockOffset.HighPart = 0;
|
||||||
|
BlockOffset.LowPart = BootBlock->BootParameters.ReservedSectorCount * 512 +
|
||||||
|
BootBlock->BootParameters.FATCount *
|
||||||
|
BootBlock->BootParameters.SectorsPerFAT * 512;
|
||||||
|
Status = ZwReadFile(FileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
DirectoryBlock,
|
||||||
|
sizeof(DirectoryBlock),
|
||||||
|
&BlockOffset,
|
||||||
|
0);
|
||||||
|
if (Status != STATUS_SUCCESS /* !NT_SUCCESS(Status) */)
|
||||||
|
{
|
||||||
|
DbgPrint("Failed to read root directory block from partition1\n");
|
||||||
|
TestFailed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print the contents */
|
||||||
|
if (!TestFailed)
|
||||||
|
{
|
||||||
|
for (Entry = 0; Entry < ENTRIES_PER_BLOCK; Entry++)
|
||||||
|
{
|
||||||
|
switch (DirectoryBlock[Entry].Filename[0])
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
DbgPrint("End of Directory.\n");
|
||||||
|
Entry = ENTRIES_PER_BLOCK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x05:
|
||||||
|
DbgPrint(" FILE: %c%.7s.%.3s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
|
||||||
|
0xe5,
|
||||||
|
&DirectoryBlock[Entry].Filename[1],
|
||||||
|
DirectoryBlock[Entry].Extension,
|
||||||
|
DirectoryBlock[Entry].FileAttribute,
|
||||||
|
DirectoryBlock[Entry].ModifiedTime,
|
||||||
|
DirectoryBlock[Entry].ModifiedDate,
|
||||||
|
DirectoryBlock[Entry].StartingCluster,
|
||||||
|
DirectoryBlock[Entry].FileSize);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x2e:
|
||||||
|
DbgPrint(" ALIAS: %.8s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
|
||||||
|
&DirectoryBlock[Entry].Filename[1],
|
||||||
|
DirectoryBlock[Entry].FileAttribute,
|
||||||
|
DirectoryBlock[Entry].ModifiedTime,
|
||||||
|
DirectoryBlock[Entry].ModifiedDate,
|
||||||
|
DirectoryBlock[Entry].StartingCluster,
|
||||||
|
DirectoryBlock[Entry].FileSize);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xe5:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DbgPrint(" FILE: %.8s.%.3s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
|
||||||
|
&DirectoryBlock[Entry].Filename[1],
|
||||||
|
DirectoryBlock[Entry].Extension,
|
||||||
|
DirectoryBlock[Entry].FileAttribute,
|
||||||
|
DirectoryBlock[Entry].ModifiedTime,
|
||||||
|
DirectoryBlock[Entry].ModifiedDate,
|
||||||
|
DirectoryBlock[Entry].StartingCluster,
|
||||||
|
DirectoryBlock[Entry].FileSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (FileHandle != NULL)
|
||||||
|
{
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TstBegin()
|
void TstBegin()
|
||||||
{
|
{
|
||||||
// TstGeneralWrite();
|
// TstGeneralWrite();
|
||||||
// TstThreadSupport();
|
// TstThreadSupport();
|
||||||
TstKeyboardRead();
|
// TstKeyboardRead();
|
||||||
|
TstIDERead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue