iPXE
Functions
efi_pxe.h File Reference

EFI PXE base code protocol. More...

#include <ipxe/efi/efi.h>
#include <ipxe/netdevice.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int efi_pxe_install (EFI_HANDLE handle, struct net_device *netdev)
 Install PXE base code protocol. More...
 
void efi_pxe_uninstall (EFI_HANDLE handle)
 Uninstall PXE base code protocol. More...
 

Detailed Description

EFI PXE base code protocol.

Definition in file efi_pxe.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_pxe_install()

int efi_pxe_install ( EFI_HANDLE  handle,
struct net_device netdev 
)

Install PXE base code protocol.

Parameters
handleEFI handle
netdevUnderlying network device
Return values
rcReturn status code

Definition at line 1588 of file efi_pxe.c.

1588  {
1590  struct tcpip_net_protocol *ipv6 = tcpip_net_protocol ( AF_INET6 );
1591  struct efi_pxe *pxe;
1592  struct in_addr ip;
1593  BOOLEAN use_ipv6;
1594  EFI_STATUS efirc;
1595  int rc;
1596 
1597  /* Allocate and initialise structure */
1598  pxe = zalloc ( sizeof ( *pxe ) );
1599  if ( ! pxe ) {
1600  rc = -ENOMEM;
1601  goto err_alloc;
1602  }
1603  ref_init ( &pxe->refcnt, efi_pxe_free );
1604  pxe->netdev = netdev_get ( netdev );
1605  pxe->name = netdev->name;
1606  pxe->handle = handle;
1607  memcpy ( &pxe->base, &efi_pxe_base_code_protocol, sizeof ( pxe->base ));
1608  pxe->base.Mode = &pxe->mode;
1610  sizeof ( pxe->apple ) );
1611  pxe->buf.op = &efi_pxe_buf_operations;
1612  intf_init ( &pxe->tftp, &efi_pxe_tftp_desc, &pxe->refcnt );
1613  intf_init ( &pxe->udp, &efi_pxe_udp_desc, &pxe->refcnt );
1614  INIT_LIST_HEAD ( &pxe->queue );
1616  &pxe->refcnt );
1617 
1618  /* Crude heuristic: assume that we prefer to use IPv4 if we
1619  * have an IPv4 address for the network device, otherwise
1620  * prefer IPv6 (if available).
1621  */
1622  fetch_ipv4_setting ( netdev_settings ( netdev ), &ip_setting, &ip );
1623  use_ipv6 = ( ip.s_addr ? FALSE : ( ipv6 != NULL ) );
1624 
1625  /* Start base code */
1626  efi_pxe_start ( &pxe->base, use_ipv6 );
1627 
1628  /* Install PXE base code protocol */
1629  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
1630  &handle,
1633  NULL ) ) != 0 ) {
1634  rc = -EEFI ( efirc );
1635  DBGC ( pxe, "PXE %s could not install base code protocol: %s\n",
1636  pxe->name, strerror ( rc ) );
1637  goto err_install_protocol;
1638  }
1639 
1640  /* Transfer reference to list and return */
1641  list_add_tail ( &pxe->list, &efi_pxes );
1642  DBGC ( pxe, "PXE %s installed for %s\n",
1643  pxe->name, efi_handle_name ( handle ) );
1644  return 0;
1645 
1647  handle,
1650  NULL );
1651  err_install_protocol:
1652  ref_put ( &pxe->refcnt );
1653  err_alloc:
1654  return rc;
1655 }
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
EFI_PXE_BASE_CODE_MODE mode
PXE base code mode.
Definition: efi_pxe.c:83
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
#define AF_INET6
IPv6 Internet addresses.
Definition: socket.h:64
struct list_head list
List of PXE base codes.
Definition: efi_pxe.c:76
static EFI_STATUS EFIAPI efi_pxe_start(EFI_PXE_BASE_CODE_PROTOCOL *base, BOOLEAN use_ipv6)
Start PXE base code.
Definition: efi_pxe.c:750
struct refcnt refcnt
Reference count.
Definition: efi_pxe.c:70
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
A PXE base code.
Definition: efi_pxe.c:68
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
Definition: settings.c:916
unsigned char BOOLEAN
Definition: ProcessorBind.h:61
static struct interface_descriptor efi_pxe_tftp_desc
PXE file data transfer interface descriptor.
Definition: efi_pxe.c:414
EFI_PXE_BASE_CODE_PROTOCOL base
PXE base code protocol.
Definition: efi_pxe.c:81
#define DBGC(...)
Definition: compiler.h:505
struct interface udp
UDP interface.
Definition: efi_pxe.c:103
struct xfer_buffer buf
Data transfer buffer.
Definition: efi_pxe.c:93
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1915
EFI_APPLE_NET_BOOT_PROTOCOL apple
Apple NetBoot protocol.
Definition: efi_pxe.c:85
EFI_GUID efi_pxe_base_code_protocol_guid
PXE base code protocol GUID.
Definition: efi_guid.c:224
static struct process_descriptor efi_pxe_process_desc
UDP close process descriptor.
Definition: efi_pxe.c:623
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition: netdevice.h:577
const char * name
Name.
Definition: efi_pxe.c:74
EFI_HANDLE handle
Installed handle.
Definition: efi_pxe.c:79
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct net_device * netdev
Underlying network device.
Definition: efi_pxe.c:72
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct tcpip_net_protocol * tcpip_net_protocol(sa_family_t sa_family)
Find TCP/IP network-layer protocol.
Definition: tcpip.c:68
static struct net_device * netdev
Definition: gdbudp.c:52
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
struct xfer_buffer_operations * op
Data transfer buffer operations.
Definition: xferbuf.h:27
static EFI_APPLE_NET_BOOT_PROTOCOL efi_apple_net_boot_protocol
Apple NetBoot protocol.
Definition: efi_pxe.c:1569
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static struct xfer_buffer_operations efi_pxe_buf_operations
PXE data transfer buffer operations.
Definition: efi_pxe.c:342
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
EFI Boot Services Table.
Definition: UefiSpec.h:1836
IP address structure.
Definition: in.h:39
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
IP4_t ip
Destination IP address.
Definition: pxe_api.h:58
static struct interface_descriptor efi_pxe_udp_desc
PXE UDP interface descriptor.
Definition: efi_pxe.c:563
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition: netdevice.h:544
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
Definition: process.h:145
struct interface tftp
(M)TFTP download interface
Definition: efi_pxe.c:96
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
EFI_GUID efi_apple_net_boot_protocol_guid
Apple NetBoot protocol GUID.
Definition: efi_guid.c:96
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
struct process process
UDP interface closer process.
Definition: efi_pxe.c:107
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct list_head queue
List of received UDP packets.
Definition: efi_pxe.c:105
#define FALSE
Definition: tlan.h:45
A network-layer protocol of the TCP/IP stack (eg.
Definition: tcpip.h:140
EFI_SYSTEM_TABLE * efi_systab
EFI_PXE_BASE_CODE_MODE * Mode
The pointer to the EFI_PXE_BASE_CODE_MODE data for this device.
Definition: PxeBaseCode.h:931
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
static void efi_pxe_free(struct refcnt *refcnt)
Free PXE base code.
Definition: efi_pxe.c:115
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static EFI_PXE_BASE_CODE_PROTOCOL efi_pxe_base_code_protocol
PXE base code protocol.
Definition: efi_pxe.c:1488
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References AF_INET6, efi_pxe::apple, efi_pxe::base, EFI_SYSTEM_TABLE::BootServices, efi_pxe::buf, DBGC, EEFI, efi_apple_net_boot_protocol, efi_apple_net_boot_protocol_guid, efi_handle_name(), efi_pxe_base_code_protocol, efi_pxe_base_code_protocol_guid, efi_pxe_buf_operations, efi_pxe_free(), efi_pxe_process_desc, efi_pxe_start(), efi_pxe_tftp_desc, efi_pxe_udp_desc, efi_systab, ENOMEM, FALSE, fetch_ipv4_setting(), handle, efi_pxe::handle, INIT_LIST_HEAD, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, intf_init(), ip, efi_pxe::list, list_add_tail, memcpy(), efi_pxe::mode, _EFI_PXE_BASE_CODE_PROTOCOL::Mode, efi_pxe::name, net_device::name, netdev, efi_pxe::netdev, netdev_get(), netdev_settings(), NULL, xfer_buffer::op, efi_pxe::process, process_init_stopped(), efi_pxe::queue, rc, ref_init, ref_put, efi_pxe::refcnt, strerror(), tcpip_net_protocol(), efi_pxe::tftp, efi_pxe::udp, EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, and zalloc().

Referenced by efi_image_exec().

◆ efi_pxe_uninstall()

void efi_pxe_uninstall ( EFI_HANDLE  handle)

Uninstall PXE base code protocol.

Parameters
handleEFI handle

Definition at line 1662 of file efi_pxe.c.

1662  {
1664  struct efi_pxe *pxe;
1665 
1666  /* Locate PXE base code */
1667  pxe = efi_pxe_find ( handle );
1668  if ( ! handle ) {
1669  DBG ( "PXE could not find base code for %s\n",
1670  efi_handle_name ( handle ) );
1671  return;
1672  }
1673 
1674  /* Stop base code */
1675  efi_pxe_stop ( &pxe->base );
1676 
1677  /* Uninstall PXE base code protocol */
1679  handle,
1682  NULL );
1683 
1684  /* Remove from list and drop list's reference */
1685  list_del ( &pxe->list );
1686  ref_put ( &pxe->refcnt );
1687 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static struct efi_pxe * efi_pxe_find(EFI_HANDLE handle)
Locate PXE base code.
Definition: efi_pxe.c:131
struct list_head list
List of PXE base codes.
Definition: efi_pxe.c:76
struct refcnt refcnt
Reference count.
Definition: efi_pxe.c:70
A PXE base code.
Definition: efi_pxe.c:68
EFI_PXE_BASE_CODE_PROTOCOL base
PXE base code protocol.
Definition: efi_pxe.c:81
EFI_APPLE_NET_BOOT_PROTOCOL apple
Apple NetBoot protocol.
Definition: efi_pxe.c:85
EFI_GUID efi_pxe_base_code_protocol_guid
PXE base code protocol GUID.
Definition: efi_guid.c:224
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
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_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
EFI_GUID efi_apple_net_boot_protocol_guid
Apple NetBoot protocol GUID.
Definition: efi_guid.c:96
EFI_SYSTEM_TABLE * efi_systab
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static EFI_STATUS EFIAPI efi_pxe_stop(EFI_PXE_BASE_CODE_PROTOCOL *base)
Stop PXE base code.
Definition: efi_pxe.c:804
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References efi_pxe::apple, efi_pxe::base, EFI_SYSTEM_TABLE::BootServices, DBG, efi_apple_net_boot_protocol_guid, efi_handle_name(), efi_pxe_base_code_protocol_guid, efi_pxe_find(), efi_pxe_stop(), efi_systab, handle, efi_pxe::list, list_del, NULL, ref_put, efi_pxe::refcnt, and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_image_exec().