Loading a 64bit kernel
Posted: Wed Jan 23, 2019 11:40 am
I'd really appreciate some hints where I could start if I want to load a 64bit C kernel using my own bootloader (like resources to read..) . I understand that loading 64bit kernels is different since you have to (?) use the fastcall calling convention. I initially wanted to use an x64 PE kernel compiled with the Visual C++ compiler, but as I understand it's quite hard to configure the compiler, I thought I'd better go with ELF (I still like the PE idea more, since doing more research into PE executables may come in handy as I've been studying a little malware analysis on Windows).
EDIT: Reading @bzt's post from here with a little more attention ,it seems that he addressed quite a few of my issues. As far as I was able to understand, it should be fine to call the entry point with a simple 'call' provided I define it as having no arguments in C? Actually, it wouldn't make sense to behave otherwise.
EDIT:
1. My real problem is connecting the bootloader (assembled using NASM) and the kernel's executable (compiled using the Visual C++ compiler).
2. Things I managed to do so far: reading from disk, jumping into the stage 2 bootloader, setting up long mode.. I also managed to build the x86_64-elf-gcc cross compiler, but I'd still like it better if I could go with PE executables instead (I read GCC can also output executables for MinGW, but I'd rather not go with that).
3. With regard to long mode, could someone point me to some resources where I could read about the GDT (entries) needed in long mode? I know about the Intel/AMD manuals, but I'd like more information about the entries (like the null one etc).
EDIT: Reading @bzt's post from here with a little more attention ,it seems that he addressed quite a few of my issues. As far as I was able to understand, it should be fine to call the entry point with a simple 'call' provided I define it as having no arguments in C? Actually, it wouldn't make sense to behave otherwise.
EDIT:
1. My real problem is connecting the bootloader (assembled using NASM) and the kernel's executable (compiled using the Visual C++ compiler).
2. Things I managed to do so far: reading from disk, jumping into the stage 2 bootloader, setting up long mode.. I also managed to build the x86_64-elf-gcc cross compiler, but I'd still like it better if I could go with PE executables instead (I read GCC can also output executables for MinGW, but I'd rather not go with that).
3. With regard to long mode, could someone point me to some resources where I could read about the GDT (entries) needed in long mode? I know about the Intel/AMD manuals, but I'd like more information about the entries (like the null one etc).