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

2

6

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?

Multinuclear answered 26/2, 2013 at 23:3 Comment(1)
Meh, screw both the BIOS and UEFI, at least until you have no choice. If it's text you want, all you have to do is put it at linear 0xB8000 aka real mode 0xB800x0x0000 and print it in pairs of 2 bytes, one ascii one color.Impeccant
L
9

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.

Levan answered 27/2, 2013 at 19:48 Comment(0)
C
4

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.

Constellation answered 27/2, 2013 at 9:55 Comment(3)
So does this mean I should not use the INT 10h in just my boot loader? or also my OS? Does my OS have to use functions from the UEFI Library? If I have gathers things right, after the exitBootServices(), I cannot use UEFI functions.Multinuclear
You would indeed not use INT 10h from your UEFI bootloader. You can use INT 10h in your OS though, but you'll most likely want to write a screen driver that writes directly to the video buffer.Constellation
@LordLoh. After exitBootServices() you can't use boot services any more. There are some UEFI services (called UEFI runtime services) that you can still call into, such as changing the screen resolution even after exitBootServices has been called.Levan

© 2022 - 2024 — McMap. All rights reserved.