Permalink
Browse files

Add implementation of pmap.9 MD functions

  • Loading branch information...
1 parent ed27bd4 commit 81a01e8a3fdbbdc78e30e5c88be018345847f1e1 @fallen committed May 8, 2013
Showing with 902 additions and 37 deletions.
  1. +46 −7 sys/arch/lm32/include/pmap.h
  2. +17 −27 sys/arch/lm32/include/pte.h
  3. +839 −0 sys/arch/lm32/lm32/pmap.c
  4. +0 −3 sys/arch/milkymist/milkymist/genassym.cf
@@ -3,24 +3,51 @@
#ifndef _LM32_PMAP_H_
#define _LM32_PMAP_H_
#include <sys/resource.h>
-#include <uvm/uvm_page.h>
#if !defined(_LOCORE) && (defined(MODULAR) || defined(_MODULE))
__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*5);
#endif /* !LOCORE && (MODULAR || _MODULE) */
+#define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */
+#define PMAP_GROWKERNEL
+#define PMAP_STEAL_MEMORY
+
+struct pmap;
+
+static __inline void
+pmap_remove_all(struct pmap *pmap)
+{
+ /* Nothing. */
+}
+
+void tlbflush(void);
+void pmap_load(void);
+void pmap_virtual_space(vaddr_t *start, vaddr_t *end);
+paddr_t pmap_phys_address(paddr_t cookie);
+void pmap_bootstrap(void);
+
+#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
+#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
+#define pmap_update(pmap) ((void)0)
+#define __HAVE_VM_PAGE_MD
+
+struct pv_entry;
+struct vm_page_md {
+ SLIST_HEAD(, pv_entry) pvh_head;
+ int pvh_flags;
+};
+
+#include <uvm/uvm_page.h>
/*
* Pmap stuff
*/
struct pmap {
- pt_entry_t *pm_ptab; /* KVA of page table */
- u_int pm_count; /* pmap reference count */
+ pt_entry_t **pm_ptp;
struct pmap_statistics pm_stats; /* pmap statistics */
int pm_refcnt;
- int pm_ptpages; /* more stats: PT pages */
};
#define L2_SLOT_PTE (KERNBASE/NBPD_L2-1) /* 767: for recursive PDP map */
@@ -31,8 +58,20 @@ struct pmap {
#define pmap_pte_set(p, n) do { *(p) = (n); } while (0)
#define pmap_pte_flush() /* nothing */
-void tlbflush(void);
-void pmap_load(void);
-void pmap_reference(pmap_t pmap);
+#define PVH_REFERENCED 1
+#define PVH_MODIFIED 2
+
+/* MD pmap utils. */
+pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t);
+bool __pmap_pte_load(pmap_t, vaddr_t, int);
+pt_entry_t *__pmap_kpte_lookup(vaddr_t);
+
+#define VM_MDPAGE_INIT(pg) \
+do { \
+ struct vm_page_md *pvh = &(pg)->mdpage; \
+ SLIST_INIT(&pvh->pvh_head); \
+ pvh->pvh_flags = 0; \
+} while (/*CONSTCOND*/0)
+
#endif /* !_LM32_PMAP_H_ */
@@ -80,38 +80,28 @@ typedef uint32_t pt_entry_t; /* PTE */
* now we define various for playing with virtual addresses
*/
-#define PG_FRAME 0xfffff000 /* page frame mask */
-#define PG_LGFRAME 0xffc00000 /* large (4MB) page frame mask */
+#define PG_FRAME (0xfffff000) /* page frame mask */
+/* software emulated bits */
-#define L1_SHIFT 12
-#define L2_SHIFT 21
+#define PG_WIRED (1 << 11)
+#define PG_NOCACHE (1 << 10)
+#define PG_WRITE_COMBINE (1 << 9)
+#define PG_WRITE_BACK (1 << 8)
+#define PG_NOCACHE_OVR (1 << 7)
+#define PG_D (1 << 6)
+
+/* hardware managed bits */
+#define PG_RO (1 << 1) /* Page read only */
+
+#define PG_PR_MASK (1 << 1) /* Page protection mask */
+
+#define L1_SHIFT (12)
+#define L2_SHIFT (21)
#define NBPD_L1 (1ULL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
#define NBPD_L2 (1ULL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */
-#define L1_MASK 0x001ff000
-
-/*
- * here we define the bits of the PDE/PTE, as described above:
- *
- * XXXCDC: need to rename these (PG_u == ugly).
- */
+#define L1_MASK (0x001ff000)
-#define PG_V 0x00000001 /* valid entry */
-#define PG_RO 0x00000000 /* read-only page */
-#define PG_RW 0x00000002 /* read-write page */
-#define PG_u 0x00000004 /* user accessible page */
-#define PG_PROT 0x00000806 /* all protection bits */
-#define PG_WT 0x00000008 /* write through */
-#define PG_N 0x00000010 /* non-cacheable */
-#define PG_U 0x00000020 /* has been used */
-#define PG_M 0x00000040 /* has been modified */
-#define PG_PAT 0x00000080 /* PAT (on pte) */
-#define PG_PS 0x00000080 /* 4MB page size (2MB for PAE) */
-#define PG_G 0x00000100 /* global, don't TLB flush */
-#define PG_AVAIL1 0x00000200 /* ignored by hardware */
-#define PG_AVAIL2 0x00000400 /* ignored by hardware */
-#define PG_AVAIL3 0x00000800 /* ignored by hardware */
-#define PG_LGPAT 0x00001000 /* PAT on large pages */
#endif /* _LM32_PTE_H_ */
Oops, something went wrong.

0 comments on commit 81a01e8

Please sign in to comment.