SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Macros
csr.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MSTATUS_UIE   (1 << 0)
 Machine Status Bit Definitions.
 
#define MSTATUS_SIE   (1 << 1)
 
#define MSTATUS_MIE   (1 << 3)
 
#define MSTATUS_UPIE   (1 << 4)
 
#define MSTATUS_SPIE   (1 << 5)
 
#define MSTATUS_MPIE   (1 << 7)
 
#define MSTATUS_SPP   (1 << 8)
 
#define MSTATUS_MPP   (3 << 11)
 
#define MSTATUS_FS   (3 << 13)
 
#define MSTATUS_XS   (3 << 15)
 
#define MSTATUS_MPRV   (1 << 17)
 
#define MSTATUS_SUM   (1 << 18)
 
#define MSTATUS_MXR   (1 << 19)
 
#define MSTATUS_TVM   (1 << 20)
 
#define MSTATUS_TW   (1 << 21)
 
#define MSTATUS32_SD   (1 << 31)
 
#define MSTATUS_UXL   (3ULL << 32)
 
#define MSTATUS_SXL   (3ULL << 34)
 
#define MSTATUS64_SD   (1ULL << 63)
 
#define MXSTATUS_MM   (1 << 15)
 Machine Extra Status Bit Definitions.
 
#define MXSTATUS_THEADISAEE   (1 << 22)
 
#define MHCR_IE   (1 << 0)
 Machine Hardware Config Bit Definitions.
 
#define MHCR_DE   (1 << 1)
 
#define MHCR_WB   (1 << 2)
 
#define MHCR_WA   (1 << 3)
 
#define MHCR_RS   (1 << 4)
 
#define MHCR_BPE   (1 << 5)
 
#define MHCR_BTE   (1 << 12)
 
#define MHINT_D_PLD   (1 << 2)
 Machine HINT Bit Definitions.
 
#define MHINT_AMR_0   (0b00 << 3)
 
#define MHINT_AMR_1   (0b01 << 3)
 
#define MHINT_AMR_2   (0b10 << 3)
 
#define MHINT_AMR_3   (0b11 << 3)
 
#define MHINT_IWPE   (1 << 10)
 
#define MHINT_PREF_N_2   (0b00 << 13)
 
#define MHINT_PREF_N_4   (0b01 << 13)
 
#define MHINT_PREF_N_8   (0b10 << 13)
 
#define MHINT_PREF_N_16   (0b11 << 13)
 
#define MHINT_AEE   (1 << 20)
 
#define MHINT_PCFIFO_FREEZE   (1 << 24)
 
#define MIP_USIP   (1 << 0)
 Machine Interrupt Pending (mip) Bit Definitions.
 
#define MIP_SSIP   (1 << 1)
 Supervisor Software Interrupt Pending.
 
#define MIP_MSIP   (1 << 3)
 Machine Software Interrupt Pending.
 
#define MIP_UTIP   (1 << 4)
 User Timer Interrupt Pending.
 
#define MIP_STIP   (1 << 5)
 Supervisor Timer Interrupt Pending.
 
#define MIP_MTIP   (1 << 7)
 Machine Timer Interrupt Pending.
 
#define MIP_UEIP   (1 << 8)
 User External Interrupt Pending.
 
#define MIP_SEIP   (1 << 9)
 Supervisor External Interrupt Pending.
 
#define MIP_MEIP   (1 << 11)
 Machine External Interrupt Pending.
 
#define MIE_USIE   (1 << 0)
 Machine Interrupt Enable (mie) Bit Definitions.
 
#define MIE_SSIE   (1 << 1)
 Supervisor Software Interrupt Enable.
 
#define MIE_MSIE   (1 << 3)
 Machine Software Interrupt Enable.
 
#define MIE_UTIE   (1 << 4)
 User Timer Interrupt Enable.
 
#define MIE_STIE   (1 << 5)
 Supervisor Timer Interrupt Enable.
 
#define MIE_MTIE   (1 << 7)
 Machine Timer Interrupt Enable.
 
#define MIE_UEIE   (1 << 8)
 User External Interrupt Enable.
 
#define MIE_SEIE   (1 << 9)
 Supervisor External Interrupt Enable.
 
#define MIE_MEIE   (1 << 11)
 Machine External Interrupt Enable.
 
#define PRV_U   (0)
 
#define PRV_S   (1)
 
#define PRV_H   (2)
 
#define PRV_M   (3)
 
#define csr_swap(csr, val)
 Swap the value of a CSR with a new value.
 
#define csr_read(csr)
 Read the value of a CSR.
 
