disk: Signature double checking for EFI volume detection fallback
This commit is contained in:
parent
f20457f671
commit
3dbd494f87
@ -9,6 +9,7 @@
|
||||
#endif
|
||||
#include <lib/blib.h>
|
||||
#include <lib/print.h>
|
||||
#include <lib/rand.h>
|
||||
#include <mm/pmm.h>
|
||||
#include <sys/cpu.h>
|
||||
|
||||
@ -69,7 +70,7 @@ static size_t fastest_xfer_size(struct volume *volume) {
|
||||
rm_int(0x13, &r, &r);
|
||||
if (r.eflags & EFLAGS_CF) {
|
||||
int ah = (r.eax >> 8) & 0xff;
|
||||
printv("Disk error %x. Drive %x", ah, volume->drive);
|
||||
print("Disk error %x. Drive %x", ah, volume->drive);
|
||||
return 8;
|
||||
}
|
||||
dap.lba += xfer_sizes[i];
|
||||
@ -228,7 +229,6 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE efi_handle) {
|
||||
|
||||
status = gBS->HandleProtocol(efi_handle, &block_io_guid, (void **)&block_io);
|
||||
if (status) {
|
||||
printv("Failed to match handle %X (1)\n", efi_handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -250,7 +250,6 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE efi_handle) {
|
||||
uint32_t crc32 = get_crc32(unique_sector_pool, volume_index[i]->sector_size);
|
||||
|
||||
if (crc32 == volume_index[i]->unique_sector_crc32) {
|
||||
printv("Matched handle %X with volume %X\n", efi_handle, volume_index[i]);
|
||||
return volume_index[i];
|
||||
}
|
||||
}
|
||||
@ -264,7 +263,9 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE efi_handle) {
|
||||
if (status)
|
||||
return NULL;
|
||||
|
||||
uint64_t signature = BUILD_ID;
|
||||
uint64_t signature = rand64();
|
||||
uint64_t new_signature;
|
||||
do { new_signature = rand64(); } while (new_signature == signature);
|
||||
uint64_t orig;
|
||||
|
||||
status = disk_io->ReadDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &orig);
|
||||
@ -292,8 +293,20 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE efi_handle) {
|
||||
sizeof(uint64_t), &compare);
|
||||
|
||||
if (compare == signature) {
|
||||
ret = volume_index[i];
|
||||
break;
|
||||
// Double check
|
||||
status = disk_io->WriteDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &new_signature);
|
||||
|
||||
cur_disk_io->ReadDisk(cur_disk_io,
|
||||
volume_index[i]->block_io->Media->MediaId,
|
||||
0 + volume_index[i]->first_sect * 512,
|
||||
sizeof(uint64_t), &compare);
|
||||
|
||||
if (compare == new_signature) {
|
||||
ret = volume_index[i];
|
||||
break;
|
||||
}
|
||||
|
||||
status = disk_io->WriteDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &signature);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,8 +319,6 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE efi_handle) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
printv("Failed to match handle %X (2)\n", efi_handle);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -358,13 +369,6 @@ static void find_unique_sectors(void) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (volume_index[i]->unique_sector_valid == false) {
|
||||
printv("Not able to match unique sector for volume %X\n", volume_index[i]);
|
||||
} else {
|
||||
printv("Matched volume %X with uniq: %U, crc32: %x\n",
|
||||
volume_index[i]->unique_sector, volume_index[i]->unique_sector_crc32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,6 @@ UINTN efi_mmap_size = 0, efi_desc_size = 0;
|
||||
UINT32 efi_desc_ver = 0;
|
||||
#endif
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
bool parse_resolution(size_t *width, size_t *height, size_t *bpp, const char *buf) {
|
||||
size_t res[3] = {0};
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <lib/blib.h>
|
||||
#include <lib/print.h>
|
||||
|
||||
bool verbose = true;
|
||||
|
||||
void copyright_notice(void) {
|
||||
print("Limine " LIMINE_VERSION "\n");
|
||||
print(LIMINE_COPYRIGHT "\n");
|
||||
|
@ -548,8 +548,6 @@ char *menu(char **cmdline) {
|
||||
if (menu_resolution != NULL)
|
||||
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
||||
|
||||
print("menu: Loading...");
|
||||
|
||||
term_vbe(req_width, req_height);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
DEFAULT_ENTRY=1
|
||||
TIMEOUT=3
|
||||
GRAPHICS=yes
|
||||
MENU_FONT=boot:///boot/font.bin
|
||||
VERBOSE=yes
|
||||
|
||||
THEME_BACKGROUND=50000000
|
||||
|
Loading…
Reference in New Issue
Block a user