uefi: Add hacky support for determining boot drive was a CD
This commit is contained in:
parent
094c8eca5b
commit
7950ac5997
16
Makefile
16
Makefile
|
@ -6,7 +6,7 @@ DESTDIR =
|
|||
|
||||
PATH := $(shell pwd)/toolchain/bin:$(PATH)
|
||||
|
||||
.PHONY: all clean install distclean limine-bios limine-uefi limine-bios-clean limine-uefi-clean stage23-bios stage23-bios-clean stage23-uefi stage23-uefi-clean decompressor decompressor-clean toolchain test.hdd echfs-test ext2-test fat16-test fat32-test iso9660-test pxe-test uefi-test
|
||||
.PHONY: all clean install distclean limine-bios limine-uefi limine-bios-clean limine-uefi-clean stage23-bios stage23-bios-clean stage23-uefi stage23-uefi-clean decompressor decompressor-clean toolchain test.hdd echfs-test ext2-test fat16-test fat32-test iso9660-test pxe-test uefi-test uefi-iso9660-test
|
||||
|
||||
all:
|
||||
$(MAKE) limine-uefi
|
||||
|
@ -191,6 +191,20 @@ iso9660-test:
|
|||
genisoimage -no-emul-boot -b boot/limine-cd.bin -boot-load-size 4 -boot-info-table -o test.iso test_image/
|
||||
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -cdrom test.iso -debugcon stdio
|
||||
|
||||
uefi-iso9660-test:
|
||||
$(MAKE) ovmf
|
||||
$(MAKE) test-clean
|
||||
$(MAKE) test.hdd
|
||||
$(MAKE) limine-uefi
|
||||
$(MAKE) -C test
|
||||
rm -rf test_image/
|
||||
mkdir -p test_image/boot
|
||||
cp -rv bin/* test/* test_image/boot/
|
||||
mkdir -p test_image/EFI/BOOT
|
||||
cp -v bin/BOOTX64.EFI test_image/EFI/BOOT/
|
||||
genisoimage -no-emul-boot -b boot/limine-cd.bin -boot-load-size 4 -boot-info-table -o test.iso test_image/
|
||||
qemu-system-x86_64 -L ovmf -bios ovmf/OVMF.fd -net none -smp 4 -enable-kvm -cpu host -cdrom test.iso -debugcon stdio
|
||||
|
||||
pxe-test:
|
||||
$(MAKE) test-clean
|
||||
$(MAKE) limine-bios
|
||||
|
|
|
@ -189,6 +189,8 @@ void disk_create_index(void) {
|
|||
#if defined (uefi)
|
||||
|
||||
struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
|
||||
EFI_STATUS status;
|
||||
|
||||
struct volume *ret = NULL;
|
||||
|
||||
EFI_GUID disk_io_guid = DISK_IO_PROTOCOL;
|
||||
|
@ -206,8 +208,18 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
|
|||
|
||||
uefi_call_wrapper(disk_io->ReadDisk, 5, disk_io, block_io->Media->MediaId, 0,
|
||||
sizeof(uint64_t), &orig);
|
||||
uefi_call_wrapper(disk_io->WriteDisk, 5, disk_io, block_io->Media->MediaId, 0,
|
||||
sizeof(uint64_t), &signature);
|
||||
|
||||
status = uefi_call_wrapper(disk_io->WriteDisk, 5,
|
||||
disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &signature);
|
||||
|
||||
if (status) {
|
||||
// Really hacky support for CDs because they are read-only
|
||||
for (size_t i = 0; i < volume_index_i; i++) {
|
||||
if (volume_index[i]->drive == 0xe0)
|
||||
return volume_index[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < volume_index_i; i++) {
|
||||
uint64_t compare;
|
||||
|
@ -314,6 +326,12 @@ void disk_create_index(void) {
|
|||
size_t drives_counter = 0x80;
|
||||
|
||||
for (size_t i = 0; i < handles_size / sizeof(EFI_HANDLE); i++) {
|
||||
EFI_GUID disk_io_guid = DISK_IO_PROTOCOL;
|
||||
EFI_DISK_IO *disk_io = NULL;
|
||||
|
||||
uefi_call_wrapper(gBS->HandleProtocol, 3, handles[i], &disk_io_guid,
|
||||
&disk_io);
|
||||
|
||||
EFI_BLOCK_IO *drive = NULL;
|
||||
|
||||
status = uefi_call_wrapper(gBS->HandleProtocol, 3, handles[i],
|
||||
|
@ -325,9 +343,18 @@ void disk_create_index(void) {
|
|||
if (drive->Media->LogicalPartition)
|
||||
continue;
|
||||
|
||||
uint64_t orig;
|
||||
uefi_call_wrapper(disk_io->ReadDisk, 5,
|
||||
disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
|
||||
status = uefi_call_wrapper(disk_io->WriteDisk, 5,
|
||||
disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
|
||||
|
||||
struct volume *block = ext_mem_alloc(sizeof(struct volume));
|
||||
|
||||
block->drive = drives_counter++;
|
||||
if (status)
|
||||
block->drive = 0xe0;
|
||||
else
|
||||
block->drive = drives_counter++;
|
||||
block->efi_handle = handles[i];
|
||||
block->partition = -1;
|
||||
block->sector_size = drive->Media->BlockSize;
|
||||
|
|
Loading…
Reference in New Issue