Page 1 of 1

Execute other machine code from kernel

Posted: Thu Sep 17, 2020 1:07 pm
by 24ratcma
Hello. I am new to OS developing and I started working on my very first operating system. So far it is just one kernel file in a iso, but I was wondering how would I be able to make a C function that would execute a .asm or a machine code file in the same directory? Would I have to do stuff with file management? Thank you for your time.

Re: Execute other machine code from kernel

Posted: Thu Sep 17, 2020 9:16 pm
by alexfru
Yes, you'd need some kind of file system and some kind of memory manager and probably also a scheduler and a bunch of device drivers (timer, disk, keyboard/display/UART)...

Or you could fake most of it by showing different pictures in response to keyboard input. But then it wouldn't be an OS, obviously.

Re: Execute other machine code from kernel

Posted: Fri Sep 18, 2020 2:04 am
by Velko
It's a long way until you'll be able to load additional files from disk.

At the beginning, the easiest way is to link everything together into a single kernel binary.

Once you really start to feel need for separate binaries (userspace programs, etc.) the next step might be to configure bootloader (e.g. GRUB) to load them as modules. Bootloader will place them somewhere in the memory, you'll have to figure out the exact addresses by parsing the information (Multiboot structures), it passes to your kernel.