1*e13ab1eaSNico Boehr /* SPDX-License-Identifier: GPL-2.0 */ 2*e13ab1eaSNico Boehr /* 3*e13ab1eaSNico Boehr * Copyright IBM Corp. 2017, 2022 4*e13ab1eaSNico Boehr * Author(s): Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> 5*e13ab1eaSNico Boehr * Nico Boehr <nrb@linux.ibm.com> 6*e13ab1eaSNico Boehr */ 7*e13ab1eaSNico Boehr #include <asm/interrupt.h> 8*e13ab1eaSNico Boehr 9*e13ab1eaSNico Boehr #ifndef PAGE_STATES_H 10*e13ab1eaSNico Boehr #define PAGE_STATES_H 11*e13ab1eaSNico Boehr 12*e13ab1eaSNico Boehr #define ESSA_GET_STATE 0 13*e13ab1eaSNico Boehr #define ESSA_SET_STABLE 1 14*e13ab1eaSNico Boehr #define ESSA_SET_UNUSED 2 15*e13ab1eaSNico Boehr #define ESSA_SET_VOLATILE 3 16*e13ab1eaSNico Boehr #define ESSA_SET_POT_VOLATILE 4 17*e13ab1eaSNico Boehr #define ESSA_SET_STABLE_RESIDENT 5 18*e13ab1eaSNico Boehr #define ESSA_SET_STABLE_IF_RESIDENT 6 19*e13ab1eaSNico Boehr #define ESSA_SET_STABLE_NODAT 7 20*e13ab1eaSNico Boehr 21*e13ab1eaSNico Boehr #define ESSA_MAX ESSA_SET_STABLE_NODAT 22*e13ab1eaSNico Boehr 23*e13ab1eaSNico Boehr #define ESSA_USAGE_STABLE 0 24*e13ab1eaSNico Boehr #define ESSA_USAGE_UNUSED 1 25*e13ab1eaSNico Boehr #define ESSA_USAGE_POT_VOLATILE 2 26*e13ab1eaSNico Boehr #define ESSA_USAGE_VOLATILE 3 27*e13ab1eaSNico Boehr 28*e13ab1eaSNico Boehr static unsigned long essa(uint8_t state, unsigned long paddr) 29*e13ab1eaSNico Boehr { 30*e13ab1eaSNico Boehr uint64_t extr_state; 31*e13ab1eaSNico Boehr 32*e13ab1eaSNico Boehr asm volatile(".insn rrf,0xb9ab0000,%[extr_state],%[addr],%[new_state],0" \ 33*e13ab1eaSNico Boehr : [extr_state] "=d" (extr_state) \ 34*e13ab1eaSNico Boehr : [addr] "a" (paddr), [new_state] "i" (state)); 35*e13ab1eaSNico Boehr 36*e13ab1eaSNico Boehr return (unsigned long)extr_state; 37*e13ab1eaSNico Boehr } 38*e13ab1eaSNico Boehr 39*e13ab1eaSNico Boehr /* 40*e13ab1eaSNico Boehr * Unfortunately the availability is not indicated by stfl bits, but 41*e13ab1eaSNico Boehr * we have to try to execute it and test for an operation exception. 42*e13ab1eaSNico Boehr */ 43*e13ab1eaSNico Boehr static inline bool check_essa_available(void) 44*e13ab1eaSNico Boehr { 45*e13ab1eaSNico Boehr expect_pgm_int(); 46*e13ab1eaSNico Boehr essa(ESSA_GET_STATE, 0); 47*e13ab1eaSNico Boehr return clear_pgm_int() == 0; 48*e13ab1eaSNico Boehr } 49*e13ab1eaSNico Boehr 50*e13ab1eaSNico Boehr #endif 51