Changes to support new VFAT functions and the loader

svn path=/trunk/; revision=140
This commit is contained in:
Rex Jolliff 1998-12-30 22:48:14 +00:00
parent 6ce4528a80
commit 3244132cc7
10 changed files with 112 additions and 58 deletions

View file

@ -1946,12 +1946,14 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
PIDE_CONTROLLER_EXTENSION ControllerExtension;
// Setup Extension pointer
CHECKPOINT;
ControllerExtension = (PIDE_CONTROLLER_EXTENSION) Context;
// Handle state change if necessary
switch (ControllerExtension->TimerState)
{
case IDETimerResetWaitForBusyNegate:
CHECKPOINT;
if (!(IDEReadStatus(ControllerExtension->CommandPortBase) &
IDE_SR_BUSY))
{
@ -1962,6 +1964,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
break;
case IDETimerResetWaitForDrdyAssert:
CHECKPOINT;
if (IDEReadStatus(ControllerExtension->CommandPortBase) &
IDE_SR_DRQ)
{
@ -1988,12 +1991,14 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
// If we're counting down, then count.
if (ControllerExtension->TimerCount > 0)
{
CHECKPOINT;
ControllerExtension->TimerCount--;
// Else we'll check the state and process if necessary
}
else
{
CHECKPOINT;
switch (ControllerExtension->TimerState)
{
case IDETimerIdle:
@ -2001,6 +2006,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
case IDETimerCmdWait:
// Command timed out, reset drive and try again or fail
CHECKPOINT;
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
{
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
@ -2015,6 +2021,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
case IDETimerResetWaitForBusyNegate:
case IDETimerResetWaitForDrdyAssert:
CHECKPOINT;
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
IDEFinishOperation(ControllerExtension);

View file

@ -36,10 +36,8 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,DiskSector,Buffer);
// sectorNumber.HighPart = 0;
// sectorNumber.LowPart = DiskSector * BLOCKSIZE;
sectorNumber.LowPart=DiskSector<<9;
sectorNumber.HighPart=DiskSector>>23;
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
KeInitializeEvent(&event, NotificationEvent, FALSE);
sectorSize = BLOCKSIZE*SectorCount;
@ -84,7 +82,11 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
if (!NT_SUCCESS(status)) {
DbgPrint("IO failed!!! VFATREadSectors : Error code: %x\n", status);
DbgPrint("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
pDeviceObject,DiskSector,Buffer,sectorNumber.HighPart,sectorNumber.LowPart);
pDeviceObject,
DiskSector,
Buffer,
GET_LARGE_INTEGER_HIGH_PART(sectorNumber),
GET_LARGE_INTEGER_LOW_PART(sectorNumber));
ExFreePool(mbr);
return FALSE;
}
@ -113,8 +115,8 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,DiskSector,Buffer);
sectorNumber.HighPart = 0;
sectorNumber.LowPart = DiskSector * BLOCKSIZE;
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
KeInitializeEvent(&event, NotificationEvent, FALSE);

View file

@ -1,4 +1,4 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -105,9 +105,9 @@ NTSTATUS FsdGetFileDirectoryInformation(PFCB pFcb,
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
DeviceExt->BytesPerCluster) *
DeviceExt->BytesPerCluster;
pInfo->AllocationSize.LowPart= AllocSize;
pInfo->AllocationSize.HighPart= AllocSize >>32;
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
pInfo->FileAttributes=pFcb->entry.Attrib;
return STATUS_SUCCESS;
}
@ -138,8 +138,7 @@ NTSTATUS FsdGetFileFullDirectoryInformation(PFCB pFcb,
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
DeviceExt->BytesPerCluster) *
DeviceExt->BytesPerCluster;
pInfo->AllocationSize.LowPart= AllocSize;
pInfo->AllocationSize.HighPart= (AllocSize >>32);
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
pInfo->FileAttributes=pFcb->entry.Attrib;
// pInfo->EaSize=;
return STATUS_SUCCESS;
@ -176,8 +175,7 @@ DPRINT("sizeof %d,Length %d, BufLength %d, Next %d\n"
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
DeviceExt->BytesPerCluster) *
DeviceExt->BytesPerCluster;
pInfo->AllocationSize.LowPart= AllocSize;
pInfo->AllocationSize.HighPart= AllocSize >>32;
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
pInfo->FileAttributes=pFcb->entry.Attrib;
// pInfo->EaSize=;
for (i=0;i<8 && (pFcb->entry.Filename[i]!=' ') ;i++)

View file

@ -26,7 +26,7 @@
#include <wstring.h>
#include <ddk/cctypes.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
#include "vfat.h"
@ -657,15 +657,29 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
{
PWSTR current;
PWSTR next;
PWSTR string = FileName;
PFCB ParentFcb = NULL;
PFCB Fcb = ExAllocatePool(NonPagedPool,sizeof(FCB));
PWSTR string;
PFCB ParentFcb;
PFCB Fcb;
PFCB Temp;
NTSTATUS Status;
DPRINT("FsdOpenFile(%08lx, %08lx, %08lx)\n",
DeviceExt,
FileObject,
FileName);
CHECKPOINT;
string = FileName;
CHECKPOINT;
ParentFcb = NULL;
CHECKPOINT;
Fcb = ExAllocatePool(NonPagedPool, sizeof(FCB));
CHECKPOINT;
next = &string[0];
CHECKPOINT;
current = next+1;
CHECKPOINT;
while (next!=NULL)
{
DPRINT("current %w next %x\n",current,next);
@ -678,9 +692,11 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
*next=0;
}
CHECKPOINT;
Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
if (Status != STATUS_SUCCESS)
{
/* FIXME: should the FCB be freed here? */
return(Status);
}
Temp = Fcb;
@ -693,6 +709,7 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
Fcb = ParentFcb;
}
ParentFcb = Temp;
CHECKPOINT;
}
FileObject->FsContext = ParentFcb;
DPRINT("file opn, fcb=%x\n",ParentFcb);
@ -1014,21 +1031,33 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
* FUNCTION: Create or open a file
*/
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = Stack->FileObject;
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
NTSTATUS Status;
PDEVICE_EXTENSION DeviceExt;
DPRINT("VFAT FsdCreate...\n");
DPRINT("FsdCreate(DeviceObject %08lx, Irp %08lx)\n",
DeviceObject,
Irp);
Stack = IoGetCurrentIrpStackLocation(Irp);
CHECKPOINT;
FileObject = Stack->FileObject;
CHECKPOINT;
DeviceExt = DeviceObject->DeviceExtension;
CHECKPOINT;
Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
CHECKPOINT;
Irp->IoStatus.Status = Status;
CHECKPOINT;
Irp->IoStatus.Information = 0;
CHECKPOINT;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
CHECKPOINT;
return Status;
}
@ -1049,7 +1078,7 @@ NTSTATUS FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Length = Stack->Parameters.Write.Length;
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Offset = Stack->Parameters.Write.ByteOffset.LowPart;
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Write.ByteOffset);
Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset);
@ -1078,7 +1107,7 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Length = Stack->Parameters.Read.Length;
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Offset = Stack->Parameters.Read.ByteOffset.LowPart;
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset);
Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset,
&LengthRead);

