flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Format options for UEFI OS bootloader Goto page Previous 1, 2 |
Author |
|
sinsi 26 Oct 2023, 23:34
You can download the UEFI spec from https://uefi.org/specsandtesttools
|
|||
26 Oct 2023, 23:34 |
|
pfranz 27 Oct 2023, 01:28
sinsi wrote: You can download the UEFI spec from https://uefi.org/specsandtesttools I cannot find where it says that an OS bootloader must be called according to the fastcall specification. Why not use a simple jump? |
|||
27 Oct 2023, 01:28 |
|
revolution 27 Oct 2023, 02:26
pfranz wrote: Why not use a simple jump? |
|||
27 Oct 2023, 02:26 |
|
sinsi 27 Oct 2023, 02:50
|
|||
27 Oct 2023, 02:50 |
|
pfranz 28 Oct 2023, 13:27
sinsi wrote: Not sure if you need a GPT disk and/or an EFI System partition (type 0xEF) for booting Could you please post the VHD of this example? I tried creating a VHD myself, another using GParted, but I always end up in the UEFI shell and have to manually boot from file. VirtualBox version is 6.1.48. |
|||
28 Oct 2023, 13:27 |
|
sinsi 28 Oct 2023, 14:08
I'm using VirtualBox 7.0.8, so ymmv
|
|||||||||||
28 Oct 2023, 14:08 |
|
Feryno 28 Oct 2023, 18:21
pfranz wrote:
use this: Code: lea rdx,[string] That's because when uefi finds the base address specified in your binary already used, it relocates binary to different base address - the solution is to use relocs or to use RIP-relative addressing mode which works no matter at which base address is the binary relocated. Did you try to create FAT12 formatted 1,44 MB floppy image and put you program into \EFI\BOOT\bootx64.efi ? Yes hdd image should be GPT formatted (you can use e.g. linux for creating and accessing such image), so floppy image seems to be much easier to create / write file there. |
|||
28 Oct 2023, 18:21 |
|
pfranz 30 Oct 2023, 03:46
I tried sinsi's harddisk image and it didn't work. After a lot of experimenting, it turned out that it was some kind of misconfiguration in VirtualBox, that wouldn't be fixed by reinstalling it and deleting the virtual machines directory.
So I reinstalled Linux and both sinsi's and my hard disk image worked straightaway in VirtualBox 6.1.48 and 7.0.12. My disk image has just a legacy mbr with only one EF partition from lba1 to the end. I create the partition with mkfs.msdos -C, I mount it, I copy the uefi files, I unmount it, I append mbr and vhd sections, and it works. I tried with the diskette image but apparently uefi doesn't even see the volume. |
|||
30 Oct 2023, 03:46 |
|
revolution 30 Oct 2023, 05:10
pfranz wrote: So I reinstalled Linux ... |
|||
30 Oct 2023, 05:10 |
|
pfranz 30 Oct 2023, 19:02
Feryno wrote: Did you try to create FAT12 formatted 1,44 MB floppy image and put you program into \EFI\BOOT\bootx64.efi ? Yes hdd image should be GPT formatted (you can use e.g. linux for creating and accessing such image), so floppy image seems to be much easier to create / write file there. After reinstallation, my legacy MBR EF hard disk image worked fine. I prepared a CD image with no emulation EF partition as per specification, it booted too. Everything was working flawlessly. Then I built a 1.44 floppy image the way you described (that is how I did the hd and cd partitions), tried to boot from it, UEFI found no map and didn't even see it. Removed floppy controller, attached hard disk and cd. None of them works now: they drop into the shell and I have to launch bootx64.efi manually, using "Boot from file". By the way, where does VirtualBox keep its configuration? I deleted the virtual machines and /etc/vbox directories, but still remembers my machine on reinstallation. |
|||
30 Oct 2023, 19:02 |
|
revolution 30 Oct 2023, 19:54
pfranz wrote: By the way, where does VirtualBox keep its configuration? Code: ${HOME}/.config/VirtualBox/VirtualBox.xml |
|||
30 Oct 2023, 19:54 |
|
pfranz 31 Oct 2023, 05:11
Feryno wrote: Did you try to create FAT12 formatted 1,44 MB floppy image |
|||
31 Oct 2023, 05:11 |
|
Feryno 31 Oct 2023, 10:18
pfranz - I didn't. It is an idea which may help you to track the problem. I work directly on hardware and not on emulators. I execute 'efi' app from USB stick under uefi shell and I start 'efiboot' from hdd (GPT formatted with EFI system partition) after writing necessary nvram variables (BootXXXX, BootOrder).
You can create such floppy in a way like this: dd if=/dev/zero of=./fd.img bs=512 count=2880 mkfs.msdos ./fd.img mkdir /mnt/floppy mount ./fd.img /mnt/floppy -o loop mkdir /mnt/floppy/EFI mkdir /mnt/floppy/EFI/BOOT cp mybinary.efi /mnt/floppy/EFI/BOOT/bootx64.efi umount /mnt/floppy
|
|||||||||||
31 Oct 2023, 10:18 |
|
pfranz 01 Nov 2023, 04:12
Feryno wrote: pfranz - I didn't. It is an idea which may help you to track the problem. I work directly on hardware and not on emulators. I execute 'efi' app from USB stick under uefi shell and I start 'efiboot' from hdd I had built my image exactly as you described (save that I use mkfs -C option instead of dd), and your image is not seen at all, like mine. Have you ever booted a real efi system from floppy, or know someone who did? |
|||
01 Nov 2023, 04:12 |
|
Feryno 01 Nov 2023, 11:44
I tried just now with vmware workstation 16 and the floppy image works well
If you manage to make the floppy image to work, you can copy there your executable and debug it (there is uefi debugger). These commands: s single step t trace over g run c code dump h help
|
|||||||||||||||||||
01 Nov 2023, 11:44 |
|
pfranz 02 Nov 2023, 23:50
Feryno wrote: I tried just now with vmware workstation 16 and the floppy image works well Anyway I don't think I need to debug EFI applications, but with 15.5.7 I couldn't find how to use EFI. Thanks for your suggestions, though. |
|||
02 Nov 2023, 23:50 |
|
Feryno 03 Nov 2023, 03:59
That's why I'm still using 16.1.0 build-17198959 because I read that 16.2 disabled mounting hard disk images into host OS so I did not update to newer versions since then.
Bugs are everywhere, especially in such big product like this. VmWare ESXi uses also the same hypervisor and it was possible to completely crash VM in ESXi 6.7 on an attempt to start a child hypervisor inside VM with disabled (!) CR8 load exiting on Intel CPU, surprisingly it ran well with this feature enabled (just with much worse performance due to much more unwanted vm exits). They luckily fixed it in ESXi 7. |
|||
03 Nov 2023, 03:59 |
|
bzt 17 Jan 2024, 09:46
pfranz wrote: I meant, where in the UEFI specification is written that an OS bootloader must be treated as a FASTCALL routine? pfranz wrote: Because it sounds strange to me (I would transfer control with a jump, there is no need for a call): it may be common practice now but not in the future pfranz wrote: I read in the spec that GPT requires an EE protective MBR and cannot coexist with an EF system partition. pfranz wrote: My disk image has just a legacy mbr with only one EF partition from lba1 to the end. I create the partition with mkfs.msdos -C, I mount it, I copy the uefi files, I unmount it, I append mbr and vhd sections, and it works. pfranz wrote: I asked because I think an EFI system is not supposed to boot from a floppy |
|||
17 Jan 2024, 09:46 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.