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 - 2012, 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.
248 IN UINT16 QueryHandle
,
250 IN BOOLEAN RandomView
258 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
259 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
262 LibSmbiosGetEPS (&SMBiosTable
);
263 if (SMBiosTable
== NULL
) {
264 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
265 return EFI_BAD_BUFFER_SIZE
;
268 if (CompareMem (SMBiosTable
->AnchorString
, "_SM_", 4) == 0) {
270 // Have got SMBIOS table
272 SmbiosPrintEPSInfo (SMBiosTable
, Option
);
274 SmbiosMajorVersion
= SMBiosTable
->MajorVersion
;
275 SmbiosMinorVersion
= SMBiosTable
->MinorVersion
;
277 ShellPrintEx(-1,-1,L
"=========================================================\n");
278 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND
), gShellDebug1HiiHandle
);
280 if (QueryType
== STRUCTURE_TYPE_RANDOM
) {
281 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM
), gShellDebug1HiiHandle
);
283 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE
), gShellDebug1HiiHandle
, QueryType
);
287 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM
), gShellDebug1HiiHandle
);
289 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE
), gShellDebug1HiiHandle
, QueryHandle
);
292 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE
), gShellDebug1HiiHandle
);
293 ShellPrintEx(-1,-1,GetShowTypeString (gShowType
));
294 ShellPrintEx(-1,-1,L
"\n\n");
298 // Get internal commands, such as change options.
300 Status = WaitEnter ();
301 if (EFI_ERROR (Status)) {
302 if (Status == EFI_ABORTED) {
311 // Searching and display structure info
313 Handle
= QueryHandle
;
314 for (Index
= 0; Index
< SMBiosTable
->NumberOfSmbiosStructures
; Index
++) {
316 // if reach the end of table, break..
318 if (Handle
== INVALID_HANDLE
) {
322 // handle then point to the next!
324 if (LibGetSmbiosStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
328 SmbiosStruct
.Raw
= Buffer
;
331 // if QueryType==Random, print this structure.
332 // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
333 // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
335 if (QueryType
!= STRUCTURE_TYPE_RANDOM
&& SmbiosStruct
.Hdr
->Type
!= QueryType
) {
339 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
340 ShellPrintHiiEx(-1,-1,NULL
,
341 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT
),
342 gShellDebug1HiiHandle
,
343 SmbiosStruct
.Hdr
->Type
,
344 SmbiosStruct
.Hdr
->Handle
346 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH
), gShellDebug1HiiHandle
, Index
, Length
);
348 // Addr of structure in structure in table
350 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR
), gShellDebug1HiiHandle
, (UINTN
) Buffer
);
351 DumpHex (0, 0, Length
, Buffer
);
355 // Get internal commands, such as change options.
357 Status = WaitEnter ();
358 if (EFI_ERROR (Status)) {
359 if (Status == EFI_ABORTED) {
367 if (gShowType
!= SHOW_NONE
) {
369 // Print structure information
371 SmbiosPrintStructure (&SmbiosStruct
, gShowType
);
372 ShellPrintEx(-1,-1,L
"\n");
376 // Get internal commands, such as change options.
378 Status = WaitEnter ();
379 if (EFI_ERROR (Status)) {
380 if (Status == EFI_ABORTED) {
392 // Support Execution Interrupt.
394 if (ShellGetExecutionBreakFlag ()) {
399 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
403 return EFI_BAD_BUFFER_SIZE
;
407 Query all structures Data from SMBIOS table and Display
408 the information to users as required display option.
410 @param[in] QueryType Structure type to view.
411 @param[in] QueryHandle Structure handle to view.
412 @param[in] Option Display option: none,outline,normal,detail.
413 @param[in] RandomView Support for -h parameter.
415 @retval EFI_SUCCESS print is successful.
416 @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
422 IN UINT16 QueryHandle
,
424 IN BOOLEAN RandomView
431 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
432 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
435 LibSmbios64BitGetEPS (&SMBiosTable
);
436 if (SMBiosTable
== NULL
) {
437 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
438 return EFI_BAD_BUFFER_SIZE
;
441 if (CompareMem (SMBiosTable
->AnchorString
, "_SM3_", 5) == 0) {
443 // Have got SMBIOS table
445 Smbios64BitPrintEPSInfo (SMBiosTable
, Option
);
447 SmbiosMajorVersion
= SMBiosTable
->MajorVersion
;
448 SmbiosMinorVersion
= SMBiosTable
->MinorVersion
;
450 ShellPrintEx(-1,-1,L
"=========================================================\n");
451 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND
), gShellDebug1HiiHandle
);
453 if (QueryType
== STRUCTURE_TYPE_RANDOM
) {
454 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM
), gShellDebug1HiiHandle
);
456 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE
), gShellDebug1HiiHandle
, QueryType
);
460 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM
), gShellDebug1HiiHandle
);
462 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE
), gShellDebug1HiiHandle
, QueryHandle
);
465 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE
), gShellDebug1HiiHandle
);
466 ShellPrintEx(-1,-1,GetShowTypeString (gShowType
));
467 ShellPrintEx(-1,-1,L
"\n\n");
471 // Get internal commands, such as change options.
473 Status = WaitEnter ();
474 if (EFI_ERROR (Status)) {
475 if (Status == EFI_ABORTED) {
484 // Searching and display structure info
486 Handle
= QueryHandle
;
487 for (Index
= 0; Index
< mNumberOfSmbios64BitStructures
; Index
++) {
489 // if reach the end of table, break..
491 if (Handle
== INVALID_HANDLE
) {
495 // handle then point to the next!
497 if (LibGetSmbios64BitStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
501 SmbiosStruct
.Raw
= Buffer
;
504 // if QueryType==Random, print this structure.
505 // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
506 // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
508 if (QueryType
!= STRUCTURE_TYPE_RANDOM
&& SmbiosStruct
.Hdr
->Type
!= QueryType
) {
512 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
513 ShellPrintHiiEx(-1,-1,NULL
,
514 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT
),
515 gShellDebug1HiiHandle
,
516 SmbiosStruct
.Hdr
->Type
,
517 SmbiosStruct
.Hdr
->Handle
519 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH
), gShellDebug1HiiHandle
, Index
, Length
);
521 // Addr of structure in structure in table
523 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR
), gShellDebug1HiiHandle
, (UINTN
) Buffer
);
524 DumpHex (0, 0, Length
, Buffer
);
528 // Get internal commands, such as change options.
530 Status = WaitEnter ();
531 if (EFI_ERROR (Status)) {
532 if (Status == EFI_ABORTED) {
540 if (gShowType
!= SHOW_NONE
) {
542 // Print structure information
544 SmbiosPrintStructure (&SmbiosStruct
, gShowType
);
545 ShellPrintEx(-1,-1,L
"\n");
549 // Get internal commands, such as change options.
551 Status = WaitEnter ();
552 if (EFI_ERROR (Status)) {
553 if (Status == EFI_ABORTED) {
565 // Support Execution Interrupt.
567 if (ShellGetExecutionBreakFlag ()) {
572 ShellPrintEx(-1,-1,L
"\n=========================================================\n");
576 return EFI_BAD_BUFFER_SIZE
;
580 Function to initialize the global mStatisticsTable object.
582 @retval EFI_SUCCESS print is successful.
586 InitSmbiosTableStatistics (
596 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
597 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
598 STRUCTURE_STATISTICS
*StatisticsPointer
;
601 LibSmbiosGetEPS (&SMBiosTable
);
602 if (SMBiosTable
== NULL
) {
603 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
604 return EFI_NOT_FOUND
;
607 if (CompareMem (SMBiosTable
->AnchorString
, "_SM_", 4) != 0) {
608 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE
), gShellDebug1HiiHandle
);
609 return EFI_INVALID_PARAMETER
;
612 // Allocate memory to mStatisticsTable
614 if (mStatisticsTable
!= NULL
) {
615 FreePool (mStatisticsTable
);
616 mStatisticsTable
= NULL
;
619 mStatisticsTable
= (STRUCTURE_STATISTICS
*) AllocateZeroPool (SMBiosTable
->NumberOfSmbiosStructures
* sizeof (STRUCTURE_STATISTICS
));
621 if (mStatisticsTable
== NULL
) {
622 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM
), gShellDebug1HiiHandle
);
623 return EFI_OUT_OF_RESOURCES
;
627 StatisticsPointer
= mStatisticsTable
;
630 // search from the first one
632 Handle
= INVALID_HANDLE
;
633 LibGetSmbiosStructure (&Handle
, NULL
, NULL
);
634 for (Index
= 1; Index
<= SMBiosTable
->NumberOfSmbiosStructures
; Index
++) {
636 // If reach the end of table, break..
638 if (Handle
== INVALID_HANDLE
) {
642 // After LibGetSmbiosStructure(), handle then point to the next!
644 if (LibGetSmbiosStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
648 SmbiosStruct
.Raw
= Buffer
;
651 // general statistics
653 StatisticsPointer
->Index
= Index
;
654 StatisticsPointer
->Type
= SmbiosStruct
.Hdr
->Type
;
655 StatisticsPointer
->Handle
= SmbiosStruct
.Hdr
->Handle
;
656 StatisticsPointer
->Length
= Length
;
657 StatisticsPointer
->Addr
= Offset
;
659 Offset
= (UINT16
) (Offset
+ Length
);
661 StatisticsPointer
= &mStatisticsTable
[Index
];
668 @param[in] Smbios64EntryPoint SMBIOS 64-bit entry point.
669 @param[out] NumberOfSmbios64Structures The number of structures in 64-bit SMBIOS table.
670 @param[out] Smbios64TableLength The total length of 64-bit SMBIOS table.
672 @retval EFI_SUCCESS Calculation was successful.
676 CalculateSmbios64BitStructureCountAndLength (
677 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios64EntryPoint
,
678 UINTN
*NumberOfSmbios64Structures
,
679 UINTN
*Smbios64TableLength
682 SMBIOS_STRUCTURE_POINTER Smbios
;
685 *Smbios64TableLength
= 0;
686 *NumberOfSmbios64Structures
= 0;
688 Smbios
.Raw
= (UINT8
*)(UINTN
)(Smbios64EntryPoint
->TableAddress
);
690 if (Smbios
.Hdr
->Type
== 127) {
692 // Reach the end of table type 127
694 (*NumberOfSmbios64Structures
)++;
695 (*Smbios64TableLength
) += sizeof (SMBIOS_STRUCTURE
);
701 // Walk to next structure
703 LibGetSmbiosString (&Smbios
, (UINT16
) (-1));
705 // Length = Next structure head - this structure head
707 (*Smbios64TableLength
) += (UINTN
) (Smbios
.Raw
- Raw
);
708 if ((*Smbios64TableLength
) > Smbios64EntryPoint
->TableMaximumSize
) {
710 // The actual table length exceeds maximum table size,
711 // There should be something wrong with SMBIOS table.
713 return EFI_INVALID_PARAMETER
;
715 (*NumberOfSmbios64Structures
)++;
720 Function to initialize the global mSmbios64BitStatisticsTable object.
722 @retval EFI_SUCCESS print is successful.
726 InitSmbios64BitTableStatistics (
736 SMBIOS_STRUCTURE_POINTER SmbiosStruct
;
737 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
738 STRUCTURE_STATISTICS
*StatisticsPointer
;
741 LibSmbios64BitGetEPS (&SMBiosTable
);
742 if (SMBiosTable
== NULL
) {
743 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
744 return EFI_NOT_FOUND
;
747 if (CompareMem (SMBiosTable
->AnchorString
, "_SM3_", 5) != 0) {
748 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE
), gShellDebug1HiiHandle
);
749 return EFI_INVALID_PARAMETER
;
752 // Allocate memory to mSmbios64BitStatisticsTable
754 if (mSmbios64BitStatisticsTable
!= NULL
) {
755 FreePool (mSmbios64BitStatisticsTable
);
756 mSmbios64BitStatisticsTable
= NULL
;
759 // Calculate number of smbios structures
761 Status
= CalculateSmbios64BitStructureCountAndLength (SMBiosTable
, &mNumberOfSmbios64BitStructures
, &mSmbios64BitTableLength
);
762 if ((EFI_ERROR (Status
)) || (mSmbios64BitTableLength
> SMBiosTable
->TableMaximumSize
)) {
763 return EFI_INVALID_PARAMETER
;
766 mSmbios64BitStatisticsTable
= (STRUCTURE_STATISTICS
*) AllocateZeroPool (mNumberOfSmbios64BitStructures
* sizeof (STRUCTURE_STATISTICS
));
768 if (mSmbios64BitStatisticsTable
== NULL
) {
769 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM
), gShellDebug1HiiHandle
);
770 return EFI_OUT_OF_RESOURCES
;
774 StatisticsPointer
= mSmbios64BitStatisticsTable
;
777 // search from the first one
779 Handle
= INVALID_HANDLE
;
780 LibGetSmbios64BitStructure (&Handle
, NULL
, NULL
);
781 for (Index
= 1; Index
<= mNumberOfSmbios64BitStructures
; Index
++) {
783 // If reach the end of table, break..
785 if (Handle
== INVALID_HANDLE
) {
789 // After LibGetSmbios64BitStructure(), handle then point to the next!
791 if (LibGetSmbios64BitStructure (&Handle
, &Buffer
, &Length
) != DMI_SUCCESS
) {
795 SmbiosStruct
.Raw
= Buffer
;
798 // general statistics
800 StatisticsPointer
->Index
= Index
;
801 StatisticsPointer
->Type
= SmbiosStruct
.Hdr
->Type
;
802 StatisticsPointer
->Handle
= SmbiosStruct
.Hdr
->Handle
;
803 StatisticsPointer
->Length
= Length
;
804 StatisticsPointer
->Addr
= Offset
;
806 Offset
= (UINT16
) (Offset
+ Length
);
808 StatisticsPointer
= &mSmbios64BitStatisticsTable
[Index
];
815 Function to display the global mStatisticsTable object.
817 @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
819 @retval EFI_SUCCESS print is successful.
823 DisplayStatisticsTable (
829 STRUCTURE_STATISTICS
*StatisticsPointer
;
830 SMBIOS_TABLE_ENTRY_POINT
*SMBiosTable
;
833 if (Option
< SHOW_OUTLINE
) {
837 // display EPS information firstly
839 LibSmbiosGetEPS (&SMBiosTable
);
840 if (SMBiosTable
== NULL
) {
841 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
842 return EFI_UNSUPPORTED
;
845 ShellPrintEx(-1,-1,L
"\n============================================================\n");
846 SmbiosPrintEPSInfo (SMBiosTable
, Option
);
848 if (Option
< SHOW_NORMAL
) {
852 if (mStatisticsTable
== NULL
) {
853 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS
), gShellDebug1HiiHandle
);
854 return EFI_NOT_FOUND
;
857 ShellPrintEx(-1,-1,L
"============================================================\n");
858 StatisticsPointer
= &mStatisticsTable
[0];
859 Num
= SMBiosTable
->NumberOfSmbiosStructures
;
861 // display statistics table content
863 for (Index
= 1; Index
<= Num
; Index
++) {
864 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX
), gShellDebug1HiiHandle
, StatisticsPointer
->Index
);
865 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE
), gShellDebug1HiiHandle
, StatisticsPointer
->Type
);
866 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE
), gShellDebug1HiiHandle
, StatisticsPointer
->Handle
);
867 if (Option
>= SHOW_DETAIL
) {
868 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET
), gShellDebug1HiiHandle
, StatisticsPointer
->Addr
);
869 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH
), gShellDebug1HiiHandle
, StatisticsPointer
->Length
);
872 ShellPrintEx(-1,-1,L
"\n");
873 StatisticsPointer
= &mStatisticsTable
[Index
];
876 // Display 20 lines and wait for a page break
878 if (Index % 20 == 0) {
879 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
880 Status = WaitEnter ();
881 if (EFI_ERROR (Status)) {
882 if (Status == EFI_ABORTED) {
896 Function to display the global mSmbios64BitStatisticsTable object.
898 @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
900 @retval EFI_SUCCESS print is successful.
904 DisplaySmbios64BitStatisticsTable (
910 STRUCTURE_STATISTICS
*StatisticsPointer
;
911 SMBIOS_TABLE_3_0_ENTRY_POINT
*SMBiosTable
;
914 if (Option
< SHOW_OUTLINE
) {
918 // display EPS information firstly
920 LibSmbios64BitGetEPS (&SMBiosTable
);
921 if (SMBiosTable
== NULL
) {
922 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE
), gShellDebug1HiiHandle
);
923 return EFI_UNSUPPORTED
;
926 ShellPrintEx(-1,-1,L
"\n============================================================\n");
927 Smbios64BitPrintEPSInfo (SMBiosTable
, Option
);
929 if (Option
< SHOW_NORMAL
) {
933 if (mSmbios64BitStatisticsTable
== NULL
) {
934 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS
), gShellDebug1HiiHandle
);
935 return EFI_NOT_FOUND
;
938 ShellPrintEx(-1,-1,L
"============================================================\n");
939 StatisticsPointer
= &mSmbios64BitStatisticsTable
[0];
940 Num
= mNumberOfSmbios64BitStructures
;
942 // display statistics table content
944 for (Index
= 1; Index
<= Num
; Index
++) {
945 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX
), gShellDebug1HiiHandle
, StatisticsPointer
->Index
);
946 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE
), gShellDebug1HiiHandle
, StatisticsPointer
->Type
);
947 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE
), gShellDebug1HiiHandle
, StatisticsPointer
->Handle
);
948 if (Option
>= SHOW_DETAIL
) {
949 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET
), gShellDebug1HiiHandle
, StatisticsPointer
->Addr
);
950 ShellPrintHiiEx(-1,-1,NULL
,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH
), gShellDebug1HiiHandle
, StatisticsPointer
->Length
);
953 ShellPrintEx(-1,-1,L
"\n");
954 StatisticsPointer
= &mSmbios64BitStatisticsTable
[Index
];
957 // Display 20 lines and wait for a page break
959 if (Index % 20 == 0) {
960 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
961 Status = WaitEnter ();
962 if (EFI_ERROR (Status)) {
963 if (Status == EFI_ABORTED) {
977 function to return a string of the detail level.
979 @param[in] ShowType The detail level whose name is desired in clear text.
981 @return A pointer to a string representing the ShowType (or 'undefined type' if not known).
998 return L
"SHOW_OUTLINE";
1001 return L
"SHOW_NORMAL";
1004 return L
"SHOW_DETAIL";
1010 return L
"Undefined type";