1*433d6423SLionel Sambuc /* 2*433d6423SLionel Sambuc * \brief Virtual page-table facility 3*433d6423SLionel Sambuc * \author Thomas Friebel <tf13@os.inf.tu-dresden.de> 4*433d6423SLionel Sambuc * \author Christian Helmuth <ch12@os.inf.tu-dresden.de> 5*433d6423SLionel Sambuc * \date 2006-11-03 6*433d6423SLionel Sambuc */ 7*433d6423SLionel Sambuc 8*433d6423SLionel Sambuc #ifndef _DDEKIT_PGTAB_H 9*433d6423SLionel Sambuc #define _DDEKIT_PGTAB_H 10*433d6423SLionel Sambuc 11*433d6423SLionel Sambuc #include <ddekit/ddekit.h> 12*433d6423SLionel Sambuc 13*433d6423SLionel Sambuc #include <ddekit/types.h> 14*433d6423SLionel Sambuc 15*433d6423SLionel Sambuc /* FIXME Region types may be defined by pgtab users. Do we really need them 16*433d6423SLionel Sambuc * here? */ 17*433d6423SLionel Sambuc enum ddekit_pgtab_type 18*433d6423SLionel Sambuc { 19*433d6423SLionel Sambuc PTE_TYPE_OTHER, PTE_TYPE_LARGE, PTE_TYPE_UMA, PTE_TYPE_CONTIG 20*433d6423SLionel Sambuc }; 21*433d6423SLionel Sambuc 22*433d6423SLionel Sambuc 23*433d6423SLionel Sambuc /** 24*433d6423SLionel Sambuc * Set virtual->physical mapping for VM region 25*433d6423SLionel Sambuc * 26*433d6423SLionel Sambuc * \param virt virtual start address for region 27*433d6423SLionel Sambuc * \param phys physical start address for region 28*433d6423SLionel Sambuc * \param pages number of pages in region 29*433d6423SLionel Sambuc * \param type pgtab type for region 30*433d6423SLionel Sambuc */ 31*433d6423SLionel Sambuc void ddekit_pgtab_set_region(void *virt, ddekit_addr_t phys, int pages, 32*433d6423SLionel Sambuc int type); 33*433d6423SLionel Sambuc 34*433d6423SLionel Sambuc 35*433d6423SLionel Sambuc /** 36*433d6423SLionel Sambuc * Set virtual->physical mapping for VM region given a specific size in bytes. 37*433d6423SLionel Sambuc * 38*433d6423SLionel Sambuc * Internally, DDEKit manages regions with pages. However, DDEs do not need to tangle 39*433d6423SLionel Sambuc * with the underlying mechanism and therefore can use this function that takes care 40*433d6423SLionel Sambuc * of translating a size to an amount of pages. 41*433d6423SLionel Sambuc */ 42*433d6423SLionel Sambuc void ddekit_pgtab_set_region_with_size(void *virt, ddekit_addr_t phys, 43*433d6423SLionel Sambuc int size, int type); 44*433d6423SLionel Sambuc 45*433d6423SLionel Sambuc 46*433d6423SLionel Sambuc /** 47*433d6423SLionel Sambuc * Clear virtual->physical mapping for VM region 48*433d6423SLionel Sambuc * 49*433d6423SLionel Sambuc * \param virt virtual start address for region 50*433d6423SLionel Sambuc * \param type pgtab type for region 51*433d6423SLionel Sambuc */ 52*433d6423SLionel Sambuc void ddekit_pgtab_clear_region(void *virt, int type); 53*433d6423SLionel Sambuc 54*433d6423SLionel Sambuc /** 55*433d6423SLionel Sambuc * Get physical address for virtual address 56*433d6423SLionel Sambuc * 57*433d6423SLionel Sambuc * \param virt virtual address 58*433d6423SLionel Sambuc * 59*433d6423SLionel Sambuc * \return physical address 60*433d6423SLionel Sambuc */ 61*433d6423SLionel Sambuc ddekit_addr_t ddekit_pgtab_get_physaddr(const void *virt); 62*433d6423SLionel Sambuc 63*433d6423SLionel Sambuc /** 64*433d6423SLionel Sambuc * Get virtual address for physical address 65*433d6423SLionel Sambuc * 66*433d6423SLionel Sambuc * \param physical physical address 67*433d6423SLionel Sambuc * 68*433d6423SLionel Sambuc * \return virtual address 69*433d6423SLionel Sambuc */ 70*433d6423SLionel Sambuc ddekit_addr_t ddekit_pgtab_get_virtaddr(const ddekit_addr_t physical); 71*433d6423SLionel Sambuc 72*433d6423SLionel Sambuc /** 73*433d6423SLionel Sambuc * Get type of VM region. 74*433d6423SLionel Sambuc * 75*433d6423SLionel Sambuc * \param virt virtual address 76*433d6423SLionel Sambuc 77*433d6423SLionel Sambuc * \return VM region type 78*433d6423SLionel Sambuc */ 79*433d6423SLionel Sambuc int ddekit_pgtab_get_type(const void *virt); 80*433d6423SLionel Sambuc 81*433d6423SLionel Sambuc /** 82*433d6423SLionel Sambuc * Get size of VM region. 83*433d6423SLionel Sambuc * 84*433d6423SLionel Sambuc * \param virt virtual address 85*433d6423SLionel Sambuc * 86*433d6423SLionel Sambuc * \return VM region size (in bytes) 87*433d6423SLionel Sambuc */ 88*433d6423SLionel Sambuc int ddekit_pgtab_get_size(const void *virt); 89*433d6423SLionel Sambuc 90*433d6423SLionel Sambuc #endif 91