Hi:
Casm wrote:
My understanding of the HAL is that it is something comparable to the real mode BIOS, except that it goes further and tries to provide a standard interface to things like the interrupt controller. Then the device drivers are built on top of that. That way an operating system can be moved to a new architecture with relatively little code having to be rewritten.
Depends on how you look at it:
To take your proposed example, interrupt controller management (which is a layer which lies beneath IRQ management, and which the IRQ management layer calls upon when it's managing IRQs): The IRQ managament code would call upon the IRQ controller code which would then delve deep within its many layers of hardware abstraction and wave its wand, fulfil the kernel's request, then return to the kernel reporting that all's well that ends well. Then you may also have other early chipset specific features which need to be called upon before the driver subsystem is initialized, such as watchdog device petting, and timer functionality, and firmware interface specifics, like communicating with the firmware on a board if it uses a standard firmware interface like EFI, or OpenFirmware, etc.
Now all of these are good candidates to place into an "HAL" all tied together, and in an ugly way, providing the required functions when the kernel dips its hand into that black box known as its "HAL".
Another approach would be to recognize that all code in a kernel can be categorized as one of three things: (1) Processor architecture specific code, (2) Chipset specific code, or (3) firmware interaction specific code. So IRQ controller, timer device, etc code would be code in a subfolder of "IBM-PC" or "MAC-2"; For chipsets that use Open firmware, you would have your common code written that would portably (as much as you can) provide OFW on all chipsets, then have per-chipset call-ins to augment the chipset-specific stuff for OFW boards with eccentricities, etc.
As you begin to realize this, you begin to see that a messy "HAL" as a single entity would be more portable as properly isolated chipset-specific, arch-specific, and firmware interface specific code; For things like ACPI, you can implement a simple "kernel libacpi" in its own folder under a "kernel-libs/" subfolder. Suddenly porting to new platforms gets easier since you don't have to re-write a messy "HAL" per platform, but create a new folder for the new chipset, or architecture, and write code only for what is actually new, and move on
--All the best
gravaera