iPXE
Macros | Typedefs | Functions | Variables
mp.h File Reference

Multiprocessor functions. More...

#include <stdint.h>
#include <ipxe/api.h>
#include <config/defaults.h>
#include <ipxe/null_mp.h>
#include <ipxe/efi/efi_mp.h>
#include <bits/mp.h>

Go to the source code of this file.

Macros

#define MPAPI_INLINE(_subsys, _api_func)   SINGLE_API_INLINE ( MPAPI_PREFIX_ ## _subsys, _api_func )
 Calculate static inline multiprocessor API function name. More...
 
#define PROVIDE_MPAPI(_subsys, _api_func, _func)   PROVIDE_SINGLE_API ( MPAPI_PREFIX_ ## _subsys, _api_func, _func )
 Provide a multiprocessor API implementation. More...
 
#define PROVIDE_MPAPI_INLINE(_subsys, _api_func)   PROVIDE_SINGLE_API_INLINE ( MPAPI_PREFIX_ ## _subsys, _api_func )
 Provide a static inline multiprocessor API implementation. More...
 

Typedefs

typedef unsigned long mp_addr_t
 An address within the address space for a multiprocessor function. More...
 
typedef void() mp_func_t(mp_addr_t opaque, unsigned int cpuid)
 A multiprocessor function. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void __asmcall mp_call (mp_addr_t func, mp_addr_t opaque)
 Call a multiprocessor function from C code on the current CPU. More...
 
mp_addr_t mp_address (void *address)
 Calculate address as seen by a multiprocessor function. More...
 
void mp_exec_boot (mp_func_t func, void *opaque)
 Execute a multiprocessor function on the boot processor. More...
 
void mp_start_all (mp_func_t func, void *opaque)
 Start a multiprocessor function on all application processors. More...
 
unsigned int mp_boot_cpuid (void)
 Get boot CPU identifier. More...
 
unsigned int mp_max_cpuid (void)
 Get maximum CPU identifier. More...
 

Variables

mp_func_t mp_update_max_cpuid
 Update maximum observed CPU identifier. More...
 

Detailed Description

Multiprocessor functions.

Definition in file mp.h.

Macro Definition Documentation

◆ MPAPI_INLINE

