mirror of
https://github.com/ipxe/ipxe
synced 2025-12-14 16:01:38 +03:00
[efi] Allow use of typed pointers for efi_open() et al
Provide wrapper macros to allow efi_open() and related functions to accept a pointer to any pointer type as the "interface" argument, in order to allow a substantial amount of type adjustment boilerplate to be removed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -132,10 +132,7 @@ static int efi_image_exec ( struct image *image ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct efi_snp_device *snpdev;
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
union {
|
||||
EFI_LOADED_IMAGE_PROTOCOL *image;
|
||||
void *interface;
|
||||
} loaded;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
||||
struct image *shim;
|
||||
struct image *exec;
|
||||
EFI_HANDLE handle;
|
||||
@@ -235,30 +232,30 @@ static int efi_image_exec ( struct image *image ) {
|
||||
|
||||
/* Get the loaded image protocol for the newly loaded image */
|
||||
if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid,
|
||||
&loaded.interface ) ) != 0 ) {
|
||||
&loaded ) ) != 0 ) {
|
||||
/* Should never happen */
|
||||
goto err_open_protocol;
|
||||
}
|
||||
|
||||
/* Some EFI 1.10 implementations seem not to fill in DeviceHandle */
|
||||
if ( loaded.image->DeviceHandle == NULL ) {
|
||||
if ( loaded->DeviceHandle == NULL ) {
|
||||
DBGC ( image, "EFIIMAGE %s filling in missing DeviceHandle\n",
|
||||
image->name );
|
||||
loaded.image->DeviceHandle = snpdev->handle;
|
||||
loaded->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 );
|
||||
assert ( loaded->ParentHandle == efi_image_handle );
|
||||
assert ( loaded->DeviceHandle == snpdev->handle );
|
||||
assert ( loaded->LoadOptionsSize == 0 );
|
||||
assert ( loaded->LoadOptions == NULL );
|
||||
|
||||
/* Record image code type */
|
||||
type = loaded.image->ImageCodeType;
|
||||
type = loaded->ImageCodeType;
|
||||
|
||||
/* Set command line */
|
||||
loaded.image->LoadOptions = cmdline;
|
||||
loaded.image->LoadOptionsSize =
|
||||
loaded->LoadOptions = cmdline;
|
||||
loaded->LoadOptionsSize =
|
||||
( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) );
|
||||
|
||||
/* Release network devices for use via SNP */
|
||||
|
||||
Reference in New Issue
Block a user