Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does booting in EFI mode mean that I shall not have access to BIOS interrupts?

I am attempting to develop a simple OS. I have done some assembly programs before and have had to use INT 10h to display characters to the screen. I understand that UEFI has support for legacy BIOS and may still be able to use INT 10h services. However, If I choose to build a pure UEFI bootable OS, should I avoid using INT 10h? Or am I looking at things the wrong way?

In other words, does the drilled down printf to stdout (screen) end up calling the BIOS INT 10h? Or is the question - "Is SYS_WRITE function call based on INT 10h?" more appropriate?

Will I still have to create a boot sector with 512 bytes and place them as the zeroth sector on a disk (or disk image)? Does the location 0x7c00 have significance anymore?

like image 261
Lord Loh. Avatar asked Feb 26 '13 23:02

Lord Loh.


2 Answers

If your bootloader is a UEFI bootloader (you will know if it is), then you may not use BIOS at all including int 0x10 - you must use UEFI bootservices which provide all of the functionality that BIOS would otherwise provide to legacy boot systems.

If you are not writing a UEFI bootloader, but your hardware is UEFI enabled, your bootloader will be loaded in "legacy" mode, and you will be able to use BIOS as before.

Or to put it another way, your boot image can either be a UEFI bootloader, or it can be a legacy BIOS image. Legacy BIOS images can't use UEFI, and UEFI bootloaders can't use BIOS.

In other words, does the drilled down printf to stdout (screen) end up calling the BIOS INT 10h? Or is the question - "Is SYS_WRITE function call based on INT 10h?" more appropriate?

Depends who wrote your printf function (you're the OS, there's no-one beneath you). If you call Int 0x10 and haven't set up the IDT to handle that as a call into UEFI to write a character to the screen, then you're just using undefined behaviour.

Will I still have to create a boot sector with 512 bytes and place them as the zeroth sector on a disk (or disk image)? Does the location 0x7c00 have significance anymore?

No, and no. UEFI supports much larger bootloaders, and are not loaded at 0x7C00. If you want to know which memory regions have special significance, you must ask UEFI to give you a memory map.

like image 99
SecurityMatt Avatar answered Sep 21 '22 16:09

SecurityMatt


The PC BIOS is not part of the UEFI programming model, so you shouldn't use it in UEFI applications. For printing to the screen for instance you would use a function from the UEFI library.

Reading the first sector from a disk and loading it to 0x7C00 is a BIOS specific booting protocol. UEFI bootloaders are loaded from a filesystem. You can read more about it on the OSDev Wiki.

like image 45
Martijn van den Broek Avatar answered Sep 23 '22 16:09

Martijn van den Broek