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

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

#include <string.h>
#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 49 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 53 of file efi_bofm.c.

◆ IBM_BOFM_TABLE

#define IBM_BOFM_TABLE   BOFM_DataStructure_t

Definition at line 100 of file efi_bofm.c.

Typedef Documentation

◆ IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL

Definition at line 102 of file efi_bofm.c.

◆ IBM_BOFM_DRIVER_CONFIGURATION_PROTOCOL2

Definition at line 105 of file efi_bofm.c.

◆ ControllerHandle

Definition at line 110 of file efi_bofm.c.

◆ SupporttedOptions

Definition at line 110 of file efi_bofm.c.

◆ iSCSI_Parameter_Version

Definition at line 110 of file efi_bofm.c.

◆ BOFM_Parameter_Version

Definition at line 110 of file efi_bofm.c.

◆ ResetRequired

Definition at line 118 of file efi_bofm.c.

◆ BOFMReturnCode

Definition at line 118 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 166 of file efi_bofm.c.

166  {
168  struct efi_pci_device efipci;
169  union {
171  void *interface;
172  } bofm1;
173  EFI_STATUS efirc;
174  int rc;
175 
176  /* Get PCI device information */
177  if ( ( rc = efipci_info ( device, &efipci ) ) != 0 )
178  return rc;
179 
180  /* Look for a BOFM driver */
181  if ( ( rc = bofm_find_driver ( &efipci.pci ) ) != 0 ) {
182  DBGCP ( device, "EFIBOFM %s has no driver\n",
183  efi_handle_name ( device ) );
184  return rc;
185  }
186 
187  /* Locate BOFM protocol */
188  if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL,
189  &bofm1.interface ) ) != 0 ) {
190  rc = -EEFI ( efirc );
191  DBGC ( device, "EFIBOFM %s cannot find BOFM protocol\n",
192  efi_handle_name ( device ) );
193  return rc;
194  }
195 
196  /* Register support for this device */
197  if ( ( efirc = bofm1.bofm1->RegisterSupport ( bofm1.bofm1, device,
198  0x04 /* Can change MAC */,
199  0x00 /* No iSCSI */,
200  0x02 /* Version */ ))!=0){
201  rc = -EEFI ( efirc );
202  DBGC ( device, "EFIBOFM %s could not register support: %s\n",
203  efi_handle_name ( device ), strerror ( rc ) );
204  return rc;
205  }
206 
207  DBGC ( device, "EFIBOFM %s has driver \"%s\"\n",
208  efi_handle_name ( device ), efipci.pci.id->name );
209  return 0;
210 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
int efipci_info(EFI_HANDLE device, struct efi_pci_device *efipci)
Get EFI PCI device information.
Definition: efi_pci.c:704
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:2008
#define DBGC(...)
Definition: compiler.h:505
A hardware device.
Definition: device.h:76
An object interface.
Definition: interface.h:124
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
An EFI PCI device.
Definition: efi_pci.h:21
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
static EFI_GUID bofm1_protocol_guid
BOFM1 protocol GUID.
Definition: efi_bofm.c:153
#define DBGCP(...)
Definition: compiler.h:539
int bofm_find_driver(struct pci_device *pci)
Find BOFM driver for PCI device.
Definition: bofm.c:89
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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, efi_pci_device::pci, 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 218 of file efi_bofm.c.

