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 efi_pci_device efipci;
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, &efipci ) ) != 0 )
177  return rc;
178 
179  /* Look for a BOFM driver */
180  if ( ( rc = bofm_find_driver ( &efipci.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 ), efipci.pci.id->name );
208  return 0;
209 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
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:171
int efipci_info(EFI_HANDLE device, struct efi_pci_device *efipci)
Get EFI PCI device information.
Definition: efi_pci.c:872
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1995
#define DBGC(...)
Definition: compiler.h:505
A hardware device.
Definition: device.h:73
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:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
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: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
#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 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 efi_pci_device efipci;
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  &efipci ) ) != 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 ),
278  &efipci.pci );
279  DBGC ( device, "EFIBOFM %s status %08x\n",
280  efi_handle_name ( device ), bofmrc );
281  DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n",
282  efi_handle_name ( device ) );
283  DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
284  if ( bofmtab2 ) {
285  DBGC2 ( device, "EFIBOFM %s version 2 after processing:\n",
286  efi_handle_name ( device ) );
287  DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
288  }
289 
290  /* Return BOFM status */
291  if ( bofmtab2 ) {
292  if ( ( efirc = bofm2.bofm2->SetStatus ( bofm2.bofm2, device,
293  FALSE, bofmrc ) ) != 0){
294  rc = -EEFI ( efirc );
295  DBGC ( device, "EFIBOFM %s could not set BOFM2 "
296  "status: %s\n", efi_handle_name ( device ),
297  strerror ( rc ) );
298  goto err_set_status;
299  }
300  } else {
301  if ( ( efirc = bofm1.bofm1->SetStatus ( bofm1.bofm1, device,
302  FALSE, bofmrc ) ) != 0){
303  rc = -EEFI ( efirc );
304  DBGC ( device, "EFIBOFM %s could not set BOFM "
305  "status: %s\n", efi_handle_name ( device ),
306  strerror ( rc ) );
307  goto err_set_status;
308  }
309  }
310 
311  /* BOFM (ab)uses the "start" method to mean "process and exit" */
312  rc = -EAGAIN;
313 
314  err_set_status:
315  err_locate_bofm:
316  efipci_close ( device );
317  err_open:
318  return rc;
319 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
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:171
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1995
#define IBM_BOFM_TABLE
Definition: efi_bofm.c:99
int efipci_open(EFI_HANDLE device, UINT32 attributes, struct efi_pci_device *efipci)
Open EFI PCI device.
Definition: efi_pci.c:781
#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:124
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
#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
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:858
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: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:321
Definition: efi.h:59

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

326  {
327 
328  /* Should never happen */
329  assert ( 0 );
330 }
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().