本文整理汇总了C++中EFI_BOOT_SERVICES::UnloadImage方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_BOOT_SERVICES::UnloadImage方法的具体用法?C++ EFI_BOOT_SERVICES::UnloadImage怎么用?C++ EFI_BOOT_SERVICES::UnloadImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_BOOT_SERVICES
的用法示例。
在下文中一共展示了EFI_BOOT_SERVICES::UnloadImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
EFI_STATUS EFIAPI
OvrUnloadImage(
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
Status = gOrgBS.UnloadImage(ImageHandle);
PRINT("->UnloadImage(%p) = %r\n", ImageHandle, Status);
return Status;
}
示例2: efi_image_probe
/**
* Probe EFI image
*
* @v image EFI file
* @ret rc Return status code
*/
static int efi_image_probe ( struct image *image ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE handle;
EFI_STATUS efirc;
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, NULL,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
image, efi_strerror ( efirc ) );
return -ENOEXEC;
}
/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
*/
bs->UnloadImage ( handle );
return 0;
}
示例3: efi_image_probe
/**
* Probe EFI image
*
* @v image EFI file
* @ret rc Return status code
*/
static int efi_image_probe ( struct image *image ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
static EFI_DEVICE_PATH_PROTOCOL empty_path = {
.Type = END_DEVICE_PATH_TYPE,
.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE,
.Length[0] = sizeof ( empty_path ),
};
EFI_HANDLE handle;
EFI_STATUS efirc;
int rc;
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, &empty_path,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
rc = -EEFI_LOAD ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
image, strerror ( rc ) );
return rc;
}
/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
*/
bs->UnloadImage ( handle );
return 0;
}
/** EFI image type */
struct image_type efi_image_type __image_type ( PROBE_NORMAL ) = {
.name = "EFI",
.probe = efi_image_probe,
.exec = efi_image_exec,
};
示例4: efi_image_exec
//.........这里部分代码省略.........
goto err_no_snpdev;
}
/* Install file I/O protocols */
if ( ( rc = efi_file_install ( &snpdev->handle ) ) != 0 ) {
DBGC ( image, "EFIIMAGE %p could not install file protocol: "
"%s\n", image, strerror ( rc ) );
goto err_file_install;
}
/* Install iPXE download protocol */
if ( ( rc = efi_download_install ( &snpdev->handle ) ) != 0 ) {
DBGC ( image, "EFIIMAGE %p could not install iPXE download "
"protocol: %s\n", image, strerror ( rc ) );
goto err_download_install;
}
/* Create device path for image */
path = efi_image_path ( image, &snpdev->path );
if ( ! path ) {
DBGC ( image, "EFIIMAGE %p could not create device path\n",
image );
rc = -ENOMEM;
goto err_image_path;
}
/* Create command line for image */
cmdline = efi_image_cmdline ( image );
if ( ! cmdline ) {
DBGC ( image, "EFIIMAGE %p could not create command line\n",
image );
rc = -ENOMEM;
goto err_cmdline;
}
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
rc = -EEFI_LOAD ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
image, strerror ( rc ) );
goto err_load_image;
}
/* Get the loaded image protocol for the newly loaded image */
efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid,
&loaded.interface, efi_image_handle,
NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL );
if ( efirc ) {
/* Should never happen */
rc = -EEFI ( efirc );
goto err_open_protocol;
}
/* Sanity checks */
assert ( loaded.image->ParentHandle == efi_image_handle );
assert ( loaded.image->DeviceHandle == snpdev->handle );
assert ( loaded.image->LoadOptionsSize == 0 );
assert ( loaded.image->LoadOptions == NULL );
/* Set command line */
loaded.image->LoadOptions = cmdline;
loaded.image->LoadOptionsSize =
( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) );
/* Start the image */
if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
rc = -EEFI_START ( efirc );
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
image, strerror ( rc ) );
goto err_start_image;
}
/* Success */
rc = 0;
err_start_image:
err_open_protocol:
/* Unload the image. We can't leave it loaded, because we
* have no "unload" operation.
*/
if ( ( efirc = bs->UnloadImage ( handle ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not unload: %s\n",
image, strerror ( rc ) );
}
err_load_image:
free ( cmdline );
err_cmdline:
free ( path );
err_image_path:
efi_download_uninstall ( snpdev->handle );
err_download_install:
efi_file_uninstall ( snpdev->handle );
err_file_install:
err_no_snpdev:
return rc;
}
示例5: efi_image_exec
//.........这里部分代码省略.........
rc = -ENOMEM;
goto err_image_path;
}
/* Create command line for image */
cmdline = efi_image_cmdline ( image );
if ( ! cmdline ) {
DBGC ( image, "EFIIMAGE %p could not create command line\n",
image );
rc = -ENOMEM;
goto err_cmdline;
}
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
rc = -EEFI_LOAD ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
image, strerror ( rc ) );
goto err_load_image;
}
/* Get the loaded image protocol for the newly loaded image */
efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid,
&loaded.interface, efi_image_handle,
NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL );
if ( efirc ) {
/* Should never happen */
rc = -EEFI ( efirc );
goto err_open_protocol;
}
/* Some EFI 1.10 implementations seem not to fill in DeviceHandle */
if ( loaded.image->DeviceHandle == NULL ) {
DBGC ( image, "EFIIMAGE %p filling in missing DeviceHandle\n",
image );
loaded.image->DeviceHandle = snpdev->handle;
}
/* Sanity checks */
assert ( loaded.image->ParentHandle == efi_image_handle );
assert ( loaded.image->DeviceHandle == snpdev->handle );
assert ( loaded.image->LoadOptionsSize == 0 );
assert ( loaded.image->LoadOptions == NULL );
/* Set command line */
loaded.image->LoadOptions = cmdline;
loaded.image->LoadOptionsSize =
( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) );
/* Release network devices for use via SNP */
efi_snp_release();
/* Wrap calls made by the loaded image (for debugging) */
efi_wrap ( handle );
/* Start the image */
if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
rc = -EEFI_START ( efirc );
DBGC ( image, "EFIIMAGE %p could not start (or returned with "
"error): %s\n", image, strerror ( rc ) );
goto err_start_image;
}
/* Success */
rc = 0;
err_start_image:
efi_snp_claim();
err_open_protocol:
/* If there was no error, then the image must have been
* started and returned successfully. It either unloaded
* itself, or it intended to remain loaded (e.g. it was a
* driver). We therefore do not unload successful images.
*
* If there was an error, attempt to unload the image. This
* may not work. In particular, there is no way to tell
* whether an error returned from StartImage() was due to
* being unable to start the image (in which case we probably
* should call UnloadImage()), or due to the image itself
* returning an error (in which case we probably should not
* call UnloadImage()). We therefore ignore any failures from
* the UnloadImage() call itself.
*/
if ( rc != 0 )
bs->UnloadImage ( handle );
err_load_image:
free ( cmdline );
err_cmdline:
free ( path );
err_image_path:
efi_download_uninstall ( snpdev->handle );
err_download_install:
efi_file_uninstall ( snpdev->handle );
err_file_install:
err_no_snpdev:
return rc;
}