loader.efi: replace HandleProtocol() with OpenProtocol()
The HandleProtocol() is deprecated interface and we should use OpenProtocol() instead. Moreover, in some firmware implementation(s), the HandleProtocol() does return device path using static storage, so we can not keep the value returned there. With same firmware, the OpenProtocol() does return data we do not need to clone. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D21162
This commit is contained in:
parent
e9660daffb
commit
110d56cbf4
@ -61,7 +61,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath)
|
||||
int preferred;
|
||||
|
||||
/* Figure out if we're dealing with an actual partition. */
|
||||
status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath);
|
||||
status = OpenProtocolByHandle(h, &DevicePathGUID, (void **)&devpath);
|
||||
if (status == EFI_UNSUPPORTED)
|
||||
return (0);
|
||||
|
||||
@ -77,7 +77,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath)
|
||||
efi_free_devpath_name(text);
|
||||
}
|
||||
#endif
|
||||
status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(h, &BlockIoProtocolGUID, (void **)&blkio);
|
||||
if (status == EFI_UNSUPPORTED)
|
||||
return (0);
|
||||
|
||||
|
@ -146,7 +146,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath)
|
||||
EFI_STATUS status;
|
||||
|
||||
/* Figure out if we're dealing with an actual partition. */
|
||||
status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath);
|
||||
status = OpenProtocolByHandle(h, &DevicePathGUID, (void **)&devpath);
|
||||
if (status != EFI_SUCCESS)
|
||||
return;
|
||||
#ifdef EFI_DEBUG
|
||||
@ -169,7 +169,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath)
|
||||
return;
|
||||
}
|
||||
}
|
||||
status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(h, &BlockIoProtocolGUID, (void **)&blkio);
|
||||
if (status != EFI_SUCCESS) {
|
||||
DPRINTF("Can't get the block I/O protocol block\n");
|
||||
return;
|
||||
|
@ -44,8 +44,8 @@ efi_lookup_image_devpath(EFI_HANDLE handle)
|
||||
EFI_DEVICE_PATH *devpath;
|
||||
EFI_STATUS status;
|
||||
|
||||
status = BS->HandleProtocol(handle, &ImageDevicePathGUID,
|
||||
(VOID **)&devpath);
|
||||
status = OpenProtocolByHandle(handle, &ImageDevicePathGUID,
|
||||
(void **)&devpath);
|
||||
if (EFI_ERROR(status))
|
||||
devpath = NULL;
|
||||
return (devpath);
|
||||
@ -57,7 +57,8 @@ efi_lookup_devpath(EFI_HANDLE handle)
|
||||
EFI_DEVICE_PATH *devpath;
|
||||
EFI_STATUS status;
|
||||
|
||||
status = BS->HandleProtocol(handle, &DevicePathGUID, (VOID **)&devpath);
|
||||
status = OpenProtocolByHandle(handle, &DevicePathGUID,
|
||||
(void **)&devpath);
|
||||
if (EFI_ERROR(status))
|
||||
devpath = NULL;
|
||||
return (devpath);
|
||||
|
@ -286,7 +286,7 @@ efinet_init(struct iodesc *desc, void *machdep_hint)
|
||||
}
|
||||
|
||||
h = nif->nif_driver->netif_ifs[nif->nif_unit].dif_private;
|
||||
status = BS->HandleProtocol(h, &sn_guid, (VOID **)&nif->nif_devdata);
|
||||
status = OpenProtocolByHandle(h, &sn_guid, (void **)&nif->nif_devdata);
|
||||
if (status != EFI_SUCCESS) {
|
||||
printf("net%d: cannot fetch interface data (status=%lu)\n",
|
||||
nif->nif_unit, EFI_ERROR_CODE(status));
|
||||
|
@ -297,8 +297,8 @@ efipart_hdd(EFI_DEVICE_PATH *dp)
|
||||
}
|
||||
|
||||
/* Make sure we do have the media. */
|
||||
status = BS->HandleProtocol(efipart_handles[i],
|
||||
&blkio_guid, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(efipart_handles[i], &blkio_guid,
|
||||
(void **)&blkio);
|
||||
if (EFI_ERROR(status))
|
||||
return (false);
|
||||
|
||||
@ -439,8 +439,8 @@ efipart_updatecd(void)
|
||||
if (efipart_hdd(devpath))
|
||||
continue;
|
||||
|
||||
status = BS->HandleProtocol(efipart_handles[i],
|
||||
&blkio_guid, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(efipart_handles[i], &blkio_guid,
|
||||
(void **)&blkio);
|
||||
if (EFI_ERROR(status))
|
||||
continue;
|
||||
/*
|
||||
@ -691,8 +691,8 @@ efipart_updatehd(void)
|
||||
if (!efipart_hdd(devpath))
|
||||
continue;
|
||||
|
||||
status = BS->HandleProtocol(efipart_handles[i],
|
||||
&blkio_guid, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(efipart_handles[i], &blkio_guid,
|
||||
(void **)&blkio);
|
||||
if (EFI_ERROR(status))
|
||||
continue;
|
||||
|
||||
@ -779,7 +779,7 @@ efipart_print_common(struct devsw *dev, pdinfo_list_t *pdlist, int verbose)
|
||||
snprintf(line, sizeof(line),
|
||||
" %s%d", dev->dv_name, pd->pd_unit);
|
||||
printf("%s:", line);
|
||||
status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio);
|
||||
status = OpenProtocolByHandle(h, &blkio_guid, (void **)&blkio);
|
||||
if (!EFI_ERROR(status)) {
|
||||
printf(" %llu",
|
||||
blkio->Media->LastBlock == 0? 0:
|
||||
@ -862,7 +862,7 @@ efipart_open(struct open_file *f, ...)
|
||||
return (EIO);
|
||||
|
||||
if (pd->pd_blkio == NULL) {
|
||||
status = BS->HandleProtocol(pd->pd_handle, &blkio_guid,
|
||||
status = OpenProtocolByHandle(pd->pd_handle, &blkio_guid,
|
||||
(void **)&pd->pd_blkio);
|
||||
if (EFI_ERROR(status))
|
||||
return (efi_status_to_errno(status));
|
||||
|
@ -103,7 +103,7 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
|
||||
/* Use efi_exit() from here on... */
|
||||
|
||||
status = BS->HandleProtocol(IH, &image_protocol, (VOID**)&img);
|
||||
status = OpenProtocolByHandle(IH, &image_protocol, (void**)&img);
|
||||
if (status != EFI_SUCCESS)
|
||||
efi_exit(status);
|
||||
|
||||
|
@ -244,7 +244,8 @@ efifb_uga_get_pciio(void)
|
||||
/* Get the PCI I/O interface of the first handle that supports it. */
|
||||
pciio = NULL;
|
||||
for (hp = buf; hp < buf + bufsz; hp++) {
|
||||
status = BS->HandleProtocol(*hp, &pciio_guid, (void **)&pciio);
|
||||
status = OpenProtocolByHandle(*hp, &pciio_guid,
|
||||
(void **)&pciio);
|
||||
if (status == EFI_SUCCESS) {
|
||||
free(buf);
|
||||
return (pciio);
|
||||
|
@ -128,7 +128,7 @@ has_keyboard(void)
|
||||
*/
|
||||
hin_end = &hin[sz / sizeof(*hin)];
|
||||
for (walker = hin; walker < hin_end; walker++) {
|
||||
status = BS->HandleProtocol(*walker, &devid, (VOID **)&path);
|
||||
status = OpenProtocolByHandle(*walker, &devid, (void **)&path);
|
||||
if (EFI_ERROR(status))
|
||||
continue;
|
||||
|
||||
@ -864,7 +864,7 @@ main(int argc, CHAR16 *argv[])
|
||||
archsw.arch_zfs_probe = efi_zfs_probe;
|
||||
|
||||
/* 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
|
||||
@ -1004,7 +1004,8 @@ main(int argc, CHAR16 *argv[])
|
||||
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) {
|
||||
text = efi_devpath_name(imgpath);
|
||||
if (text != NULL) {
|
||||
@ -1464,7 +1465,7 @@ command_chain(int argc, char *argv[])
|
||||
command_errmsg = "LoadImage failed";
|
||||
return (CMD_ERROR);
|
||||
}
|
||||
status = BS->HandleProtocol(loaderhandle, &LoadedImageGUID,
|
||||
status = OpenProtocolByHandle(loaderhandle, &LoadedImageGUID,
|
||||
(void **)&loaded_image);
|
||||
|
||||
if (argc > 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user