Hardware Abstraction Layer

From ReactOS Wiki
Revision as of 05:29, 3 April 2012 by BrentNewland (talk | contribs)
Jump to: navigation, search


The HAL makes it possible for the x86 ReactOS kernel and HAL to run on different x86 motherboards. The HAL abstracts motherboard specific code from the kernel, so that different motherboards do not require changes in the kernel. Examples for different hardware designs are the standard PC, the Japanese NEC PC98 or x86 SGI workstations.





  • HAL dispatch tables and other HAL improvements

The HAL was separated from Ntoskrnl.exe in ReactOS 0.0.19


  • Added HalpGetIsaInterruptVector, HalpTranslatePciAddress,
  • Improved PCI support (Hartmut Birr)


  • Improved DMA support in the HAL (Vizzini)


  • KiAcquire/ReleaseSpinLock adaption (Gunnar Dalsnes)
  • Spinlock can also be acquired using KeAcquireSpinLockRaiseToSynch(), take this into account when checking the IRQL on release (Gé van Geldorp)


  • Spinlock can also be acquired using KeAcquireSpinLockRaiseToSynch() (Ge van Geldorp)


  • Initialize the serial port to reasonable state after the detection (required by Virtual PC) (Filip Navara)
  • Avoid collision with compiler generated label (Ge van Geldorp)


  • Implementation of HalReadDmaCounter. (Filip Navara)
  • Let HalAllocateCommonBuffer allocated 64K aligned memory. (Filip Navara)
  • Change IoMapTransfer to support auto initialize and single transfer mode, 16-bit DMA and common buffers. (Filip Navara)
  • Stop DMA transfer in IoFlushAdapterBuffers. (Filip Navara)
  • Replaced all single pushf/popf inline assembler instructions with a macro which doesn't change the stack layout. (Hartmut Birr)


  • Create a new HAL to support the Xbox (Gé van Geldorp)
  • Rewritten DMA routines. (Alex Ionescu)
  • Used the time stamp counter from a pentium if it is available (in KeStallExecutionProcessor/KeQueryPerformanceCounter). (Hartmut Birr)
  • Improved smp functions. Changed/rewrote parts of the mp code to get my ASUS p2b-ds motherboard to working. Fixed the enabling/disabling of the higher irqs in Enable8259AIrq/Disable8259AIrq. Moved the local apic functions into its own file. Implemented the IpiInterrupt. Changed the destination of the startup ipis. Enabled interrupts on calls to KiDispatchInterrupt and KiDeliverApc. Delivered dpcs always on HalEndSystemInterrupt. Set the logical apic id according to the processor number from ntoskrnl. Dipped the code between HalInitializeProcessor and HalStartNextProcessor. (Hartmut Birr)


  • Complete reimplementation of HAL DMA routines:
    • Proper support for bus-master device adapters.
    • Real implementation of map registers.
    • Basic support for emulating scatter/gather DMA on devices that don't support it in hardware.
    • Support for transfers that aren't page aligned.
    • Proper detection and support of EISA DMA controllers.
    • Fixed prototype for HalFlushCommonBuffer.