218  {
220  EFI_HANDLE device = efidev->device;
221  union {
223  void *interface;
224  } bofm1;
225  union {
227  void *interface;
228  } bofm2;
229  struct efi_pci_device efipci;
230  IBM_BOFM_TABLE *bofmtab;
231  IBM_BOFM_TABLE *bofmtab2;
232  int bofmrc;
233  EFI_STATUS efirc;
234  int rc;
235 
236  /* Get PCI device information */
237  if ( ( rc = efipci_info ( device, &efipci ) ) != 0 ) {
238  DBGC ( device, "EFIBOFM %s cannot get PCI information: %s\n",
239  efi_handle_name ( device ), strerror ( rc ) );
240  goto err_info;
241  }
242 
243  /* Open PCI I/O protocol */
245  &efipci.io ) ) != 0 ) {
246  DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n",
247  efi_handle_name ( device ), strerror ( rc ) );
248  goto err_open;
249  }
250 
251  /* Locate BOFM protocol */
252  if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL,
253  &bofm1.interface ) ) != 0 ) {
254  rc = -EEFI ( efirc );
255  DBGC ( device, "EFIBOFM %s cannot find BOFM protocol\n",
256  efi_handle_name ( device ) );
257  goto err_locate_bofm;
258  }
259  bofmtab = &bofm1.bofm1->BofmTable;
260  DBGC ( device, "EFIBOFM %s found version 1 BOFM table at %p+%04x\n",
261  efi_handle_name ( device ), bofmtab, bofmtab->Parameters.Length);
262 
263  /* Locate BOFM2 protocol, if available */
264  if ( ( efirc = bs->LocateProtocol ( &bofm2_protocol_guid, NULL,
265  &bofm2.interface ) ) == 0 ) {
266  bofmtab2 = &bofm2.bofm2->BofmTable;
267  DBGC ( device, "EFIBOFM %s found version 2 BOFM table at "
268  "%p+%04x\n", efi_handle_name ( device ), bofmtab2,
269  bofmtab2->Parameters.Length );
270  assert ( bofm2.bofm2->RegisterSupport ==
271  bofm1.bofm1->RegisterSupport );
272  } else {
273  DBGC ( device, "EFIBOFM %s cannot find BOFM2 protocol\n",
274  efi_handle_name ( device ) );
275  /* Not a fatal error; may be a BOFM1-only system */
276  bofmtab2 = NULL;
277  }
278 
279  /* Process BOFM table */
280  DBGC2 ( device, "EFIBOFM %s version 1 before 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 before processing:\n",
285  efi_handle_name ( device ) );
286  DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
287  }
288  bofmrc = bofm ( ( bofmtab2 ? bofmtab2 : bofmtab ), &efipci.pci );
289  DBGC ( device, "EFIBOFM %s status %08x\n",
290  efi_handle_name ( device ), bofmrc );
291  DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n",
292  efi_handle_name ( device ) );
293  DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
294  if ( bofmtab2 ) {
295  DBGC2 ( device, "EFIBOFM %s version 2 after processing:\n",
296  efi_handle_name ( device ) );
297  DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
298  }
299 
300  /* Return BOFM status */
301  if ( bofmtab2 ) {
302  if ( ( efirc = bofm2.bofm2->SetStatus ( bofm2.bofm2, device,
303  FALSE, bofmrc ) ) != 0){
304  rc = -EEFI ( efirc );
305  DBGC ( device, "EFIBOFM %s could not set BOFM2 "
306  "status: %s\n", efi_handle_name ( device ),
307  strerror ( rc ) );
308  goto err_set_status;
309  }
310  } else {
311  if ( ( efirc = bofm1.bofm1->SetStatus ( bofm1.bofm1, device,
312  FALSE, bofmrc ) ) != 0){
313  rc = -EEFI ( efirc );
314  DBGC ( device, "EFIBOFM %s could not set BOFM "
315  "status: %s\n", efi_handle_name ( device ),
316  strerror ( rc ) );
317  goto err_set_status;
318  }
319  }
320 
321  /* BOFM (ab)uses the "start" method to mean "process and exit" */
322  rc = -EAGAIN;
323 
324  err_set_status:
325  err_locate_bofm:
327  err_open:
328  err_info:
329  return rc;
330 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
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:174
int efipci_info(EFI_HANDLE device, struct efi_pci_device *efipci)
Get EFI PCI device information.
Definition: efi_pci.c:704
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:2008
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:312
#define efi_open_unsafe(handle, protocol, interface)
Open protocol for unsafe persistent use.
Definition: efi.h:458
#define IBM_BOFM_TABLE
Definition: efi_bofm.c:100
#define DBGC(...)
Definition: compiler.h:505
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
A hardware device.
Definition: device.h:76
void efi_close_unsafe(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for unsafe persistent use.
Definition: efi_open.c:218
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:124
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
#define DBGC2_HD(...)
Definition: compiler.h:524
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
An EFI PCI device.
Definition: efi_pci.h:21
int bofm(void *bofmtab, struct pci_device *pci)
Process BOFM table.
Definition: bofm.c:235
static EFI_GUID bofm2_protocol_guid
BOFM2 protocol GUID.
Definition: efi_bofm.c:157
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
static EFI_GUID bofm1_protocol_guid
BOFM1 protocol GUID.
Definition: efi_bofm.c:153
#define FALSE
Definition: tlan.h:45
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
Definition: efi.h:61

References assert(), bofm(), bofm1_protocol_guid, bofm2_protocol_guid, EFI_SYSTEM_TABLE::BootServices, DBGC, DBGC2, DBGC2_HD, efi_device::device, EAGAIN, EEFI, efi_close_unsafe(), efi_handle_name(), efi_open_unsafe, efi_pci_io_protocol_guid, efi_systab, efipci_info(), FALSE, IBM_BOFM_TABLE, efi_pci_device::io, EFI_BOOT_SERVICES::LocateProtocol, NULL, efi_pci_device::pci, rc, and strerror().

◆ efi_bofm_stop()

static void efi_bofm_stop ( struct efi_device *efidev  __unused)
static

Detach driver from device.

Parameters
deviceEFI device

Definition at line 337 of file efi_bofm.c.

337  {
338 
339  /* Should never happen */
340  assert ( 0 );
341 }
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:49

BOFM1 protocol GUID.

Definition at line 153 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 157 of file efi_bofm.c.

Referenced by efi_bofm_start().