0

So years back my high school computer science teacher was going on about that games from the early days could "now" be fitted on a bios chip. Later decided to study engineering thanks to that guy. A bunch of years passed, bios flash chips got bigger and now I decided to take on the challenge. I dug up a small kernel and user space image from a class and decided to use it as a base. It's a small multi threaded network game, a couple of MBs in size. I still have the source code but as university projects went, we didn't use version control and it might take quite sometime to get it working again. I still have the working images though. Note, the kernel is responsible for the switch to long mode.

kernel-x86_64-pc99: ELF 32-bit LSB executable, Intel 80386
module: ELF 64-bit LSB executable, x86-64

Of course I could use some UEFI and embed the images together with grub but that's just overkill and not the point of the exercise as I kinda want to explore the bare metal x86 area.

I don't need a huge setup, basically just a PCI net device and serial for debugging. So I decided to modify a small bios i.e. qboot to my needs. Everything runs with qemu (+ kernel + initrd option) but qboot loads the kernel+module from the qemu fw_cfg. Now I am trying to get rid of all the qemu stuff and there is still things to do.

And here is my question, how do I add the images to the bios binary?

Can I somehow add the images (as a section) to my bios elf before dumping it as a binary? And how would I later in my bios code find the address and size of my images?

Currently I am testing everything on qemu to not burn my flat but later I intend to flash it onto an old Gigabyte Mobo.

meME
  • 1
  • 1
  • 2
    This won't work unless you **deeply** know what a BIOS actually does nowadays. For example, you **can't use the RAM** until you initialise the memory controller. You can't use the PCI until you initialise the PCIe root ports. You need a FIT since Haswell and you need a valid flash descriptor for the PCH to boot the system. And so on. Some of these initialisation are not documented. You can start studying the Coreboot project but it won't be just like writing binaries to the flash ROM. The easiest way is doing an ELF DXE but that won't be "bare metal". – Margaret Bloom Mar 04 '21 at 22:19
  • It's probably easier to do this on an ARM SoC. x86s are employed in extremely different machines and require a lot of initialisation. But if you have time, it's surely a fun project! – Margaret Bloom Mar 04 '21 at 22:22

0 Answers0