include/mips.h — MIPS CP0 access

MIPS32r2 CP0 access, interrupt masking and barrier helpers for C.

mfc0(reg, sel)

Read a CP0 register.

Parameters:
  • reg – CP0 register number (C0_*).

  • sel – Select field.

Returns:

The register value (uint32_t).

mtc0(reg, sel, val)

Write a CP0 register, followed by EHB.

Parameters:
  • reg – CP0 register number (C0_*).

  • sel – Select field.

  • val – The value.

C0_INDEX

CP0 Index.

C0_ENTRYLO0

CP0 EntryLo0.

C0_ENTRYLO1

CP0 EntryLo1.

C0_PAGEMASK

CP0 PageMask.

C0_WIRED

CP0 Wired.

C0_BADVADDR

CP0 BadVAddr.

C0_COUNT

CP0 Count (core clock / 2).

C0_ENTRYHI

CP0 EntryHi.

C0_COMPARE

CP0 Compare (timer interrupt).

C0_STATUS

CP0 Status.

C0_CAUSE

CP0 Cause.

C0_EPC

CP0 EPC.

static inline uint32_t irq_save(void)

Mask interrupts.

Returns:

The previous Status; pass it to irq_restore().

static inline void irq_restore(uint32_t s)

Unmask interrupts if they were enabled before irq_save().

Parameters:
static inline void mips_sync(void)

SYNC: order memory accesses.

static inline void mips_ehb(void)

EHB: clear execution hazards (after CP0 writes).

static inline void mips_wait(void)

WAIT: sleep until an interrupt.