Bare Metal Programming
Bare metal programming is the art of writing code for a microcomputer that runs directly on the hardware (metal) bypassing the need for an operating system.
This method of programming was common practice back in the early days of software development and was prevalent amongst games developers.
The practice probably died out after the advent of Microsoft’s DirectX API. Up until that point the only games you’d get in Windows 3.1 were simple affairs, such as Minesweeper. Windows didn’t really have any API calls in the operating system to help games developers; usually the operating system just sat there getting in the way.
Games on PCs generally ran from DOS using third party libraries (such as DOS/4G) to handle the memory, BIOS or DOS calls for floppy disk access and the programmers own routines to handle input, graphics and sound.
This usually involved the programmer writing their own libraries to directly access parts of the hardware. In practice this meant games supported a limited number of video modes (VGA, EGA and CGA) and sound cards (usually any sound card that was designed to be Soundblaster Compatible).
It often left users getting frustrated working out how to get a particular game working on their PC hardware. I worked for a games company that had a technical support line around this time. The majority of calls were about compatibility issues.
DirectX was Microsoft’s answer to these problems and another; how to make Windows the primary OS for PC rather than just a pretty GUI for DOS. This would involve dropping DOS altogether and migrating the desktop from the Windows 9x kernel to the Windows NT one.
It’s not possible to make this step if the user has to drop back into DOS every time they need to run an application that is graphically demanding such as a game.
The DirectX APIs act as a thin Hardware Abstraction Layer between the game and the hardware. Microsoft provide the API for graphics and sound, the hardware manufacturers make hardware and drivers that run on this API, the games developers now have a standard API for games development and the user doesn’t have to worry about a thing.
DirectX was released in 1995 for Windows 95. Despite early versions being a vast improvement on Windows GDI games developers were not convinced. Thankfully everyone persevered and DirectX is now an excellent platform for games development. It’s used widely for games development on PCs, the Xbox and the Sega Dreamcast and other graphically intense applications, such as video players and CAD/3D modelling applications.
The downside of all this is that most commercial programmers no longer develop directly on the hardware; there is usually a more convenient API or OS call. As a result of this, manufacturers no longer have to make their hardware backwards compatible; all compatibility is done at the API or HAL level. Hardware is also more complicated; the APIs drive the manufacturers to offload more of the processing to the hardware, thus increasing the complexity and number of different types of hardware that need to be supported.
This means it’s not really worth doing bare metal programming on PCs in all but a limited number of instances, such as OS or driver development.
This is why I love early 8 and 16 bit computers and am coming to respect the Raspberry PI. I initially thought that it’d be just a cheap board that promoted Linux development but secretly hoped that the community would grasp the bare metal nettle and boy, have they!
It’s early days, but there are already a load of great articles, tutorials and examples on developing on it bare-metal (baking PI) and Broadcomm have open sourced the userland libraries for the GPU. The platform is fixed, so with the possible exception of RAM size or exposed GPIO pins my Raspberry PI is pretty much the same as yours.
This is a perfect opportunity for kids to ditch Linux and learn how to program the way their fathers did. For the keen this opens up the opportunity to learn assembly language and become real programmers. I for one think this is brilliant and can’t wait to try it out myself.