iPXE
Data Structures | Macros | Typedefs | Functions | Variables
efi_bofm.c File Reference

IBM BladeCenter Open Fabric Manager (BOFM) EFI interface. More...

#include <errno.h>
#include <ipxe/bofm.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_pci.h>
#include <ipxe/efi/efi_driver.h>

Go to the source code of this file.

Data Structures

struct  BOFM_EPID_Results_t
 
struct  BOFM_Parameters_t
 
struct  BOFM_Results_t
 
struct  BOFM_DataStructure_t
 
struct  _IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL
 
struct  _IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL2
 

Macros

#define IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL_GUID
 
#define IBM_BOFM_DRIVER_CONFIGURATION2_PROTOCOL_GUID
 
#define IBM_BOFM_TABLE   BOFM_DataStructure_t
 

Typedefs

typedef struct _IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL
 
typedef struct _IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL2 IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL2
 
typedef EFI_HANDLE ControllerHandle
 
typedef EFI_HANDLE UINT8 SupporttedOptions
 
typedef EFI_HANDLE UINT8 UINT8 iSCSI_Parameter_Version
 
typedef EFI_HANDLE UINT8 UINT8 UINT8 BOFM_Parameter_Version
 
typedef EFI_HANDLE BOOLEAN ResetRequired
 
typedef EFI_HANDLE BOOLEAN UINT8 BOFMReturnCode
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
typedef EFI_STATUS (EFIAPI *IBM_BOFM_DRIVER_CONFIGURATION_SUPPORT)(IN IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL *This
 
static int efi_bofm_supported (EFI_HANDLE device)
 Check if device is supported. More...
 
static int efi_bofm_start (struct efi_device *efidev)
 Attach driver to device. More...
 
static void efi_bofm_stop (struct efi_device *efidev __unused)
 Detach driver from device. More...
 
struct efi_driver efi_bofm_driver __efi_driver (EFI_DRIVER_EARLY)
 EFI BOFM driver. More...
 

Variables

static EFI_GUID bofm1_protocol_guid
 BOFM1 protocol GUID. More...
 
static EFI_GUID bofm2_protocol_guid
 BOFM2 protocol GUID. More...
 

Detailed Description

IBM BladeCenter Open Fabric Manager (BOFM) EFI interface.

Definition in file efi_bofm.c.

Macro Definition Documentation

◆ IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL_GUID

#define IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL_GUID
Value:
{ 0x03207ce2, 0xd9c7, 0x11dc, \
{ 0xa9, 0x4d, 0x00, 0x19, 0x7d, 0x89, 0x02, 0x38 } }

Definition at line 48 of file efi_bofm.c.

◆ IBM_BOFM_DRIVER_CONFIGURATION2_PROTOCOL_GUID

#define IBM_BOFM_DRIVER_CONFIGURATION2_PROTOCOL_GUID
Value:
{ 0xe82a9763, 0x0584, 0x4e41, \
{ 0xbb, 0x39, 0xe0, 0xcd, 0xb8, 0xc1, 0xf0, 0xfc } }

Definition at line 52 of file efi_bofm.c.

◆ IBM_BOFM_TABLE

#define IBM_BOFM_TABLE   BOFM_DataStructure_t

Definition at line 99 of file efi_bofm.c.

Typedef Documentation

◆ IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL

Definition at line 101 of file efi_bofm.c.

◆ IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL2

Definition at line 104 of file efi_bofm.c.

◆ ControllerHandle

Definition at line 109 of file efi_bofm.c.

◆ SupporttedOptions

Definition at line 109 of file efi_bofm.c.

◆ iSCSI_Parameter_Version

Definition at line 109 of file efi_bofm.c.

◆ BOFM_Parameter_Version

Definition at line 109 of file efi_bofm.c.

◆ ResetRequired

Definition at line 117 of file efi_bofm.c.

◆ BOFMReturnCode

Definition at line 117 of file efi_bofm.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ EFI_STATUS()

typedef EFI_STATUS ( EFIAPI IBM_BOFM_DRIVER_CONFIGURATION_SUPPORT)

◆ efi_bofm_supported()

static int efi_bofm_supported ( EFI_HANDLE  device)
static

Check if device is supported.

Parameters
deviceEFI device handle
Return values
rcReturn status code

Definition at line 165 of file efi_bofm.c.

165  {
167  struct pci_device pci;
168  union {
170  void *interface;
171  } bofm1;
172  EFI_STATUS efirc;
173  int rc;
174 
175  /* Get PCI device information */
176  if ( ( rc = efipci_info ( device, &pci ) ) != 0 )
177  return rc;
178 
179  /* Look for a BOFM driver */
180  if ( ( rc = bofm_find_driver ( &pci ) ) != 0 ) {
181  DBGCP ( device, "EFIBOFM %s has no driver\n",
182  efi_handle_name ( device ) );
183  return rc;
184  }
185 
186  /* Locate BOFM protocol */
187  if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL,
188  &bofm1.interface ) ) != 0 ) {
189  rc = -EEFI ( efirc );
190  DBGC ( device, "EFIBOFM %s cannot find BOFM protocol\n",
191  efi_handle_name ( device ) );
192  return rc;
193  }
194 
195  /* Register support for this device */
196  if ( ( efirc = bofm1.bofm1->RegisterSupport ( bofm1.bofm1, device,
197  0x04 /* Can change MAC */,
198  0x00 /* No iSCSI */,
199  0x02 /* Version */ ))!=0){
200  rc = -EEFI ( efirc );
201  DBGC ( device, "EFIBOFM %s could not register support: %s\n",
202  efi_handle_name ( device ), strerror ( rc ) );
203  return rc;
204  }
205 
206  DBGC ( device, "EFIBOFM %s has driver \"%s\"\n",
207  efi_handle_name ( device ), pci.id->name );
208  return 0;
209 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1914
#define DBGC(...)
Definition: compiler.h:505
A hardware device.
Definition: device.h:73
An object interface.
Definition: interface.h:109
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
A PCI device.
Definition: pci.h:187
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
static EFI_GUID bofm1_protocol_guid
BOFM1 protocol GUID.
Definition: efi_bofm.c:152
#define DBGCP(...)
Definition: compiler.h:539
int bofm_find_driver(struct pci_device *pci)
Find BOFM driver for PCI device.
Definition: bofm.c:90
EFI_SYSTEM_TABLE * efi_systab
int efipci_info(EFI_HANDLE device, struct pci_device *pci)
Get EFI PCI device information.
Definition: efi_pci.c:330
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References bofm1_protocol_guid, bofm_find_driver(), EFI_SYSTEM_TABLE::BootServices, DBGC, DBGCP, EEFI, efi_handle_name(), efi_systab, efipci_info(), pci_device::id, EFI_BOOT_SERVICES::LocateProtocol, pci_device_id::name, NULL, rc, and strerror().

