summaryrefslogtreecommitdiff
path: root/src/sys/include/arch/amd64/mmu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/include/arch/amd64/mmu.h')
-rw-r--r--src/sys/include/arch/amd64/mmu.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/sys/include/arch/amd64/mmu.h b/src/sys/include/arch/amd64/mmu.h
index 09298b6..0cecd68 100644
--- a/src/sys/include/arch/amd64/mmu.h
+++ b/src/sys/include/arch/amd64/mmu.h
@@ -35,6 +35,46 @@
#ifndef _MACHINE_MMU_H_
#define _MACHINE_MMU_H_
+#include <sys/cpuvar.h>
+#include <sys/param.h>
+#include <vm/vm.h>
+
+/*
+ * Standard memory protection flags
+ */
+#define MMU_PROT_NONE 0x0 /* Nothing */
+#define MMU_PROT_READ BIT(0) /* Readable */
+#define MMU_PROT_WRITE BIT(1) /* Writable */
+#define MMU_PROT_EXEC BIT(2) /* Executable */
+
+
+/*
+ * This will represent a virtual to
+ * physical address mapping.
+ *
+ * @va: Virtual address
+ * @pa: Physical address
+ */
+struct mmu_map {
+ vaddr_t va;
+ paddr_t pa;
+};
+
+/*
+ * Represents the current virtual address
+ *
+ * @cr3: The value of CR3 for this VAS
+ */
+struct vm_vas {
+ paddr_t cr3;
+};
+
+/*
+ * Global early kernel VAS structure used in the
+ * creation of new virtual address spaces.
+ */
+extern struct vm_vas g_kvas;
+
/*
* Initialize arch-specific MMU state such as
* page tables, initial mappings and sanity checks.
@@ -44,4 +84,24 @@
*/
int mmu_init(void);
+/*
+ * Map a single virtual page into physical address
+ * space.
+ *
+ * @spec: Mapping specifier (virtual/physical address)
+ * @prot: Protection flags for the mapping (see MMU_PROT_*)
+ */
+int mmu_map_single(struct vm_vas *vas, struct mmu_map *spec, int prot);
+
+/*
+ * Get a pointer to the current virtual address
+ * space.
+ *
+ * @vasres_p: Resulting VAS is written here
+ *
+ * Returns zero on success, otherwise a less than zero
+ * value on failure.
+ */
+int mmu_this_vas(struct vm_vas *vasres_p);
+
#endif /* !_MACHINE_MMU_H_ */