1 /** @file 2 Module for clarifying the content of the smbios structure element info. 3 4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #include "../UefiShellDebug1CommandsLib.h" 16 #include "PrintInfo.h" 17 #include "QueryTable.h" 18 #include "EventLogInfo.h" 19 20 /** 21 Function to display system event log access information. 22 23 @param[in] Key Additional information to print. 24 @param[in] Option Whether to print the additional information. 25 **/ 26 VOID 27 DisplaySELAccessMethod ( 28 IN CONST UINT8 Key, 29 IN CONST UINT8 Option 30 ) 31 { 32 // 33 // Print prompt 34 // 35 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ACCESS_METHOD), gShellDebug1HiiHandle); 36 PRINT_INFO_OPTION (Key, Option); 37 38 // 39 // Print value info 40 // 41 switch (Key) { 42 case 0: 43 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_EIGHT_BIT), gShellDebug1HiiHandle); 44 break; 45 46 case 1: 47 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TWO_EIGHT_BITS), gShellDebug1HiiHandle); 48 break; 49 50 case 2: 51 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_SIXTEEN_BIT), gShellDebug1HiiHandle); 52 break; 53 54 case 3: 55 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MEM_MAPPED_PHYS), gShellDebug1HiiHandle); 56 break; 57 58 case 4: 59 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_VIA_GENERAL), gShellDebug1HiiHandle); 60 break; 61 62 default: 63 if (Key <= 0x7f) { 64 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle); 65 } else { 66 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR_OEM), gShellDebug1HiiHandle); 67 } 68 } 69 } 70 71 /** 72 Function to display system event log status information. 73 74 @param[in] Key Additional information to print. 75 @param[in] Option Whether to print the additional information. 76 **/ 77 VOID 78 DisplaySELLogStatus ( 79 UINT8 Key, 80 UINT8 Option 81 ) 82 { 83 // 84 // Print prompt 85 // 86 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_STATUS), gShellDebug1HiiHandle); 87 PRINT_INFO_OPTION (Key, Option); 88 89 // 90 // Print value info 91 // 92 if ((Key & 0x01) != 0) { 93 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle); 94 } else { 95 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle); 96 } 97 98 if ((Key & 0x02) != 0) { 99 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_FULL), gShellDebug1HiiHandle); 100 } else { 101 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_NOT_FULL), gShellDebug1HiiHandle); 102 } 103 104 if ((Key & 0xFC) != 0) { 105 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RES_BITS_NOT_ZERO), gShellDebug1HiiHandle, Key & 0xFC); 106 } 107 } 108 109 /** 110 Function to display system event log header format information. 111 112 @param[in] Key Additional information to print. 113 @param[in] Option Whether to print the additional information. 114 **/ 115 VOID 116 DisplaySysEventLogHeaderFormat ( 117 UINT8 Key, 118 UINT8 Option 119 ) 120 { 121 // 122 // Print prompt 123 // 124 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_FORMAT), gShellDebug1HiiHandle); 125 PRINT_INFO_OPTION (Key, Option); 126 127 // 128 // Print value info 129 // 130 if (Key == 0x00) { 131 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle); 132 } else if (Key == 0x01) { 133 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle); 134 } else if (Key <= 0x7f) { 135 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE), gShellDebug1HiiHandle); 136 } else { 137 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle); 138 } 139 } 140 141 /** 142 Display the header information for SEL log items. 143 144 @param[in] Key The information key. 145 @param[in] Option The option index. 146 **/ 147 VOID 148 DisplaySELLogHeaderLen ( 149 UINT8 Key, 150 UINT8 Option 151 ) 152 { 153 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_LEN), gShellDebug1HiiHandle); 154 PRINT_INFO_OPTION (Key, Option); 155 156 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_VAR_D), gShellDebug1HiiHandle, Key & 0x7F); 157 158 // 159 // The most-significant bit of the field specifies 160 // whether (0) or not (1) the record has been read 161 // 162 if ((Key & 0x80) != 0) { 163 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_READ), gShellDebug1HiiHandle); 164 } else { 165 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_NOT_READ), gShellDebug1HiiHandle); 166 } 167 } 168 169 /** 170 Display the header information for type 1 items. 171 172 @param[in] LogHeader The buffer with the information. 173 **/ 174 VOID 175 DisplaySysEventLogHeaderType1 ( 176 IN UINT8 *LogHeader 177 ) 178 { 179 LOG_HEADER_TYPE1_FORMAT *Header; 180 181 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG), gShellDebug1HiiHandle); 182 183 // 184 // Print Log Header Type1 Format info 185 // 186 Header = (LOG_HEADER_TYPE1_FORMAT *) (LogHeader); 187 188 ShellPrintHiiEx(-1,-1,NULL, 189 STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_OEM_RESERVED), 190 gShellDebug1HiiHandle, 191 Header->OEMReserved[0], 192 Header->OEMReserved[1], 193 Header->OEMReserved[2], 194 Header->OEMReserved[3], 195 Header->OEMReserved[4] 196 ); 197 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_TIME), gShellDebug1HiiHandle, Header->Metw); 198 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_COUNT), gShellDebug1HiiHandle, Header->Meci); 199 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_ADDRESS), gShellDebug1HiiHandle, Header->CMOSAddress); 200 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_INDEX), gShellDebug1HiiHandle, Header->CMOSBitIndex); 201 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUM_STARTING_OFF), gShellDebug1HiiHandle, Header->StartingOffset); 202 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUN_BYTE_COUNT), gShellDebug1HiiHandle, Header->ChecksumOffset); 203 ShellPrintHiiEx(-1,-1,NULL, 204 STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RESERVED), 205 gShellDebug1HiiHandle, 206 Header->OEMReserved[0], 207 Header->OEMReserved[1], 208 Header->OEMReserved[2] 209 ); 210 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_HEADER_REVISION), gShellDebug1HiiHandle, Header->HeaderRevision); 211 } 212 213 /** 214 Function to display system event log header information. 215 216 @param[in] LogHeaderFormat Format identifier. 217 @param[in] LogHeader Format informcation. 218 **/ 219 VOID 220 DisplaySysEventLogHeader ( 221 UINT8 LogHeaderFormat, 222 UINT8 *LogHeader 223 ) 224 { 225 // 226 // Print prompt 227 // 228 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER), gShellDebug1HiiHandle); 229 230 // 231 // Print value info 232 // 233 if (LogHeaderFormat == 0x00) { 234 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle); 235 } else if (LogHeaderFormat == 0x01) { 236 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle); 237 DisplaySysEventLogHeaderType1 (LogHeader); 238 } else if (LogHeaderFormat <= 0x7f) { 239 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FUTURE_ASSIGN), gShellDebug1HiiHandle); 240 } else { 241 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle); 242 } 243 } 244 245 /** 246 Display the El Vdf information. 247 248 @param[in] ElVdfType The information type. 249 @param[in] VarData The information buffer. 250 **/ 251 VOID 252 DisplayElVdfInfo ( 253 UINT8 ElVdfType, 254 UINT8 *VarData 255 ) 256 { 257 UINT16 *Word; 258 UINT32 *Dword; 259 260 // 261 // Display Type Name 262 // 263 DisplaySELVarDataFormatType (ElVdfType, SHOW_DETAIL); 264 265 // 266 // Display Type description 267 // 268 switch (ElVdfType) { 269 case 0: 270 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_STD_FORMAT), gShellDebug1HiiHandle); 271 break; 272 273 case 1: 274 Word = (UINT16 *) (VarData + 1); 275 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle); 276 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word); 277 break; 278 279 case 2: 280 Dword = (UINT32 *) (VarData + 1); 281 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); 282 break; 283 284 case 3: 285 Word = (UINT16 *) (VarData + 1); 286 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle); 287 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word); 288 // 289 // Followed by a multiple-event counter 290 // 291 Dword = (UINT32 *) (VarData + 1); 292 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); 293 break; 294 295 case 4: 296 Dword = (UINT32 *) (VarData + 1); 297 DisplayPostResultsBitmapDw1 (*Dword, SHOW_DETAIL); 298 Dword++; 299 DisplayPostResultsBitmapDw2 (*Dword, SHOW_DETAIL); 300 break; 301 302 case 5: 303 Dword = (UINT32 *) (VarData + 1); 304 DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL); 305 break; 306 307 case 6: 308 Dword = (UINT32 *) (VarData + 1); 309 DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL); 310 // 311 // Followed by a multiple-event counter 312 // 313 Dword = (UINT32 *) (VarData + 1); 314 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword); 315 break; 316 317 default: 318 if (ElVdfType <= 0x7F) { 319 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_UNUSED_AVAIL_FOR_ASSIGN), gShellDebug1HiiHandle); 320 } else { 321 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_SYSTEM), gShellDebug1HiiHandle); 322 } 323 } 324 } 325 326 /** 327 Function to display system event log data. 328 329 @param[in] LogData The data information. 330 @param[in] LogAreaLength Length of the data. 331 **/ 332 VOID 333 DisplaySysEventLogData ( 334 UINT8 *LogData, 335 UINT16 LogAreaLength 336 ) 337 { 338 LOG_RECORD_FORMAT *Log; 339 UINT8 ElVdfType; 340 // 341 // Event Log Variable Data Format Types 342 // 343 UINTN Offset; 344 345 // 346 // Print prompt 347 // 348 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG_2), gShellDebug1HiiHandle); 349 350 // 351 // Print Log info 352 // 353 Offset = 0; 354 Log = (LOG_RECORD_FORMAT *) LogData; 355 while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) { 356 // 357 // Get a Event Log Record 358 // 359 Log = (LOG_RECORD_FORMAT *) (LogData + Offset); 360 361 if (Log != NULL) { 362 // 363 // Display Event Log Record Information 364 // 365 DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL); 366 DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL); 367 368 Offset += Log->Length; 369 // 370 // Display Log Header Date/Time Fields 371 // These fields contain the BCD representation of the date and time 372 // (as read from CMOS) of the occurrence of the event 373 // So Print as hex and represent decimal 374 // 375 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle); 376 if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) { 377 Print (L"19"); 378 } else if (Log != NULL && Log->Year <= 79) { 379 Print (L"20"); 380 } else { 381 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle); 382 continue; 383 } 384 385 ShellPrintHiiEx(-1,-1,NULL, 386 STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS), 387 gShellDebug1HiiHandle, 388 Log->Year, 389 Log->Month, 390 Log->Day, 391 Log->Hour, 392 Log->Minute, 393 Log->Second 394 ); 395 396 // 397 // Display Variable Data Format 398 // 399 if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) { 400 continue; 401 } 402 403 ElVdfType = Log->LogVariableData[0]; 404 DisplayElVdfInfo (ElVdfType, Log->LogVariableData); 405 } 406 } 407 } 408