3 ms·
This project sounds amazing and very interesting! I have one question: how does it work on bare metal? I tried to look for an explanation in the documentation b
by etamponi 6y ago
This project sounds amazing and very interesting! I have one question: how does it work on bare metal? I tried to look for an explanation in the documentation but I couldn't find anything. The specific questions I have are:
1) How does this interact with a boot loader like GRUB? Or does it come with its own boot loader? But in this case, shouldn't this go in a specific location on the boot disk?
2) How does it handle io in bare metal mode? Specifically: sockets.
- jart 6y agoAuthor here. Bare metal so far has been a "we built it because we could" kind of feature, so please be warned it's not as polished. Here's a quick tutorial. Basically, ape/ape.S is a traditional BIOS bootloader. It also embeds a GRUB stub, which basically just switches back to the real mode BIOS bootloader entrypoint. So it should work with or without GRUB. The boot sector loads the rest of your executable of disk and prints "actually portable executable" to your display. It then configures standard i/o to use serial uart, sets up the page tables, enters long mode, and calls _start(). That's all I've got working so far. I would love to have e1000 and virtio though! To try it out, here's how you build the included PC BIOS system emulator and boot an x86-64 ape executable that prints a spinning deathstar: m=tiny; make -j12 MODE=$m o/$m/tool/build/blinkenlights.com o/$m/tool/viz/deathstar.com && o/$m/tool/build/blinkenlights.com -rt o/$m/tool/viz/deathstar.com Video screencast: https://justine.lol/cosmopolitan/deathstar.html https://justine.lol/cosmopolitan/deathstar.html See also: https://justine.lol/blinkenlights/manual.html https://justine.lol/blinkenlights/manual.html Enjoy!
- etamponi 6y agoThank you, so if I understood correctly, I should write the binary starting from the boot sector, and it can overflow and go on subsequent sectors too, because ape/ape.S will be at the beginning of the binary, and so the boot sector will have the necessary bits in place to load the rest of the program in memory. Am I right? Can't wait to try it!