copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser
https://copy.sh/v86/
BSD 2-Clause "Simplified" License
19.87k stars 1.41k forks source link

Support for UEFI BIOS #263

Open jparris opened 5 years ago

jparris commented 5 years ago

Hi there,

I made an attempt to boot using a uefi bios and failed. I'd loved to see uefi support so I can demo a personal project on a webpage.

I attempted to boot using a prebuilt ia32 uefi package from here https://www.kraxel.org/repos/jenkins/edk2/

I unpacked the files like so

ymir:foo$ rpm2cpio edk2.git-ovmf-ia32-0-20181129.806.ga5274cdc87.noarch.rpm | cpio -idmv
./usr/share/doc/edk2.git-ovmf-ia32
./usr/share/doc/edk2.git-ovmf-ia32/README
./usr/share/edk2.git
./usr/share/edk2.git/ovmf-ia32
./usr/share/edk2.git/ovmf-ia32/OVMF-need-smm.fd
./usr/share/edk2.git/ovmf-ia32/OVMF-pure-efi.fd
./usr/share/edk2.git/ovmf-ia32/OVMF-with-csm.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_CODE-need-smm.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_CODE-pure-efi.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_CODE-with-csm.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_VARS-need-smm.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_VARS-pure-efi.fd
./usr/share/edk2.git/ovmf-ia32/OVMF_VARS-with-csm.fd
./usr/share/edk2.git/ovmf-ia32/UefiShell.iso
29490 blocks

Then moved the UEFI binary & iso in v86

ymir:foo$ cp usr/share/edk2.git/ovmf-ia32/OVMF-pure-efi.fd ../v86/bios/
ymir:foo$ cp usr/share/edk2.git/ovmf-ia32/UefiShell.iso ../v86/images/

I made these changes to basic.html to point to the uefi bios & iso.

--- a/examples/basic.html
+++ b/examples/basic.html
@@ -12,13 +12,10 @@ window.onload = function()
         vga_memory_size: 2 * 1024 * 1024,
         screen_container: document.getElementById("screen_container"),
         bios: {
-            url: "../bios/seabios.bin",
-        },
-        vga_bios: {
-            url: "../bios/vgabios.bin",
+            url: "../bios/OVMF-pure-efi.fd",
         },
         cdrom: {
-            url: "../images/linux.iso",
+            url: "../images/UefiShell.iso",
         },
         autostart: true,
     });

The last step were make run and finally navigated to http://127.0.0.1:8000/examples/basic.html only to see black screen and no output. I also tried leaving the vga bios in place.

Note I can boot into the uefi shell with qemu-system-i386 -bios bios/OVMF.fd -cdrom images/UefiShell.iso

Cheers, Jon

BelleNottelling commented 5 years ago

You have two vga bioses and are still using the original bios.. Or am I mistaken?

jparris commented 5 years ago

Hi Ben,

The basic.html section was a diff although I didn't explain that. Here's the js section plain.

[nix-shell:~/v86]$ cat examples/basic.html 
<!doctype html>
<title>Basic Emulator</title><!-- not BASIC! -->

<script src="../build/libv86.js"></script>
<script>
"use strict";

window.onload = function()
{
    var emulator = window.emulator = new V86Starter({
        memory_size: 32 * 1024 * 1024,
        vga_memory_size: 2 * 1024 * 1024,
        screen_container: document.getElementById("screen_container"),
        bios: {
            url: "../bios/OVMF-pure-efi.fd",
        },
        cdrom: {
            url: "../images/UefiShell.iso",
        },
        autostart: true,
    });
}
...
BelleNottelling commented 5 years ago

Could you please upload these bios files? I don't know how to extract / use a rpmfile

jparris commented 5 years ago

Hi Ben,

Here you go. I had to zip together OVMF-pure-efi.fd & UefiShell.iso into ovmf-ia32.zip because of github upload restrictions.

Cheers, Jon

BelleNottelling commented 5 years ago

Thank you!

copy commented 5 years ago

Is edk2 for real machines? What does qemu use for UEFI boot? I believe seabios has an uefi build, which is more likely going to work.

I also tried leaving the vga bios in place.

The vgabios is loaded by the bios (using a legacy mechanism), it's very unlikely to be loaded by your uefi. Also note that the bios is responsible for booting the CD, so you'll need to leave the bios in place if you want to run the uefi from an iso image.

CompeyDev commented 6 months ago

Hey! This thread doesn't really clarify what the way to go forward is; how should I go ahead to load an EFI program? Does SeaBIOS have a UEFI build? How can I get my hands on that?

What does qemu use for UEFI boot?

For QEMU, we tend to use OVMF for EFI booting.