2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
11 #include <asm/sgidefs.h>
13 #if _MIPS_SIM != _MIPS_SIM_ABI64 && defined(CONFIG_64BIT)
15 /* Building 32-bit VDSO for the 64-bit kernel. Fake a 32-bit Kconfig. */
17 #define CONFIG_32BIT 1
19 #include <asm-generic/atomic64.h>
29 static inline unsigned long get_vdso_base(void)
34 * We can't use cpu_has_mips_r6 since it needs the cpu_data[]
37 #ifdef CONFIG_CPU_MIPSR6
39 * lapc <symbol> is an alias to addiupc reg, <symbol> - .
41 * We can't use addiupc because there is no label-label
42 * support for the addiupc reloc
44 __asm__("lapc %0, _start \n"
48 * Get the base load address of the VDSO. We have to avoid generating
49 * relocations and references to the GOT because ld.so does not peform
50 * relocations on the VDSO. We use the current offset from the VDSO base
51 * and perform a PC-relative branch which gives the absolute address in
52 * ra, and take the difference. The assembler chokes on
53 * "li %0, _start - .", so embed the offset as a word and branch over
63 " .word _start - . \n"
65 " " STR(PTR_ADDU) " %0, $31, %0 \n"
70 #endif /* CONFIG_CPU_MIPSR6 */
75 static inline const union mips_vdso_data *get_vdso_data(void)
77 return (const union mips_vdso_data *)(get_vdso_base() - PAGE_SIZE);
80 #ifdef CONFIG_CLKSRC_MIPS_GIC
82 static inline void __iomem *get_gic(const union mips_vdso_data *data)
84 return (void __iomem *)((unsigned long)data & PAGE_MASK) - PAGE_SIZE;
87 #endif /* CONFIG_CLKSRC_MIPS_GIC */
89 #endif /* __ASSEMBLY__ */