mirror of https://github.com/ipxe/ipxe.git
[efi] Use efi_open() for all ephemeral protocol opens
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/34/merge
parent
5a5e2a1dae
commit
bac3187439
|
@ -493,9 +493,7 @@ static struct net_device_operations snpnet_operations = {
|
|||
* @ret rc Return status code
|
||||
*/
|
||||
int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE parent;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Check that this is not a device we are providing ourselves */
|
||||
|
@ -506,13 +504,11 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
|||
}
|
||||
|
||||
/* Test for presence of protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device, protocol,
|
||||
NULL, efi_image_handle, device,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
|
||||
if ( ( rc = efi_open ( device, protocol, NULL ) ) != 0 ) {
|
||||
DBGCP ( device, "HANDLE %s is not a %s device\n",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( protocol ) );
|
||||
return -EEFI ( efirc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Check that there are no instances of this protocol further
|
||||
|
|
|
@ -86,13 +86,11 @@ static struct chained_protocol chained_mnp = {
|
|||
* @v chained Chainloaded protocol
|
||||
*/
|
||||
static void chained_locate ( struct chained_protocol *chained ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE device = efi_loaded_image->DeviceHandle;
|
||||
EFI_HANDLE handle;
|
||||
void *match = NULL;
|
||||
void *interface;
|
||||
unsigned int skip;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Identify target device handle */
|
||||
|
@ -111,11 +109,8 @@ static void chained_locate ( struct chained_protocol *chained ) {
|
|||
}
|
||||
|
||||
/* Get protocol instance */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
handle, chained->protocol, &interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL )) != 0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, chained->protocol,
|
||||
&interface ) ) != 0 ) {
|
||||
DBGC ( device, "CHAINED %s could not open %s on ",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( chained->protocol ) );
|
||||
|
@ -123,8 +118,6 @@ static void chained_locate ( struct chained_protocol *chained ) {
|
|||
efi_handle_name ( handle ), strerror ( rc ) );
|
||||
break;
|
||||
}
|
||||
bs->CloseProtocol ( handle, chained->protocol,
|
||||
efi_image_handle, handle );
|
||||
|
||||
/* Stop if we reach a non-matching protocol instance */
|
||||
if ( match && ( match != interface ) ) {
|
||||
|
@ -154,20 +147,16 @@ static void chained_locate ( struct chained_protocol *chained ) {
|
|||
*/
|
||||
static int chained_supported ( EFI_HANDLE device,
|
||||
struct chained_protocol *chained ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
void *interface;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Get protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device, chained->protocol, &interface,
|
||||
efi_image_handle, device,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, chained->protocol,
|
||||
&interface ) ) != 0 ) {
|
||||
DBGCP ( device, "CHAINED %s is not a %s device\n",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( chained->protocol ) );
|
||||
goto err_open_protocol;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Ignore non-matching handles */
|
||||
|
@ -175,21 +164,13 @@ static int chained_supported ( EFI_HANDLE device,
|
|||
DBGC2 ( device, "CHAINED %s is not the chainloaded %s\n",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( chained->protocol ) );
|
||||
rc = -ENOTTY;
|
||||
goto err_no_match;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
DBGC ( device, "CHAINED %s is the chainloaded %s\n",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( chained->protocol ) );
|
||||
|
||||
err_no_match:
|
||||
bs->CloseProtocol ( device, chained->protocol, efi_image_handle,
|
||||
device );
|
||||
err_open_protocol:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1291,7 +1291,6 @@ static struct usb_host_operations usbio_operations = {
|
|||
* @ret rc Return status code
|
||||
*/
|
||||
static int usbio_supported ( EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_USB_DEVICE_DESCRIPTOR device;
|
||||
EFI_USB_INTERFACE_DESCRIPTOR interface;
|
||||
struct usb_function_descriptor desc;
|
||||
|
@ -1305,14 +1304,11 @@ static int usbio_supported ( EFI_HANDLE handle ) {
|
|||
int rc;
|
||||
|
||||
/* Get protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid,
|
||||
&usb.interface, efi_image_handle,
|
||||
handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_usb_io_protocol_guid,
|
||||
&usb.interface ) ) != 0 ) {
|
||||
DBGCP ( handle, "USB %s is not a USB device\n",
|
||||
efi_handle_name ( handle ) );
|
||||
goto err_open_protocol;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Get device descriptor */
|
||||
|
@ -1321,7 +1317,7 @@ static int usbio_supported ( EFI_HANDLE handle ) {
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( handle, "USB %s could not get device descriptor: "
|
||||
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_get_device_descriptor;
|
||||
return rc;
|
||||
}
|
||||
memset ( &desc, 0, sizeof ( desc ) );
|
||||
desc.vendor = device.IdVendor;
|
||||
|
@ -1333,7 +1329,7 @@ static int usbio_supported ( EFI_HANDLE handle ) {
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( handle, "USB %s could not get interface descriptor: "
|
||||
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_get_interface_descriptor;
|
||||
return rc;
|
||||
}
|
||||
desc.class.class.class = interface.InterfaceClass;
|
||||
desc.class.class.subclass = interface.InterfaceSubClass;
|
||||
|
@ -1341,21 +1337,10 @@ static int usbio_supported ( EFI_HANDLE handle ) {
|
|||
|
||||
/* Look for a driver for this interface */
|
||||
driver = usb_find_driver ( &desc, &id );
|
||||
if ( ! driver ) {
|
||||
rc = -ENOTSUP;
|
||||
goto err_unsupported;
|
||||
}
|
||||
if ( ! driver )
|
||||
return -ENOTSUP;
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_unsupported:
|
||||
err_get_interface_descriptor:
|
||||
err_get_device_descriptor:
|
||||
bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
err_open_protocol:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1471,7 +1456,6 @@ static int usbio_config ( struct usbio_device *usbio ) {
|
|||
* @ret rc Return status code
|
||||
*/
|
||||
static int usbio_path ( struct usbio_device *usbio ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE handle = usbio->handle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
EFI_DEVICE_PATH_PROTOCOL *end;
|
||||
|
@ -1481,19 +1465,14 @@ static int usbio_path ( struct usbio_device *usbio ) {
|
|||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
} u;
|
||||
size_t len;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Open device path protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle,
|
||||
&efi_device_path_protocol_guid,
|
||||
&u.interface, efi_image_handle,
|
||||
handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( usbio, "USBIO %s cannot open device path protocol: "
|
||||
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_open_protocol;
|
||||
return rc;
|
||||
}
|
||||
path = u.interface;
|
||||
|
||||
|
@ -1502,8 +1481,7 @@ static int usbio_path ( struct usbio_device *usbio ) {
|
|||
if ( len < sizeof ( *usbpath ) ) {
|
||||
DBGC ( usbio, "USBIO %s underlength device path\n",
|
||||
efi_handle_name ( handle ) );
|
||||
rc = -EINVAL;
|
||||
goto err_underlength;
|
||||
return -EINVAL;
|
||||
}
|
||||
usbpath = ( ( ( void * ) path ) + len - sizeof ( *usbpath ) );
|
||||
if ( ! ( ( usbpath->Header.Type == MESSAGING_DEVICE_PATH ) &&
|
||||
|
@ -1511,34 +1489,18 @@ static int usbio_path ( struct usbio_device *usbio ) {
|
|||
DBGC ( usbio, "USBIO %s not a USB device path: ",
|
||||
efi_handle_name ( handle ) );
|
||||
DBGC ( usbio, "%s\n", efi_devpath_text ( path ) );
|
||||
rc = -EINVAL;
|
||||
goto err_non_usb;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Allocate copy of device path */
|
||||
usbio->path = malloc ( len + sizeof ( *end ) );
|
||||
if ( ! usbio->path ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
if ( ! usbio->path )
|
||||
return -ENOMEM;
|
||||
memcpy ( usbio->path, path, ( len + sizeof ( *end ) ) );
|
||||
usbio->usbpath = ( ( ( void * ) usbio->path ) + len -
|
||||
sizeof ( *usbpath ) );
|
||||
|
||||
/* Close protocol */
|
||||
bs->CloseProtocol ( handle, &efi_device_path_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
|
||||
return 0;
|
||||
|
||||
free ( usbio->path );
|
||||
err_alloc:
|
||||
err_non_usb:
|
||||
err_underlength:
|
||||
bs->CloseProtocol ( handle, &efi_device_path_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
err_open_protocol:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -234,12 +234,9 @@ static int efi_image_exec ( struct image *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 ) {
|
||||
if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid,
|
||||
&loaded.interface ) ) != 0 ) {
|
||||
/* Should never happen */
|
||||
rc = -EEFI ( efirc );
|
||||
goto err_open_protocol;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,23 +48,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
int efi_set_autoboot_ll_addr ( EFI_HANDLE device,
|
||||
EFI_DEVICE_PATH_PROTOCOL *path ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *snp;
|
||||
void *interface;
|
||||
} snp;
|
||||
EFI_SIMPLE_NETWORK_MODE *mode;
|
||||
EFI_STATUS efirc;
|
||||
unsigned int vlan;
|
||||
int rc;
|
||||
|
||||
/* Look for an SNP instance on the image's device handle */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_simple_network_protocol_guid,
|
||||
&snp.interface, efi_image_handle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid,
|
||||
&snp.interface ) ) != 0 ) {
|
||||
DBGC ( device, "EFI %s has no SNP instance: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
return rc;
|
||||
|
@ -90,9 +84,5 @@ int efi_set_autoboot_ll_addr ( EFI_HANDLE device,
|
|||
efi_handle_name ( device ), vlan );
|
||||
}
|
||||
|
||||
/* Close protocol */
|
||||
bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
|
||||
efi_image_handle, NULL );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -518,8 +518,6 @@ static int efi_block_describe ( void ) {
|
|||
*/
|
||||
static int efi_block_root ( unsigned int drive, EFI_HANDLE handle,
|
||||
EFI_FILE_PROTOCOL **root ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_GUID *protocol = &efi_simple_file_system_protocol_guid;
|
||||
union {
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
|
||||
void *interface;
|
||||
|
@ -528,13 +526,11 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle,
|
|||
int rc;
|
||||
|
||||
/* Open filesystem protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_simple_file_system_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( drive, "EFIBLK %#02x could not open %s filesystem: %s\n",
|
||||
drive, efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Open root volume */
|
||||
|
@ -542,16 +538,10 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle,
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( drive, "EFIBLK %#02x could not open %s root: %s\n",
|
||||
drive, efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_volume;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_volume:
|
||||
bs->CloseProtocol ( handle, protocol, efi_image_handle, handle );
|
||||
err_open:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -674,22 +664,17 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle,
|
|||
EFI_DEVICE_PATH_PROTOCOL *path,
|
||||
struct san_boot_config *config,
|
||||
EFI_DEVICE_PATH_PROTOCOL **fspath ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_GUID *protocol = &efi_device_path_protocol_guid;
|
||||
union {
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
void *interface;
|
||||
} u;
|
||||
EFI_FILE *root;
|
||||
union uuid guid;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Identify device path */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( drive, "EFIBLK %#02x could not open %s device path: "
|
||||
"%s\n", drive, efi_handle_name ( handle ),
|
||||
strerror ( rc ) );
|
||||
|
@ -758,7 +743,6 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle,
|
|||
err_wrong_guid:
|
||||
err_no_guid:
|
||||
err_not_child:
|
||||
bs->CloseProtocol ( handle, protocol, efi_image_handle, handle );
|
||||
err_open:
|
||||
return rc;
|
||||
}
|
||||
|
@ -776,7 +760,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle,
|
|||
struct san_boot_config *config,
|
||||
EFI_DEVICE_PATH_PROTOCOL **fspath ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_GUID *protocol = &efi_device_path_protocol_guid;
|
||||
union {
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
void *interface;
|
||||
|
@ -791,10 +774,8 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle,
|
|||
efi_block_connect ( drive, handle );
|
||||
|
||||
/* Identify device path */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( drive, "EFIBLK %#02x could not open device path: %s\n",
|
||||
drive, strerror ( rc ) );
|
||||
goto err_open;
|
||||
|
@ -824,7 +805,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle,
|
|||
|
||||
bs->FreePool ( handles );
|
||||
err_locate:
|
||||
bs->CloseProtocol ( handle, protocol, efi_image_handle, handle );
|
||||
err_open:
|
||||
return rc;
|
||||
}
|
||||
|
@ -921,52 +901,37 @@ static int efi_block_exec ( unsigned int drive,
|
|||
* equivalent functionality to BIOS drive numbers.
|
||||
*/
|
||||
static int efi_block_local ( EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_GUID *protocol = &efi_block_io_protocol_guid;
|
||||
struct san_device *sandev;
|
||||
struct efi_block_data *block;
|
||||
union {
|
||||
EFI_BLOCK_IO_PROTOCOL *blockio;
|
||||
void *interface;
|
||||
} u;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Check if handle belongs to a SAN device */
|
||||
for_each_sandev ( sandev ) {
|
||||
block = sandev->priv;
|
||||
if ( handle == block->handle ) {
|
||||
rc = -ENOTTY;
|
||||
goto err_sandev;
|
||||
}
|
||||
if ( handle == block->handle )
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/* Open block I/O protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_block_io_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( handle, "EFIBLK %s could not open block I/O: %s\n",
|
||||
efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Do not assign drive numbers for partitions */
|
||||
if ( u.blockio->Media->LogicalPartition ) {
|
||||
rc = -ENOTTY;
|
||||
DBGC2 ( handle, "EFLBLK %s is a partition\n",
|
||||
efi_handle_name ( handle ) );
|
||||
goto err_partition;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_partition:
|
||||
bs->CloseProtocol ( handle, protocol, efi_image_handle, handle );
|
||||
err_open:
|
||||
err_sandev:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,38 +46,31 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
int efi_cachedhcp_record ( EFI_HANDLE device,
|
||||
EFI_DEVICE_PATH_PROTOCOL *path ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
unsigned int vlan;
|
||||
union {
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *pxe;
|
||||
void *interface;
|
||||
} pxe;
|
||||
EFI_PXE_BASE_CODE_MODE *mode;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Get VLAN tag, if any */
|
||||
vlan = efi_path_vlan ( path );
|
||||
|
||||
/* Look for a PXE base code instance on the image's device handle */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_pxe_base_code_protocol_guid,
|
||||
&pxe.interface, efi_image_handle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_pxe_base_code_protocol_guid,
|
||||
&pxe.interface ) ) != 0 ) {
|
||||
DBGC ( device, "EFI %s has no PXE base code instance: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Do not attempt to cache IPv6 packets */
|
||||
mode = pxe.pxe->Mode;
|
||||
if ( mode->UsingIpv6 ) {
|
||||
rc = -ENOTSUP;
|
||||
DBGC ( device, "EFI %s has IPv6 PXE base code\n",
|
||||
efi_handle_name ( device ) );
|
||||
goto err_ipv6;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Record DHCPACK, if present */
|
||||
|
@ -87,7 +80,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
|
|||
sizeof ( mode->DhcpAck ) ) ) != 0 ) ) {
|
||||
DBGC ( device, "EFI %s could not record DHCPACK: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_dhcpack;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Record ProxyDHCPOFFER, if present */
|
||||
|
@ -97,7 +90,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
|
|||
sizeof ( mode->ProxyOffer ) ) ) != 0)){
|
||||
DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_proxydhcp;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Record PxeBSACK, if present */
|
||||
|
@ -107,18 +100,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
|
|||
sizeof ( mode->PxeReply ) ) ) != 0)){
|
||||
DBGC ( device, "EFI %s could not record PXEBSACK: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_pxebs;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_pxebs:
|
||||
err_proxydhcp:
|
||||
err_dhcpack:
|
||||
err_ipv6:
|
||||
bs->CloseProtocol ( device, &efi_pxe_base_code_protocol_guid,
|
||||
efi_image_handle, NULL );
|
||||
err_open:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -328,14 +328,12 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
|
|||
* @ret name Driver name, or NULL
|
||||
*/
|
||||
static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_COMPONENT_NAME_PROTOCOL *name;
|
||||
void *interface;
|
||||
} u;
|
||||
EFI_HANDLE image;
|
||||
const char *name;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Sanity check */
|
||||
if ( ! binding ) {
|
||||
|
@ -345,22 +343,14 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) {
|
|||
|
||||
/* Try to open component name protocol on image handle */
|
||||
image = binding->ImageHandle;
|
||||
if ( ( efirc = bs->OpenProtocol ( image,
|
||||
&efi_component_name_protocol_guid,
|
||||
&u.interface, efi_image_handle, image,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){
|
||||
if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBG ( "[DriverBinding no ComponentName]" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Try to get name from component name protocol */
|
||||
name = efi_driver_name ( u.name );
|
||||
|
||||
/* Close component name protocol */
|
||||
bs->CloseProtocol ( image, &efi_component_name_protocol_guid,
|
||||
efi_image_handle, image );
|
||||
|
||||
return name;
|
||||
return efi_driver_name ( u.name );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,14 +360,12 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) {
|
|||
* @ret name Driver name, or NULL
|
||||
*/
|
||||
static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE image;
|
||||
union {
|
||||
EFI_COMPONENT_NAME2_PROTOCOL *name2;
|
||||
void *interface;
|
||||
} u;
|
||||
const char *name;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Sanity check */
|
||||
if ( ! binding ) {
|
||||
|
@ -387,22 +375,14 @@ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){
|
|||
|
||||
/* Try to open component name protocol on image handle */
|
||||
image = binding->ImageHandle;
|
||||
if ( ( efirc = bs->OpenProtocol ( image,
|
||||
&efi_component_name2_protocol_guid,
|
||||
&u.interface, efi_image_handle, image,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){
|
||||
if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBG ( "[DriverBinding no ComponentName2]" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Try to get name from component name protocol */
|
||||
name = efi_driver_name2 ( u.name2 );
|
||||
|
||||
/* Close component name protocol */
|
||||
bs->CloseProtocol ( image, &efi_component_name2_protocol_guid,
|
||||
efi_image_handle, image );
|
||||
|
||||
return name;
|
||||
return efi_driver_name2 ( u.name2 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -669,6 +649,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
|
|||
void *interface;
|
||||
const char *name;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Fail immediately for NULL handles */
|
||||
if ( ! handle )
|
||||
|
@ -681,10 +662,8 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
|
|||
DBG2 ( "<%d", i );
|
||||
|
||||
/* Try to open the applicable protocol */
|
||||
efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
|
||||
efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL );
|
||||
if ( efirc != 0 ) {
|
||||
if ( ( rc = efi_open ( handle, type->protocol,
|
||||
&interface ) ) != 0 ) {
|
||||
DBG2 ( ">" );
|
||||
continue;
|
||||
}
|
||||
|
@ -692,12 +671,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
|
|||
/* Try to get name from this protocol */
|
||||
DBG2 ( "-" );
|
||||
name = type->name ( interface );
|
||||
DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
|
||||
|
||||
/* Close protocol */
|
||||
bs->CloseProtocol ( handle, type->protocol,
|
||||
efi_image_handle, handle );
|
||||
DBG2 ( ">" );
|
||||
DBG2 ( "%c>", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
|
||||
|
||||
/* Use this name, if possible */
|
||||
if ( name && name[0] )
|
||||
|
|
|
@ -68,7 +68,6 @@ static int efi_driver_disconnecting;
|
|||
* @ret efidev EFI device, or NULL on error
|
||||
*/
|
||||
struct efi_device * efidev_alloc ( EFI_HANDLE device ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct efi_device *efidev = NULL;
|
||||
union {
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
|
@ -76,26 +75,21 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) {
|
|||
} path;
|
||||
EFI_DEVICE_PATH_PROTOCOL *path_end;
|
||||
size_t path_len;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Open device path */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_device_path_protocol_guid,
|
||||
&path.interface, efi_image_handle,
|
||||
device,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid,
|
||||
&path.interface ) ) != 0 ) {
|
||||
DBGC ( device, "EFIDRV %s could not open device path: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_open_path;
|
||||
return NULL;
|
||||
}
|
||||
path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) );
|
||||
|
||||
/* Allocate and initialise structure */
|
||||
efidev = zalloc ( sizeof ( *efidev ) + path_len );
|
||||
if ( ! efidev )
|
||||
goto err_alloc;
|
||||
return NULL;
|
||||
efidev->device = device;
|
||||
efidev->dev.desc.bus_type = BUS_TYPE_EFI;
|
||||
efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) );
|
||||
|
@ -103,10 +97,6 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) {
|
|||
INIT_LIST_HEAD ( &efidev->dev.children );
|
||||
list_add ( &efidev->dev.siblings, &efi_devices );
|
||||
|
||||
err_alloc:
|
||||
bs->CloseProtocol ( device, &efi_device_path_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
err_open_path:
|
||||
return efidev;
|
||||
}
|
||||
|
||||
|
@ -375,21 +365,18 @@ static EFI_STATUS EFIAPI
|
|||
efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused,
|
||||
EFI_HANDLE device, EFI_HANDLE child,
|
||||
CHAR8 *language, CHAR16 **controller_name ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_COMPONENT_NAME2_PROTOCOL *name2;
|
||||
void *interface;
|
||||
} name2;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance
|
||||
* installed on child handle, if present.
|
||||
*/
|
||||
if ( ( child != NULL ) &&
|
||||
( ( efirc = bs->OpenProtocol (
|
||||
child, &efi_component_name2_protocol_guid,
|
||||
&name2.interface, NULL, NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) ) {
|
||||
( ( rc = efi_open ( child, &efi_component_name2_protocol_guid,
|
||||
&name2.interface ) ) == 0 ) ) {
|
||||
return name2.name2->GetControllerName ( name2.name2, device,
|
||||
child, language,
|
||||
controller_name );
|
||||
|
|
|
@ -263,13 +263,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
|
|||
efi_cmdline_len = efi_loaded_image->LoadOptionsSize;
|
||||
|
||||
/* Get loaded image's device handle's device path */
|
||||
if ( ( efirc = bs->OpenProtocol ( efi_loaded_image->DeviceHandle,
|
||||
&efi_device_path_protocol_guid,
|
||||
&device_path, image_handle, NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( efi_loaded_image->DeviceHandle,
|
||||
&efi_device_path_protocol_guid,
|
||||
&device_path ) ) != 0 ) {
|
||||
DBGC ( systab, "EFI could not get loaded image's device path: "
|
||||
"%s", strerror ( rc ) );
|
||||
efirc = EFIRC ( rc );
|
||||
goto err_no_device_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,6 @@ static int efi_local_check_volume_name ( struct efi_local *local,
|
|||
*/
|
||||
static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device,
|
||||
EFI_FILE_PROTOCOL **root ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
void *interface;
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
|
||||
|
@ -217,15 +216,11 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device,
|
|||
int rc;
|
||||
|
||||
/* Open file system protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_simple_file_system_protocol_guid,
|
||||
&u.interface, efi_image_handle,
|
||||
device,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_simple_file_system_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n",
|
||||
local, efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_filesystem;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Open root directory */
|
||||
|
@ -233,17 +228,10 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device,
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( local, "LOCAL %p could not open volume on %s: %s\n",
|
||||
local, efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_volume;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_volume:
|
||||
bs->CloseProtocol ( device, &efi_simple_file_system_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
err_filesystem:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,7 +72,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle,
|
||||
struct pci_range *range ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
void *interface;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
|
||||
|
@ -94,15 +93,12 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle,
|
|||
range->count = 0;
|
||||
|
||||
/* Open root bridge I/O protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle,
|
||||
&efi_pci_root_bridge_io_protocol_guid,
|
||||
&root.interface, efi_image_handle, handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||
&root.interface ) ) != 0 ) {
|
||||
DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n",
|
||||
PCI_ARGS ( pci ), efi_handle_name ( handle ),
|
||||
strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Get ACPI resource descriptors */
|
||||
|
@ -112,7 +108,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle,
|
|||
DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for "
|
||||
"%s: %s\n", PCI_ARGS ( pci ),
|
||||
efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_config;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Parse resource descriptors */
|
||||
|
@ -159,14 +155,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle,
|
|||
range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 );
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_config:
|
||||
bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
err_open:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,7 +249,7 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Open EFI PCI root bridge I/O protocol
|
||||
* Open EFI PCI root bridge I/O protocol for ephemeral use
|
||||
*
|
||||
* @v pci PCI device
|
||||
* @ret handle EFI PCI root bridge handle
|
||||
|
@ -269,25 +258,20 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) {
|
|||
*/
|
||||
static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle,
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct pci_range tmp;
|
||||
union {
|
||||
void *interface;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
|
||||
} u;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Find matching root bridge I/O protocol handle */
|
||||
if ( ( rc = efipci_discover_any ( pci, &tmp, handle ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* (Re)open PCI root bridge I/O protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( *handle,
|
||||
&efi_pci_root_bridge_io_protocol_guid,
|
||||
&u.interface, efi_image_handle, *handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
/* Open PCI root bridge I/O protocol */
|
||||
if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n",
|
||||
PCI_ARGS ( pci ), efi_handle_name ( *handle ),
|
||||
strerror ( rc ) );
|
||||
|
@ -300,19 +284,6 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close EFI PCI root bridge I/O protocol
|
||||
*
|
||||
* @v handle EFI PCI root bridge handle
|
||||
*/
|
||||
static void efipci_root_close ( EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
|
||||
/* Close protocol */
|
||||
bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate EFI PCI configuration space address
|
||||
*
|
||||
|
@ -346,7 +317,7 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
|
|||
|
||||
/* Open root bridge */
|
||||
if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 )
|
||||
goto err_root;
|
||||
return rc;
|
||||
|
||||
/* Read from configuration space */
|
||||
if ( ( efirc = root->Pci.Read ( root, EFIPCI_WIDTH ( location ),
|
||||
|
@ -356,13 +327,10 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
|
|||
DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx "
|
||||
"failed: %s\n", PCI_ARGS ( pci ),
|
||||
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
||||
goto err_read;
|
||||
return rc;
|
||||
}
|
||||
|
||||
err_read:
|
||||
efipci_root_close ( handle );
|
||||
err_root:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,7 +350,7 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
|
|||
|
||||
/* Open root bridge */
|
||||
if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 )
|
||||
goto err_root;
|
||||
return rc;
|
||||
|
||||
/* Read from configuration space */
|
||||
if ( ( efirc = root->Pci.Write ( root, EFIPCI_WIDTH ( location ),
|
||||
|
@ -392,13 +360,10 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
|
|||
DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx "
|
||||
"failed: %s\n", PCI_ARGS ( pci ),
|
||||
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
||||
goto err_write;
|
||||
return rc;
|
||||
}
|
||||
|
||||
err_write:
|
||||
efipci_root_close ( handle );
|
||||
err_root:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -469,7 +434,6 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr,
|
|||
}
|
||||
|
||||
err_config:
|
||||
efipci_root_close ( handle );
|
||||
err_root:
|
||||
return ioremap ( bus_addr, len );
|
||||
}
|
||||
|
@ -778,7 +742,6 @@ static struct dma_operations efipci_dma_operations = {
|
|||
* @ret rc Return status code
|
||||
*/
|
||||
int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_PCI_IO_PROTOCOL *pci_io;
|
||||
void *interface;
|
||||
|
@ -789,14 +752,11 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) {
|
|||
int rc;
|
||||
|
||||
/* See if device is a PCI device */
|
||||
if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid,
|
||||
&pci_io.interface,
|
||||
efi_image_handle, device,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI_PCI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_pci_io_protocol_guid,
|
||||
&pci_io.interface ) ) != 0 ) {
|
||||
DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_open_protocol;
|
||||
return rc;
|
||||
}
|
||||
efipci->io = pci_io.pci_io;
|
||||
|
||||
|
@ -807,7 +767,7 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) {
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( device, "EFIPCI %s could not get PCI location: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_get_location;
|
||||
return rc;
|
||||
}
|
||||
busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
|
||||
pci_init ( &efipci->pci, busdevfn );
|
||||
|
@ -836,17 +796,10 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) {
|
|||
DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI "
|
||||
"configuration: %s\n",
|
||||
PCI_ARGS ( &efipci->pci ), strerror ( rc ) );
|
||||
goto err_pci_read_config;
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_pci_read_config:
|
||||
err_get_location:
|
||||
bs->CloseProtocol ( device, &efi_pci_io_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
err_open_protocol:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -45,7 +45,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding,
|
||||
EFI_HANDLE *handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_SERVICE_BINDING_PROTOCOL *sb;
|
||||
void *interface;
|
||||
|
@ -54,14 +53,11 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding,
|
|||
int rc;
|
||||
|
||||
/* Open service binding protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface,
|
||||
efi_image_handle, service,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) {
|
||||
DBGC ( service, "EFISVC %s cannot open %s binding: %s\n",
|
||||
efi_handle_name ( service ), efi_guid_ntoa ( binding ),
|
||||
strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Create child handle */
|
||||
|
@ -70,19 +66,13 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding,
|
|||
DBGC ( service, "EFISVC %s could not create %s child: %s\n",
|
||||
efi_handle_name ( service ), efi_guid_ntoa ( binding ),
|
||||
strerror ( rc ) );
|
||||
goto err_create;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
DBGC ( service, "EFISVC %s created %s child ",
|
||||
efi_handle_name ( service ), efi_guid_ntoa ( binding ) );
|
||||
DBGC ( service, "%s\n", efi_handle_name ( *handle ) );
|
||||
|
||||
err_create:
|
||||
bs->CloseProtocol ( service, binding, efi_image_handle, service );
|
||||
err_open:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +85,6 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding,
|
|||
*/
|
||||
int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding,
|
||||
EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_SERVICE_BINDING_PROTOCOL *sb;
|
||||
void *interface;
|
||||
|
@ -108,14 +97,11 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding,
|
|||
DBGC ( service, "%s\n", efi_handle_name ( handle ) );
|
||||
|
||||
/* Open service binding protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface,
|
||||
efi_image_handle, service,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) {
|
||||
DBGC ( service, "EFISVC %s cannot open %s binding: %s\n",
|
||||
efi_handle_name ( service ), efi_guid_ntoa ( binding ),
|
||||
strerror ( rc ) );
|
||||
goto err_open;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Destroy child handle */
|
||||
|
@ -125,14 +111,8 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding,
|
|||
efi_handle_name ( service ), efi_guid_ntoa ( binding ) );
|
||||
DBGC ( service, "%s: %s\n",
|
||||
efi_handle_name ( handle ), strerror ( rc ) );
|
||||
goto err_destroy;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_destroy:
|
||||
bs->CloseProtocol ( service, binding, efi_image_handle, service );
|
||||
err_open:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,6 @@ static EFIAPI EFI_STATUS efi_shim_get_memory_map ( UINTN *len,
|
|||
* @ret rc Return status code
|
||||
*/
|
||||
static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *pxe;
|
||||
void *interface;
|
||||
|
@ -281,14 +280,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) {
|
|||
int rc;
|
||||
|
||||
/* Locate PXE base code */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle,
|
||||
&efi_pxe_base_code_protocol_guid,
|
||||
&u.interface, efi_image_handle, NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_pxe_base_code_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( &efi_shim, "SHIM could not open PXE base code: %s\n",
|
||||
strerror ( rc ) );
|
||||
goto err_no_base;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Stop PXE base code */
|
||||
|
@ -296,18 +292,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) {
|
|||
rc = -EEFI ( efirc );
|
||||
DBGC ( &efi_shim, "SHIM could not stop PXE base code: %s\n",
|
||||
strerror ( rc ) );
|
||||
goto err_stop;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
DBGC ( &efi_shim, "SHIM stopped PXE base code\n" );
|
||||
|
||||
err_stop:
|
||||
bs->CloseProtocol ( handle, &efi_pxe_base_code_protocol_guid,
|
||||
efi_image_handle, NULL );
|
||||
err_no_base:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,12 +56,8 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol,
|
|||
int rc;
|
||||
|
||||
/* Get device path */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_device_path_protocol_guid,
|
||||
&u.interface,
|
||||
efi_image_handle, device,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( device, "EFIDEV %s cannot open device path: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_open_device_path;
|
||||
|
@ -100,14 +96,9 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol,
|
|||
efi_path_terminate ( end );
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
err_locate_protocol:
|
||||
free ( path );
|
||||
err_alloc_path:
|
||||
bs->CloseProtocol ( device, &efi_device_path_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
err_open_device_path:
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -161,21 +161,14 @@ static int efi_veto_uninstall ( struct efi_veto *veto ) {
|
|||
int rc;
|
||||
|
||||
/* Open driver binding protocol */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
driver, &efi_driver_binding_protocol_guid,
|
||||
&binding.interface, efi_image_handle, driver,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
|
||||
&binding.interface ) ) != 0 ) {
|
||||
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
||||
"protocol: %s\n", efi_handle_name ( driver ),
|
||||
strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Close driver binding protocol */
|
||||
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
||||
efi_image_handle, driver );
|
||||
|
||||
/* Uninstall driver binding protocol */
|
||||
if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
|
||||
driver, &efi_driver_binding_protocol_guid,
|
||||
|
@ -541,7 +534,6 @@ static struct efi_veto_candidate efi_vetoes[] = {
|
|||
*/
|
||||
static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
||||
struct efi_veto *veto ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
||||
void *interface;
|
||||
|
@ -568,47 +560,35 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||
memset ( veto, 0, sizeof ( *veto ) );
|
||||
|
||||
/* Open driver binding protocol */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
driver, &efi_driver_binding_protocol_guid,
|
||||
&binding.interface, efi_image_handle, driver,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
|
||||
&binding.interface ) ) != 0 ) {
|
||||
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
||||
"protocol: %s\n", efi_handle_name ( driver ),
|
||||
strerror ( rc ) );
|
||||
goto err_binding;
|
||||
return rc;
|
||||
}
|
||||
image = binding.binding->ImageHandle;
|
||||
|
||||
/* Open loaded image protocol */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
image, &efi_loaded_image_protocol_guid,
|
||||
&loaded.interface, efi_image_handle, image,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( image, &efi_loaded_image_protocol_guid,
|
||||
&loaded.interface ) ) != 0 ) {
|
||||
DBGC ( driver, "EFIVETO %s could not open",
|
||||
efi_handle_name ( driver ) );
|
||||
DBGC ( driver, " %s loaded image protocol: %s\n",
|
||||
efi_handle_name ( image ), strerror ( rc ) );
|
||||
goto err_loaded;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Open component name protocol, if present */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
image, &efi_component_name2_protocol_guid,
|
||||
&wtf2.interface, efi_image_handle, image,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid,
|
||||
&wtf2.interface ) ) != 0 ) {
|
||||
/* Ignore failure; is not required to be present */
|
||||
wtf2.interface = NULL;
|
||||
}
|
||||
|
||||
/* Open obsolete component name protocol, if present */
|
||||
if ( ( efirc = bs->OpenProtocol (
|
||||
image, &efi_component_name_protocol_guid,
|
||||
&wtf.interface, efi_image_handle, image,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||
if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid,
|
||||
&wtf.interface ) ) != 0 ) {
|
||||
/* Ignore failure; is not required to be present */
|
||||
wtf.interface = NULL;
|
||||
}
|
||||
|
||||
/* Get driver name, if available */
|
||||
|
@ -643,25 +623,7 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||
}
|
||||
}
|
||||
|
||||
/* Success */
|
||||
rc = 0;
|
||||
|
||||
/* Close protocols */
|
||||
if ( wtf.wtf ) {
|
||||
bs->CloseProtocol ( image, &efi_component_name_protocol_guid,
|
||||
efi_image_handle, image );
|
||||
}
|
||||
if ( wtf2.wtf2 ) {
|
||||
bs->CloseProtocol ( image, &efi_component_name2_protocol_guid,
|
||||
efi_image_handle, image );
|
||||
}
|
||||
bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid,
|
||||
efi_image_handle, image );
|
||||
err_loaded:
|
||||
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
||||
efi_image_handle, driver );
|
||||
err_binding:
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -248,20 +248,15 @@ static int efi_prescroll ( unsigned int lines ) {
|
|||
* @v handle Image handle
|
||||
*/
|
||||
static void efi_dump_image ( EFI_HANDLE handle ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
union {
|
||||
EFI_LOADED_IMAGE_PROTOCOL *image;
|
||||
void *intf;
|
||||
} loaded;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Open loaded image protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle,
|
||||
&efi_loaded_image_protocol_guid,
|
||||
&loaded.intf, efi_image_handle, NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid,
|
||||
&loaded.intf ) ) != 0 ) {
|
||||
DBGC ( colour, "WRAP %s could not get loaded image protocol: "
|
||||
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
|
||||
return;
|
||||
|
@ -277,10 +272,6 @@ static void efi_dump_image ( EFI_HANDLE handle ) {
|
|||
DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle ));
|
||||
DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) );
|
||||
DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) );
|
||||
|
||||
/* Close loaded image protocol */
|
||||
bs->CloseProtocol ( handle, &efi_loaded_image_protocol_guid,
|
||||
efi_image_handle, NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue