xv6-simplified 0.1
简化版xv6
Loading...
Searching...
No Matches
Macros | Typedefs
riscv.h File Reference

操作riscv底层结构的一系列函数和数据结构 More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MSTATUS_MPP_MASK   (3L << 11)
 
#define MSTATUS_MPP_M   (3L << 11)
 
#define MSTATUS_MPP_S   (1L << 11)
 
#define MSTATUS_MPP_U   (0L << 11)
 
#define MSTATUS_MIE   (1L << 3)
 
#define MSTATUS_SIE   (1L << 1)
 
#define MSTATUS_MPIE   (1L << 7)
 
#define MSTATUS_SPIE   (1L << 5)
 
#define SSTATUS_SPP   (1L << 8)
 
#define SSTATUS_SPIE   (1L << 5)
 
#define SSTATUS_UPIE   (1L << 4)
 
#define SSTATUS_SIE   (1L << 1)
 
#define SSTATUS_UIE   (1L << 0)
 
#define SIE_SEIE   (1L << 9)
 
#define SIE_STIE   (1L << 5)
 
#define SIE_SSIE   (1L << 1)
 
#define MIE_MEIE   (1L << 11)
 
#define MIE_MTIE   (1L << 7)
 
#define MIE_MSIE   (1L << 3)
 
#define SATP_MASK   (0xF << 60)
 
#define SATP_SV39   (8L << 60)
 
#define SATP_SV48   (9L << 60)
 
#define MAKE_SATP(pagetable)   ( SATP_SV39 | (((uint64)pagetable) >> 12) )
 
#define MAKE_SV48(pagetable)   ( SATP_SV48 | (((uint64)pagetable) >> 12) )
 
#define PGSIZE   4096
 
#define PGSHIFT   12
 
#define PTE_V   (1L << 0)
 
#define PTE_R   (1L << 1)
 
#define PTE_W   (1L << 2)
 
#define PTE_X   (1L << 3)
 
#define PTE_U   (1L << 4)
 
#define PA2PTE(pa)   ((((uint64)(pa)) >> 12) << 10)
 
#define PTE2PA(pte)   (((pte) >> 10) << 12)
 
#define PTE_FLAGS(pte)   ((pte) & 0x3FF)
 
#define PXMASK   0x1FF
 
#define PXSHIFT(level)   ( PGSHIFT + (9*(level)) )
 
#define PX(level, va)   ( (((uint64)(va)) >> PXSHIFT(level)) & PXMASK)
 
#define PGROUNDUP(sz)   ( ((sz) + PGSIZE - 1) & ~(PGSIZE-1) )
 
#define PGROUNDDOWN(a)   ( (a) & ~(PGSIZE-1) )
 
#define MAXVA   (1L << (9 + 9 + 9 + 12 - 1))
 
#define MAXVA_48   (1L << (9 + 9 + 9 + 9 + 12 - 1))
 

Typedefs

typedef uint64 pte_t
 
typedef uint64pagetable_t
 

Detailed Description

操作riscv底层结构的一系列函数和数据结构

Date
23.04.25
Author
xin
Version
0.1 @status Stable

Macro Definition Documentation

◆ MAKE_SATP

#define MAKE_SATP (   pagetable)    ( SATP_SV39 | (((uint64)pagetable) >> 12) )

◆ MAKE_SV48

#define MAKE_SV48 (   pagetable)    ( SATP_SV48 | (((uint64)pagetable) >> 12) )

◆ MAXVA

#define MAXVA   (1L << (9 + 9 + 9 + 12 - 1))

◆ MAXVA_48

#define MAXVA_48   (1L << (9 + 9 + 9 + 9 + 12 - 1))

◆ MIE_MEIE

#define MIE_MEIE   (1L << 11)

◆ MIE_MSIE

#define MIE_MSIE   (1L << 3)

◆ MIE_MTIE

#define MIE_MTIE   (1L << 7)

◆ MSTATUS_MIE

#define MSTATUS_MIE   (1L << 3)

◆ MSTATUS_MPIE

#define MSTATUS_MPIE   (1L << 7)

◆ MSTATUS_MPP_M

#define MSTATUS_MPP_M   (3L << 11)

◆ MSTATUS_MPP_MASK

#define MSTATUS_MPP_MASK   (3L << 11)

◆ MSTATUS_MPP_S

#define MSTATUS_MPP_S   (1L << 11)

◆ MSTATUS_MPP_U

#define MSTATUS_MPP_U   (0L << 11)

◆ MSTATUS_SIE

#define MSTATUS_SIE   (1L << 1)

◆ MSTATUS_SPIE

#define MSTATUS_SPIE   (1L << 5)

◆ PA2PTE

#define PA2PTE (   pa)    ((((uint64)(pa)) >> 12) << 10)

◆ PGROUNDDOWN

#define PGROUNDDOWN (   a)    ( (a) & ~(PGSIZE-1) )

◆ PGROUNDUP

#define PGROUNDUP (   sz)    ( ((sz) + PGSIZE - 1) & ~(PGSIZE-1) )

◆ PGSHIFT

#define PGSHIFT   12

◆ PGSIZE

#define PGSIZE   4096

◆ PTE2PA

#define PTE2PA (   pte)    (((pte) >> 10) << 12)

◆ PTE_FLAGS

#define PTE_FLAGS (   pte)    ((pte) & 0x3FF)

◆ PTE_R

#define PTE_R   (1L << 1)

◆ PTE_U

#define PTE_U   (1L << 4)

◆ PTE_V

#define PTE_V   (1L << 0)

◆ PTE_W

#define PTE_W   (1L << 2)

◆ PTE_X

#define PTE_X   (1L << 3)

◆ PX

#define PX (   level,
  va 
)    ( (((uint64)(va)) >> PXSHIFT(level)) & PXMASK)

◆ PXMASK

#define PXMASK   0x1FF

◆ PXSHIFT

#define PXSHIFT (   level)    ( PGSHIFT + (9*(level)) )

◆ SATP_MASK

#define SATP_MASK   (0xF << 60)

◆ SATP_SV39

#define SATP_SV39   (8L << 60)

◆ SATP_SV48

#define SATP_SV48   (9L << 60)

◆ SIE_SEIE

#define SIE_SEIE   (1L << 9)

◆ SIE_SSIE

#define SIE_SSIE   (1L << 1)

◆ SIE_STIE

#define SIE_STIE   (1L << 5)

◆ SSTATUS_SIE

#define SSTATUS_SIE   (1L << 1)

◆ SSTATUS_SPIE

#define SSTATUS_SPIE   (1L << 5)

◆ SSTATUS_SPP

#define SSTATUS_SPP   (1L << 8)

◆ SSTATUS_UIE

#define SSTATUS_UIE   (1L << 0)

◆ SSTATUS_UPIE

#define SSTATUS_UPIE   (1L << 4)

Typedef Documentation

◆ pagetable_t

typedef uint64* pagetable_t

◆ pte_t

typedef uint64 pte_t