coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
lib_helpers.h File Reference
#include <stdint.h>
Include dependency graph for lib_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EL0   0
 
#define EL1   1
 
#define EL2   2
 
#define EL3   3
 
#define CURRENT_EL_MASK   0x3
 
#define CURRENT_EL_SHIFT   2
 
#define SPSR_USE_L   0
 
#define SPSR_USE_H   1
 
#define SPSR_L_H_MASK   1
 
#define SPSR_M_SHIFT   4
 
#define SPSR_ERET_32   (1 << SPSR_M_SHIFT)
 
#define SPSR_ERET_64   (0 << SPSR_M_SHIFT)
 
#define SPSR_FIQ   (1 << 6)
 
#define SPSR_IRQ   (1 << 7)
 
#define SPSR_SERROR   (1 << 8)
 
#define SPSR_DEBUG   (1 << 9)
 
#define SPSR_EXCEPTION_MASK   (SPSR_FIQ | SPSR_IRQ | SPSR_SERROR | SPSR_DEBUG)
 
#define SCR_NS   (1 << 0) /* EL0/1 are non-secure */
 
#define SCR_IRQ   (1 << 1) /* Take IRQs in EL3 */
 
#define SCR_FIQ   (1 << 2) /* Take FIQs in EL3 */
 
#define SCR_EA   (1 << 3) /* Take EA/SError in EL3 */
 
#define SCR_SMD   (1 << 7) /* Disable SMC instruction */
 
#define SCR_HCE   (1 << 8) /* Enable HVC instruction */
 
#define SCR_SIF   (1 << 9) /* Forbid insns from NS memory */
 
#define SCR_RW   (1 << 10) /* Lower ELs are AArch64 */
 
#define SCR_ST   (1 << 11) /* Don't trap secure CNTPS */
 
#define SCR_TWI   (1 << 12) /* Trap WFI to EL3 */
 
#define SCR_TWE   (1 << 13) /* Trap WFE to EL3 */
 
#define SCR_TLOR   (1 << 14) /* Trap LOR accesses to EL3 */
 
#define SCR_TERR   (1 << 15) /* Trap ERR accesses to EL3 */
 
#define SCR_APK   (1 << 16) /* Don't trap ptrauth keys */
 
#define SCR_API   (1 << 17) /* Don't trap ptrauth insn */
 
#define SCR_EEL2   (1 << 18) /* Enable secure EL2 */
 
#define SCR_EASE   (1 << 19) /* Sync EAs use SError vector */
 
#define SCR_NMEA   (1 << 20) /* Disallow EL3 SError masking */
 
#define SCR_FIEN   (1 << 21) /* Don't trap EXRPFG */
 
#define SCR_RES1   (3 << 4)
 
#define HCR_RW_SHIFT   31
 
#define HCR_LOWER_AARCH64   (1 << HCR_RW_SHIFT)
 
#define HCR_LOWER_AARCH32   (0 << HCR_RW_SHIFT)
 
#define SCTLR_M   (1 << 0) /* MMU enable */
 
#define SCTLR_A   (1 << 1) /* Alignment check enable */
 
#define SCTLR_C   (1 << 2) /* Data/unified cache enable */
 
#define SCTLR_SA   (1 << 3) /* Stack alignment check enable */
 
#define SCTLR_NAA   (1 << 6) /* non-aligned access STA/LDR */
 
#define SCTLR_I   (1 << 12) /* Instruction cache enable */
 
#define SCTLR_ENDB   (1 << 13) /* Pointer auth (data B) */
 
#define SCTLR_WXN   (1 << 19) /* Write permission implies XN */
 
#define SCTLR_IESB   (1 << 21) /* Implicit error sync event */
 
#define SCTLR_EE   (1 << 25) /* Exception endianness (BE) */
 
#define SCTLR_ENDA   (1 << 27) /* Pointer auth (data A) */
 
#define SCTLR_ENIB   (1 << 30) /* Pointer auth (insn B) */
 
#define SCTLR_ENIA   (1 << 31) /* Pointer auth (insn A) */
 
#define SCTLR_RES1
 
