M8SBC-486: BIOS
[Go back to the main page of this project] [Previous part]

This content may be updated as the BIOS is still in development. Last updated: 09/01/2025
Also, the BIOS sources on the project's GitHub are coming soon
First version BIOS

I already have a working machine that can execute something. However, I want it to do more, such as being able to boot existing operating systems like DOS or Linux. For that, I need a BIOS (Basic Input/Output System). However, my system is not fully PC compatible, so most existing BIOSes probably won't work. So, I decided to write one myself. Something minimal - just enough to boot DOS.
BIOSes from that era are written in assembly. I found that boring and exhausting, so I decided to make C work on this thing. There's one issue: the CPU is running in real mode. This means there is no memory protection, a limit of 16-bit instructions, and segmented memory access. The latter is problematic for higher-level programming languages like C. I eventually found something that might work for my needs: ia16-elf-gcc. It's a GCC port for 16-bit x86 processors, like the 8086. It works in real mode. Its current maximum target is the 286 processor (it won't generate instructions or use features of the 386, 486 or later processors), but its ability to target real mode is what made me choose it. Nevertheless, you will see later that I had to write assembly code anyway.
As for the name, I decided to go with "SeaPig." It's definitely not inspired by anything...
Initialization
Before running C, we should test some of the memory and prepare the C environment (prepare the segment registers, zero the BSS, etc.). We have to do this mostly in assembly because we don't really have another option. While checking the memory, we can only trust the storage in the CPU registers. So, the pre-C part consists of:
- PIC initialization
- Cache initialization
- Base 64 KB memory test
- Set up the stack
- Detect the CPU model
- Prepare C environment
Graphics logo in text mode
One of my childhood memories is of the Award BIOS and its famous Energy Star logo in the top right corner. One interesting thing about it is that it's a bitmap displayed in text only mode. It would be cool to recreate that. The first thing I implemented in this BIOS was the graphics logo. It might not be very serious, but I think it's cool and it's a kind of stability test before booting further (as it must use I/O and memory).
The Award BIOS and other BIOSes that display logos in text mode modify the VGA font to do so. Each character is 8x16 pixels. The VGA font has 256 entries, but most of the time only half of them are used (mainly letters and numbers). We can use the remaining characters to display something else. After reading some documentation and looking at some code I found on the internet, I managed to implement this. I did it this way: First, I wrote a Python script that converts a bitmap into an array that I can write directly into the font data. The script also generates a mapping for the characters. It even checks for repeating segments to save characters. In the BIOS code, I first save the characters that I will replace into RAM so that I can restore them after POST. Then, I write my custom font data and finally, I write the characters in the fixed positions as defined by the mapping. We have the logo displayed! We can color it based on the division into characters, with a maximum of two colors for the 8x16 area. After POST, we just have to restore the font.

I also added a display of the information detected by the pre-C section, which, in my opinion looked pretty nice at that point. Since the CPUID instruction only appeared in late 486 models, I couldn’t rely on it and chose not to implement a check for its presence. At the time there were only a few major x86 vendors: Intel, AMD and Cyrix. They all followed Intel’s design closely. AMD made an almost identical clone, while Cyrix differed in how it handled division. That behavioral quirk made it possible to distinguish Cyrix chips from the Intel/AMD group, although telling Intel and AMD apart remained difficult. To identify the specific 486 variant (SX, DX, or DX2), I used a feature common to all of them. After a reset, these processors place their identification value in the EDX register. Because I am writing the BIOS, I can just save that value and use it later. More information on CPU detection, including the Cyrix quirk can be found here.
After getting basic things to work, I started working on BIOS interrupts. Real mode operating systems such as MS-DOS require them to function. They essentially allow the operating system to easily interface with the hardware and many programs use them. So far, I haven't implemented enough of them to boot DOS. I got the "Starting MS-DOS..." message, meaning I passed the first stage of the bootloader but not any further. I will update this section later on as I manage to boot DOS or get further.
For now, this BIOS only supports performing the POST and booting from the primary IDE drive. This implementation is sufficient to boot some hobby operating systems. At one point, I started developing my own operating system before switching to developing a port of Linux. Notably, my OS was capable of booting on both the M8SBC-486 and a real x86 PC.
The image below shows cubicDoom running on the M8SBC-486. It's a ray-casting game that fits in a boot sector. Since the keyboard controller was unfinished, I couldn't move but it worked!

Rewritten BIOS
The thing that bothered me the most was that I couldn't get MS-DOS to boot. Out of curiosity, I started looking on GitHub for BIOS projects to see what I was doing wrong or to try to get one running. I came across this BIOS made by b-dmitry1. I modified it slightly, such as removing the second PIC initialization and it worked! From my initial tests, the BIOS has issues with CompactFlash cards in its original form (or maybe some incompatibility issue occurs when running it on my board). So, I wrote an MS-DOS 6.22 image with HIMEM disabled to an IDE hard drive and I couldn't believe my eyes - MS-DOS booted "first try"! Read more about MS-DOS here. I contacted the author regarding licensing and rights to this BIOS because the repository didn't have a LICENSE file at the time. He praised my board (thanks) and added an MIT license. Therefore, I decided to rewrite my BIOS from scratch, this time based on his code. Special thanks to him for his work!

I don't think my previous work was worthless, as it allowed me to test the stability of my board and learn a lot about BIOS development.
I started working on the BIOS by expanding it. The fancy features, such as the POST screen and hard drive detection were created using new C code. The real mode assembly and C code are stored in two different binary blobs. The assembly code calls the C binary which switches the CPU to protected mode, does its work, switches the CPU back to real mode and passes control back to the assembly. I decided to run the C code in protected mode because it's easier to write and compile C code for that mode. Also, I can test the entire memory range, not just the first megabyte (as limited by real mode). Here's a list of what my BIOS adds/modifies:
- A POST screen with CPU detection and a logo (code mostly taken from my previous BIOS version)
- Hard drive detection
- Full memory test
- My board and 486 specific features (cache)
- Extended BIOS INT calls (memory map, LBA hard drive access)
- An "About" page showing the BIOS version, credits and project info
- Settings menu (BIOS menu)
- Better compatibility with hardware and software
A screenshot of this BIOS POST is at the top of this page.

More coming soon
Last updated: 09/01/2026




![Validate my RSS feed [Valid RSS]](http://maniek86.xyz/cmsesus/uploads/image/valid-rss-rogers.png)
