It started when I realised how much new hardware support and "capabilities" were going to have to be written for my own project.
The normal mechanism for handling this in any normal project is to create a library and then let the linker determine what needs to be included. Overtime as project mature it is common for libraries to become very interdependant thus causing the whole library to effectively get linked in thus causeing code size bloat (not good for our type of project where resources are very finite). Where there are choices with a common API - you select which library you add to your make.
With ChibiOS - this has been built without the use of any libraries and yet there are obviously choices being made between common API components eg. at a board and at an architecture level. How does this work? By using halconf.h to specify what gets included and then the make system assembling all the bits necessary to make that happen including getting the right hardware dependant version of include files are needed. Very elegant! Down side - careful thought has to be given to the structure to ensure the dependancies work, and every file in the dependance list gets compiled even if it results in no actual code. For a RTOS this compromise is well worth while as run-time performance is more important than compile time performance.
So, the thought behind HALEXT (nothing to do with GDISP yet) is to extend that structure to all the addon stuff that is being built that doesn't directly fit in ChibiOS itself. Components then get comiled in or out based on HAL_USE_XXX defines in halconf.h just like for ChibiOS itself. This greatly simplifies the task of creating a new application - just turn on those sub-systems you think you will need.
The 2nd advantage of doing this is that it allows "layered" drivers to be written that require a lower level driver to perform more "base" functions. In the traditional library and directory technique the dependancies can become hard to track particularly when you start putting in alternative implementations for different layers in the model. With the ChibiOS style implementation (that halext implements) all this is taken care of for you by the make system and the driver writers. Incompatible options can be compile time error'ed.
An example of the use of this layering is...
High Level Routines For Reading Bitmap Files (a driver for reading bitmaps)
-> GDISP (a general display driver)
-> GISP_LLD (an LCD hardware driver - many options)
Another more complex example
Tone Generator Driver
-> Audio Wave Mixer Driver
-> Audio Hardware driver eg. I2C Crystal Codec OR PWM Audio Driver
-> If using PWM Audio Driver this layers on the ChibiOS PWM driver
or -> If using I2C Crystal Codec this layers on the ChibiOS I2C driver
The same Tone Generator Driver may instead by built with this structure...
Tone Generator Driver
-> PWM Squarewave Audio Driver
-> ChibiOS PWM driver
The trick is in defining the interfaces between each layer and being able to turn on and off functionality in a higher level driver if the lower level driver doesn't support it. That controllable functionality is not easily possible in the standard seperate directory library type approach as you are effectively generating dependancies based on functionality between the layers. It could be done with "discover" type functions but this introduces extra run-time handling code and prevents the removal of dead code by the compiler.
Hence halext was born.
GDISP then becomes a graphics driver in the halext structure that layers its functionality on the gdisp_lld low level display drivers. In this case GDISP is currently quite thin containing a couple of string functions and a box function. All else is past to the low level drivers. Other things that GDISP will contain (but not yet)...
- Multi-thread protection for the gdisp_lld low level drivers. This might be MUTEX style or Asynchronous Thread style (or maybe both with a user-selectable option).
- Possibly a VMT implementation to allow one of a number of low level drivers to be selected at run-time by the presense or otherwise of particular hardware.
The only other unusual factor in this is that the gdisp_lld low level drivers use this feature on/off capability to allow them to control how much functionality they want to render in hardware. If the hardware supports line drawing then the hardware does it. If not then an emulation routine is automatically turned on to provide this function for it. Some functions can't be emulated (like pixel read-back) and so if the hardware doesn't support it then the high level layer (GDISP) is told to turn off the use of that function in any functions it provides (in this case the high level pixel read-back routines are simply not compiled and are therefore not available to the application).
Hope that helps the thinking.