iPXE
Data Structures | Functions | Variables
snponly.c File Reference

EFI chainloaded-device-only driver. More...

#include <string.h>
#include <errno.h>
#include <ipxe/init.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/Protocol/SimpleNetwork.h>
#include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
#include "snpnet.h"
#include "nii.h"

Go to the source code of this file.

Data Structures

struct  chained_protocol
 A chainloaded protocol. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int chained_locate (struct chained_protocol *chained)
 Locate chainloaded protocol instance.
static int chained_supported (EFI_HANDLE device, struct chained_protocol *chained)
 Check to see if driver supports a device.
static int snponly_supported (EFI_HANDLE device)
 Check to see if driver supports a device.
static int niionly_supported (EFI_HANDLE device)
 Check to see if driver supports a device.
struct efi_driver snponly_driver __efi_driver (EFI_DRIVER_NORMAL)
 EFI SNP chainloading-device-only driver.
static void chained_init (void)
 Initialise EFI chainloaded-device-only driver.
struct init_fn chained_init_fn __init_fn (INIT_LATE)
 EFI chainloaded-device-only initialisation function.

Variables

static struct chained_protocol chained_snp
 Chainloaded SNP protocol.
static struct chained_protocol chained_nii
 Chainloaded NII protocol.

Detailed Description

EFI chainloaded-device-only driver.

Definition in file snponly.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int chained_locate ( struct chained_protocol chained) [static]

Locate chainloaded protocol instance.

Parameters:
chainedChainloaded protocol
Return values:
rcReturn status code

Definition at line 74 of file snponly.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, EFI_LOADED_IMAGE_PROTOCOL::DeviceHandle, EEFI, efi_guid_ntoa(), efi_handle_name(), efi_image_handle, efi_loaded_image, efi_locate_device(), EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, chained_protocol::interface, EFI_BOOT_SERVICES::OpenProtocol, chained_protocol::protocol, rc, and strerror().

Referenced by chained_init().

                                                               {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_HANDLE device = efi_loaded_image->DeviceHandle;
        EFI_HANDLE parent;
        EFI_STATUS efirc;
        int rc;

        /* Locate handle supporting this protocol */
        if ( ( rc = efi_locate_device ( device, chained->protocol,
                                        &parent ) ) != 0 ) {
                DBGC ( device, "CHAINED %s does not support %s: %s\n",
                       efi_handle_name ( device ),
                       efi_guid_ntoa ( chained->protocol ), strerror ( rc ) );
                goto err_locate_device;
        }
        DBGC ( device, "CHAINED %s found %s on ", efi_handle_name ( device ),
               efi_guid_ntoa ( chained->protocol ) );
        DBGC ( device, "%s\n", efi_handle_name ( parent ) );

        /* Get protocol instance */
        if ( ( efirc = bs->OpenProtocol ( parent, chained->protocol,
                                          &chained->interface, efi_image_handle,
                                          device,
                                          EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
                rc = -EEFI ( efirc );
                DBGC ( device, "CHAINED %s could not open %s on ",
                       efi_handle_name ( device ),
                       efi_guid_ntoa ( chained->protocol ) );
                DBGC ( device, "%s: %s\n",
                       efi_handle_name ( parent ), strerror ( rc ) );
                goto err_open_protocol;
        }

 err_locate_device:
        bs->CloseProtocol ( parent, chained->protocol, efi_image_handle,
                            device );
 err_open_protocol:
        return rc;
}
static int chained_supported ( EFI_HANDLE  device,
struct chained_protocol chained 
) [static]

Check to see if driver supports a device.

Parameters:
deviceEFI device handle
chainedChainloaded protocol
Return values:
rcReturn status code

Definition at line 121 of file snponly.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGCP, EEFI, efi_guid_ntoa(), efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, ENOTTY, chained_protocol::interface, EFI_BOOT_SERVICES::OpenProtocol, chained_protocol::protocol, and rc.

Referenced by niionly_supported(), and snponly_supported().

                                                                  {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_STATUS efirc;
        void *interface;
        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 );
                DBGCP ( device, "CHAINED %s is not a %s device\n",
                        efi_handle_name ( device ),
                        efi_guid_ntoa ( chained->protocol ) );
                goto err_open_protocol;
        }

        /* Test for a match against the chainloading device */
        if ( interface != chained->interface ) {
                DBGC ( device, "CHAINED %s %p is not the chainloaded %s\n",
                       efi_handle_name ( device ), interface,
                       efi_guid_ntoa ( chained->protocol ) );
                rc = -ENOTTY;
                goto err_no_match;
        }

        /* Success */
        rc = 0;
        DBGC ( device, "CHAINED %s %p is the chainloaded %s\n",
               efi_handle_name ( device ), interface,
               efi_guid_ntoa ( chained->protocol ) );

 err_no_match:
        bs->CloseProtocol ( device, chained->protocol, efi_image_handle,
                            device );
 err_open_protocol:
        return rc;
}
static int snponly_supported ( EFI_HANDLE  device) [static]

Check to see if driver supports a device.

Parameters:
deviceEFI device handle
Return values:
rcReturn status code

Definition at line 167 of file snponly.c.

References chained_supported().

                                                   {

        return chained_supported ( device, &chained_snp );
}
static int niionly_supported ( EFI_HANDLE  device) [static]

Check to see if driver supports a device.

Parameters:
deviceEFI device handle
Return values:
rcReturn status code

Definition at line 178 of file snponly.c.

References chained_supported().

                                                   {

        return chained_supported ( device, &chained_nii );
}
struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL  ) [read]

EFI SNP chainloading-device-only driver.

EFI NII chainloading-device-only driver.

static void chained_init ( void  ) [static]

Initialise EFI chainloaded-device-only driver.

Definition at line 203 of file snponly.c.

References chained_locate().

struct init_fn chained_init_fn __init_fn ( INIT_LATE  ) [read]

EFI chainloaded-device-only initialisation function.


Variable Documentation

struct chained_protocol chained_snp [static]
Initial value:

Chainloaded SNP protocol.

Definition at line 59 of file snponly.c.

struct chained_protocol chained_nii [static]
Initial value:
 {
        .protocol = &efi_nii31_protocol_guid,
}

Chainloaded NII protocol.

Definition at line 64 of file snponly.c.