#define csr_write(csr, val)
 Write a new value to a CSR.
 
#define csr_read_set(csr, val)
 Read and set bits in a CSR.
 
#define csr_set(csr, val)
 Set bits in a CSR.
 
#define csr_read_clear(csr, val)
 Read a CSR and clear specified bits.
 
#define csr_clear(csr, val)
 Clear specified bits in a CSR.
 

Macro Definition Documentation

◆ csr_clear

#define csr_clear (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrc " #csr ", %0" \
: \
: "rK"(__v) \
: "memory"); \
})
ul val
Definition memtester.c:33

Clear specified bits in a CSR.

This macro clears the specified bits in the given CSR.

Parameters
csrThe CSR to clear bits in.
valThe bits to clear in the CSR.

◆ csr_read

#define csr_read (   csr)
Value:
({ \
register unsigned long __v; \
__asm__ __volatile__("csrr %0, " #csr \
: "=r"(__v) \
: \
: "memory"); \
__v; \
})

Read the value of a CSR.

This macro reads the current value of the specified CSR.

Parameters
csrThe CSR to read.
Returns
The current value of the CSR.

◆ csr_read_clear

#define csr_read_clear (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrrc %0, " #csr ", %1" \
: "=r"(__v) \
: "rK"(__v) \
: "memory"); \
__v; \
})

Read a CSR and clear specified bits.

This macro reads the current value of the specified CSR and clears the specified bits.

Parameters
csrThe CSR to read and clear bits in.
valThe bits to clear in the CSR.
Returns
The previous value of the CSR.

◆ csr_read_set

#define csr_read_set (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrrs %0, " #csr ", %1" \
: "=r"(__v) \
: "rK"(__v) \
: "memory"); \
__v; \
})

Read and set bits in a CSR.

This macro reads the current value of the specified CSR and sets the specified bits.

Parameters
csrThe CSR to read and set bits in.
valThe bits to set in the CSR.
Returns
The previous value of the CSR.

◆ csr_set

#define csr_set (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrs " #csr ", %0" \
: \
: "rK"(__v) \
: "memory"); \
})

Set bits in a CSR.

This macro sets the specified bits in the given CSR.

Parameters
csrThe CSR to set bits in.
valThe bits to set in the CSR.

◆ csr_swap

#define csr_swap (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrrw %0, " #csr ", %1" \
: "=r"(__v) \
: "rK"(__v) \
: "memory"); \
__v; \
})

Swap the value of a CSR with a new value.

This macro writes the new value to the specified CSR and returns the old value.

Parameters
csrThe CSR to swap with.
valThe new value to write to the CSR.
Returns
The old value of the CSR.

◆ csr_write

#define csr_write (   csr,
  val 
)
Value:
({ \
unsigned long __v = (unsigned long) (val); \
__asm__ __volatile__("csrw " #csr ", %0" \
: \
: "rK"(__v) \
: "memory"); \
})

Write a new value to a CSR.

This macro writes a new value to the specified CSR.

Parameters
csrThe CSR to write to.
valThe value to write to the CSR.

◆ MHCR_BPE

#define MHCR_BPE   (1 << 5)

◆ MHCR_BTE

#define MHCR_BTE   (1 << 12)

◆ MHCR_DE

#define MHCR_DE   (1 << 1)

◆ MHCR_IE

#define MHCR_IE   (1 << 0)

Machine Hardware Config Bit Definitions.

◆ MHCR_RS

#define MHCR_RS   (1 << 4)

◆ MHCR_WA

#define MHCR_WA   (1 << 3)

◆ MHCR_WB

#define MHCR_WB   (1 << 2)

◆ MHINT_AEE

#define MHINT_AEE   (1 << 20)

◆ MHINT_AMR_0

#define MHINT_AMR_0   (0b00 << 3)

◆ MHINT_AMR_1

#define MHINT_AMR_1   (0b01 << 3)

◆ MHINT_AMR_2

#define MHINT_AMR_2   (0b10 << 3)

◆ MHINT_AMR_3

#define MHINT_AMR_3   (0b11 << 3)

◆ MHINT_D_PLD

#define MHINT_D_PLD   (1 << 2)

Machine HINT Bit Definitions.

◆ MHINT_IWPE

#define MHINT_IWPE   (1 << 10)

◆ MHINT_PCFIFO_FREEZE

#define MHINT_PCFIFO_FREEZE   (1 << 24)

◆ MHINT_PREF_N_16

#define MHINT_PREF_N_16   (0b11 << 13)

◆ MHINT_PREF_N_2

#define MHINT_PREF_N_2   (0b00 << 13)