View file

@ -5,7 +5,9 @@
OBJECTS= blockdev.o iface.o dir.o
all: $(OBJECTS)
all: vfatfsd.o
vfatfsd.o: $(OBJECTS)
$(LD) $(OBJECTS) -r -o vfatfsd.o
$(NM) --numeric-sort vfatfsd.o > vfatfsd.sym

View file

@ -17,7 +17,7 @@
#include <internal/string.h>
#include <wstring.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *************************************************************/
@ -165,13 +165,13 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
}
// DPRINT("Remainder %x\n",Remainder);
// DPRINT("Remainder %w\n",Remainder);
DPRINT("Remainder %x\n",Remainder);
DPRINT("Remainder %w\n",Remainder);
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
wstrlen(Remainder));
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
// DPRINT("FileObject->FileName.Buffer %x %w\n",
// FileObject->FileName.Buffer,FileObject->FileName.Buffer);
DPRINT("FileObject->FileName.Buffer %x %w\n",
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
}
CHECKPOINT;
@ -190,6 +190,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
KeInitializeEvent(&Event,NotificationEvent,FALSE);
DPRINT("DevObj StackSize %d\n", DeviceObject->StackSize);
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (Irp==NULL)
{

View file

@ -33,7 +33,7 @@
#include <internal/io.h>
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ****************************************************************/
@ -125,7 +125,12 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
* RETURNS: A pointer to the stack location
*/
{
return(&Irp->Stack[Irp->CurrentLocation]);
DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
Irp,
Irp->CurrentLocation,
Irp->StackCount);
return &Irp->Stack[Irp->CurrentLocation];
}
@ -144,6 +149,11 @@ PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
* RETURNS: A pointer to the stack location
*/
{
DPRINT("IoGetNextIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
Irp,
Irp->CurrentLocation,
Irp->StackCount);
assert(Irp!=NULL);
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
return(&Irp->Stack[Irp->CurrentLocation-1]);
@ -154,17 +164,22 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
* FUNCTION: Sends an IRP to the next lower driver
*/
{
NTSTATUS Status;
PDRIVER_OBJECT drv = DevObject->DriverObject;
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
DPRINT("Deviceobject %x\n",DevObject);
DPRINT("Irp %x\n",irp);
irp->Tail.Overlay.CurrentStackLocation--;
irp->CurrentLocation--;
DPRINT("Io stack address %x\n",param);
DPRINT("Function %d Routine %x\n",param->MajorFunction,
drv->MajorFunction[param->MajorFunction]);
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
Status = drv->MajorFunction[param->MajorFunction](DevObject,irp);
return Status;
}
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)