(Filip Navara)



  • Export KeAcquire/ReleaseQueuedSpinlocks (Aleksey Bragin)
  • Fix wrong prototype of HalEndSystemInterrupt (Aleksey Bragin)
  • Stall the CPU after each I/O command to simulate I/O delay. (Alex Ionescu)
  • Make HalMakeBeep a bit nicer by making the PUCHAR typedef part of the TIMER constants. (Alex Ionescu)
  • Flush write buffers before rebooting. (Alex Ionescu)
  • Refactor sending the reset command since it's not always a matter of using the keyboard port. (Alex Ionescu)
  • HalReturnToFirmware does a HalpReboot no matter what parameter is sent. (Alex Ionescu)
  • Implement HalSystemVectorDispatchEntry, KeFlushWriteBuffer, HalFlushCommonBuffer, HalAllocateCrashDumpRegisters. (Alex Ionescu)
  • Add lots of missing PCI definitions to the DDK, and to the internal file pci.h (Alex Ionescu)
  • Make HAL compilable with the WDK thanks to a nice hack/trick I found. (Alex Ionescu)
  • Delete HAL cruft files. (Alex Ionescu)
  • Implement (or cleanup + mark as implemented, these are 4 line functions) HalDisplayString, HalAcquireDisplayOwnership, HalSetDisplayParameters, HalQueryDisplayParameters, HalInitailizeProcessor, HalAllProcessorsStarted, HalStartNextProcessor, HalProcessorIdle, HalRequestIpi. (Alex Ionescu)
  • Fix some prototype definitions and cleanup some formatting. (Alex Ionescu)
  • Export ExiTryToAcquireFastMutex from ntoskrnl, I had forgotten to export this ages ago when adding the other Exi*FastMutex* stuff. (Alex Ionescu)
  • Remove fmutex.c and fastmutex functions from HAL. The whole point of having the Exi ones in the kernel was that HAL calls them through forward exports now (so any old driver can still link with HAL). Now we don't duplicate the implementation anymore. (Alex Ionescu)
  • Remove DriverEntry, it's useless. Also move HalReportResourceUsage to halinit because it's a call-once-on-boot function much akin a HalInitPhase2 function, so delete resource.c (Alex Ionescu)
  • Keep track of interrupt affinity and active processor mask each time a new CPU initializes. (Alex Ionescu)
  • Reorganize HAL exports and export KeTRyToAcquireQueuedSpinlock and KeTryToAcquireQueuedSpinLockRaisetoSynch. (Alex Ionescu)
  • Add stub for HalSetTimeIncrement. (Alex Ionescu)
  • Cleanup CMOS-related routines (Get/Set environment value and get/set RTC). Fixup some prototypes as well. Inline HalpReadCmos/HalpWriteCmos instead of having a separate function. (Alex Ionescu)
  • Fixup wrong protypes for various Queued Spinlock functions. (Alex Ionescu)
  • HAL Initialization Rewrite: Initailize the clock increment separately from the calibration of stall execution. (Alex Ionescu)
  • HAL Initialization Rewrite: Raise IRQL to the current IRQL (basically a no-op) to force a standard PIC state. Will be needed for the new IRQ implementation when it'll work. (Alex Ionescu)
  • HAL Initialization Rewrite: Scan commandline for PCILOCK and BREAK parameters during hal initalization. The former is not supported, only saved, while the latter causes a breakpoint just like the windows implemetnation. (Alex Ionescu)
  • HAL Initialization Rewrite: Get the bus type (ISA, EISA, MCA) on startup to support bootup from NTLDR. (Alex Ionescu)
  • HAL Initialization Rewrite: Validate HAL to match the kernel (checked kernel and UP kernel). Also make the kernel set the proper PRCB flags for this. (Alex Ionescu)
  • HAL Initialization Rewrite: Initialize the CMOS lock. (Alex Ionescu)
  • HAL Initialization Rewrite: Setup HAL Dispatch table and enable call to HalQuerySystemInformation in the kernel since it now works. (Alex Ionescu)
  • Rewrite bus functions to get rid of the idea of "Bus handlers". This is a deprecated NT4 concept that ReactOS copied and only slows down performance. (Alex Ionescu)
  • Support custom private dispatch table PCI functions. (Alex Ionescu)
  • Provide default PCI functions. (Alex Ionescu)
  • Rewrite PCI functions using clean structures and code instead of magic macros and undocumented magic values. Use simple macros to generate PCI bus operations for write/read uchar, ushort and ulong. (Alex Ionescu)
  • Simplify function definitions for CMOS access. (Alex Ionescu)
  • Unify some dupli/tripi-cated code. (Alex Ionescu)
  • Fix definition of HaliSetSystemInformation. (Alex Ionescu)
  • Fix definitions of Bus Handler functions (add NTAPI). (Alex Ionescu)
  • Add official BUS_HANDLER definition to NDK. (Alex Ionescu)
  • Fix definition of HAL_PRIVATE_DISPATCH. (Alex Ionescu)
  • Remove some derecated code (isa.c and mca.c). (Alex Ionescu)
  • Fix prototype/definition of HalCalibratePerformanceCounter and properly implement it. (Alex Ionescu)
  • Implement KeStallExecutionProcessor in its own assembly file isntead of using inlined GCC assembly, and align the loop to 16 bytes for more streamlined execution speed. (Alex Ionescu)
  • Mask out clock interrupt during Phase 0 and Initialize clock interrupt on HAL Phase 1. This enables the HAL clock interrupt which was already written. (Alex Ionescu)
  • Make the clock interrupt use HalpCurrentTimeIncrement instead of hardcoding a value. (Alex Ionescu)
  • Re-implement HalpInitializeClock to allow for dynamic increments from 1ms to 15ms with appropriate rollovers and to call KeSetTimeIncrement to update timer values with the kernel. (Alex Ionescu)
  • Implement HalSetTimeIncrement to allow changing the clock ms increment (but this isn't yet respected). (Alex Ionescu)
  • Remove system/runtime update routines from the deprecated IRQ implementation and use the newer assembly ones already written, since we're now using the HAL clock interrupt. Remove other unused code. (Alex Ionescu)
  • Fix more bugs in new hal IRQ implementation (that still isn't used yet due to regressions) and implement HalClearSoftwareInterrupt. (Alex Ionescu)
  • There's no such thing as Phase 2 HAL init. (Alex Ionescu)
  • Only map the 0x0 physical address in HalpReboot when enabling warm-reboot, there's no need to map it during init and keep it allocated during the whole time. (Alex Ionescu)
  • Implement a working version of KeQueryPerformanceCounter based on the C implementation (without the strange MHZed-based code) and also support updating the performance timer during a clock interrupt, otherwise the value might become stale during the query. (Alex Ionescu)
  • Update clock interrupt handler to update the performance counter, and also detect if someone changed the clock rate (but don't yet support this). (Alex Ionescu)
  • Finally figured out a way to make the old HAL IRQ implementation work with the new Ke Interrupt implementation without requiring my new HAL IRQ code (which doesn't work). (Alex Ionescu)
  • Add profil.c and stub HalStartProfileInterrupt, HalStopProfileInterrupt and HalSetProfileInterval, and export these functions. (Alex Ionescu)
  • KdComPortInUse is exported by HAL, not kdcom, so make the change. (Alex Ionescu)
  • Register the KD support routines that kdcom on NT uses and implement most of them (except support for PCI Debug Cards). (Alex Ionescu)
  • I can now get Windows to recognize the HAL but it freezes during loading (Due to broken IRQL implementation) and WinDBG won't connect to it. (Alex Ionescu)


  • Reimplement HalpAssignPCISlotResources() based on the old implementation (Aleksey Bragin)