18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * psr.h: This file holds the macros for masking off various parts of 48c2ecf20Sopenharmony_ci * the processor status register on the Sparc. This is valid 58c2ecf20Sopenharmony_ci * for Version 8. On the V9 this is renamed to the PSTATE 68c2ecf20Sopenharmony_ci * register and its members are accessed as fields like 78c2ecf20Sopenharmony_ci * PSTATE.PRIV for the current CPU privilege level. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci#ifndef __LINUX_SPARC_PSR_H 128c2ecf20Sopenharmony_ci#define __LINUX_SPARC_PSR_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <uapi/asm/psr.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 188c2ecf20Sopenharmony_ci/* Get the %psr register. */ 198c2ecf20Sopenharmony_cistatic inline unsigned int get_psr(void) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci unsigned int psr; 228c2ecf20Sopenharmony_ci __asm__ __volatile__( 238c2ecf20Sopenharmony_ci "rd %%psr, %0\n\t" 248c2ecf20Sopenharmony_ci "nop\n\t" 258c2ecf20Sopenharmony_ci "nop\n\t" 268c2ecf20Sopenharmony_ci "nop\n\t" 278c2ecf20Sopenharmony_ci : "=r" (psr) 288c2ecf20Sopenharmony_ci : /* no inputs */ 298c2ecf20Sopenharmony_ci : "memory"); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci return psr; 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic inline void put_psr(unsigned int new_psr) 358c2ecf20Sopenharmony_ci{ 368c2ecf20Sopenharmony_ci __asm__ __volatile__( 378c2ecf20Sopenharmony_ci "wr %0, 0x0, %%psr\n\t" 388c2ecf20Sopenharmony_ci "nop\n\t" 398c2ecf20Sopenharmony_ci "nop\n\t" 408c2ecf20Sopenharmony_ci "nop\n\t" 418c2ecf20Sopenharmony_ci : /* no outputs */ 428c2ecf20Sopenharmony_ci : "r" (new_psr) 438c2ecf20Sopenharmony_ci : "memory", "cc"); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Get the %fsr register. Be careful, make sure the floating point 478c2ecf20Sopenharmony_ci * enable bit is set in the %psr when you execute this or you will 488c2ecf20Sopenharmony_ci * incur a trap. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciextern unsigned int fsr_storage; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic inline unsigned int get_fsr(void) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci unsigned int fsr = 0; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci __asm__ __volatile__( 588c2ecf20Sopenharmony_ci "st %%fsr, %1\n\t" 598c2ecf20Sopenharmony_ci "ld %1, %0\n\t" 608c2ecf20Sopenharmony_ci : "=r" (fsr) 618c2ecf20Sopenharmony_ci : "m" (fsr_storage)); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return fsr; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#endif /* !(__ASSEMBLY__) */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#endif /* !(__LINUX_SPARC_PSR_H) */ 69