2 Tools of clarify the content of the smbios table.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellDebug1CommandsLib.h"
17 #include "LibSmbiosView.h"
18 #include "SmbiosView.h"
19 #include "PrintInfo.h"
20 #include "QueryTable.h"
22 UINT8 gShowType
= SHOW_DETAIL
;
23 STATIC STRUCTURE_STATISTICS
*mStatisticsTable
= NULL
;
24 STATIC STRUCTURE_STATISTICS
*mSmbios64BitStatisticsTable
= NULL
;
26 UINT8 SmbiosMajorVersion
;
27 UINT8 SmbiosMinorVersion
;
29 UINTN mNumberOfSmbios64BitStructures
;
30 UINTN mSmbios64BitTableLength
;
32 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
41 Function for 'smbiosview' command.
43 @param[in] ImageHandle Handle to the Image (NULL if Internal).
44 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
48 ShellCommandRunSmbiosView (
49 IN EFI_HANDLE ImageHandle
,
50 IN EFI_SYSTEM_TABLE
*SystemTable
61 SHELL_STATUS ShellStatus
;
64 mStatisticsTable
= NULL
;
65 mSmbios64BitStatisticsTable
= NULL
;
67 ShellStatus
= SHELL_SUCCESS
;
69 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
70 if (EFI_ERROR(Status
)) {
71 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
72 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, L
"smbiosview", ProblemParam
);
73 FreePool(ProblemParam
);
74 ShellStatus
= SHELL_INVALID_PARAMETER
;
79 if (ShellCommandLineGetCount(Package
) > 1) {
80 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"smbiosview");
81 ShellStatus
= SHELL_INVALID_PARAMETER
;
82 } else if (ShellCommandLineGetFlag(Package
, L
"-t") && ShellCommandLineGetValue(Package
, L
"-t") == NULL
) {
83 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"smbiosview", L
"-t");
84 ShellStatus
= SHELL_INVALID_PARAMETER
;
85 } else if (ShellCommandLineGetFlag(Package
, L
"-h") && ShellCommandLineGetValue(Package
, L
"-h") == NULL
) {
86 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"smbiosview", L
"-h");
87 ShellStatus
= SHELL_INVALID_PARAMETER
;
89 (ShellCommandLineGetFlag(Package
, L
"-t") && ShellCommandLineGetFlag(Package
, L
"-h")) ||
90 (ShellCommandLineGetFlag(Package
, L
"-t") && ShellCommandLineGetFlag(Package
, L
"-s")) ||
91 (ShellCommandLineGetFlag(Package
, L
"-t") && ShellCommandLineGetFlag(Package
, L
"-a")) ||
92 (ShellCommandLineGetFlag(Package
, L
"-h") && ShellCommandLineGetFlag(Package
, L
"-s")) ||
93 (ShellCommandLineGetFlag(Package
, L
"-h") && ShellCommandLineGetFlag(Package
, L
"-a")) ||
94 (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetFlag(Package
, L
"-a"))
96 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"smbiosview");
97 ShellStatus
= SHELL_INVALID_PARAMETER
;
103 Status1
= LibSmbiosInit ();
104 Status2
= LibSmbios64BitInit ();
105 if (EFI_ERROR (Status1
) && EFI_ERROR (Status2
)) {
106 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE
), gShellDebug1HiiHandle
);
107 ShellStatus
= SHELL_NOT_FOUND
;
111 StructType
= STRUCTURE_TYPE_RANDOM
;
114 Temp
= ShellCommandLineGetValue(Package
, L
"-t");
116 StructType
= (UINT8
) ShellStrToUintn (Temp
);
119 if (ShellCommandLineGetFlag(Package
, L
"-a")) {
120 gShowType
= SHOW_ALL
;
123 if (!EFI_ERROR (Status1
)) {
125 // Initialize the StructHandle to be the first handle
127 StructHandle
= INVALID_HANDLE
;
128 LibGetSmbiosStructure (&StructHandle
, NULL
, NULL
);
130 Temp
= ShellCommandLineGetValue(Package
, L
"-h");
133 StructHandle
= (UINT16
) ShellStrToUintn(Temp
);
136 // build statistics table
138 Status
= InitSmbiosTableStatistics ();
139 if (EFI_ERROR (Status
)) {
140 ShellStatus
= SHELL_NOT_FOUND
;
144 if (ShellCommandLineGetFlag(Package
, L
"-s")) {
145 Status
= DisplayStatisticsTable (SHOW_DETAIL
);
146 if (EFI_ERROR(Status
)) {
147 ShellStatus
= SHELL_NOT_FOUND
;
153 // Show SMBIOS structure information
155 Status
= SMBiosView (StructType
, StructHandle
, gShowType
, RandomView
);
156 if (EFI_ERROR(Status
)) {
157 ShellStatus
= SHELL_NOT_FOUND
;
163 if (!EFI_ERROR (Status2
)) {
165 // build statistics table
167 Status
= InitSmbios64BitTableStatistics ();
168 if (EFI_ERROR (Status
)) {
169 ShellStatus
= SHELL_NOT_FOUND
;
173 // Initialize the StructHandle to be the first handle
175 StructHandle
= INVALID_HANDLE
;
176 LibGetSmbios64BitStructure (&StructHandle
, NULL
, NULL
);
178 Temp
= ShellCommandLineGetValue(Package
, L
"-h");
181 StructHandle
= (UINT16
) ShellStrToUintn(Temp
);
184 if (ShellCommandLineGetFlag(Package
, L
"-s")) {
185 Status
= DisplaySmbios64BitStatisticsTable (SHOW_DETAIL
);
186 if (EFI_ERROR(Status
)) {
187 ShellStatus
= SHELL_NOT_FOUND
;
193 // Show SMBIOS structure information
195 Status
= SMBios64View (StructType
, StructHandle
, gShowType
, RandomView
);
196 if (EFI_ERROR(Status
)) {
197 ShellStatus
= SHELL_NOT_FOUND
;
206 if (mStatisticsTable
!= NULL
) {
208 // Release statistics table
210 FreePool (mStatisticsTable
);
211 mStatisticsTable
= NULL
;
214 if (mSmbios64BitStatisticsTable
!= NULL
) {
216 // Release statistics table
218 FreePool (mSmbios64BitStatisticsTable
);
219 mSmbios64BitStatisticsTable
= NULL
;
222 if (Package
!= NULL
) {
223 ShellCommandLineFreeVarList (Package
);
227 LibSmbios64BitCleanup ();
233 Query all structures Data from SMBIOS table and Display
234 the information to users as required display option.
236 @param[in] QueryType Structure type to view.
237 @param[in] QueryHandle Structure handle to view.
238 @param[in] Option Display option: none,outline,normal,detail.
239 @param[in] RandomView Support for -h parameter.
241 @retval EFI_SUCCESS print is successful.
242 @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
247 IN UINT16 QueryHandle
,
249 IN BOOLEAN RandomView
257 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
258 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
261 LibSmbiosGetEPS (&SMBiosTable
);
262 if (SMBiosTable
== NULL
) {
263 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
264 return EFI_BAD_BUFFER_SIZE
;
267 if (CompareMem (SMBiosTable
->AnchorString
, "_SM_", 4) == 0) {
269 // Have got SMBIOS table
271 SmbiosPrintEPSInfo (SMBiosTable
, Option
);
273 SmbiosMajorVersion
= SMBiosTable
->MajorVersion
;
274 SmbiosMinorVersion
= SMBiosTable
->MinorVersion
;
276 ShellPrintEx(-1,-1,L
"=========================================================\n");
277 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND
), gShellDebug1HiiHandle
);
279 if (QueryType
== STRUCTURE_TYPE_RANDOM
) {
280 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM
), gShellDebug1HiiHandle
);
282 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE
), gShellDebug1HiiHandle
, QueryType
);
286 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM
), gShellDebug1HiiHandle
);
288 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE
), gShellDebug1HiiHandle
, QueryHandle
);
291 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE
), gShellDebug1HiiHandle
);
292 ShellPrintEx(-1,-1,GetShowTypeString (gShowType
));
293 ShellPrintEx(-1,-1,L
"\n\n");
297 // Get internal commands, such as change options.
299 Status = WaitEnter ();
300 if (EFI_ERROR (Status)) {
301 if (Status == EFI_ABORTED) {
310 // Searching and display structure info
312 Handle
= QueryHandle
;
313 for (Index
= 0; Index
< SMBiosTable
->NumberOfSmbiosStructures
; Index
++) {
315 // if reach the end of table, break..
317 if (Handle
== INVALID_HANDLE
) {
321 // handle then point to the next!
323 if (LibGetSmbiosStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
327 SmbiosStruct
.Raw
= Buffer
;
330 // if QueryType==Random, print this structure.
331 // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
332 // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
334 if (QueryType
!= STRUCTURE_TYPE_RANDOM
&& SmbiosStruct
.Hdr
->Type
!= QueryType
) {
338 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
339 ShellPrintHiiEx(-1,-1,NULL
,
340 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT
),
341 gShellDebug1HiiHandle
,
342 SmbiosStruct
.Hdr
->Type
,
343 SmbiosStruct
.Hdr
->Handle
345 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH
), gShellDebug1HiiHandle
, Index
, Length
);
347 // Addr of structure in structure in table
349 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR
), gShellDebug1HiiHandle
, (UINTN
) Buffer
);
350 DumpHex (0, 0, Length
, Buffer
);
354 // Get internal commands, such as change options.
356 Status = WaitEnter ();
357 if (EFI_ERROR (Status)) {
358 if (Status == EFI_ABORTED) {
366 if (gShowType
!= SHOW_NONE
) {
368 // Print structure information
370 SmbiosPrintStructure (&SmbiosStruct
, gShowType
);
371 ShellPrintEx(-1,-1,L
"\n");
375 // Get internal commands, such as change options.
377 Status = WaitEnter ();
378 if (EFI_ERROR (Status)) {
379 if (Status == EFI_ABORTED) {
391 // Support Execution Interrupt.
393 if (ShellGetExecutionBreakFlag ()) {
398 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
402 return EFI_BAD_BUFFER_SIZE
;
406 Query all structures Data from SMBIOS table and Display
407 the information to users as required display option.
409 @param[in] QueryType Structure type to view.
410 @param[in] QueryHandle Structure handle to view.
411 @param[in] Option Display option: none,outline,normal,detail.
412 @param[in] RandomView Support for -h parameter.
414 @retval EFI_SUCCESS print is successful.
415 @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
420 IN UINT16 QueryHandle
,
422 IN BOOLEAN RandomView
429 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
430 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
433 LibSmbios64BitGetEPS (&SMBiosTable
);
434 if (SMBiosTable
== NULL
) {
435 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
436 return EFI_BAD_BUFFER_SIZE
;
439 if (CompareMem (SMBiosTable
->AnchorString
, "_SM3_", 5) == 0) {
441 // Have got SMBIOS table
443 Smbios64BitPrintEPSInfo (SMBiosTable
, Option
);
445 SmbiosMajorVersion
= SMBiosTable
->MajorVersion
;
446 SmbiosMinorVersion
= SMBiosTable
->MinorVersion
;
448 ShellPrintEx(-1,-1,L
"=========================================================\n");
449 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND
), gShellDebug1HiiHandle
);
451 if (QueryType
== STRUCTURE_TYPE_RANDOM
) {
452 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM
), gShellDebug1HiiHandle
);
454 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE
), gShellDebug1HiiHandle
, QueryType
);
458 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM
), gShellDebug1HiiHandle
);
460 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE
), gShellDebug1HiiHandle
, QueryHandle
);
463 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE
), gShellDebug1HiiHandle
);
464 ShellPrintEx(-1,-1,GetShowTypeString (gShowType
));
465 ShellPrintEx(-1,-1,L
"\n\n");
469 // Get internal commands, such as change options.
471 Status = WaitEnter ();
472 if (EFI_ERROR (Status)) {
473 if (Status == EFI_ABORTED) {
482 // Searching and display structure info
484 Handle
= QueryHandle
;
485 for (Index
= 0; Index
< mNumberOfSmbios64BitStructures
; Index
++) {
487 // if reach the end of table, break..
489 if (Handle
== INVALID_HANDLE
) {
493 // handle then point to the next!
495 if (LibGetSmbios64BitStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
499 SmbiosStruct
.Raw
= Buffer
;
502 // if QueryType==Random, print this structure.
503 // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
504 // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
506 if (QueryType
!= STRUCTURE_TYPE_RANDOM
&& SmbiosStruct
.Hdr
->Type
!= QueryType
) {
510 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
511 ShellPrintHiiEx(-1,-1,NULL
,
512 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT
),
513 gShellDebug1HiiHandle
,
514 SmbiosStruct
.Hdr
->Type
,
515 SmbiosStruct
.Hdr
->Handle
517 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH
), gShellDebug1HiiHandle
, Index
, Length
);
519 // Addr of structure in structure in table
521 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR
), gShellDebug1HiiHandle
, (UINTN
) Buffer
);
522 DumpHex (0, 0, Length
, Buffer
);
526 // Get internal commands, such as change options.
528 Status = WaitEnter ();
529 if (EFI_ERROR (Status)) {
530 if (Status == EFI_ABORTED) {
538 if (gShowType
!= SHOW_NONE
) {
540 // Print structure information
542 SmbiosPrintStructure (&SmbiosStruct
, gShowType
);
543 ShellPrintEx(-1,-1,L
"\n");
547 // Get internal commands, such as change options.
549 Status = WaitEnter ();
550 if (EFI_ERROR (Status)) {
551 if (Status == EFI_ABORTED) {
563 // Support Execution Interrupt.
565 if (ShellGetExecutionBreakFlag ()) {
570 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
574 return EFI_BAD_BUFFER_SIZE
;
578 Function to initialize the global mStatisticsTable object.
580 @retval EFI_SUCCESS print is successful.
583 InitSmbiosTableStatistics (
593 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
594 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
595 STRUCTURE_STATISTICS
*StatisticsPointer
;
598 LibSmbiosGetEPS (&SMBiosTable
);
599 if (SMBiosTable
== NULL
) {
600 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
601 return EFI_NOT_FOUND
;
604 if (CompareMem (SMBiosTable
->AnchorString
, "_SM_", 4) != 0) {
605 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE
), gShellDebug1HiiHandle
);
606 return EFI_INVALID_PARAMETER
;
609 // Allocate memory to mStatisticsTable
611 if (mStatisticsTable
!= NULL
) {
612 FreePool (mStatisticsTable
);
613 mStatisticsTable
= NULL
;
616 mStatisticsTable
= (STRUCTURE_STATISTICS
*) AllocateZeroPool (SMBiosTable
->NumberOfSmbiosStructures
* sizeof (STRUCTURE_STATISTICS
));
618 if (mStatisticsTable
== NULL
) {
619 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM
), gShellDebug1HiiHandle
);
620 return EFI_OUT_OF_RESOURCES
;
624 StatisticsPointer
= mStatisticsTable
;
627 // search from the first one
629 Handle
= INVALID_HANDLE
;
630 LibGetSmbiosStructure (&Handle
, NULL
, NULL
);
631 for (Index
= 1; Index
<= SMBiosTable
->NumberOfSmbiosStructures
; Index
++) {
633 // If reach the end of table, break..
635 if (Handle
== INVALID_HANDLE
) {
639 // After LibGetSmbiosStructure(), handle then point to the next!
641 if (LibGetSmbiosStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
645 SmbiosStruct
.Raw
= Buffer
;
648 // general statistics
650 StatisticsPointer
->Index
= Index
;
651 StatisticsPointer
->Type
= SmbiosStruct
.Hdr
->Type
;
652 StatisticsPointer
->Handle
= SmbiosStruct
.Hdr
->Handle
;
653 StatisticsPointer
->Length
= Length
;
654 StatisticsPointer
->Addr
= Offset
;
656 Offset
= (UINT16
) (Offset
+ Length
);
658 StatisticsPointer
= &mStatisticsTable
[Index
];
665 @param[in] Smbios64EntryPoint SMBIOS 64-bit entry point.
666 @param[out] NumberOfSmbios64Structures The number of structures in 64-bit SMBIOS table.
667 @param[out] Smbios64TableLength The total length of 64-bit SMBIOS table.
669 @retval EFI_SUCCESS Calculation was successful.
672 CalculateSmbios64BitStructureCountAndLength (
673 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios64EntryPoint
,
674 UINTN
*NumberOfSmbios64Structures
,
675 UINTN
*Smbios64TableLength
678 SMBIOS_STRUCTURE_POINTER Smbios
;
681 *Smbios64TableLength
= 0;
682 *NumberOfSmbios64Structures
= 0;
684 Smbios
.Raw
= (UINT8
*)(UINTN
)(Smbios64EntryPoint
->TableAddress
);
686 if (Smbios
.Hdr
->Type
== 127) {
688 // Reach the end of table type 127
690 (*NumberOfSmbios64Structures
)++;
691 (*Smbios64TableLength
) += sizeof (SMBIOS_STRUCTURE
);
697 // Walk to next structure
699 LibGetSmbiosString (&Smbios
, (UINT16
) (-1));
701 // Length = Next structure head - this structure head
703 (*Smbios64TableLength
) += ((UINTN
) Smbios
.Raw
- (UINTN
) Raw
);
704 if ((*Smbios64TableLength
) > Smbios64EntryPoint
->TableMaximumSize
) {
706 // The actual table length exceeds maximum table size,
707 // There should be something wrong with SMBIOS table.
709 return EFI_INVALID_PARAMETER
;
711 (*NumberOfSmbios64Structures
)++;
716 Function to initialize the global mSmbios64BitStatisticsTable object.
718 @retval EFI_SUCCESS print is successful.
721 InitSmbios64BitTableStatistics (
731 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
732 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
733 STRUCTURE_STATISTICS
*StatisticsPointer
;
736 LibSmbios64BitGetEPS (&SMBiosTable
);
737 if (SMBiosTable
== NULL
) {
738 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
739 return EFI_NOT_FOUND
;
742 if (CompareMem (SMBiosTable
->AnchorString
, "_SM3_", 5) != 0) {
743 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE
), gShellDebug1HiiHandle
);
744 return EFI_INVALID_PARAMETER
;
747 // Allocate memory to mSmbios64BitStatisticsTable
749 if (mSmbios64BitStatisticsTable
!= NULL
) {
750 FreePool (mSmbios64BitStatisticsTable
);
751 mSmbios64BitStatisticsTable
= NULL
;
754 // Calculate number of smbios structures
756 Status
= CalculateSmbios64BitStructureCountAndLength (SMBiosTable
, &mNumberOfSmbios64BitStructures
, &mSmbios64BitTableLength
);
757 if ((EFI_ERROR (Status
)) || (mSmbios64BitTableLength
> SMBiosTable
->TableMaximumSize
)) {
758 return EFI_INVALID_PARAMETER
;
761 mSmbios64BitStatisticsTable
= (STRUCTURE_STATISTICS
*) AllocateZeroPool (mNumberOfSmbios64BitStructures
* sizeof (STRUCTURE_STATISTICS
));
763 if (mSmbios64BitStatisticsTable
== NULL
) {
764 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM
), gShellDebug1HiiHandle
);
765 return EFI_OUT_OF_RESOURCES
;
769 StatisticsPointer
= mSmbios64BitStatisticsTable
;
772 // search from the first one
774 Handle
= INVALID_HANDLE
;
775 LibGetSmbios64BitStructure (&Handle
, NULL
, NULL
);
776 for (Index
= 1; Index
<= mNumberOfSmbios64BitStructures
; Index
++) {
778 // If reach the end of table, break..
780 if (Handle
== INVALID_HANDLE
) {
784 // After LibGetSmbios64BitStructure(), handle then point to the next!
786 if (LibGetSmbios64BitStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
790 SmbiosStruct
.Raw
= Buffer
;
793 // general statistics
795 StatisticsPointer
->Index
= Index
;
796 StatisticsPointer
->Type
= SmbiosStruct
.Hdr
->Type
;
797 StatisticsPointer
->Handle
= SmbiosStruct
.Hdr
->Handle
;
798 StatisticsPointer
->Length
= Length
;
799 StatisticsPointer
->Addr
= Offset
;
801 Offset
= (UINT16
) (Offset
+ Length
);
803 StatisticsPointer
= &mSmbios64BitStatisticsTable
[Index
];
810 Function to display the global mStatisticsTable object.
812 @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
814 @retval EFI_SUCCESS print is successful.
817 DisplayStatisticsTable (
823 STRUCTURE_STATISTICS
*StatisticsPointer
;
824 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
827 if (Option
< SHOW_OUTLINE
) {
831 // display EPS information firstly
833 LibSmbiosGetEPS (&SMBiosTable
);
834 if (SMBiosTable
== NULL
) {
835 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
836 return EFI_UNSUPPORTED
;
839 ShellPrintEx(-1,-1,L
"\n============================================================\n");
840 SmbiosPrintEPSInfo (SMBiosTable
, Option
);
842 if (Option
< SHOW_NORMAL
) {
846 if (mStatisticsTable
== NULL
) {
847 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS
), gShellDebug1HiiHandle
);
848 return EFI_NOT_FOUND
;
851 ShellPrintEx(-1,-1,L
"============================================================\n");
852 StatisticsPointer
= &mStatisticsTable
[0];
853 Num
= SMBiosTable
->NumberOfSmbiosStructures
;
855 // display statistics table content
857 for (Index
= 1; Index
<= Num
; Index
++) {
858 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX
), gShellDebug1HiiHandle
, StatisticsPointer
->Index
);
859 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE
), gShellDebug1HiiHandle
, StatisticsPointer
->Type
);
860 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE
), gShellDebug1HiiHandle
, StatisticsPointer
->Handle
);
861 if (Option
>= SHOW_DETAIL
) {
862 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET
), gShellDebug1HiiHandle
, StatisticsPointer
->Addr
);
863 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH
), gShellDebug1HiiHandle
, StatisticsPointer
->Length
);
866 ShellPrintEx(-1,-1,L
"\n");
867 StatisticsPointer
= &mStatisticsTable
[Index
];
870 // Display 20 lines and wait for a page break
872 if (Index % 20 == 0) {
873 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
874 Status = WaitEnter ();
875 if (EFI_ERROR (Status)) {
876 if (Status == EFI_ABORTED) {
890 Function to display the global mSmbios64BitStatisticsTable object.
892 @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
894 @retval EFI_SUCCESS print is successful.
897 DisplaySmbios64BitStatisticsTable (
903 STRUCTURE_STATISTICS
*StatisticsPointer
;
904 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
907 if (Option
< SHOW_OUTLINE
) {
911 // display EPS information firstly
913 LibSmbios64BitGetEPS (&SMBiosTable
);
914 if (SMBiosTable
== NULL
) {
915 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
916 return EFI_UNSUPPORTED
;
919 ShellPrintEx(-1,-1,L
"\n============================================================\n");
920 Smbios64BitPrintEPSInfo (SMBiosTable
, Option
);
922 if (Option
< SHOW_NORMAL
) {
926 if (mSmbios64BitStatisticsTable
== NULL
) {
927 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS
), gShellDebug1HiiHandle
);
928 return EFI_NOT_FOUND
;
931 ShellPrintEx(-1,-1,L
"============================================================\n");
932 StatisticsPointer
= &mSmbios64BitStatisticsTable
[0];
933 Num
= mNumberOfSmbios64BitStructures
;
935 // display statistics table content
937 for (Index
= 1; Index
<= Num
; Index
++) {
938 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX
), gShellDebug1HiiHandle
, StatisticsPointer
->Index
);
939 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE
), gShellDebug1HiiHandle
, StatisticsPointer
->Type
);
940 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE
), gShellDebug1HiiHandle
, StatisticsPointer
->Handle
);
941 if (Option
>= SHOW_DETAIL
) {
942 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET
), gShellDebug1HiiHandle
, StatisticsPointer
->Addr
);
943 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH
), gShellDebug1HiiHandle
, StatisticsPointer
->Length
);
946 ShellPrintEx(-1,-1,L
"\n");
947 StatisticsPointer
= &mSmbios64BitStatisticsTable
[Index
];
950 // Display 20 lines and wait for a page break
952 if (Index % 20 == 0) {
953 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
954 Status = WaitEnter ();
955 if (EFI_ERROR (Status)) {
956 if (Status == EFI_ABORTED) {
970 function to return a string of the detail level.
972 @param[in] ShowType The detail level whose name is desired in clear text.
974 @return A pointer to a string representing the ShowType (or 'undefined type' if not known).
990 return L
"SHOW_OUTLINE";
993 return L
"SHOW_NORMAL";
996 return L
"SHOW_DETAIL";
1002 return L
"Undefined type";