From: Eric Kohl Date: Wed, 26 Feb 2003 14:14:47 +0000 (+0000) Subject: Fixed some hal dispatch table issues. X-Git-Tag: ReactOS-0.1.1~255 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=64e0e8247960fd3118c2d4916e101df026adf57d Fixed some hal dispatch table issues. Improved HalExamineMBR() to detect disk managers. svn path=/trunk/; revision=4200 --- diff --git a/reactos/hal/halx86/Makefile b/reactos/hal/halx86/Makefile index 2da7f86fe94..effc32791b3 100644 --- a/reactos/hal/halx86/Makefile +++ b/reactos/hal/halx86/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.6 2002/10/02 19:32:57 ekohl Exp $ +# $Id: Makefile,v 1.7 2003/02/26 14:14:03 ekohl Exp $ PATH_TO_TOP = ../.. @@ -50,7 +50,6 @@ HAL_OBJECTS = \ halinit.o \ isa.o \ kdbg.o \ - mbr.o \ mca.o \ misc.o \ mp.o \ diff --git a/reactos/hal/halx86/bus.c b/reactos/hal/halx86/bus.c index 849c99107ae..6d8f697bc52 100644 --- a/reactos/hal/halx86/bus.c +++ b/reactos/hal/halx86/bus.c @@ -1,4 +1,4 @@ -/* $Id: bus.c,v 1.5 2002/12/09 19:44:44 hbirr Exp $ +/* $Id: bus.c,v 1.6 2003/02/26 14:14:03 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -16,7 +16,7 @@ /* INCLUDES *****************************************************************/ #include -#include +#include #include #define NDEBUG @@ -40,6 +40,7 @@ HalpNoAdjustResourceList(PBUS_HANDLER BusHandler, return STATUS_UNSUCCESSFUL; } + static NTSTATUS STDCALL HalpNoAssignSlotResources(PBUS_HANDLER BusHandler, ULONG BusNumber, @@ -53,6 +54,7 @@ HalpNoAssignSlotResources(PBUS_HANDLER BusHandler, return STATUS_NOT_SUPPORTED; } + static ULONG STDCALL HalpNoBusData(PBUS_HANDLER BusHandler, ULONG BusNumber, @@ -64,6 +66,7 @@ HalpNoBusData(PBUS_HANDLER BusHandler, return 0; } + static ULONG STDCALL HalpNoGetInterruptVector(PBUS_HANDLER BusHandler, ULONG BusNumber, @@ -75,6 +78,7 @@ HalpNoGetInterruptVector(PBUS_HANDLER BusHandler, return 0; } + static ULONG STDCALL HalpNoTranslateBusAddress(PBUS_HANDLER BusHandler, ULONG BusNumber, @@ -130,58 +134,59 @@ HalpAllocateBusHandler(INTERFACE_TYPE InterfaceType, VOID HalpInitBusHandlers(VOID) { - PBUS_HANDLER BusHandler; + PBUS_HANDLER BusHandler; - /* general preparations */ - KeInitializeSpinLock(&HalpBusHandlerSpinLock); - InitializeListHead(&HalpBusHandlerList); + /* General preparations */ + KeInitializeSpinLock(&HalpBusHandlerSpinLock); + InitializeListHead(&HalpBusHandlerList); - /* initialize hal dispatch tables */ -#if 0 + /* Initialize hal dispatch tables */ + HalQuerySystemInformation = HalpQuerySystemInformation; +#if 0 + HalSetSystemInformation = HalpSetSystemInformation; - HalDispatchTable->HalQueryBusSlots = HaliQueryBusSlots; + HalQueryBusSlots = HalpQueryBusSlots; #endif - /* add system bus handler */ - BusHandler = HalpAllocateBusHandler(Internal, - ConfigurationSpaceUndefined, - 0); - if (BusHandler == NULL) - return; - BusHandler->GetInterruptVector = - (pGetInterruptVector)HalpGetSystemInterruptVector; - BusHandler->TranslateBusAddress = - (pTranslateBusAddress)HalpTranslateSystemBusAddress; - - /* add cmos bus handler */ - BusHandler = HalpAllocateBusHandler(InterfaceTypeUndefined, - Cmos, - 0); - if (BusHandler == NULL) - return; - BusHandler->GetBusData = (pGetSetBusData)HalpGetCmosData; - BusHandler->SetBusData = (pGetSetBusData)HalpSetCmosData; - - /* add isa bus handler */ - BusHandler = HalpAllocateBusHandler(Isa, - ConfigurationSpaceUndefined, - 0); - if (BusHandler == NULL) - return; - - BusHandler->GetInterruptVector = - (pGetInterruptVector)HalpGetIsaInterruptVector; - BusHandler->TranslateBusAddress = - (pTranslateBusAddress)HalpTranslateIsaBusAddress; + /* Add system bus handler */ + BusHandler = HalpAllocateBusHandler(Internal, + ConfigurationSpaceUndefined, + 0); + if (BusHandler == NULL) + return; + BusHandler->GetInterruptVector = + (pGetInterruptVector)HalpGetSystemInterruptVector; + BusHandler->TranslateBusAddress = + (pTranslateBusAddress)HalpTranslateSystemBusAddress; + + /* Add cmos bus handler */ + BusHandler = HalpAllocateBusHandler(InterfaceTypeUndefined, + Cmos, + 0); + if (BusHandler == NULL) + return; + BusHandler->GetBusData = (pGetSetBusData)HalpGetCmosData; + BusHandler->SetBusData = (pGetSetBusData)HalpSetCmosData; + + /* Add isa bus handler */ + BusHandler = HalpAllocateBusHandler(Isa, + ConfigurationSpaceUndefined, + 0); + if (BusHandler == NULL) + return; + BusHandler->GetInterruptVector = + (pGetInterruptVector)HalpGetIsaInterruptVector; + BusHandler->TranslateBusAddress = + (pTranslateBusAddress)HalpTranslateIsaBusAddress; - /* add MicroChannel bus handler */ + /* Add MicroChannel bus handler */ BusHandler = HalpAllocateBusHandler(MicroChannel, Pos, 0); - if (BusHandler == NULL) - return; + if (BusHandler == NULL) + return; BusHandler->GetBusData = (pGetSetBusData)HalpGetMicroChannelData; } diff --git a/reactos/hal/halx86/drive.c b/reactos/hal/halx86/drive.c index 71eab0400f4..29f0a20edd3 100644 --- a/reactos/hal/halx86/drive.c +++ b/reactos/hal/halx86/drive.c @@ -1,4 +1,4 @@ -/* $Id: drive.c,v 1.3 2002/09/08 10:22:24 chorns Exp $ +/* $Id: drive.c,v 1.4 2003/02/26 14:14:03 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -22,10 +22,10 @@ IoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PUCHAR NtSystemPath, OUT PSTRING NtSystemPathString) { - HalDispatchTable.HalIoAssignDriveLetters(LoaderBlock, - NtDeviceName, - NtSystemPath, - NtSystemPathString); + HalIoAssignDriveLetters(LoaderBlock, + NtDeviceName, + NtSystemPath, + NtSystemPathString); } /* EOF */ diff --git a/reactos/hal/halx86/halinit.c b/reactos/hal/halx86/halinit.c index 327aef5fb2b..394e008ae96 100644 --- a/reactos/hal/halx86/halinit.c +++ b/reactos/hal/halx86/halinit.c @@ -1,4 +1,4 @@ -/* $Id: halinit.c,v 1.3 2002/09/08 10:22:24 chorns Exp $ +/* $Id: halinit.c,v 1.4 2003/02/26 14:14:03 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -14,7 +14,6 @@ #include #include #include -#include #ifdef MP #include @@ -58,8 +57,8 @@ HalInitSystem (ULONG BootPhase, } else if (BootPhase == 1) { - HalpInitBusHandlers (); - HalpCalibrateStallExecution (); + HalpInitBusHandlers(); + HalpCalibrateStallExecution(); /* Enumerate the devices on the motherboard */ HalpStartEnumerator(); diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index 704c2b3cf10..87939c1589a 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -45,4 +45,12 @@ struct _ADAPTER_OBJECT { BOOLEAN Inuse; }; +/* sysinfo.c */ +NTSTATUS STDCALL +HalpQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); + + #endif /* __INTERNAL_HAL_HAL_H */ diff --git a/reactos/hal/halx86/mbr.c b/reactos/hal/halx86/mbr.c deleted file mode 100644 index 5dc30a9e203..00000000000 --- a/reactos/hal/halx86/mbr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/hal/x86/mbr.c - * PURPOSE: Functions for reading the master boot record (MBR) - * PROGRAMMER: David Welch (welch@cwcom.net) - * UPDATE HISTORY: - * Created 22/05/98 - */ - -/* INCLUDES *****************************************************************/ - -#include - -#include - -/* FUNCTIONS *****************************************************************/ - -VOID HalExamineMBR(PDEVICE_OBJECT DeviceObject, - ULONG SectorSize, - ULONG MBRTypeIdentifier, - PVOID Buffer) -{ - UNIMPLEMENTED; -} diff --git a/reactos/hal/halx86/sysinfo.c b/reactos/hal/halx86/sysinfo.c index 5d04be8449c..fb17cbceeee 100644 --- a/reactos/hal/halx86/sysinfo.c +++ b/reactos/hal/halx86/sysinfo.c @@ -11,13 +11,66 @@ /* INCLUDES *****************************************************************/ #include +#include +#include +#define NDEBUG #include -/* FUNCTIONS *****************************************************************/ -VOID HalQuerySystemInformation() +/* FUNCTIONS ****************************************************************/ + +NTSTATUS STDCALL +HalpQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength) +{ + ULONG DataLength; + NTSTATUS Status; + + DPRINT1("HalpQuerySystemInformation() called\n"); + + *ReturnedLength = 0; + + DataLength = 0; + + switch(InformationClass) + { +#if 0 + case HalInstalledBusInformation: + Status = HalpQueryBusInformation(BufferSize, + Buffer, + ReturnedLength); + break; +#endif + + default: + DataLength = 0; + Status = STATUS_INVALID_LEVEL; + break; + } + + if (DataLength != 0) + { + if (DataLength > BufferSize) + DataLength = BufferSize; + +// RtlCopyMemory(); + + *ReturnedLength = DataLength; + } + + return(Status); +} + + +#if 0 +NTSTATUS +HalpSetSystemInformation(VOID) { UNIMPLEMENTED; } - +#endif + +/* EOF */ diff --git a/reactos/include/ddk/halfuncs.h b/reactos/include/ddk/halfuncs.h index a5d303f766a..e9e274a1d85 100644 --- a/reactos/include/ddk/halfuncs.h +++ b/reactos/include/ddk/halfuncs.h @@ -1,6 +1,6 @@ #ifndef __INCLUDE_DDK_HALFUNCS_H #define __INCLUDE_DDK_HALFUNCS_H -/* $Id: halfuncs.h,v 1.3 2002/09/08 10:47:44 chorns Exp $ */ +/* $Id: halfuncs.h,v 1.4 2003/02/26 14:11:41 ekohl Exp $ */ VOID STDCALL HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); @@ -70,12 +70,16 @@ HalEndSystemInterrupt(KIRQL Irql, ULONG Unknown2); -/* Is this function really exported ?? */ -VOID -HalExamineMBR(PDEVICE_OBJECT DeviceObject, - ULONG SectorSize, - ULONG MBRTypeIdentifier, - PVOID Buffer); +/* + * HalExamineMBR() is not exported explicitly. + * It is exported by the HalDispatchTable. + * + * VOID + * HalExamineMBR(PDEVICE_OBJECT DeviceObject, + * ULONG SectorSize, + * ULONG MBRTypeIdentifier, + * PVOID Buffer); + */ BOOLEAN STDCALL HalFlushCommonBuffer(ULONG Unknown1, @@ -150,9 +154,13 @@ HalQueryDisplayParameters(PULONG DispSizeX, VOID STDCALL HalQueryRealTimeClock(PTIME_FIELDS Time); -/* Is this function really exported ?? */ -VOID -HalQuerySystemInformation(VOID); +/* + * HalQuerySystemInformation() is not exported explicitly. + * It is exported by the HalDispatchTable. + * + * VOID + * HalQuerySystemInformation(VOID); + */ ULONG STDCALL HalReadDmaCounter(PADAPTER_OBJECT AdapterObject); diff --git a/reactos/include/ddk/haltypes.h b/reactos/include/ddk/haltypes.h index a4342667ec9..e4c9cb9c84c 100644 --- a/reactos/include/ddk/haltypes.h +++ b/reactos/include/ddk/haltypes.h @@ -1,4 +1,4 @@ -/* $Id: haltypes.h,v 1.8 2002/11/24 18:26:40 robd Exp $ +/* $Id: haltypes.h,v 1.9 2003/02/26 14:11:41 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -430,14 +430,29 @@ typedef struct _HAL_DISPATCH pHalReferenceBusHandler HalDereferenceBusHandler; } HAL_DISPATCH, *PHAL_DISPATCH; -#define HAL_DISPATCH_VERSION 1 - #ifdef __NTOSKRNL__ extern HAL_DISPATCH EXPORTED HalDispatchTable; +#define HALDISPATCH (&HalDispatchTable) #else -extern HAL_DISPATCH IMPORTED HalDispatchTable; +extern PHAL_DISPATCH IMPORTED HalDispatchTable; +#define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable) #endif +#define HAL_DISPATCH_VERSION 1 +#define HalDispatchTableVersion HALDISPATCH->Version +#define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation +#define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation +#define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots +#define HalDeviceControl HALDISPATCH->HalDeviceControl +#define HalExamineMBR HALDISPATCH->HalExamineMBR +#define HalIoAssignDriveLetters HALDISPATCH->HalIoAssignDriveLetters +#define HalIoReadPartitionTable HALDISPATCH->HalIoReadPartitionTable +#define HalIoSetPartitionInformation HALDISPATCH->HalIoSetPartitionInformation +#define HalIoWritePartitionTable HALDISPATCH->HalIoWritePartitionTable +#define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus +#define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler +#define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler + /* Hal private dispatch table */ @@ -446,15 +461,15 @@ typedef struct _HAL_PRIVATE_DISPATCH ULONG Version; } HAL_PRIVATE_DISPATCH, *PHAL_PRIVATE_DISPATCH; -#define HAL_PRIVATE_DISPATCH_VERSION 1 - #ifdef __NTOSKRNL__ extern HAL_PRIVATE_DISPATCH EXPORTED HalPrivateDispatchTable; #else -extern HAL_PRIVATE_DISPATCH IMPORTED HalPrivateDispatchTable; +extern PHAL_PRIVATE_DISPATCH IMPORTED HalPrivateDispatchTable; #endif +#define HAL_PRIVATE_DISPATCH_VERSION 1 + /* diff --git a/reactos/ntoskrnl/io/parttab.c b/reactos/ntoskrnl/io/parttab.c index 870ec509a85..e179fc01f2d 100644 --- a/reactos/ntoskrnl/io/parttab.c +++ b/reactos/ntoskrnl/io/parttab.c @@ -1,4 +1,4 @@ -/* $Id: parttab.c,v 1.3 2002/09/08 10:23:25 chorns Exp $ +/* $Id: parttab.c,v 1.4 2003/02/26 14:12:43 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -25,10 +25,10 @@ IoReadPartitionTable(PDEVICE_OBJECT DeviceObject, BOOLEAN ReturnRecognizedPartitions, PDRIVE_LAYOUT_INFORMATION *PartitionBuffer) { - return HalDispatchTable.HalIoReadPartitionTable(DeviceObject, - SectorSize, - ReturnRecognizedPartitions, - PartitionBuffer); + return(HalIoReadPartitionTable(DeviceObject, + SectorSize, + ReturnRecognizedPartitions, + PartitionBuffer)); } @@ -38,10 +38,10 @@ IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject, ULONG PartitionNumber, ULONG PartitionType) { - return HalDispatchTable.HalIoSetPartitionInformation(DeviceObject, - SectorSize, - PartitionNumber, - PartitionType); + return(HalIoSetPartitionInformation(DeviceObject, + SectorSize, + PartitionNumber, + PartitionType)); } @@ -52,11 +52,11 @@ IoWritePartitionTable(PDEVICE_OBJECT DeviceObject, ULONG NumberOfHeads, PDRIVE_LAYOUT_INFORMATION PartitionBuffer) { - return HalDispatchTable.HalIoWritePartitionTable(DeviceObject, - SectorSize, - SectorsPerTrack, - NumberOfHeads, - PartitionBuffer); + return(HalIoWritePartitionTable(DeviceObject, + SectorSize, + SectorsPerTrack, + NumberOfHeads, + PartitionBuffer)); } /* EOF */ diff --git a/reactos/ntoskrnl/io/xhaldisp.c b/reactos/ntoskrnl/io/xhaldisp.c index da656ccdbe7..3f0afdeb5f3 100644 --- a/reactos/ntoskrnl/io/xhaldisp.c +++ b/reactos/ntoskrnl/io/xhaldisp.c @@ -1,4 +1,4 @@ -/* $Id: xhaldisp.c,v 1.7 2002/09/08 10:23:26 chorns Exp $ +/* $Id: xhaldisp.c,v 1.8 2003/02/26 14:12:43 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -42,8 +42,11 @@ HAL_PRIVATE_DISPATCH EXPORTED HalPrivateDispatchTable = // HalHandlerForConfigSpace // HalCompleteDeviceControl // HalRegisterBusHandler - // any more?? + // ?? + // ?? + // ?? + // ?? + // ?? }; /* EOF */ - diff --git a/reactos/ntoskrnl/io/xhaldrv.c b/reactos/ntoskrnl/io/xhaldrv.c index 793ddf80392..825986795b0 100644 --- a/reactos/ntoskrnl/io/xhaldrv.c +++ b/reactos/ntoskrnl/io/xhaldrv.c @@ -1,4 +1,4 @@ -/* $Id: xhaldrv.c,v 1.25 2002/09/08 10:23:26 chorns Exp $ +/* $Id: xhaldrv.c,v 1.26 2003/02/26 14:12:43 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -40,13 +40,23 @@ typedef struct _PARTITION unsigned char EndingCylinder; unsigned int StartingBlock; unsigned int SectorCount; -} PARTITION, *PPARTITION; +} PACKED PARTITION, *PPARTITION; typedef struct _PARTITION_TABLE { PARTITION Partition[PARTITION_TBL_SIZE]; unsigned short Magic; -} PARTITION_TABLE, *PPARTITION_TABLE; +} PACKED PARTITION_TABLE, *PPARTITION_TABLE; + +typedef struct _MBR +{ + UCHAR MbrBootCode[442]; /* 0x000 */ + ULONG Signature; /* 0x1B8 */ + USHORT Unused; /* 0x1BC */ + PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */ + USHORT Magic; /* 0x1FE */ +} PACKED MBR, *PMBR; + /* FUNCTIONS *****************************************************************/ @@ -168,11 +178,12 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject, KEVENT Event; IO_STATUS_BLOCK StatusBlock; LARGE_INTEGER Offset; - PUCHAR LocalBuffer; + PULONG Shift; + PMBR Mbr; PIRP Irp; NTSTATUS Status; - DPRINT("xHalExamineMBR()\n"); + DPRINT1("xHalExamineMBR()\n"); *Buffer = NULL; if (SectorSize < 512) @@ -180,20 +191,20 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject, if (SectorSize > 4096) SectorSize = 4096; - LocalBuffer = (PUCHAR)ExAllocatePool(PagedPool, - SectorSize); - if (LocalBuffer == NULL) + Mbr = (PMBR)ExAllocatePool(PagedPool, + SectorSize); + if (Mbr == NULL) return; KeInitializeEvent(&Event, NotificationEvent, FALSE); + /* Read MBR (Master Boot Record) */ Offset.QuadPart = 0; - Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, DeviceObject, - LocalBuffer, + Mbr, SectorSize, &Offset, &Event, @@ -215,25 +226,32 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject, { DPRINT("xHalExamineMBR failed (Status = 0x%08lx)\n", Status); - ExFreePool(LocalBuffer); + ExFreePool(Mbr); return; } - if (LocalBuffer[0x1FE] != 0x55 || LocalBuffer[0x1FF] != 0xAA) + if (Mbr->Magic != PARTITION_MAGIC) { - DPRINT("xHalExamineMBR: invalid MBR signature\n"); - ExFreePool(LocalBuffer); + DPRINT("xHalExamineMBR: invalid MBR magic value\n"); + ExFreePool(Mbr); return; } - if (LocalBuffer[0x1C2] != MBRTypeIdentifier) + if (Mbr->Partition[0].PartitionType != MBRTypeIdentifier) { DPRINT("xHalExamineMBR: invalid MBRTypeIdentifier\n"); - ExFreePool(LocalBuffer); + ExFreePool(Mbr); return; } - *Buffer = (PVOID)LocalBuffer; + if (Mbr->Partition[0].PartitionType == 0x54) + { + /* Found 'Ontrack Disk Manager'. Shift all sectors by 63 */ + Shift = (PULONG)Mbr; + *Shift = 63; + } + + *Buffer = (PVOID)Mbr; }