Added support for the Ontrack Disk Manager.

svn path=/trunk/; revision=4451
This commit is contained in:
Eric Kohl 2003-03-28 22:47:33 +00:00
parent 1d95979106
commit 7bf5e6cae6
2 changed files with 69 additions and 26 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: disk.c,v 1.22 2003/02/26 16:25:40 ekohl Exp $ /* $Id: disk.c,v 1.23 2003/03/28 22:45:47 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -48,6 +48,13 @@ typedef struct _DISK_DATA
BOOLEAN DriveNotReady; BOOLEAN DriveNotReady;
} DISK_DATA, *PDISK_DATA; } DISK_DATA, *PDISK_DATA;
typedef enum _DISK_MANAGER
{
NoDiskManager,
OntrackDiskManager,
EZ_Drive
} DISK_MANAGER;
BOOLEAN STDCALL BOOLEAN STDCALL
DiskClassFindDevices(PDRIVER_OBJECT DriverObject, DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
@ -403,6 +410,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
ULONG PartitionNumber; ULONG PartitionNumber;
PVOID MbrBuffer; PVOID MbrBuffer;
NTSTATUS Status; NTSTATUS Status;
DISK_MANAGER DiskManager = NoDiskManager;
DPRINT("DiskClassCreateDeviceObject() called\n"); DPRINT("DiskClassCreateDeviceObject() called\n");
@ -548,9 +556,8 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
&MbrBuffer); &MbrBuffer);
if (MbrBuffer != NULL) if (MbrBuffer != NULL)
{ {
DPRINT1("Found 'Ontrack Disk Manager'!\n"); DPRINT("Found 'Ontrack Disk Manager'!\n");
KeBugCheck(0); DiskManager = OntrackDiskManager;
ExFreePool(MbrBuffer); ExFreePool(MbrBuffer);
MbrBuffer = NULL; MbrBuffer = NULL;
} }
@ -561,13 +568,18 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
&MbrBuffer); &MbrBuffer);
if (MbrBuffer != NULL) if (MbrBuffer != NULL)
{ {
DPRINT1("Found 'EZ-Drive' disk manager!\n"); DPRINT("Found 'EZ-Drive' disk manager!\n");
KeBugCheck(0); DiskManager = EZ_Drive;
ExFreePool(MbrBuffer); ExFreePool(MbrBuffer);
MbrBuffer = NULL; MbrBuffer = NULL;
} }
/* Start disk at sector 63 if the Ontrack Disk Manager was found */
if (DiskManager == OntrackDiskManager)
{
DiskDeviceExtension->StartingOffset.QuadPart =
(ULONGLONG)(63 * DiskDeviceExtension->DiskGeometry->BytesPerSector);
}
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) && if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia)) (DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
@ -667,8 +679,17 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
PartitionDeviceExtension->DiskGeometry = DiskDeviceExtension->DiskGeometry; PartitionDeviceExtension->DiskGeometry = DiskDeviceExtension->DiskGeometry;
PartitionDeviceExtension->PhysicalDevice = DiskDeviceExtension->PhysicalDevice; PartitionDeviceExtension->PhysicalDevice = DiskDeviceExtension->PhysicalDevice;
PartitionDeviceExtension->PortCapabilities = Capabilities; PartitionDeviceExtension->PortCapabilities = Capabilities;
PartitionDeviceExtension->StartingOffset.QuadPart = if (DiskManager == OntrackDiskManager)
PartitionEntry->StartingOffset.QuadPart; {
PartitionDeviceExtension->StartingOffset.QuadPart =
PartitionEntry->StartingOffset.QuadPart +
(ULONGLONG)(63 * DiskDeviceExtension->DiskGeometry->BytesPerSector);
}
else
{
PartitionDeviceExtension->StartingOffset.QuadPart =
PartitionEntry->StartingOffset.QuadPart;
}
PartitionDeviceExtension->PartitionLength.QuadPart = PartitionDeviceExtension->PartitionLength.QuadPart =
PartitionEntry->PartitionLength.QuadPart; PartitionEntry->PartitionLength.QuadPart;
PartitionDeviceExtension->PortNumber = (UCHAR)PortNumber; PartitionDeviceExtension->PortNumber = (UCHAR)PortNumber;

View file

@ -1,4 +1,4 @@
/* $Id: xhaldrv.c,v 1.28 2003/03/04 21:58:05 ekohl Exp $ /* $Id: xhaldrv.c,v 1.29 2003/03/28 22:47:33 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -58,7 +58,8 @@ typedef struct _MBR
typedef enum _DISK_MANAGER typedef enum _DISK_MANAGER
{ {
NoDiskManager, NoDiskManager,
OntrackDiskManager OntrackDiskManager,
EZ_Drive
} DISK_MANAGER; } DISK_MANAGER;
@ -188,7 +189,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
PIRP Irp; PIRP Irp;
NTSTATUS Status; NTSTATUS Status;
DPRINT1("xHalExamineMBR()\n"); DPRINT("xHalExamineMBR()\n");
*Buffer = NULL; *Buffer = NULL;
if (SectorSize < 512) if (SectorSize < 512)
@ -229,7 +230,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Reading MBR failed (Status 0x%08lx)\n", DPRINT("Reading MBR failed (Status 0x%08lx)\n",
Status); Status);
ExFreePool(Sector); ExFreePool(Sector);
return; return;
@ -239,14 +240,14 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
if (Mbr->Magic != PARTITION_MAGIC) if (Mbr->Magic != PARTITION_MAGIC)
{ {
DPRINT1("Invalid MBR magic value\n"); DPRINT("Invalid MBR magic value\n");
ExFreePool(Sector); ExFreePool(Sector);
return; return;
} }
if (Mbr->Partition[0].PartitionType != MBRTypeIdentifier) if (Mbr->Partition[0].PartitionType != MBRTypeIdentifier)
{ {
DPRINT1("Invalid MBRTypeIdentifier\n"); DPRINT("Invalid MBRTypeIdentifier\n");
ExFreePool(Sector); ExFreePool(Sector);
return; return;
} }
@ -254,7 +255,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
if (Mbr->Partition[0].PartitionType == 0x54) if (Mbr->Partition[0].PartitionType == 0x54)
{ {
/* Found 'Ontrack Disk Manager'. Shift all sectors by 63 */ /* Found 'Ontrack Disk Manager'. Shift all sectors by 63 */
DPRINT1("Found 'Ontrack Disk Manager'!\n"); DPRINT("Found 'Ontrack Disk Manager'!\n");
Shift = (PULONG)Mbr; Shift = (PULONG)Mbr;
*Shift = 63; *Shift = 63;
} }
@ -615,8 +616,9 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
KEVENT Event; KEVENT Event;
IO_STATUS_BLOCK StatusBlock; IO_STATUS_BLOCK StatusBlock;
ULARGE_INTEGER PartitionOffset; ULARGE_INTEGER PartitionOffset;
ULARGE_INTEGER nextPartitionOffset; ULARGE_INTEGER RealPartitionOffset;
ULARGE_INTEGER containerOffset; ULARGE_INTEGER nextPartitionOffset;
ULARGE_INTEGER containerOffset;
PUCHAR SectorBuffer; PUCHAR SectorBuffer;
PIRP Irp; PIRP Irp;
NTSTATUS Status; NTSTATUS Status;
@ -638,14 +640,26 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
*PartitionBuffer = NULL; *PartitionBuffer = NULL;
/* Check for 'Ontrack Disk Manager' */ /* Check for 'Ontrack Disk Manager' */
xHalExamineMBR(DeviceObject,
SectorSize,
0x54,
&MbrBuffer);
if (MbrBuffer != NULL)
{
DPRINT("Found 'Ontrack Disk Manager'\n");
DiskManager = OntrackDiskManager;
ExFreePool(MbrBuffer);
}
/* Check for 'EZ-Drive' */
xHalExamineMBR(DeviceObject, xHalExamineMBR(DeviceObject,
SectorSize, SectorSize,
0x55, 0x55,
&MbrBuffer); &MbrBuffer);
if (MbrBuffer != NULL) if (MbrBuffer != NULL)
{ {
DPRINT1("Found 'Ontrack Disk Manager'\n"); DPRINT("Found 'EZ-Drive'\n");
DiskManager = OntrackDiskManager; DiskManager = EZ_Drive;
ExFreePool(MbrBuffer); ExFreePool(MbrBuffer);
} }
@ -667,25 +681,33 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
RtlZeroMemory(LayoutBuffer, RtlZeroMemory(LayoutBuffer,
0x1000); 0x1000);
PartitionOffset.QuadPart = 0; PartitionOffset.QuadPart = (ULONGLONG)0;
containerOffset.QuadPart = 0; containerOffset.QuadPart = (ULONGLONG)0;
do do
{ {
if (DiskManager == OntrackDiskManager)
PartitionOffset.QuadPart += (63 * 512);
KeInitializeEvent(&Event, KeInitializeEvent(&Event,
NotificationEvent, NotificationEvent,
FALSE); FALSE);
DPRINT("PartitionOffset: %I64u\n", PartitionOffset.QuadPart / SectorSize); DPRINT("PartitionOffset: %I64u\n", PartitionOffset.QuadPart / SectorSize);
if (DiskManager == OntrackDiskManager)
{
RealPartitionOffset.QuadPart = PartitionOffset.QuadPart + (ULONGLONG)(63 * SectorSize);
}
else
{
RealPartitionOffset.QuadPart = PartitionOffset.QuadPart;
}
DPRINT("RealPartitionOffset: %I64u\n", RealPartitionOffset.QuadPart / SectorSize);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
DeviceObject, DeviceObject,
SectorBuffer, SectorBuffer,
SectorSize, SectorSize,
(PLARGE_INTEGER)&PartitionOffset, (PLARGE_INTEGER)&RealPartitionOffset,
&Event, &Event,
&StatusBlock); &StatusBlock);
Status = IoCallDriver(DeviceObject, Status = IoCallDriver(DeviceObject,