C ++ execute code from file system

First of all, it was difficult to understand the name, and it is a bit ambiguous, but good.

Ok, so I have a mixed C ++ program and asm bootloader. I can copy it to my mbr and run. The only problem I am facing is the fact that mbr is very small. I assume that it is intended only to call external code written somewhere else on disk. My problem is that I'm not sure how to access this. I mean, I can put data there, I just don’t know how to programmatically access this data, since in essence the disk will not have a “file system”, just arbitrary code.

I searched the web, but the textbooks on real low-level development seem scarce.

I am even ready for a C ++ library, if one exists.

+4
source share
3 answers

The BIOS installs several interrupt handlers before running the code in the MBR. One of them can be used to work with read / write sections directly from the hard drive without an OS, device drivers, or file system.

This interrupts 19 ( 13H as better known).

You will need to use this to read the code, and then just jmp .

+2
source

Good old BIOS calls for PC. If your board is not a PC, you need information from the board manufacturer on how to access the IDE / SATA controller.

+4
source

Without knowing the platform, it is difficult to give anything but the most general overview.

The initial boot code usually asks for system firmware to copy additional blocks from disk to memory, and then can call the code contained here. On a PC system, this will mean a BIOS call.

+2
source

All Articles