From c6a3ef9f7ec6ada6ef4d529e552d51e34a00526f Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Tue, 22 Jul 2008 05:31:24 +0000 Subject: [PATCH] - Build vfatfs instead of CDFS. - Load vfatfs instead of CDFS. - Implement code in the ramdisk driver to handle both ISO and FAT ramdisks. Don't know what the big deal with support ISO ramdisks was supposed to be, when our ramdisk is FAT, and dealing with FAT is a lot easier than CDFS (no TOC emulation and other rubbish that was added). svn path=/trunk/; revision=34655 --- reactos/ReactOS-arm.rbuild | 4 +- reactos/boot/bootdata/hivesys_arm.inf | 12 +- .../drivers/storage/class/ramdisk/ramdisk.c | 142 +++++++++++++----- 3 files changed, 116 insertions(+), 42 deletions(-) diff --git a/reactos/ReactOS-arm.rbuild b/reactos/ReactOS-arm.rbuild index 6fb0a76fcd5..3cfab3d854a 100644 --- a/reactos/ReactOS-arm.rbuild +++ b/reactos/ReactOS-arm.rbuild @@ -153,8 +153,8 @@ - - + + diff --git a/reactos/boot/bootdata/hivesys_arm.inf b/reactos/boot/bootdata/hivesys_arm.inf index 28150a83265..e183d6f04d6 100644 --- a/reactos/boot/bootdata/hivesys_arm.inf +++ b/reactos/boot/bootdata/hivesys_arm.inf @@ -762,12 +762,12 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Wow","",0x00000000,"" ; PNP Root device HKLM,"SYSTEM\CurrentControlSet\Enum\HTREE\ROOT\0","",0x00000000,"" -; Cdfs (ISO96660) filesystem driver -HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","ErrorControl",0x00010001,0x00000000 -HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","Group",0x00000000,"File System" -HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","ImagePath",0x00020000,"system32\drivers\cdfs.sys" -HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","Start",0x00010001,0x00000000 -HKLM,"SYSTEM\CurrentControlSet\Services\Cdfs","Type",0x00010001,0x00000002 +; Virtual FAT filesystem driver +HKLM,"SYSTEM\CurrentControlSet\Services\fastfat","ErrorControl",0x00010001,0x00000000 +HKLM,"SYSTEM\CurrentControlSet\Services\fastfat","Group",0x00000000,"Boot File System" +HKLM,"SYSTEM\CurrentControlSet\Services\fastfat","ImagePath",0x00020000,"system32\drivers\fastfat.sys" +HKLM,"SYSTEM\CurrentControlSet\Services\fastfat","Start",0x00010001,0x00000000 +HKLM,"SYSTEM\CurrentControlSet\Services\fastfat","Type",0x00010001,0x00000002 ; RAM Disk class driver HKLM,"SYSTEM\CurrentControlSet\Services\Disk","ErrorControl",0x00010001,0x00000000 diff --git a/reactos/drivers/storage/class/ramdisk/ramdisk.c b/reactos/drivers/storage/class/ramdisk/ramdisk.c index 5aa3a4e09dd..159532b5456 100644 --- a/reactos/drivers/storage/class/ramdisk/ramdisk.c +++ b/reactos/drivers/storage/class/ramdisk/ramdisk.c @@ -23,6 +23,7 @@ #include #include #include +#include "../../../filesystems/fs_rec/fs_rec.h" #include #define NDEBUG #include @@ -265,6 +266,31 @@ QueryParameters(IN PUNICODE_STRING RegistryPath) } } +PVOID +NTAPI +RamdiskMapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension, + IN LARGE_INTEGER Offset, + IN ULONG Length, + OUT PULONG OutputLength) +{ + DPRINT1("Mapping %lx bytes at %I64x\n", Length, Offset.QuadPart); + UNIMPLEMENTED; + while (TRUE); + return NULL; +} + +PVOID +NTAPI +RamdiskUnmapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension, + IN PVOID BaseAddress, + IN LARGE_INTEGER Offset, + IN ULONG Length) +{ + UNIMPLEMENTED; + while (TRUE); + return NULL; +} + NTSTATUS NTAPI RamdiskCreateDiskDevice(IN PRAMDISK_BUS_EXTENSION DeviceExtension, @@ -279,6 +305,10 @@ RamdiskCreateDiskDevice(IN PRAMDISK_BUS_EXTENSION DeviceExtension, PVOID Buffer; WCHAR LocalBuffer[16]; UNICODE_STRING SymbolicLinkName, DriveString, GuidString, DeviceName; + PPACKED_BIOS_PARAMETER_BLOCK Parameters; + ULONG BytesPerSector, SectorsPerTrack, Heads, BytesRead; + PVOID BaseAddress; + LARGE_INTEGER CurrentOffset; // // Check if we're a CDROM-type RAM disk @@ -380,7 +410,8 @@ RamdiskCreateDiskDevice(IN PRAMDISK_BUS_EXTENSION DeviceExtension, Status = IoCreateDevice(DeviceExtension->DeviceObject->DriverObject, sizeof(RAMDISK_DRIVE_EXTENSION), &DeviceName, - FILE_DEVICE_CD_ROM, + (Input->Options.ExportAsCd) ? + FILE_DEVICE_CD_ROM : FILE_DEVICE_DISK, 0, 0, &DeviceObject); @@ -505,18 +536,86 @@ RamdiskCreateDiskDevice(IN PRAMDISK_BUS_EXTENSION DeviceExtension, GuidString.Buffer = NULL; // - // Only support ISO stuff for now + // Check if this is an ISO boot, or a registry ram drive // - ASSERT(Input->Options.ExportAsCd == TRUE); - ASSERT(Input->DiskType == FILE_DEVICE_CD_ROM_FILE_SYSTEM); + if (!(Input->Options.ExportAsCd) && + (Input->DiskType == FILE_DEVICE_CD_ROM_FILE_SYSTEM)) + { + // + // Not an ISO boot, but it's a boot FS -- map it to figure out the + // drive settings + // + CurrentOffset.QuadPart = 0; + BaseAddress = RamdiskMapPages(DriveExtension, + CurrentOffset, + PAGE_SIZE, + &BytesRead); + if (BaseAddress) + { + // + // Get the data + // + Parameters = (PPACKED_BIOS_PARAMETER_BLOCK)BaseAddress; + BytesPerSector = Parameters->BytesPerSector[0]; + SectorsPerTrack = Parameters->SectorsPerTrack[0]; + Heads = Parameters->Heads[0]; + + // + // Save it + // + DriveExtension->BytesPerSector = BytesPerSector; + DriveExtension->SectorsPerTrack = SectorsPerTrack; + DriveExtension->NumberOfHeads = Heads; + + // + // Unmap now + // + CurrentOffset.QuadPart = 0; + RamdiskUnmapPages(DriveExtension, + BaseAddress, + CurrentOffset, + BytesRead); + } + else + { + // + // Fail + // + Status = STATUS_INSUFFICIENT_RESOURCES; + goto FailCreate; + } + } // - // Setup partition parameters + // Check if the drive settings haven't been set yet // - DriveExtension->BytesPerSector = 2048; // 512 for Disk - DriveExtension->SectorsPerTrack = 32; // 128 for disk - DriveExtension->NumberOfHeads = 64; // 16 for disk - + if ((DriveExtension->BytesPerSector == 0) || + (DriveExtension->SectorsPerTrack == 0) || + (DriveExtension->NumberOfHeads == 0)) + { + // + // Check if this is a CD + // + if (Input->Options.ExportAsCd) + { + // + // Setup partition parameters default for ISO 9660 + // + DriveExtension->BytesPerSector = 2048; + DriveExtension->SectorsPerTrack = 32; + DriveExtension->NumberOfHeads = 64; + } + else + { + // + // Setup partition parameters default for FAT + // + DriveExtension->BytesPerSector = 512; + DriveExtension->SectorsPerTrack = 128; + DriveExtension->NumberOfHeads = 16; + } + } + // // Acquire the disk lock // @@ -832,31 +931,6 @@ SendIrpToThread(IN PDEVICE_OBJECT DeviceObject, } } -PVOID -NTAPI -RamdiskMapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension, - IN LARGE_INTEGER Offset, - IN ULONG Length, - OUT PULONG OutputLength) -{ - DPRINT1("Mapping %lx bytes at %I64x\n", Length, Offset.QuadPart); - UNIMPLEMENTED; - while (TRUE); - return NULL; -} - -PVOID -NTAPI -RamdiskUnmapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension, - IN PVOID BaseAddress, - IN LARGE_INTEGER Offset, - IN ULONG Length) -{ - UNIMPLEMENTED; - while (TRUE); - return NULL; -} - NTSTATUS NTAPI RamdiskReadWriteReal(IN PIRP Irp,