21

I haven't been coding much lately, but I've decided I want to start working on OS development again. Recently I heard about a system better than BIOS. I want to develop an OS for a platform that uses EFI rather than BIOS. I don't know where to start. Can anyone point me in the right direction? Quite frankly, I'm not really sure exactly what EFI is. I'm really lost and I would love to hear your input.

Thanks

3 Answers 3

29

EFI is the precursor to UEFI, which is what people actually use, although they still sometimes refer to the thing as EFI. You can get the specifications involved at uefi.org.

The UEFI Specification defines everything a boot loader might need to know. The PI Specifications define interfaces for silicon vendors to use for portability of their code in the industry. So you will hear about an OS, like Win8, requiring compliance with a certain version of the UEFI Specification, like 2.3.1c, for some features to work, like secure boot. All this goes to say that EFI does not replace BIOS so much as become a standard to which the BIOS must comply to support some operating systems.

The place to go to get started (after you get a copy of the specifications) is the TianoCore project on SourceForge. One of the projects there is OVMF, which is a virtual machine target for UEFI. You may also want to look at the NT32 target for running a command prompt under windows. These are really great tools to use when you want to design an application, like a boot loader, that sits on top of the UEFI interfaces.

As far as learning assembly, I don't recommend you start there. There is so much to know, and part of the reason that we created UEFI is so that new programmers could work in C instead of ASM. There are a few places in UEFI where we use ASM, but the build system handles the details for splicing that in, and you generally don't need either the tricky control of the state of the processor or the performance you would get from writing the ASM. The only other reason you would do it is size, and since the rest of the BIOS is going to be in C, it sort of defeats the purpose unless you rewrite the whole thing in ASM, which no one is going to do. Focus on learning the specifications and how to use them to write your own UEFI applications.

11

A late answer to this question, but I can add the following points if you haven't discovered them in the mean time:

Maybe explain what EFI means to OS development

Actually, not a lot. Well maybe a little. Okay, let's explain. UEFI provides the firmware environment for a pre-boot stage. It also provides some runtime services to the operating system, however, it is expected the operating system, not the UEFI firmware, will eventually drive the system - these services allow you perform various boot-configuration related activity - example.

The upside is that if you are prepared to use a bootloader that conforms to say multiboot 2 you don't actually need to know anything about UEFI - the bootloader will load you up according to the multiboot spec, then call ExitBootServices() which in UEFI terms destroys the firmware environment.

It is possible to produce a Linux kernel which has an EFI stub and therefore boots "without" a boot loader - this blog shows you how. You could do this for your kernel - you simply need to produce a PE/COFF kernel matching the firmware bitness.

and maybe tell me what testing environments (preferably virtual) I can us

If you can afford VMWare Workstation, this will help you massively. As well as containing a gdb stub such that you can debug any part of anything, you can also edit the virtual machine definition files (*.vmx) to contain

firmware="efi"

and voila, VMWare will boot a fully working UEFI environment. Works with Linux and Windows.

Various posts around the internet mention QEMU setups and of course VirtualBox. I have never personally successfully booted any existing system on the VirtualBox EFI platform, and I haven't tried QEMU, although I believe it and the various other emulators out there probably work.

Also should I invest time looking into ARM assembly?

That depends on your objectives. On the question of assembly, I think you should know it to write an OS. I don't think it matters for which platform you write - in fact, I think writing for multiple will make you more appreciative of the differences between machines.

Generally, however, I wouldn't attempt to write an entire OS in assembly. The principle reason for this is time - I assume this is a hobby project, so getting some reward for your extensive effort is going to be much more fun than slogging it out trying to debug assembly especially one for which you are not familiar. You can always, as you become more proficient, replace choice bits with assembler, especially as you have enough of the rest of the code to test it with.

2

You can use qemu to do some uefi application development/testing. See this for more info

Apart from that I would highly recommend getting familiar with uefi and trying to do some driver/app development in the uefi model. You could try things like running the network stack from the loader,netbooting infrastructure,probably setting up a neater pre-OS GUI. This will not only make you good at uefi but will help you understand platform specifc details.

Thats my say,but the comments above are good to bear in mind.

Not the answer you're looking for? Browse other questions tagged or ask your own question.