162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * psr.h: This file holds the macros for masking off various parts of 462306a36Sopenharmony_ci * the processor status register on the Sparc. This is valid 562306a36Sopenharmony_ci * for Version 8. On the V9 this is renamed to the PSTATE 662306a36Sopenharmony_ci * register and its members are accessed as fields like 762306a36Sopenharmony_ci * PSTATE.PRIV for the current CPU privilege level. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci#ifndef __LINUX_SPARC_PSR_H 1262306a36Sopenharmony_ci#define __LINUX_SPARC_PSR_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <uapi/asm/psr.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1862306a36Sopenharmony_ci/* Get the %psr register. */ 1962306a36Sopenharmony_cistatic inline unsigned int get_psr(void) 2062306a36Sopenharmony_ci{ 2162306a36Sopenharmony_ci unsigned int psr; 2262306a36Sopenharmony_ci __asm__ __volatile__( 2362306a36Sopenharmony_ci "rd %%psr, %0\n\t" 2462306a36Sopenharmony_ci "nop\n\t" 2562306a36Sopenharmony_ci "nop\n\t" 2662306a36Sopenharmony_ci "nop\n\t" 2762306a36Sopenharmony_ci : "=r" (psr) 2862306a36Sopenharmony_ci : /* no inputs */ 2962306a36Sopenharmony_ci : "memory"); 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci return psr; 3262306a36Sopenharmony_ci} 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistatic inline void put_psr(unsigned int new_psr) 3562306a36Sopenharmony_ci{ 3662306a36Sopenharmony_ci __asm__ __volatile__( 3762306a36Sopenharmony_ci "wr %0, 0x0, %%psr\n\t" 3862306a36Sopenharmony_ci "nop\n\t" 3962306a36Sopenharmony_ci "nop\n\t" 4062306a36Sopenharmony_ci "nop\n\t" 4162306a36Sopenharmony_ci : /* no outputs */ 4262306a36Sopenharmony_ci : "r" (new_psr) 4362306a36Sopenharmony_ci : "memory", "cc"); 4462306a36Sopenharmony_ci} 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* Get the %fsr register. Be careful, make sure the floating point 4762306a36Sopenharmony_ci * enable bit is set in the %psr when you execute this or you will 4862306a36Sopenharmony_ci * incur a trap. 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciextern unsigned int fsr_storage; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistatic inline unsigned int get_fsr(void) 5462306a36Sopenharmony_ci{ 5562306a36Sopenharmony_ci unsigned int fsr = 0; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci __asm__ __volatile__( 5862306a36Sopenharmony_ci "st %%fsr, %1\n\t" 5962306a36Sopenharmony_ci "ld %1, %0\n\t" 6062306a36Sopenharmony_ci : "=r" (fsr) 6162306a36Sopenharmony_ci : "m" (fsr_storage)); 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci return fsr; 6462306a36Sopenharmony_ci} 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#endif /* !(__ASSEMBLY__) */ 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#endif /* !(__LINUX_SPARC_PSR_H) */ 69