0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef __ASM_GENERIC_FIXMAP_H
0016 #define __ASM_GENERIC_FIXMAP_H
0017
0018 #include <linux/bug.h>
0019 #include <linux/mm_types.h>
0020
0021 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
0022 #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
0023
0024 #ifndef __ASSEMBLY__
0025
0026
0027
0028
0029
0030 static __always_inline unsigned long fix_to_virt(const unsigned int idx)
0031 {
0032 BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
0033 return __fix_to_virt(idx);
0034 }
0035
0036 static inline unsigned long virt_to_fix(const unsigned long vaddr)
0037 {
0038 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
0039 return __virt_to_fix(vaddr);
0040 }
0041
0042
0043
0044
0045
0046
0047 #ifndef FIXMAP_PAGE_NORMAL
0048 #define FIXMAP_PAGE_NORMAL PAGE_KERNEL
0049 #endif
0050 #if !defined(FIXMAP_PAGE_RO) && defined(PAGE_KERNEL_RO)
0051 #define FIXMAP_PAGE_RO PAGE_KERNEL_RO
0052 #endif
0053 #ifndef FIXMAP_PAGE_NOCACHE
0054 #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
0055 #endif
0056 #ifndef FIXMAP_PAGE_IO
0057 #define FIXMAP_PAGE_IO PAGE_KERNEL_IO
0058 #endif
0059 #ifndef FIXMAP_PAGE_CLEAR
0060 #define FIXMAP_PAGE_CLEAR __pgprot(0)
0061 #endif
0062
0063 #ifndef set_fixmap
0064 #define set_fixmap(idx, phys) \
0065 __set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL)
0066 #endif
0067
0068 #ifndef clear_fixmap
0069 #define clear_fixmap(idx) \
0070 __set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR)
0071 #endif
0072
0073
0074 #define __set_fixmap_offset(idx, phys, flags) \
0075 ({ \
0076 unsigned long ________addr; \
0077 __set_fixmap(idx, phys, flags); \
0078 ________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
0079 ________addr; \
0080 })
0081
0082 #define set_fixmap_offset(idx, phys) \
0083 __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL)
0084
0085
0086
0087
0088 #define set_fixmap_nocache(idx, phys) \
0089 __set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE)
0090
0091 #define set_fixmap_offset_nocache(idx, phys) \
0092 __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE)
0093
0094
0095
0096
0097 #define set_fixmap_io(idx, phys) \
0098 __set_fixmap(idx, phys, FIXMAP_PAGE_IO)
0099
0100 #define set_fixmap_offset_io(idx, phys) \
0101 __set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO)
0102
0103 #endif
0104 #endif