1 /* Copyright 2013-2014 IBM Corp. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 * implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef __PEL_H 17 #define __PEL_H 18 19 #include <compiler.h> 20 #include <errorlog.h> 21 22 /* Data Structures for PEL data. */ 23 24 #define PRIVATE_HEADER_SECTION_SIZE 48 25 #define USER_HEADER_SECTION_SIZE 24 26 #define SRC_SECTION_SIZE 80 27 #define SRC_SUBSECTION_SIZE 4 28 #define SRC_LENGTH 72 29 #define OPAL_MAX_SRC_BYTES 32 30 #define EXTENDED_HEADER_SECTION_SIZE 76 31 #define MTMS_SECTION_SIZE 28 32 #define IO_EVENT_SECTION_SIZE 16 33 34 #define OPAL_ELOG_VERSION 1 35 #define OPAL_ELOG_SST 0 36 #define OPAL_SRC_MAX_WORD_COUNT 8 37 38 #define OPAL_SRC_FORMAT 0x80 39 #define OPAL_FAILING_SUBSYSTEM 0x82 40 41 #define OPAL_SYS_MODEL_LEN 8 42 #define OPAL_SYS_SERIAL_LEN 12 43 #define OPAL_VER_LEN 16 44 #define OPAL_SYMPID_LEN 80 45 #define OPAL_RC_NONE 0 46 47 #define OPAL_IO_MAX_RPC_DATA 216 48 #define OPAL_SRC_SEC_VER 0x02 49 #define OPAL_EXT_HRD_VER 0x01 50 51 /* Error log reporting action */ 52 #define ERRL_ACTION_REPORT 0x2000 53 #define ERRL_ACTION_NONE 0x0000 54 55 enum elogSectionId { 56 ELOG_SID_PRIVATE_HEADER = 0x5048, /* PH */ 57 ELOG_SID_USER_HEADER = 0x5548, /* UH */ 58 ELOG_SID_EXTENDED_HEADER = 0x4548, /* EH */ 59 ELOG_SID_PRIMARY_SRC = 0x5053, /* PS */ 60 ELOG_SID_MACHINE_TYPE = 0x4D54, /* MT */ 61 ELOG_SID_SECONDARY_SRC = 0x5353, /* SS */ 62 ELOG_SID_CALL_HOME = 0x4348, /* CH */ 63 ELOG_SID_DUMP_LOCATOR = 0x4448, /* DH */ 64 ELOG_SID_SOFTWARE_ERROR = 0x5357, /* SW */ 65 ELOG_SID_PARTITION = 0x4C50, /* LP */ 66 ELOG_SID_LOGICAL_RESOURCE = 0x4C52, /* LR */ 67 ELOG_SID_HMC_ID = 0x484D, /* HM */ 68 ELOG_SID_EPOW = 0x4550, /* EP */ 69 ELOG_SID_IO_EVENT = 0x4945, /* IE */ 70 ELOG_SID_MFG_INFORMATION = 0x4D49, /* MI */ 71 ELOG_SID_USER_DEFINED = 0x5544 /* UD */ 72 }; 73 74 75 struct opal_v6_header { 76 enum elogSectionId id:16; /* section id */ 77 uint16_t length; /* section length */ 78 uint8_t version; /* section version */ 79 uint8_t subtype; /* section sub-type id */ 80 uint16_t component_id; /* component id of section creator */ 81 }; 82 83 /* opal_srctype */ 84 #define OPAL_SRC_TYPE_ERROR 0xBB 85 86 #define OPAL_CID_SAPPHIRE 'K' /* creator ID for sapphire log */ 87 #define OPAL_CID_POWERNV 'P' /* creator ID for powernv log */ 88 89 /* Origin of error, elog_origin */ 90 #define ORG_SAPPHIRE 1 91 #define ORG_POWERNV 2 92 93 /* MAX time for error log commit */ 94 #define ERRORLOG_TIMEOUT_INTERVAL 180 95 96 /*struct opal_private head section_ */ 97 struct opal_private_header_section { 98 99 struct opal_v6_header v6header; 100 uint32_t create_date; 101 uint32_t create_time; 102 uint32_t commit_date; 103 uint32_t commit_time; 104 105 uint32_t creator_id:8; /* subsystem component id */ 106 uint32_t reserved_0:16; 107 uint32_t section_count:8; /* number of sections in log */ 108 uint32_t reserved_1; 109 uint32_t creator_subid_hi; 110 uint32_t creator_subid_lo; 111 uint32_t plid; /* platform log id */ 112 uint32_t log_entry_id; /* Unique log entry id */ 113 }; 114 115 /* opal user header section */ 116 struct opal_user_header_section { 117 118 struct opal_v6_header v6header; 119 120 uint8_t subsystem_id; /* subsystem id */ 121 uint8_t event_scope; 122 uint8_t event_severity; 123 uint8_t event_type; /* error/event severity */ 124 125 uint32_t reserved_0; 126 uint16_t reserved_1; 127 uint16_t action_flags; /* error action code */ 128 uint32_t reserved_2; 129 }; 130 131 struct opal_src_section { 132 struct opal_v6_header v6header; 133 uint8_t version; 134 uint8_t flags; 135 uint8_t reserved_0; 136 uint8_t wordcount; 137 uint16_t reserved_1; 138 uint16_t srclength; 139 uint32_t hexwords[OPAL_SRC_MAX_WORD_COUNT]; 140 char srcstring[OPAL_MAX_SRC_BYTES]; 141 }; 142 143 struct opal_extended_header_section { 144 struct opal_v6_header v6header; 145 char model[OPAL_SYS_MODEL_LEN]; 146 char serial_no[OPAL_SYS_SERIAL_LEN]; 147 char opal_release_version[OPAL_VER_LEN]; 148 char opal_subsys_version[OPAL_VER_LEN]; 149 uint16_t reserved_0; 150 uint32_t extended_header_date; 151 uint32_t extended_header_time; 152 uint16_t reserved_1; 153 uint8_t reserved_2; 154 uint8_t opal_symid_len; 155 char opalsymid[OPAL_SYMPID_LEN]; 156 }; 157 158 /* opal MTMS section */ 159 struct opal_mtms_section { 160 struct opal_v6_header v6header; 161 char model[OPAL_SYS_MODEL_LEN]; 162 char serial_no[OPAL_SYS_SERIAL_LEN]; 163 }; 164 165 /* User defined section */ 166 struct opal_user_section { 167 struct opal_v6_header v6header; 168 char dump[1]; 169 }; 170 171 /* The minimum size of a PEL record */ 172 #define PEL_MIN_SIZE (PRIVATE_HEADER_SECTION_SIZE + USER_HEADER_SECTION_SIZE \ 173 + SRC_SECTION_SIZE + EXTENDED_HEADER_SECTION_SIZE \ 174 + MTMS_SECTION_SIZE) 175 176 size_t pel_size(struct errorlog *elog_data); 177 int create_pel_log(struct errorlog *elog_data, char *pel_buffer, 178 size_t pel_buffer_size) __warn_unused_result; 179 180 #endif 181