Q
Q
Qreen2021-07-11 23:41:45
Loaders
Qreen, 2021-07-11 23:41:45

UEFI - is it possible to boot a flat bin file?

I continued to study the assembly language (nasm) and low-level programming in C, until I completed the simplest bootloader that worked on BIOS interrupts and put the processor into protected mode. After that, I wrote a simple kernel in c and nasm, which can read the clave port (60h) and throw values ​​from there into the c function. It makes no sense to tell what was implemented next. I can only say that my axis worked without any problems both on qemu and on a real machine with BIOS. And then I knew the pain. After trying to boot my kernel bootloader on my new UEFI laptop, not only did it refuse to work with my OS, it didn't even see the flash drive. At the moment, the layout is this: I can compile and load a simple efi program, like:

#include <efi.h>
#include <efilib.h>
EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
   InitializeLib(ImageHandle, SystemTable);
   while(1);
   return EFI_SUCCESS;
}

I also roughly understand what GPT and MBR are. Is it possible to download my flat bin file, or did I still waste my time developing it?

PS The binary was compiled like this:
nasm -f elf32 kernel.asm -o kasm.o
gcc -m32 -c kernel.c -o kc.o -fno-pie -fstack-protector
ld -m elf_i386 -T link.ld -o kernel kasm.o kc.o
objcopy -O binary kernel kernel.bin
nasm -f bin boot.asm -o boot.bin

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question