iPXE
Functions
snp.c File Reference

SNP driver. More...

#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_snp.h>
#include "snpnet.h"
#include "nii.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int snp_supported (EFI_HANDLE device)
 Check to see if driver supports a device. More...
 
static int nii_supported (EFI_HANDLE device)
 Check to see if driver supports a device. More...
 
struct efi_driver snp_driver __efi_driver (EFI_DRIVER_NORMAL)
 EFI SNP driver. More...
 

Detailed Description

SNP driver.

Definition in file snp.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ snp_supported()

static int snp_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 45 of file snp.c.

45  {
47  EFI_STATUS efirc;
48 
49  /* Check that this is not a device we are providing ourselves */
50  if ( find_snpdev ( device ) != NULL ) {
51  DBGCP ( device, "SNP %s is provided by this binary\n",
52  efi_handle_name ( device ) );
53  return -ENOTTY;
54  }
55 
56  /* Test for presence of simple network protocol */
57  if ( ( efirc = bs->OpenProtocol ( device,
61  DBGCP ( device, "SNP %s is not an SNP device\n",
62  efi_handle_name ( device ) );
63  return -EEFI ( efirc );
64  }
65  DBGC ( device, "SNP %s is an SNP device\n",
66  efi_handle_name ( device ) );
67 
68  return 0;
69 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:236
#define DBGC(...)
Definition: compiler.h:505
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL
Definition: UefiSpec.h:1272
A hardware device.
Definition: device.h:73
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:32
struct efi_snp_device * find_snpdev(EFI_HANDLE handle)
Find SNP device by EFI device handle.
Definition: efi_snp.c:1939
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
#define DBGCP(...)
Definition: compiler.h:539
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References EFI_SYSTEM_TABLE::BootServices, DBGC, DBGCP, EEFI, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL, efi_simple_network_protocol_guid, efi_systab, ENOTTY, find_snpdev(), NULL, and EFI_BOOT_SERVICES::OpenProtocol.

◆ nii_supported()

static int nii_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 77 of file snp.c.

77  {
79  EFI_STATUS efirc;
80 
81  /* Check that this is not a device we are providing ourselves */
82  if ( find_snpdev ( device ) != NULL ) {
83  DBGCP ( device, "NII %s is provided by this binary\n",
84  efi_handle_name ( device ) );
85  return -ENOTTY;
86  }
87 
88  /* Test for presence of NII protocol */
89  if ( ( efirc = bs->OpenProtocol ( device,
93  DBGCP ( device, "NII %s is not an NII device\n",
94  efi_handle_name ( device ) );
95  return -EEFI ( efirc );
96  }
97  DBGC ( device, "NII %s is an NII device\n",
98  efi_handle_name ( device ) );
99 
100  return 0;
101 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:212
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define DBGC(...)
Definition: compiler.h:505
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL
Definition: UefiSpec.h:1272
A hardware device.
Definition: device.h:73
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:32
struct efi_snp_device * find_snpdev(EFI_HANDLE handle)
Find SNP device by EFI device handle.
Definition: efi_snp.c:1939
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
#define DBGCP(...)
Definition: compiler.h:539
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References EFI_SYSTEM_TABLE::BootServices, DBGC, DBGCP, EEFI, efi_handle_name(), efi_image_handle, efi_nii31_protocol_guid, EFI_OPEN_PROTOCOL_TEST_PROTOCOL, efi_systab, ENOTTY, find_snpdev(), NULL, and EFI_BOOT_SERVICES::OpenProtocol.

◆ __efi_driver()

struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL  )
Initial value:
= {
.name = "NII",
.supported = nii_supported,
.start = nii_start,
.stop = nii_stop,
}
int nii_start(struct efi_device *efidev)
Attach driver to device.
Definition: nii.c:1210
void nii_stop(struct efi_device *efidev)
Detach driver from device.
Definition: nii.c:1329
static int nii_supported(EFI_HANDLE device)
Check to see if driver supports a device.
Definition: snp.c:77

EFI SNP driver.

EFI NII chainloading-device-only driver.

EFI NII driver.