1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * fixmap.h: compile-time virtual memory allocation 4 */ 5 #ifndef ASM__RISCV__FIXMAP_H 6 #define ASM__RISCV__FIXMAP_H 7 8 #include <xen/bug.h> 9 #include <xen/page-size.h> 10 #include <xen/pmap.h> 11 12 #include <asm/page.h> 13 14 #define FIXMAP_ADDR(n) (FIXMAP_BASE + (n) * PAGE_SIZE) 15 16 /* Fixmap slots */ 17 #define FIX_PMAP_BEGIN (0) /* Start of PMAP */ 18 #define FIX_PMAP_END (FIX_PMAP_BEGIN + NUM_FIX_PMAP - 1) /* End of PMAP */ 19 #define FIX_MISC (FIX_PMAP_END + 1) /* Ephemeral mappings of hardware */ 20 21 #define FIX_LAST FIX_MISC 22 23 #define FIXADDR_START FIXMAP_ADDR(0) 24 #define FIXADDR_TOP FIXMAP_ADDR(FIX_LAST + 1) 25 26 #ifndef __ASSEMBLY__ 27 28 /* 29 * Direct access to xen_fixmap[] should only happen when {set, 30 * clear}_fixmap() is unusable (e.g. where we would end up to 31 * recursively call the helpers). 32 */ 33 extern pte_t xen_fixmap[]; 34 35 /* Map a page in a fixmap entry */ 36 void set_fixmap(unsigned int map, mfn_t mfn, pte_attr_t flags); 37 /* Remove a mapping from a fixmap entry */ 38 void clear_fixmap(unsigned int map); 39 40 #define fix_to_virt(slot) ((void *)FIXMAP_ADDR(slot)) 41 virt_to_fix(vaddr_t vaddr)42static inline unsigned int virt_to_fix(vaddr_t vaddr) 43 { 44 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); 45 46 return ((vaddr - FIXADDR_START) >> PAGE_SHIFT); 47 } 48 49 #endif /* __ASSEMBLY__ */ 50 51 #endif /* ASM__RISCV__FIXMAP_H */ 52