Changeset View
Changeset View
Standalone View
Standalone View
head/stand/efi/loader/main.c
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | has_keyboard(void) | ||||
/* | /* | ||||
* Look at each of the handles. If it supports the device path protocol, | * Look at each of the handles. If it supports the device path protocol, | ||||
* use it to get the device path for this handle. Then see if that | * use it to get the device path for this handle. Then see if that | ||||
* device path matches either the USB device path for keyboards or the | * device path matches either the USB device path for keyboards or the | ||||
* legacy device path for keyboards. | * legacy device path for keyboards. | ||||
*/ | */ | ||||
hin_end = &hin[sz / sizeof(*hin)]; | hin_end = &hin[sz / sizeof(*hin)]; | ||||
for (walker = hin; walker < hin_end; walker++) { | for (walker = hin; walker < hin_end; walker++) { | ||||
status = BS->HandleProtocol(*walker, &devid, (VOID **)&path); | status = OpenProtocolByHandle(*walker, &devid, (void **)&path); | ||||
if (EFI_ERROR(status)) | if (EFI_ERROR(status)) | ||||
continue; | continue; | ||||
while (!IsDevicePathEnd(path)) { | while (!IsDevicePathEnd(path)) { | ||||
/* | /* | ||||
* Check for the ACPI keyboard node. All PNP3xx nodes | * Check for the ACPI keyboard node. All PNP3xx nodes | ||||
* are keyboards of different flavors. Note: It is | * are keyboards of different flavors. Note: It is | ||||
* unclear of there's always a keyboard node when | * unclear of there's always a keyboard node when | ||||
▲ Show 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | main(int argc, CHAR16 *argv[]) | ||||
archsw.arch_autoload = efi_autoload; | archsw.arch_autoload = efi_autoload; | ||||
archsw.arch_getdev = efi_getdev; | archsw.arch_getdev = efi_getdev; | ||||
archsw.arch_copyin = efi_copyin; | archsw.arch_copyin = efi_copyin; | ||||
archsw.arch_copyout = efi_copyout; | archsw.arch_copyout = efi_copyout; | ||||
archsw.arch_readin = efi_readin; | archsw.arch_readin = efi_readin; | ||||
archsw.arch_zfs_probe = efi_zfs_probe; | archsw.arch_zfs_probe = efi_zfs_probe; | ||||
/* Get our loaded image protocol interface structure. */ | /* Get our loaded image protocol interface structure. */ | ||||
BS->HandleProtocol(IH, &imgid, (VOID**)&boot_img); | (void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img); | ||||
/* | /* | ||||
* Chicken-and-egg problem; we want to have console output early, but | * Chicken-and-egg problem; we want to have console output early, but | ||||
* some console attributes may depend on reading from eg. the boot | * some console attributes may depend on reading from eg. the boot | ||||
* device, which we can't do yet. We can use printf() etc. once this is | * device, which we can't do yet. We can use printf() etc. once this is | ||||
* done. So, we set it to the efi console, then call console init. This | * done. So, we set it to the efi console, then call console init. This | ||||
* gets us printf early, but also primes the pump for all future console | * gets us printf early, but also primes the pump for all future console | ||||
* changes to take effect, regardless of where they come from. | * changes to take effect, regardless of where they come from. | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | #define CON_MASK (RB_SERIAL | RB_MULTIPLE) | ||||
/* Determine the devpath of our image so we can prefer it. */ | /* Determine the devpath of our image so we can prefer it. */ | ||||
text = efi_devpath_name(boot_img->FilePath); | text = efi_devpath_name(boot_img->FilePath); | ||||
if (text != NULL) { | if (text != NULL) { | ||||
printf(" Load Path: %S\n", text); | printf(" Load Path: %S\n", text); | ||||
efi_setenv_freebsd_wcs("LoaderPath", text); | efi_setenv_freebsd_wcs("LoaderPath", text); | ||||
efi_free_devpath_name(text); | efi_free_devpath_name(text); | ||||
} | } | ||||
rv = BS->HandleProtocol(boot_img->DeviceHandle, &devid, (void **)&imgpath); | rv = OpenProtocolByHandle(boot_img->DeviceHandle, &devid, | ||||
(void **)&imgpath); | |||||
if (rv == EFI_SUCCESS) { | if (rv == EFI_SUCCESS) { | ||||
text = efi_devpath_name(imgpath); | text = efi_devpath_name(imgpath); | ||||
if (text != NULL) { | if (text != NULL) { | ||||
printf(" Load Device: %S\n", text); | printf(" Load Device: %S\n", text); | ||||
efi_setenv_freebsd_wcs("LoaderDev", text); | efi_setenv_freebsd_wcs("LoaderDev", text); | ||||
efi_free_devpath_name(text); | efi_free_devpath_name(text); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | command_chain(int argc, char *argv[]) | ||||
} | } | ||||
close(fd); | close(fd); | ||||
status = BS->LoadImage(FALSE, IH, NULL, buf, st.st_size, &loaderhandle); | status = BS->LoadImage(FALSE, IH, NULL, buf, st.st_size, &loaderhandle); | ||||
(void)BS->FreePool(buf); | (void)BS->FreePool(buf); | ||||
if (status != EFI_SUCCESS) { | if (status != EFI_SUCCESS) { | ||||
command_errmsg = "LoadImage failed"; | command_errmsg = "LoadImage failed"; | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
status = BS->HandleProtocol(loaderhandle, &LoadedImageGUID, | status = OpenProtocolByHandle(loaderhandle, &LoadedImageGUID, | ||||
(void **)&loaded_image); | (void **)&loaded_image); | ||||
if (argc > 2) { | if (argc > 2) { | ||||
int i, len = 0; | int i, len = 0; | ||||
CHAR16 *argp; | CHAR16 *argp; | ||||
for (i = 2; i < argc; i++) | for (i = 2; i < argc; i++) | ||||
len += strlen(argv[i]) + 1; | len += strlen(argv[i]) + 1; | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |