162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci#ifndef _POWERPC_RTAS_H 362306a36Sopenharmony_ci#define _POWERPC_RTAS_H 462306a36Sopenharmony_ci#ifdef __KERNEL__ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/spinlock.h> 762306a36Sopenharmony_ci#include <asm/page.h> 862306a36Sopenharmony_ci#include <asm/rtas-types.h> 962306a36Sopenharmony_ci#include <linux/time.h> 1062306a36Sopenharmony_ci#include <linux/cpumask.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* 1362306a36Sopenharmony_ci * Definitions for talking to the RTAS on CHRP machines. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Copyright (C) 2001 Peter Bergner 1662306a36Sopenharmony_ci * Copyright (C) 2001 PPC 64 Team, IBM Corp 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_cienum rtas_function_index { 2062306a36Sopenharmony_ci RTAS_FNIDX__CHECK_EXCEPTION, 2162306a36Sopenharmony_ci RTAS_FNIDX__DISPLAY_CHARACTER, 2262306a36Sopenharmony_ci RTAS_FNIDX__EVENT_SCAN, 2362306a36Sopenharmony_ci RTAS_FNIDX__FREEZE_TIME_BASE, 2462306a36Sopenharmony_ci RTAS_FNIDX__GET_POWER_LEVEL, 2562306a36Sopenharmony_ci RTAS_FNIDX__GET_SENSOR_STATE, 2662306a36Sopenharmony_ci RTAS_FNIDX__GET_TERM_CHAR, 2762306a36Sopenharmony_ci RTAS_FNIDX__GET_TIME_OF_DAY, 2862306a36Sopenharmony_ci RTAS_FNIDX__IBM_ACTIVATE_FIRMWARE, 2962306a36Sopenharmony_ci RTAS_FNIDX__IBM_CBE_START_PTCAL, 3062306a36Sopenharmony_ci RTAS_FNIDX__IBM_CBE_STOP_PTCAL, 3162306a36Sopenharmony_ci RTAS_FNIDX__IBM_CHANGE_MSI, 3262306a36Sopenharmony_ci RTAS_FNIDX__IBM_CLOSE_ERRINJCT, 3362306a36Sopenharmony_ci RTAS_FNIDX__IBM_CONFIGURE_BRIDGE, 3462306a36Sopenharmony_ci RTAS_FNIDX__IBM_CONFIGURE_CONNECTOR, 3562306a36Sopenharmony_ci RTAS_FNIDX__IBM_CONFIGURE_KERNEL_DUMP, 3662306a36Sopenharmony_ci RTAS_FNIDX__IBM_CONFIGURE_PE, 3762306a36Sopenharmony_ci RTAS_FNIDX__IBM_CREATE_PE_DMA_WINDOW, 3862306a36Sopenharmony_ci RTAS_FNIDX__IBM_DISPLAY_MESSAGE, 3962306a36Sopenharmony_ci RTAS_FNIDX__IBM_ERRINJCT, 4062306a36Sopenharmony_ci RTAS_FNIDX__IBM_EXTI2C, 4162306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_CONFIG_ADDR_INFO, 4262306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_CONFIG_ADDR_INFO2, 4362306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_DYNAMIC_SENSOR_STATE, 4462306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_INDICES, 4562306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_RIO_TOPOLOGY, 4662306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_SYSTEM_PARAMETER, 4762306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_VPD, 4862306a36Sopenharmony_ci RTAS_FNIDX__IBM_GET_XIVE, 4962306a36Sopenharmony_ci RTAS_FNIDX__IBM_INT_OFF, 5062306a36Sopenharmony_ci RTAS_FNIDX__IBM_INT_ON, 5162306a36Sopenharmony_ci RTAS_FNIDX__IBM_IO_QUIESCE_ACK, 5262306a36Sopenharmony_ci RTAS_FNIDX__IBM_LPAR_PERFTOOLS, 5362306a36Sopenharmony_ci RTAS_FNIDX__IBM_MANAGE_FLASH_IMAGE, 5462306a36Sopenharmony_ci RTAS_FNIDX__IBM_MANAGE_STORAGE_PRESERVATION, 5562306a36Sopenharmony_ci RTAS_FNIDX__IBM_NMI_INTERLOCK, 5662306a36Sopenharmony_ci RTAS_FNIDX__IBM_NMI_REGISTER, 5762306a36Sopenharmony_ci RTAS_FNIDX__IBM_OPEN_ERRINJCT, 5862306a36Sopenharmony_ci RTAS_FNIDX__IBM_OPEN_SRIOV_ALLOW_UNFREEZE, 5962306a36Sopenharmony_ci RTAS_FNIDX__IBM_OPEN_SRIOV_MAP_PE_NUMBER, 6062306a36Sopenharmony_ci RTAS_FNIDX__IBM_OS_TERM, 6162306a36Sopenharmony_ci RTAS_FNIDX__IBM_PARTNER_CONTROL, 6262306a36Sopenharmony_ci RTAS_FNIDX__IBM_PHYSICAL_ATTESTATION, 6362306a36Sopenharmony_ci RTAS_FNIDX__IBM_PLATFORM_DUMP, 6462306a36Sopenharmony_ci RTAS_FNIDX__IBM_POWER_OFF_UPS, 6562306a36Sopenharmony_ci RTAS_FNIDX__IBM_QUERY_INTERRUPT_SOURCE_NUMBER, 6662306a36Sopenharmony_ci RTAS_FNIDX__IBM_QUERY_PE_DMA_WINDOW, 6762306a36Sopenharmony_ci RTAS_FNIDX__IBM_READ_PCI_CONFIG, 6862306a36Sopenharmony_ci RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE, 6962306a36Sopenharmony_ci RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2, 7062306a36Sopenharmony_ci RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW, 7162306a36Sopenharmony_ci RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW, 7262306a36Sopenharmony_ci RTAS_FNIDX__IBM_SCAN_LOG_DUMP, 7362306a36Sopenharmony_ci RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR, 7462306a36Sopenharmony_ci RTAS_FNIDX__IBM_SET_EEH_OPTION, 7562306a36Sopenharmony_ci RTAS_FNIDX__IBM_SET_SLOT_RESET, 7662306a36Sopenharmony_ci RTAS_FNIDX__IBM_SET_SYSTEM_PARAMETER, 7762306a36Sopenharmony_ci RTAS_FNIDX__IBM_SET_XIVE, 7862306a36Sopenharmony_ci RTAS_FNIDX__IBM_SLOT_ERROR_DETAIL, 7962306a36Sopenharmony_ci RTAS_FNIDX__IBM_SUSPEND_ME, 8062306a36Sopenharmony_ci RTAS_FNIDX__IBM_TUNE_DMA_PARMS, 8162306a36Sopenharmony_ci RTAS_FNIDX__IBM_UPDATE_FLASH_64_AND_REBOOT, 8262306a36Sopenharmony_ci RTAS_FNIDX__IBM_UPDATE_NODES, 8362306a36Sopenharmony_ci RTAS_FNIDX__IBM_UPDATE_PROPERTIES, 8462306a36Sopenharmony_ci RTAS_FNIDX__IBM_VALIDATE_FLASH_IMAGE, 8562306a36Sopenharmony_ci RTAS_FNIDX__IBM_WRITE_PCI_CONFIG, 8662306a36Sopenharmony_ci RTAS_FNIDX__NVRAM_FETCH, 8762306a36Sopenharmony_ci RTAS_FNIDX__NVRAM_STORE, 8862306a36Sopenharmony_ci RTAS_FNIDX__POWER_OFF, 8962306a36Sopenharmony_ci RTAS_FNIDX__PUT_TERM_CHAR, 9062306a36Sopenharmony_ci RTAS_FNIDX__QUERY_CPU_STOPPED_STATE, 9162306a36Sopenharmony_ci RTAS_FNIDX__READ_PCI_CONFIG, 9262306a36Sopenharmony_ci RTAS_FNIDX__RTAS_LAST_ERROR, 9362306a36Sopenharmony_ci RTAS_FNIDX__SET_INDICATOR, 9462306a36Sopenharmony_ci RTAS_FNIDX__SET_POWER_LEVEL, 9562306a36Sopenharmony_ci RTAS_FNIDX__SET_TIME_FOR_POWER_ON, 9662306a36Sopenharmony_ci RTAS_FNIDX__SET_TIME_OF_DAY, 9762306a36Sopenharmony_ci RTAS_FNIDX__START_CPU, 9862306a36Sopenharmony_ci RTAS_FNIDX__STOP_SELF, 9962306a36Sopenharmony_ci RTAS_FNIDX__SYSTEM_REBOOT, 10062306a36Sopenharmony_ci RTAS_FNIDX__THAW_TIME_BASE, 10162306a36Sopenharmony_ci RTAS_FNIDX__WRITE_PCI_CONFIG, 10262306a36Sopenharmony_ci}; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* 10562306a36Sopenharmony_ci * Opaque handle for client code to refer to RTAS functions. All valid 10662306a36Sopenharmony_ci * function handles are build-time constants prefixed with RTAS_FN_. 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_citypedef struct { 10962306a36Sopenharmony_ci const enum rtas_function_index index; 11062306a36Sopenharmony_ci} rtas_fn_handle_t; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci#define rtas_fn_handle(x_) ((const rtas_fn_handle_t) { .index = x_, }) 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci#define RTAS_FN_CHECK_EXCEPTION rtas_fn_handle(RTAS_FNIDX__CHECK_EXCEPTION) 11662306a36Sopenharmony_ci#define RTAS_FN_DISPLAY_CHARACTER rtas_fn_handle(RTAS_FNIDX__DISPLAY_CHARACTER) 11762306a36Sopenharmony_ci#define RTAS_FN_EVENT_SCAN rtas_fn_handle(RTAS_FNIDX__EVENT_SCAN) 11862306a36Sopenharmony_ci#define RTAS_FN_FREEZE_TIME_BASE rtas_fn_handle(RTAS_FNIDX__FREEZE_TIME_BASE) 11962306a36Sopenharmony_ci#define RTAS_FN_GET_POWER_LEVEL rtas_fn_handle(RTAS_FNIDX__GET_POWER_LEVEL) 12062306a36Sopenharmony_ci#define RTAS_FN_GET_SENSOR_STATE rtas_fn_handle(RTAS_FNIDX__GET_SENSOR_STATE) 12162306a36Sopenharmony_ci#define RTAS_FN_GET_TERM_CHAR rtas_fn_handle(RTAS_FNIDX__GET_TERM_CHAR) 12262306a36Sopenharmony_ci#define RTAS_FN_GET_TIME_OF_DAY rtas_fn_handle(RTAS_FNIDX__GET_TIME_OF_DAY) 12362306a36Sopenharmony_ci#define RTAS_FN_IBM_ACTIVATE_FIRMWARE rtas_fn_handle(RTAS_FNIDX__IBM_ACTIVATE_FIRMWARE) 12462306a36Sopenharmony_ci#define RTAS_FN_IBM_CBE_START_PTCAL rtas_fn_handle(RTAS_FNIDX__IBM_CBE_START_PTCAL) 12562306a36Sopenharmony_ci#define RTAS_FN_IBM_CBE_STOP_PTCAL rtas_fn_handle(RTAS_FNIDX__IBM_CBE_STOP_PTCAL) 12662306a36Sopenharmony_ci#define RTAS_FN_IBM_CHANGE_MSI rtas_fn_handle(RTAS_FNIDX__IBM_CHANGE_MSI) 12762306a36Sopenharmony_ci#define RTAS_FN_IBM_CLOSE_ERRINJCT rtas_fn_handle(RTAS_FNIDX__IBM_CLOSE_ERRINJCT) 12862306a36Sopenharmony_ci#define RTAS_FN_IBM_CONFIGURE_BRIDGE rtas_fn_handle(RTAS_FNIDX__IBM_CONFIGURE_BRIDGE) 12962306a36Sopenharmony_ci#define RTAS_FN_IBM_CONFIGURE_CONNECTOR rtas_fn_handle(RTAS_FNIDX__IBM_CONFIGURE_CONNECTOR) 13062306a36Sopenharmony_ci#define RTAS_FN_IBM_CONFIGURE_KERNEL_DUMP rtas_fn_handle(RTAS_FNIDX__IBM_CONFIGURE_KERNEL_DUMP) 13162306a36Sopenharmony_ci#define RTAS_FN_IBM_CONFIGURE_PE rtas_fn_handle(RTAS_FNIDX__IBM_CONFIGURE_PE) 13262306a36Sopenharmony_ci#define RTAS_FN_IBM_CREATE_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_CREATE_PE_DMA_WINDOW) 13362306a36Sopenharmony_ci#define RTAS_FN_IBM_DISPLAY_MESSAGE rtas_fn_handle(RTAS_FNIDX__IBM_DISPLAY_MESSAGE) 13462306a36Sopenharmony_ci#define RTAS_FN_IBM_ERRINJCT rtas_fn_handle(RTAS_FNIDX__IBM_ERRINJCT) 13562306a36Sopenharmony_ci#define RTAS_FN_IBM_EXTI2C rtas_fn_handle(RTAS_FNIDX__IBM_EXTI2C) 13662306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_CONFIG_ADDR_INFO rtas_fn_handle(RTAS_FNIDX__IBM_GET_CONFIG_ADDR_INFO) 13762306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_CONFIG_ADDR_INFO2 rtas_fn_handle(RTAS_FNIDX__IBM_GET_CONFIG_ADDR_INFO2) 13862306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_DYNAMIC_SENSOR_STATE rtas_fn_handle(RTAS_FNIDX__IBM_GET_DYNAMIC_SENSOR_STATE) 13962306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_INDICES rtas_fn_handle(RTAS_FNIDX__IBM_GET_INDICES) 14062306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_RIO_TOPOLOGY rtas_fn_handle(RTAS_FNIDX__IBM_GET_RIO_TOPOLOGY) 14162306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_SYSTEM_PARAMETER rtas_fn_handle(RTAS_FNIDX__IBM_GET_SYSTEM_PARAMETER) 14262306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_VPD rtas_fn_handle(RTAS_FNIDX__IBM_GET_VPD) 14362306a36Sopenharmony_ci#define RTAS_FN_IBM_GET_XIVE rtas_fn_handle(RTAS_FNIDX__IBM_GET_XIVE) 14462306a36Sopenharmony_ci#define RTAS_FN_IBM_INT_OFF rtas_fn_handle(RTAS_FNIDX__IBM_INT_OFF) 14562306a36Sopenharmony_ci#define RTAS_FN_IBM_INT_ON rtas_fn_handle(RTAS_FNIDX__IBM_INT_ON) 14662306a36Sopenharmony_ci#define RTAS_FN_IBM_IO_QUIESCE_ACK rtas_fn_handle(RTAS_FNIDX__IBM_IO_QUIESCE_ACK) 14762306a36Sopenharmony_ci#define RTAS_FN_IBM_LPAR_PERFTOOLS rtas_fn_handle(RTAS_FNIDX__IBM_LPAR_PERFTOOLS) 14862306a36Sopenharmony_ci#define RTAS_FN_IBM_MANAGE_FLASH_IMAGE rtas_fn_handle(RTAS_FNIDX__IBM_MANAGE_FLASH_IMAGE) 14962306a36Sopenharmony_ci#define RTAS_FN_IBM_MANAGE_STORAGE_PRESERVATION rtas_fn_handle(RTAS_FNIDX__IBM_MANAGE_STORAGE_PRESERVATION) 15062306a36Sopenharmony_ci#define RTAS_FN_IBM_NMI_INTERLOCK rtas_fn_handle(RTAS_FNIDX__IBM_NMI_INTERLOCK) 15162306a36Sopenharmony_ci#define RTAS_FN_IBM_NMI_REGISTER rtas_fn_handle(RTAS_FNIDX__IBM_NMI_REGISTER) 15262306a36Sopenharmony_ci#define RTAS_FN_IBM_OPEN_ERRINJCT rtas_fn_handle(RTAS_FNIDX__IBM_OPEN_ERRINJCT) 15362306a36Sopenharmony_ci#define RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE rtas_fn_handle(RTAS_FNIDX__IBM_OPEN_SRIOV_ALLOW_UNFREEZE) 15462306a36Sopenharmony_ci#define RTAS_FN_IBM_OPEN_SRIOV_MAP_PE_NUMBER rtas_fn_handle(RTAS_FNIDX__IBM_OPEN_SRIOV_MAP_PE_NUMBER) 15562306a36Sopenharmony_ci#define RTAS_FN_IBM_OS_TERM rtas_fn_handle(RTAS_FNIDX__IBM_OS_TERM) 15662306a36Sopenharmony_ci#define RTAS_FN_IBM_PARTNER_CONTROL rtas_fn_handle(RTAS_FNIDX__IBM_PARTNER_CONTROL) 15762306a36Sopenharmony_ci#define RTAS_FN_IBM_PHYSICAL_ATTESTATION rtas_fn_handle(RTAS_FNIDX__IBM_PHYSICAL_ATTESTATION) 15862306a36Sopenharmony_ci#define RTAS_FN_IBM_PLATFORM_DUMP rtas_fn_handle(RTAS_FNIDX__IBM_PLATFORM_DUMP) 15962306a36Sopenharmony_ci#define RTAS_FN_IBM_POWER_OFF_UPS rtas_fn_handle(RTAS_FNIDX__IBM_POWER_OFF_UPS) 16062306a36Sopenharmony_ci#define RTAS_FN_IBM_QUERY_INTERRUPT_SOURCE_NUMBER rtas_fn_handle(RTAS_FNIDX__IBM_QUERY_INTERRUPT_SOURCE_NUMBER) 16162306a36Sopenharmony_ci#define RTAS_FN_IBM_QUERY_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_QUERY_PE_DMA_WINDOW) 16262306a36Sopenharmony_ci#define RTAS_FN_IBM_READ_PCI_CONFIG rtas_fn_handle(RTAS_FNIDX__IBM_READ_PCI_CONFIG) 16362306a36Sopenharmony_ci#define RTAS_FN_IBM_READ_SLOT_RESET_STATE rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE) 16462306a36Sopenharmony_ci#define RTAS_FN_IBM_READ_SLOT_RESET_STATE2 rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2) 16562306a36Sopenharmony_ci#define RTAS_FN_IBM_REMOVE_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW) 16662306a36Sopenharmony_ci#define RTAS_FN_IBM_RESET_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW) 16762306a36Sopenharmony_ci#define RTAS_FN_IBM_SCAN_LOG_DUMP rtas_fn_handle(RTAS_FNIDX__IBM_SCAN_LOG_DUMP) 16862306a36Sopenharmony_ci#define RTAS_FN_IBM_SET_DYNAMIC_INDICATOR rtas_fn_handle(RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR) 16962306a36Sopenharmony_ci#define RTAS_FN_IBM_SET_EEH_OPTION rtas_fn_handle(RTAS_FNIDX__IBM_SET_EEH_OPTION) 17062306a36Sopenharmony_ci#define RTAS_FN_IBM_SET_SLOT_RESET rtas_fn_handle(RTAS_FNIDX__IBM_SET_SLOT_RESET) 17162306a36Sopenharmony_ci#define RTAS_FN_IBM_SET_SYSTEM_PARAMETER rtas_fn_handle(RTAS_FNIDX__IBM_SET_SYSTEM_PARAMETER) 17262306a36Sopenharmony_ci#define RTAS_FN_IBM_SET_XIVE rtas_fn_handle(RTAS_FNIDX__IBM_SET_XIVE) 17362306a36Sopenharmony_ci#define RTAS_FN_IBM_SLOT_ERROR_DETAIL rtas_fn_handle(RTAS_FNIDX__IBM_SLOT_ERROR_DETAIL) 17462306a36Sopenharmony_ci#define RTAS_FN_IBM_SUSPEND_ME rtas_fn_handle(RTAS_FNIDX__IBM_SUSPEND_ME) 17562306a36Sopenharmony_ci#define RTAS_FN_IBM_TUNE_DMA_PARMS rtas_fn_handle(RTAS_FNIDX__IBM_TUNE_DMA_PARMS) 17662306a36Sopenharmony_ci#define RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT rtas_fn_handle(RTAS_FNIDX__IBM_UPDATE_FLASH_64_AND_REBOOT) 17762306a36Sopenharmony_ci#define RTAS_FN_IBM_UPDATE_NODES rtas_fn_handle(RTAS_FNIDX__IBM_UPDATE_NODES) 17862306a36Sopenharmony_ci#define RTAS_FN_IBM_UPDATE_PROPERTIES rtas_fn_handle(RTAS_FNIDX__IBM_UPDATE_PROPERTIES) 17962306a36Sopenharmony_ci#define RTAS_FN_IBM_VALIDATE_FLASH_IMAGE rtas_fn_handle(RTAS_FNIDX__IBM_VALIDATE_FLASH_IMAGE) 18062306a36Sopenharmony_ci#define RTAS_FN_IBM_WRITE_PCI_CONFIG rtas_fn_handle(RTAS_FNIDX__IBM_WRITE_PCI_CONFIG) 18162306a36Sopenharmony_ci#define RTAS_FN_NVRAM_FETCH rtas_fn_handle(RTAS_FNIDX__NVRAM_FETCH) 18262306a36Sopenharmony_ci#define RTAS_FN_NVRAM_STORE rtas_fn_handle(RTAS_FNIDX__NVRAM_STORE) 18362306a36Sopenharmony_ci#define RTAS_FN_POWER_OFF rtas_fn_handle(RTAS_FNIDX__POWER_OFF) 18462306a36Sopenharmony_ci#define RTAS_FN_PUT_TERM_CHAR rtas_fn_handle(RTAS_FNIDX__PUT_TERM_CHAR) 18562306a36Sopenharmony_ci#define RTAS_FN_QUERY_CPU_STOPPED_STATE rtas_fn_handle(RTAS_FNIDX__QUERY_CPU_STOPPED_STATE) 18662306a36Sopenharmony_ci#define RTAS_FN_READ_PCI_CONFIG rtas_fn_handle(RTAS_FNIDX__READ_PCI_CONFIG) 18762306a36Sopenharmony_ci#define RTAS_FN_RTAS_LAST_ERROR rtas_fn_handle(RTAS_FNIDX__RTAS_LAST_ERROR) 18862306a36Sopenharmony_ci#define RTAS_FN_SET_INDICATOR rtas_fn_handle(RTAS_FNIDX__SET_INDICATOR) 18962306a36Sopenharmony_ci#define RTAS_FN_SET_POWER_LEVEL rtas_fn_handle(RTAS_FNIDX__SET_POWER_LEVEL) 19062306a36Sopenharmony_ci#define RTAS_FN_SET_TIME_FOR_POWER_ON rtas_fn_handle(RTAS_FNIDX__SET_TIME_FOR_POWER_ON) 19162306a36Sopenharmony_ci#define RTAS_FN_SET_TIME_OF_DAY rtas_fn_handle(RTAS_FNIDX__SET_TIME_OF_DAY) 19262306a36Sopenharmony_ci#define RTAS_FN_START_CPU rtas_fn_handle(RTAS_FNIDX__START_CPU) 19362306a36Sopenharmony_ci#define RTAS_FN_STOP_SELF rtas_fn_handle(RTAS_FNIDX__STOP_SELF) 19462306a36Sopenharmony_ci#define RTAS_FN_SYSTEM_REBOOT rtas_fn_handle(RTAS_FNIDX__SYSTEM_REBOOT) 19562306a36Sopenharmony_ci#define RTAS_FN_THAW_TIME_BASE rtas_fn_handle(RTAS_FNIDX__THAW_TIME_BASE) 19662306a36Sopenharmony_ci#define RTAS_FN_WRITE_PCI_CONFIG rtas_fn_handle(RTAS_FNIDX__WRITE_PCI_CONFIG) 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci#define RTAS_UNKNOWN_SERVICE (-1) 19962306a36Sopenharmony_ci#define RTAS_INSTANTIATE_MAX (1ULL<<30) /* Don't instantiate rtas at/above this value */ 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci/* Memory set aside for sys_rtas to use with calls that need a work area. */ 20262306a36Sopenharmony_ci#define RTAS_USER_REGION_SIZE (64 * 1024) 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* RTAS return status codes */ 20562306a36Sopenharmony_ci#define RTAS_HARDWARE_ERROR -1 /* Hardware Error */ 20662306a36Sopenharmony_ci#define RTAS_BUSY -2 /* RTAS Busy */ 20762306a36Sopenharmony_ci#define RTAS_INVALID_PARAMETER -3 /* Invalid indicator/domain/sensor etc. */ 20862306a36Sopenharmony_ci#define RTAS_EXTENDED_DELAY_MIN 9900 20962306a36Sopenharmony_ci#define RTAS_EXTENDED_DELAY_MAX 9905 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci/* statuses specific to ibm,suspend-me */ 21262306a36Sopenharmony_ci#define RTAS_SUSPEND_ABORTED 9000 /* Suspension aborted */ 21362306a36Sopenharmony_ci#define RTAS_NOT_SUSPENDABLE -9004 /* Partition not suspendable */ 21462306a36Sopenharmony_ci#define RTAS_THREADS_ACTIVE -9005 /* Multiple processor threads active */ 21562306a36Sopenharmony_ci#define RTAS_OUTSTANDING_COPROC -9006 /* Outstanding coprocessor operations */ 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci/* RTAS event classes */ 21862306a36Sopenharmony_ci#define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */ 21962306a36Sopenharmony_ci#define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */ 22062306a36Sopenharmony_ci#define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */ 22162306a36Sopenharmony_ci#define RTAS_IO_EVENTS 0x08000000 /* set bit 4 */ 22262306a36Sopenharmony_ci#define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci/* RTAS event severity */ 22562306a36Sopenharmony_ci#define RTAS_SEVERITY_FATAL 0x5 22662306a36Sopenharmony_ci#define RTAS_SEVERITY_ERROR 0x4 22762306a36Sopenharmony_ci#define RTAS_SEVERITY_ERROR_SYNC 0x3 22862306a36Sopenharmony_ci#define RTAS_SEVERITY_WARNING 0x2 22962306a36Sopenharmony_ci#define RTAS_SEVERITY_EVENT 0x1 23062306a36Sopenharmony_ci#define RTAS_SEVERITY_NO_ERROR 0x0 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci/* RTAS event disposition */ 23362306a36Sopenharmony_ci#define RTAS_DISP_FULLY_RECOVERED 0x0 23462306a36Sopenharmony_ci#define RTAS_DISP_LIMITED_RECOVERY 0x1 23562306a36Sopenharmony_ci#define RTAS_DISP_NOT_RECOVERED 0x2 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci/* RTAS event initiator */ 23862306a36Sopenharmony_ci#define RTAS_INITIATOR_UNKNOWN 0x0 23962306a36Sopenharmony_ci#define RTAS_INITIATOR_CPU 0x1 24062306a36Sopenharmony_ci#define RTAS_INITIATOR_PCI 0x2 24162306a36Sopenharmony_ci#define RTAS_INITIATOR_ISA 0x3 24262306a36Sopenharmony_ci#define RTAS_INITIATOR_MEMORY 0x4 24362306a36Sopenharmony_ci#define RTAS_INITIATOR_POWERMGM 0x5 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci/* RTAS event target */ 24662306a36Sopenharmony_ci#define RTAS_TARGET_UNKNOWN 0x0 24762306a36Sopenharmony_ci#define RTAS_TARGET_CPU 0x1 24862306a36Sopenharmony_ci#define RTAS_TARGET_PCI 0x2 24962306a36Sopenharmony_ci#define RTAS_TARGET_ISA 0x3 25062306a36Sopenharmony_ci#define RTAS_TARGET_MEMORY 0x4 25162306a36Sopenharmony_ci#define RTAS_TARGET_POWERMGM 0x5 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci/* RTAS event type */ 25462306a36Sopenharmony_ci#define RTAS_TYPE_RETRY 0x01 25562306a36Sopenharmony_ci#define RTAS_TYPE_TCE_ERR 0x02 25662306a36Sopenharmony_ci#define RTAS_TYPE_INTERN_DEV_FAIL 0x03 25762306a36Sopenharmony_ci#define RTAS_TYPE_TIMEOUT 0x04 25862306a36Sopenharmony_ci#define RTAS_TYPE_DATA_PARITY 0x05 25962306a36Sopenharmony_ci#define RTAS_TYPE_ADDR_PARITY 0x06 26062306a36Sopenharmony_ci#define RTAS_TYPE_CACHE_PARITY 0x07 26162306a36Sopenharmony_ci#define RTAS_TYPE_ADDR_INVALID 0x08 26262306a36Sopenharmony_ci#define RTAS_TYPE_ECC_UNCORR 0x09 26362306a36Sopenharmony_ci#define RTAS_TYPE_ECC_CORR 0x0a 26462306a36Sopenharmony_ci#define RTAS_TYPE_EPOW 0x40 26562306a36Sopenharmony_ci#define RTAS_TYPE_PLATFORM 0xE0 26662306a36Sopenharmony_ci#define RTAS_TYPE_IO 0xE1 26762306a36Sopenharmony_ci#define RTAS_TYPE_INFO 0xE2 26862306a36Sopenharmony_ci#define RTAS_TYPE_DEALLOC 0xE3 26962306a36Sopenharmony_ci#define RTAS_TYPE_DUMP 0xE4 27062306a36Sopenharmony_ci#define RTAS_TYPE_HOTPLUG 0xE5 27162306a36Sopenharmony_ci/* I don't add PowerMGM events right now, this is a different topic */ 27262306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_POWER_SW_ON 0x60 27362306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61 27462306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_LID_OPEN 0x62 27562306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_LID_CLOSE 0x63 27662306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_SLEEP_BTN 0x64 27762306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_WAKE_BTN 0x65 27862306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_BATTERY_WARN 0x66 27962306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_BATTERY_CRIT 0x67 28062306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_SWITCH_TO_BAT 0x68 28162306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_SWITCH_TO_AC 0x69 28262306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_KBD_OR_MOUSE 0x6a 28362306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_ENCLOS_OPEN 0x6b 28462306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_ENCLOS_CLOSED 0x6c 28562306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_RING_INDICATE 0x6d 28662306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_LAN_ATTENTION 0x6e 28762306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_TIME_ALARM 0x6f 28862306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_CONFIG_CHANGE 0x70 28962306a36Sopenharmony_ci#define RTAS_TYPE_PMGM_SERVICE_PROC 0x71 29062306a36Sopenharmony_ci/* Platform Resource Reassignment Notification */ 29162306a36Sopenharmony_ci#define RTAS_TYPE_PRRN 0xA0 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci/* RTAS check-exception vector offset */ 29462306a36Sopenharmony_ci#define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_cistatic inline uint8_t rtas_error_severity(const struct rtas_error_log *elog) 29762306a36Sopenharmony_ci{ 29862306a36Sopenharmony_ci return (elog->byte1 & 0xE0) >> 5; 29962306a36Sopenharmony_ci} 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_cistatic inline uint8_t rtas_error_disposition(const struct rtas_error_log *elog) 30262306a36Sopenharmony_ci{ 30362306a36Sopenharmony_ci return (elog->byte1 & 0x18) >> 3; 30462306a36Sopenharmony_ci} 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_cistatic inline 30762306a36Sopenharmony_civoid rtas_set_disposition_recovered(struct rtas_error_log *elog) 30862306a36Sopenharmony_ci{ 30962306a36Sopenharmony_ci elog->byte1 &= ~0x18; 31062306a36Sopenharmony_ci elog->byte1 |= (RTAS_DISP_FULLY_RECOVERED << 3); 31162306a36Sopenharmony_ci} 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_cistatic inline uint8_t rtas_error_extended(const struct rtas_error_log *elog) 31462306a36Sopenharmony_ci{ 31562306a36Sopenharmony_ci return (elog->byte1 & 0x04) >> 2; 31662306a36Sopenharmony_ci} 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_cistatic inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog) 31962306a36Sopenharmony_ci{ 32062306a36Sopenharmony_ci return (elog->byte2 & 0xf0) >> 4; 32162306a36Sopenharmony_ci} 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci#define rtas_error_type(x) ((x)->byte3) 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_cistatic inline 32662306a36Sopenharmony_ciuint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog) 32762306a36Sopenharmony_ci{ 32862306a36Sopenharmony_ci return be32_to_cpu(elog->extended_log_length); 32962306a36Sopenharmony_ci} 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci#define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8)) 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_cistatic 33662306a36Sopenharmony_ciinline uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log) 33762306a36Sopenharmony_ci{ 33862306a36Sopenharmony_ci return ext_log->byte2 & 0x0F; 33962306a36Sopenharmony_ci} 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_cistatic 34262306a36Sopenharmony_ciinline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log) 34362306a36Sopenharmony_ci{ 34462306a36Sopenharmony_ci return be32_to_cpu(ext_log->company_id); 34562306a36Sopenharmony_ci} 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci/* pSeries event log format */ 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci/* Two bytes ASCII section IDs */ 35062306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_PRIV_HDR (('P' << 8) | 'H') 35162306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_USER_HDR (('U' << 8) | 'H') 35262306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_PRIMARY_SRC (('P' << 8) | 'S') 35362306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_EXTENDED_UH (('E' << 8) | 'H') 35462306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_FAILING_MTMS (('M' << 8) | 'T') 35562306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_SECONDARY_SRC (('S' << 8) | 'S') 35662306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_DUMP_LOCATOR (('D' << 8) | 'H') 35762306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_FW_ERROR (('S' << 8) | 'W') 35862306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_IMPACT_PART_ID (('L' << 8) | 'P') 35962306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_LOGIC_RESOURCE_ID (('L' << 8) | 'R') 36062306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M') 36162306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P') 36262306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E') 36362306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I') 36462306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H') 36562306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D') 36662306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_HOTPLUG (('H' << 8) | 'P') 36762306a36Sopenharmony_ci#define PSERIES_ELOG_SECT_ID_MCE (('M' << 8) | 'C') 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_cistatic 37062306a36Sopenharmony_ciinline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect) 37162306a36Sopenharmony_ci{ 37262306a36Sopenharmony_ci return be16_to_cpu(sect->id); 37362306a36Sopenharmony_ci} 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_cistatic 37662306a36Sopenharmony_ciinline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect) 37762306a36Sopenharmony_ci{ 37862306a36Sopenharmony_ci return be16_to_cpu(sect->length); 37962306a36Sopenharmony_ci} 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci#define PSERIES_HP_ELOG_RESOURCE_CPU 1 38262306a36Sopenharmony_ci#define PSERIES_HP_ELOG_RESOURCE_MEM 2 38362306a36Sopenharmony_ci#define PSERIES_HP_ELOG_RESOURCE_SLOT 3 38462306a36Sopenharmony_ci#define PSERIES_HP_ELOG_RESOURCE_PHB 4 38562306a36Sopenharmony_ci#define PSERIES_HP_ELOG_RESOURCE_PMEM 6 38662306a36Sopenharmony_ci 38762306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ACTION_ADD 1 38862306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ACTION_REMOVE 2 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ID_DRC_NAME 1 39162306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ID_DRC_INDEX 2 39262306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ID_DRC_COUNT 3 39362306a36Sopenharmony_ci#define PSERIES_HP_ELOG_ID_DRC_IC 4 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_cistruct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, 39662306a36Sopenharmony_ci uint16_t section_id); 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci/* 39962306a36Sopenharmony_ci * This can be set by the rtas_flash module so that it can get called 40062306a36Sopenharmony_ci * as the absolutely last thing before the kernel terminates. 40162306a36Sopenharmony_ci */ 40262306a36Sopenharmony_ciextern void (*rtas_flash_term_hook)(int); 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ciextern struct rtas_t rtas; 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_cis32 rtas_function_token(const rtas_fn_handle_t handle); 40762306a36Sopenharmony_cistatic inline bool rtas_function_implemented(const rtas_fn_handle_t handle) 40862306a36Sopenharmony_ci{ 40962306a36Sopenharmony_ci return rtas_function_token(handle) != RTAS_UNKNOWN_SERVICE; 41062306a36Sopenharmony_ci} 41162306a36Sopenharmony_ciextern int rtas_token(const char *service); 41262306a36Sopenharmony_ciextern int rtas_service_present(const char *service); 41362306a36Sopenharmony_ciextern int rtas_call(int token, int, int, int *, ...); 41462306a36Sopenharmony_civoid rtas_call_unlocked(struct rtas_args *args, int token, int nargs, 41562306a36Sopenharmony_ci int nret, ...); 41662306a36Sopenharmony_ciextern void __noreturn rtas_restart(char *cmd); 41762306a36Sopenharmony_ciextern void rtas_power_off(void); 41862306a36Sopenharmony_ciextern void __noreturn rtas_halt(void); 41962306a36Sopenharmony_ciextern void rtas_os_term(char *str); 42062306a36Sopenharmony_civoid rtas_activate_firmware(void); 42162306a36Sopenharmony_ciextern int rtas_get_sensor(int sensor, int index, int *state); 42262306a36Sopenharmony_ciextern int rtas_get_sensor_fast(int sensor, int index, int *state); 42362306a36Sopenharmony_ciextern int rtas_get_power_level(int powerdomain, int *level); 42462306a36Sopenharmony_ciextern int rtas_set_power_level(int powerdomain, int level, int *setlevel); 42562306a36Sopenharmony_ciextern bool rtas_indicator_present(int token, int *maxindex); 42662306a36Sopenharmony_ciextern int rtas_set_indicator(int indicator, int index, int new_value); 42762306a36Sopenharmony_ciextern int rtas_set_indicator_fast(int indicator, int index, int new_value); 42862306a36Sopenharmony_ciextern void rtas_progress(char *s, unsigned short hex); 42962306a36Sopenharmony_ciint rtas_ibm_suspend_me(int *fw_status); 43062306a36Sopenharmony_ciint rtas_error_rc(int rtas_rc); 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_cistruct rtc_time; 43362306a36Sopenharmony_ciextern time64_t rtas_get_boot_time(void); 43462306a36Sopenharmony_ciextern void rtas_get_rtc_time(struct rtc_time *rtc_time); 43562306a36Sopenharmony_ciextern int rtas_set_rtc_time(struct rtc_time *rtc_time); 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ciextern unsigned int rtas_busy_delay_time(int status); 43862306a36Sopenharmony_cibool rtas_busy_delay(int status); 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ciextern int early_init_dt_scan_rtas(unsigned long node, 44162306a36Sopenharmony_ci const char *uname, int depth, void *data); 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ciextern void pSeries_log_error(char *buf, unsigned int err_type, int fatal); 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES 44662306a36Sopenharmony_ciextern time64_t last_rtas_event; 44762306a36Sopenharmony_ciextern int clobbering_unread_rtas_event(void); 44862306a36Sopenharmony_ciextern void post_mobility_fixup(void); 44962306a36Sopenharmony_ciint rtas_syscall_dispatch_ibm_suspend_me(u64 handle); 45062306a36Sopenharmony_ci#else 45162306a36Sopenharmony_cistatic inline int clobbering_unread_rtas_event(void) { return 0; } 45262306a36Sopenharmony_cistatic inline int rtas_syscall_dispatch_ibm_suspend_me(u64 handle) 45362306a36Sopenharmony_ci{ 45462306a36Sopenharmony_ci return -EINVAL; 45562306a36Sopenharmony_ci} 45662306a36Sopenharmony_ci#endif 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci#ifdef CONFIG_PPC_RTAS_DAEMON 45962306a36Sopenharmony_ciextern void rtas_cancel_event_scan(void); 46062306a36Sopenharmony_ci#else 46162306a36Sopenharmony_cistatic inline void rtas_cancel_event_scan(void) { } 46262306a36Sopenharmony_ci#endif 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci/* Error types logged. */ 46562306a36Sopenharmony_ci#define ERR_FLAG_ALREADY_LOGGED 0x0 46662306a36Sopenharmony_ci#define ERR_FLAG_BOOT 0x1 /* log was pulled from NVRAM on boot */ 46762306a36Sopenharmony_ci#define ERR_TYPE_RTAS_LOG 0x2 /* from rtas event-scan */ 46862306a36Sopenharmony_ci#define ERR_TYPE_KERNEL_PANIC 0x4 /* from die()/panic() */ 46962306a36Sopenharmony_ci#define ERR_TYPE_KERNEL_PANIC_GZ 0x8 /* ditto, compressed */ 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ci/* All the types and not flags */ 47262306a36Sopenharmony_ci#define ERR_TYPE_MASK \ 47362306a36Sopenharmony_ci (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC | ERR_TYPE_KERNEL_PANIC_GZ) 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_ci#define RTAS_DEBUG KERN_DEBUG "RTAS: " 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_ci#define RTAS_ERROR_LOG_MAX 2048 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ci/* 48062306a36Sopenharmony_ci * Return the firmware-specified size of the error log buffer 48162306a36Sopenharmony_ci * for all rtas calls that require an error buffer argument. 48262306a36Sopenharmony_ci * This includes 'check-exception' and 'rtas-last-error'. 48362306a36Sopenharmony_ci */ 48462306a36Sopenharmony_ciextern int rtas_get_error_log_max(void); 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_ci/* Event Scan Parameters */ 48762306a36Sopenharmony_ci#define EVENT_SCAN_ALL_EVENTS 0xf0000000 48862306a36Sopenharmony_ci#define SURVEILLANCE_TOKEN 9000 48962306a36Sopenharmony_ci#define LOG_NUMBER 64 /* must be a power of two */ 49062306a36Sopenharmony_ci#define LOG_NUMBER_MASK (LOG_NUMBER-1) 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_ci/* Some RTAS ops require a data buffer and that buffer must be < 4G. 49362306a36Sopenharmony_ci * Rather than having a memory allocator, just use this buffer 49462306a36Sopenharmony_ci * (get the lock first), make the RTAS call. Copy the data instead 49562306a36Sopenharmony_ci * of holding the buffer for long. 49662306a36Sopenharmony_ci */ 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci#define RTAS_DATA_BUF_SIZE 4096 49962306a36Sopenharmony_ciextern spinlock_t rtas_data_buf_lock; 50062306a36Sopenharmony_ciextern char rtas_data_buf[RTAS_DATA_BUF_SIZE]; 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_ci/* RMO buffer reserved for user-space RTAS use */ 50362306a36Sopenharmony_ciextern unsigned long rtas_rmo_buf; 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_ci#define GLOBAL_INTERRUPT_QUEUE 9005 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci/** 50862306a36Sopenharmony_ci * rtas_config_addr - Format a busno, devfn and reg for RTAS. 50962306a36Sopenharmony_ci * @busno: The bus number. 51062306a36Sopenharmony_ci * @devfn: The device and function number as encoded by PCI_DEVFN(). 51162306a36Sopenharmony_ci * @reg: The register number. 51262306a36Sopenharmony_ci * 51362306a36Sopenharmony_ci * This function encodes the given busno, devfn and register number as 51462306a36Sopenharmony_ci * required for RTAS calls that take a "config_addr" parameter. 51562306a36Sopenharmony_ci * See PAPR requirement 7.3.4-1 for more info. 51662306a36Sopenharmony_ci */ 51762306a36Sopenharmony_cistatic inline u32 rtas_config_addr(int busno, int devfn, int reg) 51862306a36Sopenharmony_ci{ 51962306a36Sopenharmony_ci return ((reg & 0xf00) << 20) | ((busno & 0xff) << 16) | 52062306a36Sopenharmony_ci (devfn << 8) | (reg & 0xff); 52162306a36Sopenharmony_ci} 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ciextern void rtas_give_timebase(void); 52462306a36Sopenharmony_ciextern void rtas_take_timebase(void); 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci#ifdef CONFIG_PPC_RTAS 52762306a36Sopenharmony_cistatic inline int page_is_rtas_user_buf(unsigned long pfn) 52862306a36Sopenharmony_ci{ 52962306a36Sopenharmony_ci unsigned long paddr = (pfn << PAGE_SHIFT); 53062306a36Sopenharmony_ci if (paddr >= rtas_rmo_buf && paddr < (rtas_rmo_buf + RTAS_USER_REGION_SIZE)) 53162306a36Sopenharmony_ci return 1; 53262306a36Sopenharmony_ci return 0; 53362306a36Sopenharmony_ci} 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ci/* Not the best place to put pSeries_coalesce_init, will be fixed when we 53662306a36Sopenharmony_ci * move some of the rtas suspend-me stuff to pseries */ 53762306a36Sopenharmony_ciextern void pSeries_coalesce_init(void); 53862306a36Sopenharmony_civoid rtas_initialize(void); 53962306a36Sopenharmony_ci#else 54062306a36Sopenharmony_cistatic inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} 54162306a36Sopenharmony_cistatic inline void pSeries_coalesce_init(void) { } 54262306a36Sopenharmony_cistatic inline void rtas_initialize(void) { } 54362306a36Sopenharmony_ci#endif 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ciextern int call_rtas(const char *, int, int, unsigned long *, ...); 54662306a36Sopenharmony_ci 54762306a36Sopenharmony_ci#ifdef CONFIG_HV_PERF_CTRS 54862306a36Sopenharmony_civoid read_24x7_sys_info(void); 54962306a36Sopenharmony_ci#else 55062306a36Sopenharmony_cistatic inline void read_24x7_sys_info(void) { } 55162306a36Sopenharmony_ci#endif 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ci#endif /* __KERNEL__ */ 55462306a36Sopenharmony_ci#endif /* _POWERPC_RTAS_H */ 555