#define CPTR_EL3_TCPAC_SHIFT   (31)
 
#define CPTR_EL3_TTA_SHIFT   (20)
 
#define CPTR_EL3_TFP_SHIFT   (10)
 
#define CPTR_EL3_TCPAC_DISABLE   (0 << CPTR_EL3_TCPAC_SHIFT)
 
#define CPTR_EL3_TCPAC_ENABLE   (1 << CPTR_EL3_TCPAC_SHIFT)
 
#define CPTR_EL3_TTA_DISABLE   (0 << CPTR_EL3_TTA_SHIFT)
 
#define CPTR_EL3_TTA_ENABLE   (1 << CPTR_EL3_TTA_SHIFT)
 
#define CPTR_EL3_TFP_DISABLE   (0 << CPTR_EL3_TFP_SHIFT)
 
#define CPTR_EL3_TFP_ENABLE   (1 << CPTR_EL3_TFP_SHIFT)
 
#define CPACR_TTA_SHIFT   (28)
 
#define CPACR_TTA_ENABLE   (1 << CPACR_TTA_SHIFT)
 
#define CPACR_TTA_DISABLE   (0 << CPACR_TTA_SHIFT)
 
#define CPACR_FPEN_SHIFT   (20)
 
#define CPACR_TRAP_FP_EL0_EL1   (0 << CPACR_FPEN_SHIFT)
 
#define CPACR_TRAP_FP_EL0   (1 << CPACR_FPEN_SHIFT)
 
#define CPACR_TRAP_FP_DISABLE   (3 << CPACR_FPEN_SHIFT)
 
#define DAIF_DBG_BIT   (1<<3)
 
#define DAIF_ABT_BIT   (1<<2)
 
#define DAIF_IRQ_BIT   (1<<1)
 
#define DAIF_FIQ_BIT   (1<<0)
 
#define MAKE_REGISTER_ACCESSORS(reg)
 
#define MAKE_REGISTER_ACCESSORS_EL123(reg)
 

Functions

static void enable_debug_exceptions (void)
 
static void enable_serror_exceptions (void)
 
static void enable_irq (void)
 
static void enable_fiq (void)
 
static void disable_debug_exceptions (void)
 
static void disable_serror_exceptions (void)
 
static void disable_irq (void)
 
static void disable_fiq (void)
 
static void dccisw (uint64_t cisw)
 
static void dccivac (uint64_t civac)
 
static void dccsw (uint64_t csw)
 
static void dccvac (uint64_t cvac)
 
static void dccvau (uint64_t cvau)
 
static void dcisw (uint64_t isw)
 
static void dcivac (uint64_t ivac)
 
static void dczva (uint64_t zva)
 
static void iciallu (void)
 
static void icialluis (void)
 
static void icivau (uint64_t ivau)
 
static void tlbiall_el1 (void)
 
static void tlbiall_el2 (void)
 
static void tlbiall_el3 (void)
 
static void tlbiallis_el1 (void)
 
static void tlbiallis_el2 (void)
 
static void tlbiallis_el3 (void)
 
static void tlbivaa_el1 (uint64_t va)
 

Macro Definition Documentation

◆ CPACR_FPEN_SHIFT

#define CPACR_FPEN_SHIFT   (20)

Definition at line 84 of file lib_helpers.h.

◆ CPACR_TRAP_FP_DISABLE

#define CPACR_TRAP_FP_DISABLE   (3 << CPACR_FPEN_SHIFT)

Definition at line 91 of file lib_helpers.h.

◆ CPACR_TRAP_FP_EL0

#define CPACR_TRAP_FP_EL0   (1 << CPACR_FPEN_SHIFT)

Definition at line 90 of file lib_helpers.h.

◆ CPACR_TRAP_FP_EL0_EL1

#define CPACR_TRAP_FP_EL0_EL1   (0 << CPACR_FPEN_SHIFT)

Definition at line 89 of file lib_helpers.h.

◆ CPACR_TTA_DISABLE

#define CPACR_TTA_DISABLE   (0 << CPACR_TTA_SHIFT)

Definition at line 83 of file lib_helpers.h.

◆ CPACR_TTA_ENABLE

