aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/include/vmem.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv64/include/vmem.h')
-rw-r--r--arch/riscv64/include/vmem.h48
1 files changed, 21 insertions, 27 deletions
diff --git a/arch/riscv64/include/vmem.h b/arch/riscv64/include/vmem.h
index ed99843..704858b 100644
--- a/arch/riscv64/include/vmem.h
+++ b/arch/riscv64/include/vmem.h
@@ -4,6 +4,8 @@
#ifndef KMI_RISCV_VMAP_H
#define KMI_RISCV_VMAP_H
+#include "uapi.h"
+
/**
* @file vmem.h
* riscv64 definitions of arch-specific virtual memory data types and macros.
@@ -11,9 +13,6 @@
* architecture-nonspecific, but works for now.
*/
-#include <kmi/types.h>
-#include <kmi/attrs.h>
-
/**
* Number of entries in one page table, depends on if we're running riscv32 or
* riscv64.
@@ -26,30 +25,6 @@
#define RISCV_NUM_LEAVES 1024
#endif
-/** Page is active. */
-#define VM_V (1 << 0)
-
-/** Page is readable. */
-#define VM_R (1 << 1)
-
-/** Page is writable. */
-#define VM_W (1 << 2)
-
-/** Page is executable. */
-#define VM_X (1 << 3)
-
-/** Page is user-accessible. */
-#define VM_U (1 << 4)
-
-/** Page is global. */
-#define VM_G (1 << 5)
-
-/** Page has been accessed. */
-#define VM_A (1 << 6)
-
-/** Page is dirty. */
-#define VM_D (1 << 7)
-
/** Memory mode of cpu. Currently only Sv39 is supported. */
enum mm_mode {
/** 48bit effective addresses on 64bit systems. */
@@ -71,4 +46,23 @@ struct vmem {
struct vmem *leaf[RISCV_NUM_LEAVES];
};
+/**
+ * Extract virtual memory flags (MR_XXX).
+ *
+ * @param x Flags to extract virtual memory region flags from.
+ * @return Virtual memory region flags.
+ */
+#define vm_flags(x) ((x) & ~0xff)
+
+/**
+ * Extract physical memory page flags (VM_XXX).
+ *
+ * @param x Flags to extract physical memory page flags from.
+ * @return Physical memory page flags.
+ */
+#define vp_flags(x) ((x) & 0xff)
+
+/** How many VM_XXX flags architecture has. MR_XXX are applied after them. */
+#define ARCH_VP_FLAGS 8
+
#endif /* KMI_RISCV_VMAP_H */