Here's how BIOS works: basically, the computer loads the first 512 bytes of disk into memory and jumps to it. The OS takes over from there and does whatever it needs to, like bootstrapping stage 2 and loading the kernel from the filesystem. The spec[0] is 46 pages long and you are granted the rights to reproduce, distribute, and implement it free of charge.
Want to know how UEFI works? The spec[1] is a 2,899 page PDF which you have to pay to use in any way, including writing an implementation.
[0] https://web.archive.org/web/20110715081320/http://www.phoeni...
[1] https://uefi.org/specifications
Every copy of this specification should be found and burned. The ashes should be buried deep in a dark place and the earth above salted. Anyone who thinks this is the first rootkit made for it is completely insane. This thing was probably explicitly designed with rootkits in mind.