#define CPACR_TTA_ENABLE   (1 << CPACR_TTA_SHIFT)

Definition at line 82 of file lib_helpers.h.

◆ CPACR_TTA_SHIFT

#define CPACR_TTA_SHIFT   (28)

Definition at line 81 of file lib_helpers.h.

◆ CPTR_EL3_TCPAC_DISABLE

#define CPTR_EL3_TCPAC_DISABLE   (0 << CPTR_EL3_TCPAC_SHIFT)

Definition at line 74 of file lib_helpers.h.

◆ CPTR_EL3_TCPAC_ENABLE

#define CPTR_EL3_TCPAC_ENABLE   (1 << CPTR_EL3_TCPAC_SHIFT)

Definition at line 75 of file lib_helpers.h.

◆ CPTR_EL3_TCPAC_SHIFT

#define CPTR_EL3_TCPAC_SHIFT   (31)

Definition at line 71 of file lib_helpers.h.

◆ CPTR_EL3_TFP_DISABLE

#define CPTR_EL3_TFP_DISABLE   (0 << CPTR_EL3_TFP_SHIFT)

Definition at line 78 of file lib_helpers.h.

◆ CPTR_EL3_TFP_ENABLE

#define CPTR_EL3_TFP_ENABLE   (1 << CPTR_EL3_TFP_SHIFT)

Definition at line 79 of file lib_helpers.h.

◆ CPTR_EL3_TFP_SHIFT

#define CPTR_EL3_TFP_SHIFT   (10)

Definition at line 73 of file lib_helpers.h.

◆ CPTR_EL3_TTA_DISABLE

#define CPTR_EL3_TTA_DISABLE   (0 << CPTR_EL3_TTA_SHIFT)

Definition at line 76 of file lib_helpers.h.

◆ CPTR_EL3_TTA_ENABLE

#define CPTR_EL3_TTA_ENABLE   (1 << CPTR_EL3_TTA_SHIFT)

Definition at line 77 of file lib_helpers.h.

◆ CPTR_EL3_TTA_SHIFT

#define CPTR_EL3_TTA_SHIFT   (20)

Definition at line 72 of file lib_helpers.h.

◆ CURRENT_EL_MASK

#define CURRENT_EL_MASK   0x3

Definition at line 15 of file lib_helpers.h.

◆ CURRENT_EL_SHIFT

#define CURRENT_EL_SHIFT   2

Definition at line 16 of file lib_helpers.h.

◆ DAIF_ABT_BIT

#define DAIF_ABT_BIT   (1<<2)

Definition at line 94 of file lib_helpers.h.

◆ DAIF_DBG_BIT

#define DAIF_DBG_BIT   (1<<3)

Definition at line 93 of file lib_helpers.h.

◆ DAIF_FIQ_BIT

#define DAIF_FIQ_BIT   (1<<0)

Definition at line 96 of file lib_helpers.h.

◆ DAIF_IRQ_BIT

#define DAIF_IRQ_BIT   (1<<1)

Definition at line 95 of file lib_helpers.h.

◆ EL0

#define EL0   0

Definition at line 10 of file lib_helpers.h.

◆ EL1

#define EL1   1

Definition at line 11 of file lib_helpers.h.

◆ EL2

#define EL2   2

Definition at line 12 of file lib_helpers.h.

◆ EL3

#define EL3   3

Definition at line 13 of file lib_helpers.h.

◆ HCR_LOWER_AARCH32

#define HCR_LOWER_AARCH32   (0 << HCR_RW_SHIFT)

Definition at line 53 of file lib_helpers.h.

◆ HCR_LOWER_AARCH64

#define HCR_LOWER_AARCH64   (1 << HCR_RW_SHIFT)

Definition at line 52 of file lib_helpers.h.

◆ HCR_RW_SHIFT

#define HCR_RW_SHIFT   31

Definition at line 51 of file lib_helpers.h.

◆ MAKE_REGISTER_ACCESSORS