#define MPAPI_INLINE (   _subsys,
  _api_func 
)    SINGLE_API_INLINE ( MPAPI_PREFIX_ ## _subsys, _api_func )

Calculate static inline multiprocessor API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 81 of file mp.h.

◆ PROVIDE_MPAPI

#define PROVIDE_MPAPI (   _subsys,
  _api_func,
  _func 
)    PROVIDE_SINGLE_API ( MPAPI_PREFIX_ ## _subsys, _api_func, _func )

Provide a multiprocessor API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 91 of file mp.h.

◆ PROVIDE_MPAPI_INLINE

#define PROVIDE_MPAPI_INLINE (   _subsys,
  _api_func 
)    PROVIDE_SINGLE_API_INLINE ( MPAPI_PREFIX_ ## _subsys, _api_func )

Provide a static inline multiprocessor API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 100 of file mp.h.

Typedef Documentation

◆ mp_addr_t

typedef unsigned long mp_addr_t

An address within the address space for a multiprocessor function.

Application processors may be started in a different address space from the normal iPXE runtime environment. For example: under legacy BIOS the application processors will use flat 32-bit physical addressing (with no paging or virtual address offset).

Definition at line 24 of file mp.h.

◆ mp_func_t

typedef void() mp_func_t(mp_addr_t opaque, unsigned int cpuid)

A multiprocessor function.

Parameters
opaqueOpaque data pointer
cpuidCPU identifier

iPXE does not set up a normal multiprocessor environment. In particular, there is no support for dispatching code to individual processors and there is no per-CPU stack allocation.

Multiprocessor code must be prepared to run wth no stack space (and with a zero stack pointer). Functions may use the CPU identifier to construct a pointer to per-CPU result storage.

Multiprocessor functions are permitted to overwrite all registers apart from the stack pointer. On exit, the function should check the stack pointer value: if zero then the function should halt the CPU, if non-zero then the function should return in the normal way.

Multiprocessor functions do not have access to any capabilities typically provided by the firmware: they cannot, for example, write any console output.

All parameters are passed in registers, since there may be no stack available. These functions cannot be called directly from C code.

Definition at line 51 of file mp.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ mp_call()

void __asmcall mp_call ( mp_addr_t  func,
mp_addr_t  opaque 
)

Call a multiprocessor function from C code on the current CPU.

Parameters
funcMultiprocessor function
opaqueOpaque data pointer

This function must be provided for each CPU architecture to bridge the normal C ABI to the iPXE multiprocessor function ABI. It must therefore preserve any necessary registers, determine the CPU identifier, call the multiprocessor function (which may destroy any registers other than the stack pointer), restore registers, and return to the C caller.

This function must be called from within the multiprocessor address space (e.g. with flat 32-bit physical addressing for BIOS). It can be called directly from C code if the multiprocessor address space is identical to the address space used for C code (e.g. under EFI, where everything uses flat physical addresses).

Referenced by bios_mp_exec_boot(), efi_mp_call(), mp_boot_cpuid(), and mp_max_cpuid().

◆ mp_address()

mp_addr_t mp_address ( void *  address)

Calculate address as seen by a multiprocessor function.

Parameters
addressAddress in normal iPXE address space
Return values
addressAddress in application processor address space

Definition at line 25 of file efi_mp.h.

25  {
26 
27  return ( ( mp_addr_t ) address );
28 }
uint64_t address
Base address.
Definition: ena.h:24
unsigned long mp_addr_t
An address within the address space for a multiprocessor function.
Definition: mp.h:24

References address, and virt_to_phys().

Referenced by bios_mp_exec_boot(), bios_mp_start_all(), efi_mp_exec_boot(), and efi_mp_start_all().

◆ mp_exec_boot()

void mp_exec_boot ( mp_func_t  func,
void *  opaque 
)

Execute a multiprocessor function on the boot processor.

Parameters
funcMultiprocessor function
opaqueOpaque data pointer

This is a blocking operation: the call will return only when the multiprocessor function exits.

Referenced by mp_boot_cpuid(), and ucode_update_all().

◆ mp_start_all()

void mp_start_all ( mp_func_t  func,
void *  opaque 
)

Start a multiprocessor function on all application processors.

Parameters
funcMultiprocessor function
opaqueOpaque data pointer

This is a non-blocking operation: it is the caller's responsibility to provide a way to determine when the multiprocessor function has finished executing and halted its CPU.

Referenced by mp_max_cpuid(), and ucode_update_all().

◆ mp_boot_cpuid()

unsigned int mp_boot_cpuid ( void  )

Get boot CPU identifier.

Return values
idBoot CPU identifier

Definition at line 43 of file mp.c.

43  {
44  unsigned int max = 0;
45 
46  /* Update maximum to accommodate boot processor */
48  DBGC ( &mp_call, "MP boot processor ID is %#x\n", max );
49 
50  return max;
51 }
#define max(x, y)
Definition: ath.h:39
#define DBGC(...)
Definition: compiler.h:505
void __asmcall mp_call(mp_addr_t func, mp_addr_t opaque)
Call a multiprocessor function from C code on the current CPU.
mp_func_t mp_update_max_cpuid
Update maximum observed CPU identifier.
void mp_exec_boot(mp_func_t func, void *opaque)
Execute a multiprocessor function on the boot processor.

References DBGC, max, mp_call(), mp_exec_boot(), and mp_update_max_cpuid.

Referenced by mp_max_cpuid(), and ucode_update_all().

◆ mp_max_cpuid()

unsigned int mp_max_cpuid ( void  )

Get maximum CPU identifier.

Return values
maxMaximum CPU identifier

Definition at line 58 of file mp.c.

58  {
59  unsigned int max = mp_boot_cpuid();
60 
61  /* Update maximum to accommodate application processors */
64  DBGC ( &mp_call, "MP observed maximum CPU ID is %#x\n", max );
65 
66  return max;
67 }
#define MP_MAX_CPUID_WAIT_MS
Time to wait for application processors.
Definition: mp.c:36
#define max(x, y)
Definition: ath.h:39
#define DBGC(...)
Definition: compiler.h:505
void mp_start_all(mp_func_t func, void *opaque)
Start a multiprocessor function on all application processors.
void __asmcall mp_call(mp_addr_t func, mp_addr_t opaque)
Call a multiprocessor function from C code on the current CPU.
mp_func_t mp_update_max_cpuid
Update maximum observed CPU identifier.
unsigned int mp_boot_cpuid(void)
Get boot CPU identifier.
Definition: mp.c:43
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78

References DBGC, max, mdelay(), mp_boot_cpuid(), mp_call(), MP_MAX_CPUID_WAIT_MS, mp_start_all(), and mp_update_max_cpuid.

Referenced by ucode_update_all().

Variable Documentation

◆ mp_update_max_cpuid

mp_func_t mp_update_max_cpuid

Update maximum observed CPU identifier.

Parameters
opaqueOpaque data pointer
cpuidCPU identifier

This may be invoked on each processor to update a shared maximum CPU identifier value.

Referenced by mp_boot_cpuid(), and mp_max_cpuid().