Fixed some hal dispatch table issues.

Improved HalExamineMBR() to detect disk managers.

svn path=/trunk/; revision=4200
This commit is contained in:
Eric Kohl 2003-02-26 14:14:47 +00:00
parent 991196c35e
commit 64e0e82479
12 changed files with 214 additions and 131 deletions

View file

@ -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 \

View file

@ -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 <ddk/ntddk.h>
#include <internal/pool.h>
#include <hal.h>
#include <bus.h>
#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 */
HalQuerySystemInformation = HalpQuerySystemInformation;
/* initialize hal dispatch tables */
#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 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 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;
/* Add isa bus handler */
BusHandler = HalpAllocateBusHandler(Isa,
ConfigurationSpaceUndefined,
0);
if (BusHandler == NULL)
return;
BusHandler->GetInterruptVector =
(pGetInterruptVector)HalpGetIsaInterruptVector;
BusHandler->TranslateBusAddress =
(pTranslateBusAddress)HalpTranslateIsaBusAddress;
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;
}

View file

@ -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 */

View file

@ -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 <ddk/ntddk.h>
#include <roscfg.h>
#include <hal.h>
#include <internal/ntoskrnl.h>
#ifdef MP
#include <mps.h>
@ -58,8 +57,8 @@ HalInitSystem (ULONG BootPhase,
}
else if (BootPhase == 1)
{
HalpInitBusHandlers ();
HalpCalibrateStallExecution ();
HalpInitBusHandlers();
HalpCalibrateStallExecution();
/* Enumerate the devices on the motherboard */
HalpStartEnumerator();

View file

@ -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 */

View file

@ -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 <ddk/ntddk.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
VOID HalExamineMBR(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG MBRTypeIdentifier,
PVOID Buffer)
{
UNIMPLEMENTED;
}

View file

@ -11,13 +11,66 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <hal.h>
#include <bus.h>
#define NDEBUG
#include <internal/debug.h>
/* 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 */

View file

@ -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);

View file

@ -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
/*

View file

@ -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 */

View file

@ -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 */

View file

@ -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;
}