#define MAKE_REGISTER_ACCESSORS (   reg)
Value:
static inline uint64_t raw_read_##reg(void) \
{ \
uint64_t value; \
__asm__ __volatile__("mrs %0, " #reg "\n\t" \
: "=r" (value) : : "memory"); \
return value; \
} \
static inline void raw_write_##reg(uint64_t value) \
{ \
__asm__ __volatile__("msr " #reg ", %0\n\t" \
: : "r" (value) : "memory"); \
}
pte_t value
Definition: mmu.c:91
unsigned long long uint64_t
Definition: stdint.h:17

Definition at line 102 of file lib_helpers.h.

◆ MAKE_REGISTER_ACCESSORS_EL123

#define MAKE_REGISTER_ACCESSORS_EL123 (   reg)
Value:
MAKE_REGISTER_ACCESSORS(reg##_el2) \
MAKE_REGISTER_ACCESSORS(reg##_el3)
#define MAKE_REGISTER_ACCESSORS(reg)
Definition: lib_helpers.h:102

Definition at line 116 of file lib_helpers.h.

◆ SCR_API

#define SCR_API   (1 << 17) /* Don't trap ptrauth insn */

Definition at line 44 of file lib_helpers.h.

◆ SCR_APK

#define SCR_APK   (1 << 16) /* Don't trap ptrauth keys */

Definition at line 43 of file lib_helpers.h.

◆ SCR_EA

#define SCR_EA   (1 << 3) /* Take EA/SError in EL3 */

Definition at line 33 of file lib_helpers.h.

◆ SCR_EASE

#define SCR_EASE   (1 << 19) /* Sync EAs use SError vector */

Definition at line 46 of file lib_helpers.h.

◆ SCR_EEL2

#define SCR_EEL2   (1 << 18) /* Enable secure EL2 */

Definition at line 45 of file lib_helpers.h.

◆ SCR_FIEN

#define SCR_FIEN   (1 << 21) /* Don't trap EXRPFG */

Definition at line 48 of file lib_helpers.h.

◆ SCR_FIQ

#define SCR_FIQ   (1 << 2) /* Take FIQs in EL3 */

Definition at line 32 of file lib_helpers.h.

◆ SCR_HCE

#define SCR_HCE   (1 << 8) /* Enable HVC instruction */

Definition at line 35 of file lib_helpers.h.

◆ SCR_IRQ

#define SCR_IRQ   (1 << 1) /* Take IRQs in EL3 */

Definition at line 31 of file lib_helpers.h.

◆ SCR_NMEA

#define SCR_NMEA   (1 << 20) /* Disallow EL3 SError masking */

Definition at line 47 of file lib_helpers.h.

◆ SCR_NS

#define SCR_NS   (1 << 0) /* EL0/1 are non-secure */

Definition at line 30 of file lib_helpers.h.

◆ SCR_RES1

#define SCR_RES1   (3 << 4)

Definition at line 49 of file lib_helpers.h.

◆ SCR_RW

#define SCR_RW   (1 << 10) /* Lower ELs are AArch64 */

Definition at line 37 of file lib_helpers.h.

◆ SCR_SIF

#define SCR_SIF   (1 << 9) /* Forbid insns from NS memory */

Definition at line 36 of file lib_helpers.h.

◆ SCR_SMD

#define SCR_SMD   (1 << 7) /* Disable SMC instruction */

Definition at line 34 of file lib_helpers.h.

◆ SCR_ST

#define SCR_ST   (1 << 11) /* Don't trap secure CNTPS */

Definition at line 38 of file lib_helpers.h.

◆ SCR_TERR

#define SCR_TERR   (1 << 15) /* Trap ERR accesses to EL3 */

Definition at line 42 of file lib_helpers.h.

◆ SCR_TLOR

#define SCR_TLOR   (1 << 14) /* Trap LOR accesses to EL3 */

Definition at line 41 of file lib_helpers.h.

◆ SCR_TWE

#define SCR_TWE   (1 << 13) /* Trap WFE to EL3 */

Definition at line 40 of file lib_helpers.h.

◆ SCR_TWI

#define SCR_TWI   (1 << 12) /* Trap WFI to EL3 */

Definition at line 39 of file lib_helpers.h.

◆ SCTLR_A

#define SCTLR_A   (1 << 1) /* Alignment check enable */

Definition at line 56 of file lib_helpers.h.

◆ SCTLR_C

#define SCTLR_C   (1 << 2) /* Data/unified cache enable */

Definition at line 57 of file lib_helpers.h.

◆ SCTLR_EE

#define SCTLR_EE   (1 << 25) /* Exception endianness (BE) */

Definition at line 64 of file lib_helpers.h.

◆ SCTLR_ENDA

#define SCTLR_ENDA   (1 << 27) /* Pointer auth (data A) */

Definition at line 65 of file lib_helpers.h.

◆ SCTLR_ENDB

#define SCTLR_ENDB   (1 << 13) /* Pointer auth (data B) */

Definition at line 61 of file lib_helpers.h.

◆ SCTLR_ENIA

#define SCTLR_ENIA   (1 << 31) /* Pointer auth (insn A) */

Definition at line 67 of file lib_helpers.h.

◆ SCTLR_ENIB

#define SCTLR_ENIB   (1 << 30) /* Pointer auth (insn B) */

Definition at line 66 of file lib_helpers.h.

◆ SCTLR_I

#define SCTLR_I   (1 << 12) /* Instruction cache enable */

Definition at line 60 of file lib_helpers.h.

◆ SCTLR_IESB

#define SCTLR_IESB   (1 << 21) /* Implicit error sync event */

Definition at line 63 of file lib_helpers.h.

◆ SCTLR_M

#define SCTLR_M   (1 << 0) /* MMU enable */

Definition at line 55 of file lib_helpers.h.

◆ SCTLR_NAA

#define SCTLR_NAA   (1 << 6) /* non-aligned access STA/LDR */

Definition at line 59 of file lib_helpers.h.

◆ SCTLR_RES1

#define SCTLR_RES1
Value:
((0x3 << 4) | (0x1 << 11) | (0x1 << 16) | \
(0x1 << 18) | (0x3 << 22) | (0x3 << 28))

Definition at line 68 of file lib_helpers.h.

◆ SCTLR_SA

#define SCTLR_SA   (1 << 3) /* Stack alignment check enable */

Definition at line 58 of file lib_helpers.h.

◆ SCTLR_WXN

#define SCTLR_WXN   (1 << 19) /* Write permission implies XN */

Definition at line 62 of file lib_helpers.h.

◆ SPSR_DEBUG

#define SPSR_DEBUG   (1 << 9)

Definition at line 27 of file lib_helpers.h.

◆ SPSR_ERET_32

#define SPSR_ERET_32   (1 << SPSR_M_SHIFT)

Definition at line 22 of file lib_helpers.h.

◆ SPSR_ERET_64

#define SPSR_ERET_64   (0 << SPSR_M_SHIFT)

Definition at line 23 of file lib_helpers.h.

◆ SPSR_EXCEPTION_MASK

#define SPSR_EXCEPTION_MASK   (SPSR_FIQ | SPSR_IRQ | SPSR_SERROR | SPSR_DEBUG)

Definition at line 28 of file lib_helpers.h.

◆ SPSR_FIQ

#define SPSR_FIQ   (1 << 6)

Definition at line 24 of file lib_helpers.h.

◆ SPSR_IRQ

#define SPSR_IRQ   (1 << 7)

Definition at line 25 of file lib_helpers.h.

◆ SPSR_L_H_MASK

#define SPSR_L_H_MASK   1

Definition at line 20 of file lib_helpers.h.

◆ SPSR_M_SHIFT

#define SPSR_M_SHIFT   4

Definition at line 21 of file lib_helpers.h.

◆ SPSR_SERROR

#define SPSR_SERROR   (1 << 8)

Definition at line 26 of file lib_helpers.h.

◆ SPSR_USE_H

#define SPSR_USE_H   1

Definition at line 19 of file lib_helpers.h.

◆ SPSR_USE_L

#define SPSR_USE_L   0

Definition at line 18 of file lib_helpers.h.

Function Documentation

◆ dccisw()

static void dccisw ( uint64_t  cisw)
inlinestatic

Definition at line 249 of file lib_helpers.h.

◆ dccivac()

static void dccivac ( uint64_t  civac)
inlinestatic

Definition at line 254 of file lib_helpers.h.

Referenced by dcache_op_va().

Here is the caller graph for this function:

◆ dccsw()

static void dccsw ( uint64_t  csw)
inlinestatic

Definition at line 259 of file lib_helpers.h.

◆ dccvac()

static void dccvac ( uint64_t  cvac)
inlinestatic

Definition at line 264 of file lib_helpers.h.

Referenced by dcache_op_va().

Here is the caller graph for this function:

◆ dccvau()

static void dccvau ( uint64_t  cvau)
inlinestatic

Definition at line 269 of file lib_helpers.h.

◆ dcisw()

static void dcisw ( uint64_t  isw)
inlinestatic

Definition at line 274 of file lib_helpers.h.

◆ dcivac()

static void dcivac ( uint64_t  ivac)
inlinestatic

Definition at line 279 of file lib_helpers.h.

Referenced by dcache_op_va().

Here is the caller graph for this function:

◆ dczva()

static void dczva ( uint64_t  zva)
inlinestatic

Definition at line 284 of file lib_helpers.h.

◆ disable_debug_exceptions()

static void disable_debug_exceptions ( void  )
inlinestatic

Definition at line 224 of file lib_helpers.h.

References DAIF_DBG_BIT.

◆ disable_fiq()

static void disable_fiq ( void  )
inlinestatic

Definition at line 242 of file lib_helpers.h.

References DAIF_FIQ_BIT.

◆ disable_irq()

static void disable_irq ( void  )
inlinestatic

Definition at line 236 of file lib_helpers.h.

References DAIF_IRQ_BIT.

◆ disable_serror_exceptions()

static void disable_serror_exceptions ( void  )
inlinestatic

Definition at line 230 of file lib_helpers.h.

References DAIF_ABT_BIT.

◆ enable_debug_exceptions()

static void enable_debug_exceptions ( void  )
inlinestatic

Definition at line 200 of file lib_helpers.h.

References DAIF_DBG_BIT.

◆ enable_fiq()

static void enable_fiq ( void  )
inlinestatic

Definition at line 218 of file lib_helpers.h.

References DAIF_FIQ_BIT.

◆ enable_irq()

static void enable_irq ( void  )
inlinestatic

Definition at line 212 of file lib_helpers.h.

References DAIF_IRQ_BIT.

◆ enable_serror_exceptions()

static void enable_serror_exceptions ( void  )
inlinestatic

Definition at line 206 of file lib_helpers.h.

References DAIF_ABT_BIT.

◆ iciallu()

static void iciallu ( void  )
inlinestatic

Definition at line 289 of file lib_helpers.h.

◆ icialluis()

static void icialluis ( void  )
inlinestatic

Definition at line 294 of file lib_helpers.h.

◆ icivau()

static void icivau ( uint64_t  ivau)
inlinestatic

Definition at line 299 of file lib_helpers.h.

◆ tlbiall_el1()

static void tlbiall_el1 ( void  )
inlinestatic

Definition at line 305 of file lib_helpers.h.

◆ tlbiall_el2()

static void tlbiall_el2 ( void  )
inlinestatic

Definition at line 310 of file lib_helpers.h.

◆ tlbiall_el3()

static void tlbiall_el3 ( void  )
inlinestatic

Definition at line 315 of file lib_helpers.h.

Referenced by mmu_config_range(), and tlb_invalidate_all().

Here is the caller graph for this function:

◆ tlbiallis_el1()

static void tlbiallis_el1 ( void  )
inlinestatic

Definition at line 320 of file lib_helpers.h.

◆ tlbiallis_el2()

static void tlbiallis_el2 ( void  )
inlinestatic

Definition at line 325 of file lib_helpers.h.

◆ tlbiallis_el3()

static void tlbiallis_el3 ( void  )
inlinestatic

Definition at line 330 of file lib_helpers.h.

◆ tlbivaa_el1()

static void tlbivaa_el1 ( uint64_t  va)
inlinestatic

Definition at line 335 of file lib_helpers.h.