Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / loongarch / include / asm / vdso / getrandom.h
blobe80f3c4ac7481ba7f9f5d9210fefa78c3293243b
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2024 Xi Ruoyao <xry111@xry111.site>. All Rights Reserved.
4 */
5 #ifndef __ASM_VDSO_GETRANDOM_H
6 #define __ASM_VDSO_GETRANDOM_H
8 #ifndef __ASSEMBLY__
10 #include <asm/unistd.h>
11 #include <asm/vdso/vdso.h>
13 static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)
15 register long ret asm("a0");
16 register long nr asm("a7") = __NR_getrandom;
17 register void *buffer asm("a0") = _buffer;
18 register size_t len asm("a1") = _len;
19 register unsigned int flags asm("a2") = _flags;
21 asm volatile(
22 " syscall 0\n"
23 : "+r" (ret)
24 : "r" (nr), "r" (buffer), "r" (len), "r" (flags)
25 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8",
26 "memory");
28 return ret;
31 static __always_inline const struct vdso_rng_data *__arch_get_vdso_rng_data(void)
33 return &_loongarch_data.rng_data;
36 #endif /* !__ASSEMBLY__ */
38 #endif /* __ASM_VDSO_GETRANDOM_H */