2006-05-10 17:47:44 +00:00
|
|
|
/*++ NDK Version: 0098
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
Copyright (c) Alex Ionescu. All rights reserved.
|
|
|
|
|
|
|
|
Header Name:
|
|
|
|
|
|
|
|
halfuncs.h
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
|
|
|
|
Function definitions for the HAL.
|
|
|
|
|
|
|
|
Author:
|
|
|
|
|
2006-05-10 17:47:44 +00:00
|
|
|
Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
--*/
|
|
|
|
|
2005-06-18 23:33:40 +00:00
|
|
|
#ifndef _HALFUNCS_H
|
|
|
|
#define _HALFUNCS_H
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Dependencies
|
|
|
|
//
|
2005-11-25 00:17:40 +00:00
|
|
|
#include <umtypes.h>
|
|
|
|
#include <haltypes.h>
|
2006-11-14 22:42:59 +00:00
|
|
|
#include <ketypes.h>
|
2005-11-22 04:57:45 +00:00
|
|
|
|
2005-11-25 00:17:40 +00:00
|
|
|
#ifndef NTOS_MODE_USER
|
2005-06-18 23:33:40 +00:00
|
|
|
|
2006-11-14 18:17:33 +00:00
|
|
|
//
|
|
|
|
// Private HAL Callbacks
|
|
|
|
//
|
|
|
|
#define HalHandlerForBus HALPRIVATEDISPATCH->HalHandlerForBus
|
|
|
|
#define HalHandlerForConfigSpace HALPRIVATEDISPATCH->HalHandlerForConfigSpace
|
|
|
|
#define HalLocateHiberRanges HALPRIVATEDISPATCH->HalLocateHiberRanges
|
|
|
|
#define HalRegisterBusHandler HALPRIVATEDISPATCH->HalRegisterBusHandler
|
|
|
|
#define HalSetWakeEnable HALPRIVATEDISPATCH->HalSetWakeEnable
|
|
|
|
#define HalSetWakeAlarm HALPRIVATEDISPATCH->HalSetWakeAlarm
|
|
|
|
#define HalPciTranslateBusAddress HALPRIVATEDISPATCH->HalPciTranslateBusAddress
|
|
|
|
#define HalPciAssignSlotResources HALPRIVATEDISPATCH->HalPciAssignSlotResources
|
|
|
|
#define HalHaltSystem HALPRIVATEDISPATCH->HalHaltSystem
|
|
|
|
#define HalFindBusAddressTranslation HALPRIVATEDISPATCH->HalFindBusAddressTranslation
|
|
|
|
#define HalResetDisplay HALPRIVATEDISPATCH->HalResetDisplay
|
|
|
|
#define HalAllocateMapRegisters HALPRIVATEDISPATCH->HalAllocateMapRegisters
|
|
|
|
#define KdSetupPciDeviceForDebugging HALPRIVATEDISPATCH->KdSetupPciDeviceForDebugging
|
|
|
|
#define KdReleasePciDeviceforDebugging HALPRIVATEDISPATCH->KdReleasePciDeviceforDebugging
|
|
|
|
#define KdGetAcpiTablePhase0 HALPRIVATEDISPATCH->KdGetAcpiTablePhase0
|
|
|
|
#define KdCheckPowerButton HALPRIVATEDISPATCH->KdCheckPowerButton
|
|
|
|
#define HalVectorToIDTEntry HALPRIVATEDISPATCH->HalVectorToIDTEntry
|
|
|
|
#define KdMapPhysicalMemory64 HALPRIVATEDISPATCH->KdMapPhysicalMemory64
|
|
|
|
#define KdUnmapVirtualAddress HALPRIVATEDISPATCH->KdUnmapVirtualAddress
|
|
|
|
|
2006-01-07 02:06:22 +00:00
|
|
|
//
|
|
|
|
// The DDK steals these away from you.
|
|
|
|
//
|
|
|
|
#ifdef _MSC_VER
|
2007-12-04 19:22:33 +00:00
|
|
|
void __cdecl _enable(void);
|
|
|
|
void __cdecl _disable(void);
|
2006-10-26 01:49:51 +00:00
|
|
|
#pragma intrinsic(_enable)
|
|
|
|
#pragma intrinsic(_disable)
|
2006-01-07 02:06:22 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Display Functions
|
|
|
|
//
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalDisplayString(
|
|
|
|
IN PCHAR String
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialization Functions
|
|
|
|
//
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalAllProcessorsStarted(
|
|
|
|
VOID
|
|
|
|
);
|
2005-06-18 23:33:40 +00:00
|
|
|
|
2006-05-10 17:47:44 +00:00
|
|
|
#ifdef _ARC_
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalInitializeProcessor(
|
|
|
|
ULONG ProcessorNumber,
|
2006-05-10 17:47:44 +00:00
|
|
|
struct _LOADER_PARAMETER_BLOCK *LoaderBlock
|
2005-11-22 04:57:45 +00:00
|
|
|
);
|
2005-06-18 23:33:40 +00:00
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-26 05:52:40 +00:00
|
|
|
BOOLEAN
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
HalInitSystem(
|
|
|
|
ULONG BootPhase,
|
2006-05-10 17:47:44 +00:00
|
|
|
struct _LOADER_PARAMETER_BLOCK *LoaderBlock
|
2005-11-22 04:57:45 +00:00
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2006-11-14 20:59:48 +00:00
|
|
|
BOOLEAN
|
2005-11-22 04:57:45 +00:00
|
|
|
NTAPI
|
2006-11-14 20:59:48 +00:00
|
|
|
HalStartNextProcessor(
|
2006-11-14 22:42:59 +00:00
|
|
|
IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
|
2006-11-14 20:59:48 +00:00
|
|
|
IN PKPROCESSOR_STATE ProcessorState
|
2005-11-22 04:57:45 +00:00
|
|
|
);
|
2005-06-26 05:52:40 +00:00
|
|
|
|
2006-11-14 20:59:48 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2006-11-14 20:59:48 +00:00
|
|
|
VOID
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2006-11-14 20:59:48 +00:00
|
|
|
HalReturnToFirmware(
|
|
|
|
FIRMWARE_REENTRY Action
|
2005-11-22 04:57:45 +00:00
|
|
|
);
|
2005-06-18 23:33:40 +00:00
|
|
|
|
2006-09-11 06:50:19 +00:00
|
|
|
//
|
|
|
|
// CPU Routines
|
|
|
|
//
|
|
|
|
NTHALAPI
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalProcessorIdle(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Interrupt Functions
|
|
|
|
//
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-26 01:08:55 +00:00
|
|
|
BOOLEAN
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
HalBeginSystemInterrupt(
|
|
|
|
KIRQL Irql,
|
2010-01-23 19:29:33 +00:00
|
|
|
UCHAR Vector,
|
2005-06-18 23:33:40 +00:00
|
|
|
PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
2008-06-15 06:14:02 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
HalClearSoftwareInterrupt(
|
|
|
|
IN KIRQL Request
|
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2009-11-10 23:00:51 +00:00
|
|
|
VOID
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
HalDisableSystemInterrupt(
|
2010-01-23 19:29:33 +00:00
|
|
|
UCHAR Vector,
|
2005-06-18 23:33:40 +00:00
|
|
|
KIRQL Irql
|
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
BOOLEAN
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
HalEnableSystemInterrupt(
|
2010-01-23 19:29:33 +00:00
|
|
|
UCHAR Vector,
|
2005-06-18 23:33:40 +00:00
|
|
|
KIRQL Irql,
|
|
|
|
KINTERRUPT_MODE InterruptMode
|
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
VOID
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
HalEndSystemInterrupt(
|
|
|
|
KIRQL Irql,
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
IN PKTRAP_FRAME TrapFrame
|
2005-06-18 23:33:40 +00:00
|
|
|
);
|
|
|
|
|
2008-06-15 06:14:02 +00:00
|
|
|
#ifdef _ARM_ // FIXME: ndk/arm? armddk.h?
|
|
|
|
ULONG
|
|
|
|
HalGetInterruptSource(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
VOID
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
HalReportResourceUsage(
|
|
|
|
VOID
|
2005-06-18 23:33:40 +00:00
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
HalRequestSoftwareInterrupt(
|
|
|
|
KIRQL SoftwareInterruptRequested
|
|
|
|
);
|
|
|
|
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
VOID
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-11-22 04:57:45 +00:00
|
|
|
HalRequestIpi(
|
2006-05-10 17:47:44 +00:00
|
|
|
KAFFINITY TargetSet
|
2005-06-18 23:33:40 +00:00
|
|
|
);
|
|
|
|
|
2005-12-01 21:23:06 +00:00
|
|
|
NTHALAPI
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalHandleNMI(
|
2006-06-23 21:21:45 +00:00
|
|
|
PVOID NmiInfo
|
2005-12-01 21:23:06 +00:00
|
|
|
);
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
NTHALAPI
|
|
|
|
UCHAR
|
|
|
|
FASTCALL
|
|
|
|
HalSystemVectorDispatchEntry(
|
|
|
|
IN ULONG Vector,
|
|
|
|
OUT PKINTERRUPT_ROUTINE **FlatDispatch,
|
|
|
|
OUT PKINTERRUPT_ROUTINE *NoConnection
|
|
|
|
);
|
|
|
|
|
2010-07-19 15:14:34 +00:00
|
|
|
//
|
|
|
|
// Bus Functions
|
|
|
|
//
|
|
|
|
NTHALAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HalAdjustResourceList(
|
|
|
|
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
|
|
|
|
);
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Environment Functions
|
|
|
|
//
|
2006-11-16 17:30:52 +00:00
|
|
|
#ifdef _ARC_
|
2005-11-27 20:18:33 +00:00
|
|
|
NTHALAPI
|
2006-11-16 17:30:52 +00:00
|
|
|
ARC_STATUS
|
2005-09-05 04:48:20 +00:00
|
|
|
NTAPI
|
2005-06-18 23:33:40 +00:00
|
|
|
HalSetEnvironmentVariable(
|
|
|
|
IN PCH Name,
|
|
|
|
IN PCH Value
|
|
|
|
);
|
|
|
|
|
2006-11-16 17:30:52 +00:00
|
|
|
NTHALAPI
|
|
|
|
ARC_STATUS
|
|
|
|
NTAPI
|
|
|
|
HalGetEnvironmentVariable(
|
|
|
|
IN PCH Variable,
|
|
|
|
IN USHORT Length,
|
|
|
|
OUT PCH Buffer
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
//
|
|
|
|
// Profiling Functions
|
|
|
|
//
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalStartProfileInterrupt(
|
|
|
|
IN KPROFILE_SOURCE ProfileSource
|
|
|
|
);
|
|
|
|
|
|
|
|
NTHALAPI
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalStopProfileInterrupt(
|
|
|
|
IN KPROFILE_SOURCE ProfileSource
|
|
|
|
);
|
|
|
|
|
|
|
|
NTHALAPI
|
|
|
|
ULONG_PTR
|
|
|
|
NTAPI
|
|
|
|
HalSetProfileInterval(
|
|
|
|
IN ULONG_PTR Interval
|
|
|
|
);
|
|
|
|
|
2006-05-10 17:47:44 +00:00
|
|
|
//
|
|
|
|
// Time Functions
|
|
|
|
//
|
|
|
|
NTHALAPI
|
2006-06-23 21:21:45 +00:00
|
|
|
BOOLEAN
|
2006-05-10 17:47:44 +00:00
|
|
|
NTAPI
|
|
|
|
HalQueryRealTimeClock(
|
|
|
|
IN PTIME_FIELDS RtcTime
|
|
|
|
);
|
|
|
|
|
2006-10-26 01:49:51 +00:00
|
|
|
NTHALAPI
|
2006-11-16 17:30:52 +00:00
|
|
|
BOOLEAN
|
2006-10-26 01:49:51 +00:00
|
|
|
NTAPI
|
|
|
|
HalSetRealTimeClock(
|
|
|
|
IN PTIME_FIELDS RtcTime
|
|
|
|
);
|
|
|
|
|
2010-01-03 18:17:21 +00:00
|
|
|
NTHALAPI
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
HalSetTimeIncrement(
|
|
|
|
IN ULONG Increment
|
|
|
|
);
|
|
|
|
|
2005-11-25 00:17:40 +00:00
|
|
|
#endif
|
2005-06-18 23:33:40 +00:00
|
|
|
#endif
|