Improve BOOT${ARCH}.CSV support.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2016-04-12 13:41:45 -04:00
parent 6cbcfb727e
commit 47f3a65eda
2 changed files with 36 additions and 18 deletions

View File

@ -41,8 +41,9 @@ media. In that case, it'll invoke \EFI\BOOT\BOOTX64.EFI (or whatever
filename is right for your architecture.) In that case it'll be in
\EFI\BOOT, so it'll check for fallback.efi , and it'll find it and run
it. When it runs, fallback will look for every directory in \EFI\ with
a BOOT.CSV in it, and it'll parse that, and create new boot variables
from what it finds. Then it'll try to boot one of them.
a BOOT${ARCH}.CSV in it, or BOOT.CSV if that's not found. It'll parse that,
and create new boot variables from what it finds. Then it'll try to boot one
of them.
BOOT.CSV is a UCS-2 LE formatted CSV file. So it has the LE byte order
marker, and after that it's just a series of lines, each having

View File

@ -579,6 +579,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
FreePool(buffer);
buffer = NULL;
CHAR16 *bootcsv=NULL, *bootarchcsv=NULL;
bs = 0;
do {
bs = 0;
@ -608,27 +610,42 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
fi = buffer;
if (!StrCaseCmp(fi->FileName, L"boot.csv")
|| !StrCaseCmp(fi->FileName, L"boot" EFI_ARCH L".csv")) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
fi->FileName,
EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, fi->FileName, rc);
FreePool(buffer);
buffer = NULL;
continue;
}
rc = try_boot_csv(fh2, dirname, fi->FileName);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
if (!bootcsv && !StrCaseCmp(fi->FileName, L"boot.csv"))
bootcsv = StrDuplicate(fi->FileName);
if (!bootarchcsv &&
!StrCaseCmp(fi->FileName, L"boot" EFI_ARCH L".csv"))
bootarchcsv = StrDuplicate(fi->FileName);
FreePool(buffer);
buffer = NULL;
} while (bs != 0);
rc = EFI_SUCCESS;
if (bootarchcsv) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootarchcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, bootarchcsv, rc);
} else {
rc = try_boot_csv(fh2, dirname, bootarchcsv);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
}
if ((EFI_ERROR(rc) || !bootarchcsv) && bootcsv) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, bootcsv, rc);
} else {
rc = try_boot_csv(fh2, dirname, bootcsv);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
}
rc = EFI_SUCCESS;
return rc;