diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 18:58:13 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 18:58:13 +0200 |
| commit | 5890df7bf838a5a912465a1bba02e5d8cf34e33c (patch) | |
| tree | 48c17acfc5ed2b44bff817b00123288098273ecc /arch/riscv64/kernel/vmem.c | |
| parent | 5531e2eaaa2fd1dd282dba2fb5bc10e09dfec5e0 (diff) | |
| download | kmi-5890df7bf838a5a912465a1bba02e5d8cf34e33c.tar.gz kmi-5890df7bf838a5a912465a1bba02e5d8cf34e33c.zip | |
allow skipping some cache flushes in proc
Diffstat (limited to 'arch/riscv64/kernel/vmem.c')
| -rw-r--r-- | arch/riscv64/kernel/vmem.c | 81 |
1 files changed, 4 insertions, 77 deletions
diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index 1b70493..2a08854 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -16,83 +16,10 @@ #include <arch/cpu.h> #include "pages.h" #include "arch.h" +#include "pte.h" #include "csr.h" /** - * Get page table entry physical page number. - * - * @param pte Page table entry. - * @return Corresponding physical page number. - */ -#define pte_ppn(pte) (((pm_t)(pte)) >> 10) - -/** - * Get page table entry flags. - * - * @param pte Page table entry. - * @return Corresponding flags. - */ -#define pte_flags(pte) (((pm_t)(pte)) & 0xff) - -/** - * Convert physical memory address to page table entry. - * - * @param p Physical memory address. - * @param f Flags to use. - * @return Corresponding page table entry. - */ -#define to_pte(p, f) ((((p) >> page_shift()) << 10) | (f)) - -/** - * Get physical address in page table entry. - * - * @param pte Page table entry. - * @return Corresponding physical address. - */ -#define pte_paddr(pte) (pte_ppn(pte) << page_shift()) - -/** - * Get virtual address in page table entry. - * - * @param pte Page table entry. - * @return Corresponding virtual address. - */ -#define pte_addr(pte) __va(pte_paddr(pte)) - -/** - * Virtual memory address to page order index. - * - * @param a Virtual address. - * @param o Order of page. - * @return Corresponding page index. - */ -#define vm_to_index(a, o) (pm_to_index(a, o)) - -/** - * Check if page table entry is active. - * - * @param pte Page table entry. - * @return \c 0 if entry is not active, non-zero otherwise. - */ -#define is_active(pte) (pte_flags(pte) &VM_V) - -/** - * Check if page table entry is a leaf. - * - * @param pte Page table entry. - * @return \c 0 if entry is not leaf, non-zero otherwise. - */ -#define is_leaf(pte) (is_active(pte) && (pte_flags(pte) & ~VM_V)) - -/** - * Check if page table entry is a branch. - * - * @param pte Page table entry. - * @return \c 0 if entry is not branch, non-zero otherwise. - */ -#define is_branch(pte) (is_active(pte) && !(pte_flags(pte) & ~VM_V)) - -/** * Gravestone marker. * * Riscv allows us to have arbitrary data in page entries, as long as they're @@ -607,6 +534,8 @@ stat_t setup_rpc_stack(struct tcb *t) if (!page) return ERR_OOMEM; + t->arch.rpc_page = page; + if (map_vpage(t->rpc.vmem, page, RPC_STACK_BASE, flags, BASE_PAGE)) { free_page(MM_O1, page); return ERR_OOMEM; @@ -636,9 +565,7 @@ stat_t setup_rpc_stack(struct tcb *t) void destroy_rpc_stack(struct tcb *t) { - pm_t *pte = (pm_t *)t->arch.rpc_leaf; - pm_t page = (pm_t)pte_addr(*pte); - free_page(MM_O1, page); + free_page(MM_O1, t->arch.rpc_page); } void reset_rpc_stack(struct tcb *t) |
