TianoCore EDK2 master
Loading...
Searching...
No Matches
SmbiosView.c
Go to the documentation of this file.
1
12#include "LibSmbiosView.h"
13#include "SmbiosView.h"
14#include "PrintInfo.h"
15#include "QueryTable.h"
16
17UINT8 gShowType = SHOW_DETAIL;
18STATIC STRUCTURE_STATISTICS *mStatisticsTable = NULL;
19STATIC STRUCTURE_STATISTICS *mSmbios64BitStatisticsTable = NULL;
20
21UINT8 SmbiosMajorVersion;
22UINT8 SmbiosMinorVersion;
23
24UINTN mNumberOfSmbios64BitStructures;
25UINTN mSmbios64BitTableLength;
26
27STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
28 { L"-t", TypeValue },
29 { L"-h", TypeValue },
30 { L"-s", TypeFlag },
31 { L"-a", TypeFlag },
32 { NULL, TypeMax }
33};
34
42EFIAPI
44 IN EFI_HANDLE ImageHandle,
45 IN EFI_SYSTEM_TABLE *SystemTable
46 )
47{
48 UINT8 StructType;
49 UINT16 StructHandle;
50 EFI_STATUS Status;
51 EFI_STATUS Status1;
52 EFI_STATUS Status2;
53 BOOLEAN RandomView;
54 LIST_ENTRY *Package;
55 CHAR16 *ProblemParam;
56 SHELL_STATUS ShellStatus;
57 CONST CHAR16 *Temp;
58
59 mStatisticsTable = NULL;
60 mSmbios64BitStatisticsTable = NULL;
61 Package = NULL;
62 ShellStatus = SHELL_SUCCESS;
63
64 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
65 if (EFI_ERROR (Status)) {
66 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
67 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"smbiosview", ProblemParam);
68 FreePool (ProblemParam);
69 ShellStatus = SHELL_INVALID_PARAMETER;
70 } else {
71 ASSERT (FALSE);
72 }
73 } else {
74 if (ShellCommandLineGetCount (Package) > 1) {
75 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"smbiosview");
76 ShellStatus = SHELL_INVALID_PARAMETER;
77 } else if (ShellCommandLineGetFlag (Package, L"-t") && (ShellCommandLineGetValue (Package, L"-t") == NULL)) {
78 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"smbiosview", L"-t");
79 ShellStatus = SHELL_INVALID_PARAMETER;
80 } else if (ShellCommandLineGetFlag (Package, L"-h") && (ShellCommandLineGetValue (Package, L"-h") == NULL)) {
81 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"smbiosview", L"-h");
82 ShellStatus = SHELL_INVALID_PARAMETER;
83 } else if (
84 (ShellCommandLineGetFlag (Package, L"-t") && ShellCommandLineGetFlag (Package, L"-h")) ||
85 (ShellCommandLineGetFlag (Package, L"-t") && ShellCommandLineGetFlag (Package, L"-s")) ||
86 (ShellCommandLineGetFlag (Package, L"-t") && ShellCommandLineGetFlag (Package, L"-a")) ||
87 (ShellCommandLineGetFlag (Package, L"-h") && ShellCommandLineGetFlag (Package, L"-s")) ||
88 (ShellCommandLineGetFlag (Package, L"-h") && ShellCommandLineGetFlag (Package, L"-a")) ||
89 (ShellCommandLineGetFlag (Package, L"-s") && ShellCommandLineGetFlag (Package, L"-a"))
90 )
91 {
92 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"smbiosview");
93 ShellStatus = SHELL_INVALID_PARAMETER;
94 } else {
95 //
96 // Init Lib
97 //
98 Status1 = LibSmbiosInit ();
99 Status2 = LibSmbios64BitInit ();
100 if (EFI_ERROR (Status1) && EFI_ERROR (Status2)) {
101 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), gShellDebug1HiiHandle);
102 ShellStatus = SHELL_NOT_FOUND;
103 goto Done;
104 }
105
106 StructType = STRUCTURE_TYPE_RANDOM;
107 RandomView = TRUE;
108
109 Temp = ShellCommandLineGetValue (Package, L"-t");
110 if (Temp != NULL) {
111 StructType = (UINT8)ShellStrToUintn (Temp);
112 }
113
114 if (ShellCommandLineGetFlag (Package, L"-a")) {
115 gShowType = SHOW_ALL;
116 }
117
118 if (!EFI_ERROR (Status1)) {
119 //
120 // Initialize the StructHandle to be the first handle
121 //
122 StructHandle = INVALID_HANDLE;
123 LibGetSmbiosStructure (&StructHandle, NULL, NULL);
124
125 Temp = ShellCommandLineGetValue (Package, L"-h");
126 if (Temp != NULL) {
127 RandomView = FALSE;
128 StructHandle = (UINT16)ShellStrToUintn (Temp);
129 }
130
131 //
132 // build statistics table
133 //
134 Status = InitSmbiosTableStatistics ();
135 if (EFI_ERROR (Status)) {
136 ShellStatus = SHELL_NOT_FOUND;
137 goto Done;
138 }
139
140 if (ShellCommandLineGetFlag (Package, L"-s")) {
141 Status = DisplayStatisticsTable (SHOW_DETAIL);
142 if (EFI_ERROR (Status)) {
143 ShellStatus = SHELL_NOT_FOUND;
144 }
145
146 goto Show64Bit;
147 }
148
149 //
150 // Show SMBIOS structure information
151 //
152 Status = SMBiosView (StructType, StructHandle, gShowType, RandomView);
153 if (EFI_ERROR (Status)) {
154 ShellStatus = SHELL_NOT_FOUND;
155 goto Done;
156 }
157 }
158
159Show64Bit:
160 if (!EFI_ERROR (Status2)) {
161 //
162 // build statistics table
163 //
165 if (EFI_ERROR (Status)) {
166 ShellStatus = SHELL_NOT_FOUND;
167 goto Done;
168 }
169
170 //
171 // Initialize the StructHandle to be the first handle
172 //
173 StructHandle = INVALID_HANDLE;
174 LibGetSmbios64BitStructure (&StructHandle, NULL, NULL);
175
176 Temp = ShellCommandLineGetValue (Package, L"-h");
177 if (Temp != NULL) {
178 RandomView = FALSE;
179 StructHandle = (UINT16)ShellStrToUintn (Temp);
180 }
181
182 if (ShellCommandLineGetFlag (Package, L"-s")) {
183 Status = DisplaySmbios64BitStatisticsTable (SHOW_DETAIL);
184 if (EFI_ERROR (Status)) {
185 ShellStatus = SHELL_NOT_FOUND;
186 }
187
188 goto Done;
189 }
190
191 //
192 // Show SMBIOS structure information
193 //
194 Status = SMBios64View (StructType, StructHandle, gShowType, RandomView);
195 if (EFI_ERROR (Status)) {
196 ShellStatus = SHELL_NOT_FOUND;
197 }
198 }
199 }
200 }
201
202Done:
203 //
204 // Release resources
205 //
206 if (mStatisticsTable != NULL) {
207 //
208 // Release statistics table
209 //
210 FreePool (mStatisticsTable);
211 mStatisticsTable = NULL;
212 }
213
214 if (mSmbios64BitStatisticsTable != NULL) {
215 //
216 // Release statistics table
217 //
218 FreePool (mSmbios64BitStatisticsTable);
219 mSmbios64BitStatisticsTable = NULL;
220 }
221
222 if (Package != NULL) {
224 }
225
228
229 return ShellStatus;
230}
231
246 IN UINT8 QueryType,
247 IN UINT16 QueryHandle,
248 IN UINT8 Option,
249 IN BOOLEAN RandomView
250 )
251{
252 UINT16 Handle;
253 UINT8 *Buffer;
254 UINT16 Length;
255 UINTN Index;
256
257 SMBIOS_STRUCTURE_POINTER SmbiosStruct;
258 SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
259
260 SMBiosTable = NULL;
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;
265 }
266
267 if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING, SMBIOS_ANCHOR_STRING_LENGTH) == 0) {
268 //
269 // Have got SMBIOS table
270 //
271 SmbiosPrintEPSInfo (SMBiosTable, Option);
272
273 SmbiosMajorVersion = SMBiosTable->MajorVersion;
274 SmbiosMinorVersion = SMBiosTable->MinorVersion;
275
276 ShellPrintEx (-1, -1, L"=========================================================\n");
277 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), gShellDebug1HiiHandle);
278
279 if (QueryType == STRUCTURE_TYPE_RANDOM) {
280 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM), gShellDebug1HiiHandle);
281 } else {
282 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE), gShellDebug1HiiHandle, QueryType);
283 }
284
285 if (RandomView) {
286 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM), gShellDebug1HiiHandle);
287 } else {
288 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE), gShellDebug1HiiHandle, QueryHandle);
289 }
290
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");
294
295 /*
296 //
297 // Get internal commands, such as change options.
298 //
299 Status = WaitEnter ();
300 if (EFI_ERROR (Status)) {
301 if (Status == EFI_ABORTED) {
302 return EFI_SUCCESS;
303 }
304
305 return Status;
306 }
307 */
308
309 //
310 // Searching and display structure info
311 //
312 Handle = QueryHandle;
313 for (Index = 0; Index < SMBiosTable->NumberOfSmbiosStructures; Index++) {
314 //
315 // if reach the end of table, break..
316 //
317 if (Handle == INVALID_HANDLE) {
318 break;
319 }
320
321 //
322 // handle then point to the next!
323 //
324 if (LibGetSmbiosStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
325 break;
326 }
327
328 SmbiosStruct.Raw = Buffer;
329
330 //
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.
334 //
335 if ((QueryType != STRUCTURE_TYPE_RANDOM) && (SmbiosStruct.Hdr->Type != QueryType)) {
336 continue;
337 }
338
339 ShellPrintEx (-1, -1, L"\n=========================================================\n");
341 -1,
342 -1,
343 NULL,
344 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT),
345 gShellDebug1HiiHandle,
346 SmbiosStruct.Hdr->Type,
347 SmbiosStruct.Hdr->Handle
348 );
349 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length);
350 //
351 // Addr of structure in structure in table
352 //
353 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR), gShellDebug1HiiHandle, (UINTN)Buffer);
354 DumpHex (0, 0, Length, Buffer);
355
356 /*
357 //
358 // Get internal commands, such as change options.
359 //
360 Status = WaitEnter ();
361 if (EFI_ERROR (Status)) {
362 if (Status == EFI_ABORTED) {
363 return EFI_SUCCESS;
364 }
365
366 return Status;
367 }
368 */
369
370 if (gShowType != SHOW_NONE) {
371 //
372 // Print structure information
373 //
374 SmbiosPrintStructure (&SmbiosStruct, gShowType);
375 ShellPrintEx (-1, -1, L"\n");
376
377 /*
378 //
379 // Get internal commands, such as change options.
380 //
381 Status = WaitEnter ();
382 if (EFI_ERROR (Status)) {
383 if (Status == EFI_ABORTED) {
384 return EFI_SUCCESS;
385 }
386
387 return Status;
388 }
389 */
390 }
391
392 if (!RandomView) {
393 break;
394 }
395
396 //
397 // Support Execution Interrupt.
398 //
400 return EFI_ABORTED;
401 }
402 }
403
404 ShellPrintEx (-1, -1, L"\n=========================================================\n");
405 return EFI_SUCCESS;
406 }
407
408 return EFI_BAD_BUFFER_SIZE;
409}
410
425 IN UINT8 QueryType,
426 IN UINT16 QueryHandle,
427 IN UINT8 Option,
428 IN BOOLEAN RandomView
429 )
430{
431 UINT16 Handle;
432 UINT8 *Buffer;
433 UINT16 Length;
434 UINTN Index;
435 SMBIOS_STRUCTURE_POINTER SmbiosStruct;
436 SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
437
438 SMBiosTable = NULL;
439 LibSmbios64BitGetEPS (&SMBiosTable);
440 if (SMBiosTable == NULL) {
441 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
442 return EFI_BAD_BUFFER_SIZE;
443 }
444
445 if (CompareMem (SMBiosTable->AnchorString, SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH) == 0) {
446 //
447 // Have got SMBIOS table
448 //
449 Smbios64BitPrintEPSInfo (SMBiosTable, Option);
450
451 SmbiosMajorVersion = SMBiosTable->MajorVersion;
452 SmbiosMinorVersion = SMBiosTable->MinorVersion;
453
454 ShellPrintEx (-1, -1, L"=========================================================\n");
455 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), gShellDebug1HiiHandle);
456
457 if (QueryType == STRUCTURE_TYPE_RANDOM) {
458 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM), gShellDebug1HiiHandle);
459 } else {
460 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE), gShellDebug1HiiHandle, QueryType);
461 }
462
463 if (RandomView) {
464 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM), gShellDebug1HiiHandle);
465 } else {
466 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE), gShellDebug1HiiHandle, QueryHandle);
467 }
468
469 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE), gShellDebug1HiiHandle);
470 ShellPrintEx (-1, -1, GetShowTypeString (gShowType));
471 ShellPrintEx (-1, -1, L"\n\n");
472
473 /*
474 //
475 // Get internal commands, such as change options.
476 //
477 Status = WaitEnter ();
478 if (EFI_ERROR (Status)) {
479 if (Status == EFI_ABORTED) {
480 return EFI_SUCCESS;
481 }
482
483 return Status;
484 }
485 */
486
487 //
488 // Searching and display structure info
489 //
490 Handle = QueryHandle;
491 for (Index = 0; Index < mNumberOfSmbios64BitStructures; Index++) {
492 //
493 // if reach the end of table, break..
494 //
495 if (Handle == INVALID_HANDLE) {
496 break;
497 }
498
499 //
500 // handle then point to the next!
501 //
502 if (LibGetSmbios64BitStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
503 break;
504 }
505
506 SmbiosStruct.Raw = Buffer;
507
508 //
509 // if QueryType==Random, print this structure.
510 // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
511 // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
512 //
513 if ((QueryType != STRUCTURE_TYPE_RANDOM) && (SmbiosStruct.Hdr->Type != QueryType)) {
514 continue;
515 }
516
517 ShellPrintEx (-1, -1, L"\n=========================================================\n");
519 -1,
520 -1,
521 NULL,
522 STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT),
523 gShellDebug1HiiHandle,
524 SmbiosStruct.Hdr->Type,
525 SmbiosStruct.Hdr->Handle
526 );
527 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length);
528 //
529 // Addr of structure in structure in table
530 //
531 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR), gShellDebug1HiiHandle, (UINTN)Buffer);
532 DumpHex (0, 0, Length, Buffer);
533
534 /*
535 //
536 // Get internal commands, such as change options.
537 //
538 Status = WaitEnter ();
539 if (EFI_ERROR (Status)) {
540 if (Status == EFI_ABORTED) {
541 return EFI_SUCCESS;
542 }
543
544 return Status;
545 }
546 */
547
548 if (gShowType != SHOW_NONE) {
549 //
550 // Print structure information
551 //
552 SmbiosPrintStructure (&SmbiosStruct, gShowType);
553 ShellPrintEx (-1, -1, L"\n");
554
555 /*
556 //
557 // Get internal commands, such as change options.
558 //
559 Status = WaitEnter ();
560 if (EFI_ERROR (Status)) {
561 if (Status == EFI_ABORTED) {
562 return EFI_SUCCESS;
563 }
564
565 return Status;
566 }
567 */
568 }
569
570 if (!RandomView) {
571 break;
572 }
573
574 //
575 // Support Execution Interrupt.
576 //
578 return EFI_ABORTED;
579 }
580 }
581
582 ShellPrintEx (-1, -1, L"\n=========================================================\n");
583 return EFI_SUCCESS;
584 }
585
586 return EFI_BAD_BUFFER_SIZE;
587}
588
596 VOID
597 )
598{
599 UINT16 Handle;
600 UINT8 *Buffer;
601 UINT16 Length;
602 UINT16 Offset;
603 UINT16 Index;
604
605 SMBIOS_STRUCTURE_POINTER SmbiosStruct;
606 SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
607 STRUCTURE_STATISTICS *StatisticsPointer;
608
609 SMBiosTable = NULL;
610 LibSmbiosGetEPS (&SMBiosTable);
611 if (SMBiosTable == NULL) {
612 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
613 return EFI_NOT_FOUND;
614 }
615
616 if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING, SMBIOS_ANCHOR_STRING_LENGTH) != 0) {
617 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
618 return EFI_INVALID_PARAMETER;
619 }
620
621 //
622 // Allocate memory to mStatisticsTable
623 //
624 if (mStatisticsTable != NULL) {
625 FreePool (mStatisticsTable);
626 mStatisticsTable = NULL;
627 }
628
629 mStatisticsTable = (STRUCTURE_STATISTICS *)AllocateZeroPool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS));
630
631 if (mStatisticsTable == NULL) {
632 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle);
633 return EFI_OUT_OF_RESOURCES;
634 }
635
636 Offset = 0;
637 StatisticsPointer = mStatisticsTable;
638
639 //
640 // search from the first one
641 //
642 Handle = INVALID_HANDLE;
643 LibGetSmbiosStructure (&Handle, NULL, NULL);
644 for (Index = 1; Index <= SMBiosTable->NumberOfSmbiosStructures; Index++) {
645 //
646 // If reach the end of table, break..
647 //
648 if (Handle == INVALID_HANDLE) {
649 break;
650 }
651
652 //
653 // After LibGetSmbiosStructure(), handle then point to the next!
654 //
655 if (LibGetSmbiosStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
656 break;
657 }
658
659 SmbiosStruct.Raw = Buffer;
660
661 //
662 // general statistics
663 //
664 StatisticsPointer->Index = Index;
665 StatisticsPointer->Type = SmbiosStruct.Hdr->Type;
666 StatisticsPointer->Handle = SmbiosStruct.Hdr->Handle;
667 StatisticsPointer->Length = Length;
668 StatisticsPointer->Addr = Offset;
669
670 Offset = (UINT16)(Offset + Length);
671
672 StatisticsPointer = &mStatisticsTable[Index];
673 }
674
675 return EFI_SUCCESS;
676}
677
687 SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios64EntryPoint,
688 UINTN *NumberOfSmbios64Structures,
689 UINTN *Smbios64TableLength
690 )
691{
693 UINT8 *Raw;
694
695 *Smbios64TableLength = 0;
696 *NumberOfSmbios64Structures = 0;
697
698 Smbios.Raw = (UINT8 *)(UINTN)(Smbios64EntryPoint->TableAddress);
699 while (TRUE) {
700 if (Smbios.Hdr->Type == 127) {
701 //
702 // Reach the end of table type 127
703 //
704 (*NumberOfSmbios64Structures)++;
705 (*Smbios64TableLength) += sizeof (SMBIOS_STRUCTURE);
706 return EFI_SUCCESS;
707 }
708
709 Raw = Smbios.Raw;
710 //
711 // Walk to next structure
712 //
713 LibGetSmbiosString (&Smbios, (UINT16)(-1));
714 //
715 // Length = Next structure head - this structure head
716 //
717 (*Smbios64TableLength) += ((UINTN)Smbios.Raw - (UINTN)Raw);
718 if ((*Smbios64TableLength) > Smbios64EntryPoint->TableMaximumSize) {
719 //
720 // The actual table length exceeds maximum table size,
721 // There should be something wrong with SMBIOS table.
722 //
723 return EFI_INVALID_PARAMETER;
724 }
725
726 (*NumberOfSmbios64Structures)++;
727 }
728}
729
737 VOID
738 )
739{
740 UINT16 Handle;
741 UINT8 *Buffer;
742 UINT16 Length;
743 UINT16 Offset;
744 UINT16 Index;
745 EFI_STATUS Status;
746 SMBIOS_STRUCTURE_POINTER SmbiosStruct;
747 SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
748 STRUCTURE_STATISTICS *StatisticsPointer;
749
750 SMBiosTable = NULL;
751 LibSmbios64BitGetEPS (&SMBiosTable);
752 if (SMBiosTable == NULL) {
753 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
754 return EFI_NOT_FOUND;
755 }
756
757 if (CompareMem (SMBiosTable->AnchorString, SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH) != 0) {
758 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
759 return EFI_INVALID_PARAMETER;
760 }
761
762 //
763 // Allocate memory to mSmbios64BitStatisticsTable
764 //
765 if (mSmbios64BitStatisticsTable != NULL) {
766 FreePool (mSmbios64BitStatisticsTable);
767 mSmbios64BitStatisticsTable = NULL;
768 }
769
770 //
771 // Calculate number of smbios structures
772 //
773 Status = CalculateSmbios64BitStructureCountAndLength (SMBiosTable, &mNumberOfSmbios64BitStructures, &mSmbios64BitTableLength);
774 if ((EFI_ERROR (Status)) || (mSmbios64BitTableLength > SMBiosTable->TableMaximumSize)) {
775 return EFI_INVALID_PARAMETER;
776 }
777
778 mSmbios64BitStatisticsTable = (STRUCTURE_STATISTICS *)AllocateZeroPool (mNumberOfSmbios64BitStructures * sizeof (STRUCTURE_STATISTICS));
779
780 if (mSmbios64BitStatisticsTable == NULL) {
781 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle);
782 return EFI_OUT_OF_RESOURCES;
783 }
784
785 Offset = 0;
786 StatisticsPointer = mSmbios64BitStatisticsTable;
787
788 //
789 // search from the first one
790 //
791 Handle = INVALID_HANDLE;
793 for (Index = 1; (UINTN)Index <= mNumberOfSmbios64BitStructures; Index++) {
794 //
795 // If reach the end of table, break..
796 //
797 if (Handle == INVALID_HANDLE) {
798 break;
799 }
800
801 //
802 // After LibGetSmbios64BitStructure(), handle then point to the next!
803 //
804 if (LibGetSmbios64BitStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
805 break;
806 }
807
808 SmbiosStruct.Raw = Buffer;
809
810 //
811 // general statistics
812 //
813 StatisticsPointer->Index = Index;
814 StatisticsPointer->Type = SmbiosStruct.Hdr->Type;
815 StatisticsPointer->Handle = SmbiosStruct.Hdr->Handle;
816 StatisticsPointer->Length = Length;
817 StatisticsPointer->Addr = Offset;
818
819 Offset = (UINT16)(Offset + Length);
820
821 StatisticsPointer = &mSmbios64BitStatisticsTable[Index];
822 }
823
824 return EFI_SUCCESS;
825}
826
836 IN UINT8 Option
837 )
838{
839 UINTN Index;
840 UINTN Num;
841 STRUCTURE_STATISTICS *StatisticsPointer;
842 SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
843
844 SMBiosTable = NULL;
845 if (Option < SHOW_OUTLINE) {
846 return EFI_SUCCESS;
847 }
848
849 //
850 // display EPS information firstly
851 //
852 LibSmbiosGetEPS (&SMBiosTable);
853 if (SMBiosTable == NULL) {
854 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
855 return EFI_UNSUPPORTED;
856 }
857
858 ShellPrintEx (-1, -1, L"\n============================================================\n");
859 SmbiosPrintEPSInfo (SMBiosTable, Option);
860
861 if (Option < SHOW_NORMAL) {
862 return EFI_SUCCESS;
863 }
864
865 if (mStatisticsTable == NULL) {
866 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS), gShellDebug1HiiHandle);
867 return EFI_NOT_FOUND;
868 }
869
870 ShellPrintEx (-1, -1, L"============================================================\n");
871 StatisticsPointer = &mStatisticsTable[0];
872 Num = SMBiosTable->NumberOfSmbiosStructures;
873 //
874 // display statistics table content
875 //
876 for (Index = 1; Index <= Num; Index++) {
877 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);
878 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);
879 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);
880 if (Option >= SHOW_DETAIL) {
881 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);
882 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);
883 }
884
885 ShellPrintEx (-1, -1, L"\n");
886 StatisticsPointer = &mStatisticsTable[Index];
887
888 /*
889 //
890 // Display 20 lines and wait for a page break
891 //
892 if (Index % 20 == 0) {
893 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
894 Status = WaitEnter ();
895 if (EFI_ERROR (Status)) {
896 if (Status == EFI_ABORTED) {
897 return EFI_SUCCESS;
898 }
899
900 return Status;
901 }
902 }
903 */
904 }
905
906 return EFI_SUCCESS;
907}
908
918 IN UINT8 Option
919 )
920{
921 UINTN Index;
922 UINTN Num;
923 STRUCTURE_STATISTICS *StatisticsPointer;
924 SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
925
926 SMBiosTable = NULL;
927 if (Option < SHOW_OUTLINE) {
928 return EFI_SUCCESS;
929 }
930
931 //
932 // display EPS information firstly
933 //
934 LibSmbios64BitGetEPS (&SMBiosTable);
935 if (SMBiosTable == NULL) {
936 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
937 return EFI_UNSUPPORTED;
938 }
939
940 ShellPrintEx (-1, -1, L"\n============================================================\n");
941 Smbios64BitPrintEPSInfo (SMBiosTable, Option);
942
943 if (Option < SHOW_NORMAL) {
944 return EFI_SUCCESS;
945 }
946
947 if (mSmbios64BitStatisticsTable == NULL) {
948 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS), gShellDebug1HiiHandle);
949 return EFI_NOT_FOUND;
950 }
951
952 ShellPrintEx (-1, -1, L"============================================================\n");
953 StatisticsPointer = &mSmbios64BitStatisticsTable[0];
954 Num = mNumberOfSmbios64BitStructures;
955 //
956 // display statistics table content
957 //
958 for (Index = 1; Index <= Num; Index++) {
959 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);
960 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);
961 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);
962 if (Option >= SHOW_DETAIL) {
963 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);
964 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);
965 }
966
967 ShellPrintEx (-1, -1, L"\n");
968 StatisticsPointer = &mSmbios64BitStatisticsTable[Index];
969
970 /*
971 //
972 // Display 20 lines and wait for a page break
973 //
974 if (Index % 20 == 0) {
975 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
976 Status = WaitEnter ();
977 if (EFI_ERROR (Status)) {
978 if (Status == EFI_ABORTED) {
979 return EFI_SUCCESS;
980 }
981
982 return Status;
983 }
984 }
985 */
986 }
987
988 return EFI_SUCCESS;
989}
990
998CHAR16 *
1000 UINT8 ShowType
1001 )
1002{
1003 //
1004 // show type
1005 //
1006 switch (ShowType) {
1007 case SHOW_NONE:
1008 return L"SHOW_NONE";
1009
1010 case SHOW_OUTLINE:
1011 return L"SHOW_OUTLINE";
1012
1013 case SHOW_NORMAL:
1014 return L"SHOW_NORMAL";
1015
1016 case SHOW_DETAIL:
1017 return L"SHOW_DETAIL";
1018
1019 case SHOW_ALL:
1020 return L"SHOW_ALL";
1021
1022 default:
1023 return L"Undefined type";
1024 }
1025}
UINT64 UINTN
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define SMBIOS_3_0_ANCHOR_STRING
Definition: SmBios.h:65
#define SMBIOS_ANCHOR_STRING
Definition: SmBios.h:56
EFI_STATUS LibSmbiosInit(VOID)
Definition: LibSmbiosView.c:29
EFI_STATUS LibGetSmbios64BitStructure(IN OUT UINT16 *Handle, OUT UINT8 **Buffer, OUT UINT16 *Length)
VOID LibSmbios64BitGetEPS(OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure)
EFI_STATUS LibGetSmbiosStructure(IN OUT UINT16 *Handle, OUT UINT8 **Buffer, OUT UINT16 *Length)
EFI_STATUS LibSmbios64BitInit(VOID)
Definition: LibSmbiosView.c:71
CHAR8 * LibGetSmbiosString(IN SMBIOS_STRUCTURE_POINTER *Smbios, IN UINT16 StringNumber)
VOID LibSmbios64BitCleanup(VOID)
VOID LibSmbiosCleanup(VOID)
VOID LibSmbiosGetEPS(OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_NOT_FOUND
Definition: Shell.h:101
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
EFI_STATUS SmbiosPrintStructure(IN SMBIOS_STRUCTURE_POINTER *Struct, IN UINT8 Option)
Definition: PrintInfo.c:305
VOID SmbiosPrintEPSInfo(IN SMBIOS_TABLE_ENTRY_POINT *SmbiosTable, IN UINT8 Option)
Definition: PrintInfo.c:135
VOID Smbios64BitPrintEPSInfo(IN SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable, IN UINT8 Option)
Definition: PrintInfo.c:220
VOID EFIAPI DumpHex(IN UINTN Indent, IN UINTN Offset, IN UINTN DataSize, IN VOID *UserData)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
UINTN EFIAPI ShellStrToUintn(IN CONST CHAR16 *String)
BOOLEAN EFIAPI ShellGetExecutionBreakFlag(VOID)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
Definition: ShellLib.h:700
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS DisplayStatisticsTable(IN UINT8 Option)
Definition: SmbiosView.c:835
EFI_STATUS DisplaySmbios64BitStatisticsTable(IN UINT8 Option)
Definition: SmbiosView.c:917
EFI_STATUS SMBios64View(IN UINT8 QueryType, IN UINT16 QueryHandle, IN UINT8 Option, IN BOOLEAN RandomView)
Definition: SmbiosView.c:424
EFI_STATUS InitSmbiosTableStatistics(VOID)
Definition: SmbiosView.c:595
EFI_STATUS CalculateSmbios64BitStructureCountAndLength(SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios64EntryPoint, UINTN *NumberOfSmbios64Structures, UINTN *Smbios64TableLength)
Definition: SmbiosView.c:686
CHAR16 * GetShowTypeString(UINT8 ShowType)
Definition: SmbiosView.c:999
EFI_STATUS InitSmbios64BitTableStatistics(VOID)
Definition: SmbiosView.c:736
SHELL_STATUS EFIAPI ShellCommandRunSmbiosView(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: SmbiosView.c:43
EFI_STATUS SMBiosView(IN UINT8 QueryType, IN UINT16 QueryHandle, IN UINT8 Option, IN BOOLEAN RandomView)
Definition: SmbiosView.c:245
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
#define STRING_TOKEN(t)