View file

@ -91,7 +91,6 @@ VOID LdrInitModuleManagment(VOID)
NTSTATUS
LdrLoadDriver(PUNICODE_STRING Filename)
{
char BlockBuffer[512];
PVOID ModuleLoadBase;
NTSTATUS Status;
HANDLE FileHandle;
@ -107,25 +106,18 @@ LdrLoadDriver(PUNICODE_STRING Filename)
0,
NULL,
NULL);
CHECKPOINT;
Status = ZwOpenFile(&FileHandle,
FILE_ALL_ACCESS,
&FileObjectAttributes,
NULL, 0, 0);
CHECKPOINT;
if (!NT_SUCCESS(Status))
{
return Status;
}
CHECKPOINT;
/* Read first block of image to determine type */
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 512, 0, 0);
if (!NT_SUCCESS(Status))
{
ZwClose(FileHandle);
return Status;
}
CHECKPOINT;
/* Get the size of the file */
Status = ZwQueryInformationFile(FileHandle,
NULL,

View file

@ -28,7 +28,7 @@
#include <ddk/ntddk.h>
#if 0
#if CHECKED
#define VALIDATE_POOL validate_kernel_pool()
#else
#define VALIDATE_POOL
@ -528,11 +528,13 @@ asmlinkage VOID ExFreePool(PVOID block)
* block = block to free
*/
{
block_hdr* blk=address_to_block(block);
OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk);
// DbgPrint("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
// ((PULONG)&block)[-1]);
block_hdr *blk = address_to_block(block);
OLD_DPRINT("ExFreePool(block %x), size %d, caller %x\n",
block,
blk->size,
((PULONG)&block)[-1]);
OLD_DPRINT("freeing block %x\n",blk);
VALIDATE_POOL;
@ -560,9 +562,9 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
block_hdr* current=NULL;
void* block;
// DbgPrint("Blocks on free list %d\n",nr_free_blocks);
// DbgPrint("Blocks on used list %d\n",nr_used_blocks);
// OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
OLD_DPRINT("Blocks on free list %d\n",nr_free_blocks);
OLD_DPRINT("Blocks on used list %d\n",nr_used_blocks);
OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
VALIDATE_POOL;
/*
@ -602,5 +604,6 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
*/
block=block_to_address(grow_kernel_pool(size));
memset(block,0,size);
return(block);
return block;
}

View file

@ -45,11 +45,16 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
*/
{
PVOID Block;
// DbgPrint("ExAllocatePool(NumberOfBytes %d) caller %x\n",
// NumberOfBytes,((PULONG)&PoolType)[-1]);
OLD_DPRINT("ExAllocatePool(NumberOfBytes %d) caller %x\n",
NumberOfBytes,
((PULONG)&PoolType)[-1]);
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,TAG_NONE);
// DbgPrint("ExAllocatePool() = %x\n",Block);
return(Block);
OLD_DPRINT("ExAllocatePool() = %x\n",Block);
return Block;
}
PVOID ExAllocatePoolWithTag(ULONG type, ULONG size, ULONG Tag)