◆ MHINT_PREF_N_4

#define MHINT_PREF_N_4   (0b01 << 13)

◆ MHINT_PREF_N_8

#define MHINT_PREF_N_8   (0b10 << 13)

◆ MIE_MEIE

#define MIE_MEIE   (1 << 11)

Machine External Interrupt Enable.

◆ MIE_MSIE

#define MIE_MSIE   (1 << 3)

Machine Software Interrupt Enable.

◆ MIE_MTIE

#define MIE_MTIE   (1 << 7)

Machine Timer Interrupt Enable.

◆ MIE_SEIE

#define MIE_SEIE   (1 << 9)

Supervisor External Interrupt Enable.

◆ MIE_SSIE

#define MIE_SSIE   (1 << 1)

Supervisor Software Interrupt Enable.

◆ MIE_STIE

#define MIE_STIE   (1 << 5)

Supervisor Timer Interrupt Enable.

◆ MIE_UEIE

#define MIE_UEIE   (1 << 8)

User External Interrupt Enable.

◆ MIE_USIE

#define MIE_USIE   (1 << 0)

Machine Interrupt Enable (mie) Bit Definitions.

User Software Interrupt Enable

◆ MIE_UTIE

#define MIE_UTIE   (1 << 4)

User Timer Interrupt Enable.

◆ MIP_MEIP

#define MIP_MEIP   (1 << 11)

Machine External Interrupt Pending.

◆ MIP_MSIP

#define MIP_MSIP   (1 << 3)

Machine Software Interrupt Pending.

◆ MIP_MTIP

#define MIP_MTIP   (1 << 7)

Machine Timer Interrupt Pending.

◆ MIP_SEIP

#define MIP_SEIP   (1 << 9)

Supervisor External Interrupt Pending.

◆ MIP_SSIP

#define MIP_SSIP   (1 << 1)

Supervisor Software Interrupt Pending.

◆ MIP_STIP

#define MIP_STIP   (1 << 5)

Supervisor Timer Interrupt Pending.

◆ MIP_UEIP

#define MIP_UEIP   (1 << 8)

User External Interrupt Pending.

◆ MIP_USIP

#define MIP_USIP   (1 << 0)

Machine Interrupt Pending (mip) Bit Definitions.

User Software Interrupt Pending

◆ MIP_UTIP

#define MIP_UTIP   (1 << 4)

User Timer Interrupt Pending.

◆ MSTATUS32_SD

#define MSTATUS32_SD   (1 << 31)

◆ MSTATUS64_SD

#define MSTATUS64_SD   (1ULL << 63)

◆ MSTATUS_FS

#define MSTATUS_FS   (3 << 13)

◆ MSTATUS_MIE

#define MSTATUS_MIE   (1 << 3)

◆ MSTATUS_MPIE

#define MSTATUS_MPIE   (1 << 7)

◆ MSTATUS_MPP

#define MSTATUS_MPP   (3 << 11)

◆ MSTATUS_MPRV

#define MSTATUS_MPRV   (1 << 17)

◆ MSTATUS_MXR

#define MSTATUS_MXR   (1 << 19)

◆ MSTATUS_SIE

#define MSTATUS_SIE   (1 << 1)

◆ MSTATUS_SPIE

#define MSTATUS_SPIE   (1 << 5)

◆ MSTATUS_SPP

#define MSTATUS_SPP   (1 << 8)

◆ MSTATUS_SUM

#define MSTATUS_SUM   (1 << 18)

◆ MSTATUS_SXL

#define MSTATUS_SXL   (3ULL << 34)

◆ MSTATUS_TVM

#define MSTATUS_TVM   (1 << 20)

◆ MSTATUS_TW

#define MSTATUS_TW   (1 << 21)

◆ MSTATUS_UIE

#define MSTATUS_UIE   (1 << 0)

Machine Status Bit Definitions.

◆ MSTATUS_UPIE

#define MSTATUS_UPIE   (1 << 4)

◆ MSTATUS_UXL

#define MSTATUS_UXL   (3ULL << 32)

◆ MSTATUS_XS

#define MSTATUS_XS   (3 << 15)

◆ MXSTATUS_MM

#define MXSTATUS_MM   (1 << 15)

Machine Extra Status Bit Definitions.

◆ MXSTATUS_THEADISAEE

#define MXSTATUS_THEADISAEE   (1 << 22)

◆ PRV_H

#define PRV_H   (2)

◆ PRV_M

#define PRV_M   (3)

◆ PRV_S

#define PRV_S   (1)

◆ PRV_U

#define PRV_U   (0)