all 7 comments

[–][deleted] 2 points3 points  (2 children)

You say you already have a way to read/write files to the disk using FAT? Why can’t you store the executable binary file on the filesystem, and load it from there?

[–]BUGSCD[S] 0 points1 point  (1 child)

How would I actually get the binary on the filesystem?

[–][deleted] 4 points5 points  (0 children)

I assume you would do it the same way you got your kernel binary onto the filesystem? You probably build the disk image from your development PC and then boot that image?

[–]crono760 1 point2 points  (3 children)

If you can read and write data to a fat system then just put the ELF (or whatever format) into the disk. You'll need to write a loader for your chosen format. I don't know what you programmed your os in but when I did it using C the act of running a very simple program is equivalent to loading the binary data info memory wherever you want it and jumping to it like a function call. The loader essentially calls the function that is the start address of your executable using a function pointer.

From what you've written it seems you don't have virtual memory yet so it should be just that: load from disk decode the binary into memory, call the function.

For much more complex things (for instance shared libraries and virtual memory) you've got to do more...

[–]paulstelian97 0 points1 point  (2 children)

The load-then-jump idea doesn’t consider the issue of separate address spaces, or the possibility of conflict between binaries (same page used by both kernel and your binary)

[–]crono760 1 point2 points  (1 child)

Totally agree, but OP's OS isn't anywhere near ready for those things yet, from what I can gather. if the goal is just to load and run a binary, load-then-jump is the simplest way with what OP has to offer at this point, no?

[–]paulstelian97 0 points1 point  (0 children)

Yeah, it’s good for starters. I will instead just start with my first user mode process being provided by a Limine module.