Execute other machine code from kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
24ratcma
Posts: 1
Joined: Thu Sep 17, 2020 1:02 pm
Libera.chat IRC: 24ratcma

Execute other machine code from kernel

Post 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.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Execute other machine code from kernel

Post 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.
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: Execute other machine code from kernel

Post 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.
If something looks overcomplicated, most likely it is.
Post Reply