◆ efi_bofm_start()

static int efi_bofm_start ( struct efi_device efidev)
static

Attach driver to device.

Parameters
efidevEFI device
Return values
rcReturn status code

Definition at line 217 of file efi_bofm.c.

217  {
219  EFI_HANDLE device = efidev->device;
220  union {
222  void *interface;
223  } bofm1;
224  union {
226  void *interface;
227  } bofm2;
228  struct pci_device pci;
229  IBM_BOFM_TABLE *bofmtab;
230  IBM_BOFM_TABLE *bofmtab2;
231  int bofmrc;
232  EFI_STATUS efirc;
233  int rc;
234 
235  /* Open PCI device, if possible */
237  &pci ) ) != 0 )
238  goto err_open;
239 
240  /* Locate BOFM protocol */
241  if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL,
242  &bofm1.interface ) ) != 0 ) {
243  rc = -EEFI ( efirc );
244  DBGC ( device, "EFIBOFM %s cannot find BOFM protocol\n",
245  efi_handle_name ( device ) );
246  goto err_locate_bofm;
247  }
248  bofmtab = &bofm1.bofm1->BofmTable;
249  DBGC ( device, "EFIBOFM %s found version 1 BOFM table at %p+%04x\n",
250  efi_handle_name ( device ), bofmtab, bofmtab->Parameters.Length);
251 
252  /* Locate BOFM2 protocol, if available */
253  if ( ( efirc = bs->LocateProtocol ( &bofm2_protocol_guid, NULL,
254  &bofm2.interface ) ) == 0 ) {
255  bofmtab2 = &bofm2.bofm2->BofmTable;
256  DBGC ( device, "EFIBOFM %s found version 2 BOFM table at "
257  "%p+%04x\n", efi_handle_name ( device ), bofmtab2,
258  bofmtab2->Parameters.Length );
259  assert ( bofm2.bofm2->RegisterSupport ==
260  bofm1.bofm1->RegisterSupport );
261  } else {
262  DBGC ( device, "EFIBOFM %s cannot find BOFM2 protocol\n",
263  efi_handle_name ( device ) );
264  /* Not a fatal error; may be a BOFM1-only system */
265  bofmtab2 = NULL;
266  }
267 
268  /* Process BOFM table */
269  DBGC2 ( device, "EFIBOFM %s version 1 before processing:\n",
270  efi_handle_name ( device ) );
271  DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
272  if ( bofmtab2 ) {
273  DBGC2 ( device, "EFIBOFM %s version 2 before processing:\n",
274  efi_handle_name ( device ) );
275  DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
276  }
277  bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
278  DBGC ( device, "EFIBOFM %s status %08x\n",
279  efi_handle_name ( device ), bofmrc );
280  DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n",
281  efi_handle_name ( device ) );
282  DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
283  if ( bofmtab2 ) {
284  DBGC2 ( device, "EFIBOFM %s version 2 after processing:\n",
285  efi_handle_name ( device ) );
286  DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
287  }
288 
289  /* Return BOFM status */
290  if ( bofmtab2 ) {
291  if ( ( efirc = bofm2.bofm2->SetStatus ( bofm2.bofm2, device,
292  FALSE, bofmrc ) ) != 0){
293  rc = -EEFI ( efirc );
294  DBGC ( device, "EFIBOFM %s could not set BOFM2 "
295  "status: %s\n", efi_handle_name ( device ),
296  strerror ( rc ) );
297  goto err_set_status;
298  }
299  } else {
300  if ( ( efirc = bofm1.bofm1->SetStatus ( bofm1.bofm1, device,
301  FALSE, bofmrc ) ) != 0){
302  rc = -EEFI ( efirc );
303  DBGC ( device, "EFIBOFM %s could not set BOFM "
304  "status: %s\n", efi_handle_name ( device ),
305  strerror ( rc ) );
306  goto err_set_status;
307  }
308  }
309 
310  /* BOFM (ab)uses the "start" method to mean "process and exit" */
311  rc = -EAGAIN;
312 
313  err_set_status:
314  err_locate_bofm:
315  efipci_close ( device );
316  err_open:
317  return rc;
318 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1914
#define IBM_BOFM_TABLE
Definition: efi_bofm.c:99
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
A hardware device.
Definition: device.h:73
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:109
int efipci_open(EFI_HANDLE device, UINT32 attributes, struct pci_device *pci)
Open EFI PCI device.
Definition: efi_pci.c:241
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1271
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
#define DBGC2_HD(...)
Definition: compiler.h:524
A PCI device.
Definition: pci.h:187
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
static EFI_GUID bofm2_protocol_guid
BOFM2 protocol GUID.
Definition: efi_bofm.c:156
#define DBGC2(...)
Definition: compiler.h:522
int bofm(userptr_t bofmtab, struct pci_device *pci)
Process BOFM table.
Definition: bofm.c:238
void efipci_close(EFI_HANDLE device)
Close EFI PCI device.
Definition: efi_pci.c:316
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
static EFI_GUID bofm1_protocol_guid
BOFM1 protocol GUID.
Definition: efi_bofm.c:152
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
#define FALSE
Definition: tlan.h:45
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
Definition: efi.h:55

