reactos/ntoskrnl/include/internal/hal.h

171 lines
4.2 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/include/hal.h
* PURPOSE: Internal header for the I/O HAL Functions (Fstub)
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
#pragma once
//
// Default implementations of HAL dispatch table
//
VOID
FASTCALL
xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG MbrTypeIdentifier,
OUT PVOID *MbrBuffer);
VOID
FASTCALL
xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString);
NTSTATUS
FASTCALL
xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN BOOLEAN ReturnRecognizedPartitions,
IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
NTSTATUS
FASTCALL
xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG PartitionNumber,
IN ULONG PartitionType);
NTSTATUS
FASTCALL
xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer);
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly. - Fail on physical memory write like we do for read too. - Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows. - Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics. - Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely. - Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again. - Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code. - Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example). - Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers). - Crashing and rebooting from KD now works properly. svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
VOID
NTAPI
xHalHaltSystem(
VOID
);
VOID
NTAPI
xHalEndOfBoot(
VOID
);
VOID
NTAPI
xHalSetWakeEnable(
IN BOOLEAN Enable
);
UCHAR
NTAPI
xHalVectorToIDTEntry(
IN ULONG Vector
);
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly. - Fail on physical memory write like we do for read too. - Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows. - Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics. - Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely. - Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again. - Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code. - Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example). - Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers). - Crashing and rebooting from KD now works properly. svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
//
// Various offsets in the boot record
//
#define PARTITION_TABLE_OFFSET (0x1BE / 2)
#define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
#define BOOT_RECORD_RESERVED 0x1BC
#define BOOT_RECORD_SIGNATURE 0xAA55
#define NUM_PARTITION_TABLE_ENTRIES 4
//
// Helper Macros
//
#define GET_STARTING_SECTOR(p) \
((ULONG)(p->StartingSectorLsb0) + \
(ULONG)(p->StartingSectorLsb1 << 8 ) + \
(ULONG)(p->StartingSectorMsb0 << 16) + \
(ULONG)(p->StartingSectorMsb1 << 24))
#define GET_ENDING_S_OF_CHS(p) \
((UCHAR)(p->EndingCylinderLsb & 0x3F))
#define GET_PARTITION_LENGTH(p) \
((ULONG)(p->PartitionLengthLsb0) + \
(ULONG)(p->PartitionLengthLsb1 << 8) + \
(ULONG)(p->PartitionLengthMsb0 << 16) + \
(ULONG)(p->PartitionLengthMsb1 << 24))
//
// Structure describing a partition
//
typedef struct _PARTITION_DESCRIPTOR
{
UCHAR ActiveFlag;
UCHAR StartingTrack;
UCHAR StartingCylinderLsb;
UCHAR StartingCylinderMsb;
UCHAR PartitionType;
UCHAR EndingTrack;
UCHAR EndingCylinderLsb;
UCHAR EndingCylinderMsb;
UCHAR StartingSectorLsb0;
UCHAR StartingSectorLsb1;
UCHAR StartingSectorMsb0;
UCHAR StartingSectorMsb1;
UCHAR PartitionLengthLsb0;
UCHAR PartitionLengthLsb1;
UCHAR PartitionLengthMsb0;
UCHAR PartitionLengthMsb1;
} PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
//
// Structure describing a boot sector
//
typedef struct _BOOT_SECTOR_INFO
{
UCHAR JumpByte[1];
UCHAR Ignore1[2];
UCHAR OemData[8];
UCHAR BytesPerSector[2];
UCHAR Ignore2[6];
UCHAR NumberOfSectors[2];
UCHAR MediaByte[1];
UCHAR Ignore3[2];
UCHAR SectorsPerTrack[2];
UCHAR NumberOfHeads[2];
} BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
//
// Partition Table and Disk Layout
//
typedef struct _PARTITION_TABLE
{
PARTITION_INFORMATION PartitionEntry[4];
} PARTITION_TABLE, *PPARTITION_TABLE;
typedef struct _DISK_LAYOUT
{
ULONG TableCount;
ULONG Signature;
PARTITION_TABLE PartitionTable[1];
} DISK_LAYOUT, *PDISK_LAYOUT;
//
// Partition Table Entry
//
typedef struct _PTE
{
UCHAR ActiveFlag;
UCHAR StartingTrack;
USHORT StartingCylinder;
UCHAR PartitionType;
UCHAR EndingTrack;
USHORT EndingCylinder;
ULONG StartingSector;
ULONG PartitionLength;
} PTE, *PPTE;