18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_CURRENT_H 38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_CURRENT_H 48c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct task_struct; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifdef __powerpc64__ 128c2ecf20Sopenharmony_ci#include <linux/stddef.h> 138c2ecf20Sopenharmony_ci#include <asm/paca.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistatic inline struct task_struct *get_current(void) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci struct task_struct *task; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci /* get_current can be cached by the compiler, so no volatile */ 208c2ecf20Sopenharmony_ci asm ("ld %0,%1(13)" 218c2ecf20Sopenharmony_ci : "=r" (task) 228c2ecf20Sopenharmony_ci : "i" (offsetof(struct paca_struct, __current))); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci return task; 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci#define current get_current() 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#else 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * We keep `current' in r2 for speed. 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ciregister struct task_struct *current asm ("r2"); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#endif 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 388c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_CURRENT_H */ 39