References assert(), bofm(), bofm1_protocol_guid, bofm2_protocol_guid, EFI_SYSTEM_TABLE::BootServices, DBGC, DBGC2, DBGC2_HD, efi_device::device, EAGAIN, EEFI, efi_handle_name(), EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, efipci_close(), efipci_open(), FALSE, IBM_BOFM_TABLE, EFI_BOOT_SERVICES::LocateProtocol, NULL, rc, strerror(), and virt_to_user().

◆ efi_bofm_stop()

static void efi_bofm_stop ( struct efi_device *efidev  __unused)
static

Detach driver from device.

Parameters
deviceEFI device

Definition at line 325 of file efi_bofm.c.

325  {
326 
327  /* Should never happen */
328  assert ( 0 );
329 }
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)

References assert().

◆ __efi_driver()

struct efi_driver efi_bofm_driver __efi_driver ( EFI_DRIVER_EARLY  )

EFI BOFM driver.

Variable Documentation

◆ bofm1_protocol_guid

EFI_GUID bofm1_protocol_guid
static
Initial value:
=
#define IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL_GUID
Definition: efi_bofm.c:48

BOFM1 protocol GUID.

Definition at line 152 of file efi_bofm.c.

Referenced by efi_bofm_start(), and efi_bofm_supported().

◆ bofm2_protocol_guid

EFI_GUID bofm2_protocol_guid
static
Initial value:

BOFM2 protocol GUID.

Definition at line 156 of file efi_bofm.c.

Referenced by efi_bofm_start().