hc
2024-03-26 e0728245c89800c2038c23308f2d88969d5b41c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
/** @file
  This driver installs SMBIOS information for Phytium Durian platforms.
 
  Copyright (C) 2020, Phytium Technology Co Ltd. All rights reserved.<BR>
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
**/
 
 
#include <IndustryStandard/SmBios.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Platform.h>
#include <Protocol/Smbios.h>
 
// SMBIOS tables often reference each other using
// fixed constants, define a list of these constants
// for our hardcoded tables
 
#define TYPE0_STRINGS                                         \
  "PHYTIUM LTD\0"                         /* Vendor */        \
  "V1.0\0"                                /* BiosVersion */   \
  __DATE__"\0"                            /* BiosReleaseDate */
 
#define TYPE1_STRINGS                                        \
  "PHYTIUM LTD\0"                         /* Manufacturer */ \
  "Phytium Durian Development Platform\0" /* Product Name */ \
  "None\0"                                /* Version */      \
  "Not Set\0"                             /* SerialNumber */ \
  "Not set\0"                             /* SKUNumber */    \
  "FT-2000/4\0"                           /* Family */       \
 
#define TYPE2_STRINGS                                        \
  "PHYTIUM LTD\0"                         /* Manufacturer */ \
  "Phytium Durian Development Platform\0" /* Product Name */ \
  "None\0"                                /* Version */        \
  "Not Set\0"                             /* Serial */         \
  "Not Set\0"                             /* BaseBoardAssetTag */ \
  "Not Set\0"                             /* BaseBoardChassisLocation */
 
#define TYPE3_STRINGS                                       \
  "PHYTIUM LTD\0"                        /* Manufacturer */ \
  "None\0"                               /* Version */      \
  "Not Set\0"                            /* Serial  */      \
  "Not Set\0"                            /* AssetTag  */
 
#define TYPE4_STRINGS                                                   \
  "FT-2000/4\0"                          /* socket type */              \
  "PHYTIUM LTD\0"                        /* manufactuer */              \
  "FT-2000/4\0"                          /* processor version */        \
  "Not Set\0"                            /* SerialNumber */             \
  "Not Set\0"                            /* processor 2 description */  \
  "Not Set\0"                            /* AssetTag */
 
 
#define TYPE7_STRINGS                              \
  "L1 Instruction\0"                 /* L1I  */    \
  "L1 Data\0"                        /* L1D  */    \
  "L2\0"                             /* L2   */
 
#define TYPE7_L1DATA_STRINGS          \
  "L1 Data Cache\0"                  /* L1 data   */
 
 
#define TYPE7_L1INS_STRINGS           \
  "L1 Instruction Cache\0"          /* L1 ins   */
 
#define TYPE7_L2_STRINGS              \
  "L2 Cache\0"                      /* L2   */
 
#define TYPE7_L3_STRINGS              \
  "L3 Cache\0"                     /* L3   */
 
 
#define TYPE9_STRINGS                                     \
  "PCIE_SLOT0\0"                     /* Slot0 */          \
  "PCIE_SLOT1\0"                     /* Slot1 */          \
  "PCIE_SLOT2\0"                     /* Slot2 */          \
  "PCIE_SLOT3\0"                     /* Slot3 */
 
#define TYPE9_STRINGS_PCIE0X16                            \
  "PCIE0_X16\0"
 
#define TYPE9_STRINGS_PCIE0X1                             \
  "PCIE0_X1\0"
 
#define TYPE9_STRINGS_PCIE1X16                            \
  "PCIE1_X16\0"
 
#define TYPE9_STRINGS_PCIE1X1                             \
  "PCIE1_X1\0"
 
#define TYPE13_STRINGS                                    \
  "en|US|iso8859-1\0"                                     \
  "zh|CN|unicode\0"
 
 
#define TYPE16_STRINGS                                     \
  "\0"                               /* nothing */
 
#define TYPE17_STRINGS_CHANNEL0                            \
  "SOCKET 0 CHANNEL 0 DIMM 0\0"     /* location */         \
  "Bank0\0"                         /* bank description */ \
  "Not Set\0"              \
  "Not Set\0"              \
  "Not Set\0"              \
  "Not Set\0"
 
#define TYPE17_STRINGS_CHANNEL1                            \
  "SOCKET 0 CHANNEL 1 DIMM 0\0"    /* location */          \
  "Bank0\0"                \
  "Not Set\0"              \
  "Not Set\0"              \
  "Not Set\0"              \
  "Not Set\0"
 
 
#define TYPE19_STRINGS                                \
  "\0"                              /* nothing */
 
#define TYPE32_STRINGS                                \
  "\0"                              /* nothing */
 
#define TYPE39_STRINGS                          \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/    \
  "Not specified\0"       /* not specified*/
 
#define TYPE38_STRINGS                          \
  "\0"
 
//
// Type definition and contents of the default SMBIOS table.
// This table covers only the minimum structures required by
// the SMBIOS specification (section 6.2, version 3.0)
//
#pragma pack(1)
typedef struct {
  SMBIOS_TABLE_TYPE0 Base;
  INT8              Strings[sizeof (TYPE0_STRINGS)];
} ARM_TYPE0;
 
typedef struct {
  SMBIOS_TABLE_TYPE1 Base;
  UINT8              Strings[sizeof (TYPE1_STRINGS)];
} ARM_TYPE1;
 
typedef struct {
  SMBIOS_TABLE_TYPE2 Base;
  UINT8              Strings[sizeof (TYPE2_STRINGS)];
} ARM_TYPE2;
 
typedef struct {
  SMBIOS_TABLE_TYPE3 Base;
  UINT8              Strings[sizeof (TYPE3_STRINGS)];
} ARM_TYPE3;
 
typedef struct {
  SMBIOS_TABLE_TYPE4 Base;
  UINT8              Strings[sizeof (TYPE4_STRINGS)];
} ARM_TYPE4;
 
typedef struct {
  SMBIOS_TABLE_TYPE7 Base;
  UINT8              Strings[sizeof (TYPE7_L1DATA_STRINGS)];
} ARM_TYPE7_L1DATA;
 
typedef struct {
  SMBIOS_TABLE_TYPE7 Base;
  UINT8              Strings[sizeof (TYPE7_L1INS_STRINGS)];
} ARM_TYPE7_L1INS;
 
typedef struct {
  SMBIOS_TABLE_TYPE7 Base;
  UINT8              Strings[sizeof (TYPE7_L2_STRINGS)];
} ARM_TYPE7_L2;
 
typedef struct {
  SMBIOS_TABLE_TYPE7 Base;
  UINT8              Strings[sizeof (TYPE7_L3_STRINGS)];
} ARM_TYPE7_L3;
 
 
typedef struct {
  SMBIOS_TABLE_TYPE9 Base;
  UINT8              Strings[sizeof (TYPE9_STRINGS)];
} ARM_TYPE9;
 
typedef struct {
  SMBIOS_TABLE_TYPE9 Base;
  UINT8              Strings[sizeof (TYPE9_STRINGS_PCIE0X16)];
} ARM_TYPE9_PCIE0X16;
 
typedef struct {
  SMBIOS_TABLE_TYPE9 Base;
  UINT8              Strings[sizeof (TYPE9_STRINGS_PCIE0X1)];
} ARM_TYPE9_PCIE0X1;
 
typedef struct {
  SMBIOS_TABLE_TYPE9 Base;
  UINT8              Strings[sizeof (TYPE9_STRINGS_PCIE1X16)];
} ARM_TYPE9_PCIE1X16;
 
typedef struct {
  SMBIOS_TABLE_TYPE9 Base;
  UINT8              Strings[sizeof (TYPE9_STRINGS_PCIE1X1)];
} ARM_TYPE9_PCIE1X1;
 
 
typedef struct {
  SMBIOS_TABLE_TYPE13 Base;
  UINT8              Strings[sizeof (TYPE13_STRINGS)];
} ARM_TYPE13;
 
typedef struct {
  SMBIOS_TABLE_TYPE16 Base;
  UINT8              Strings[sizeof (TYPE16_STRINGS)];
} ARM_TYPE16;
 
typedef struct {
  SMBIOS_TABLE_TYPE17 Base;
  UINT8               Strings[sizeof (TYPE17_STRINGS_CHANNEL0)];
} ARM_TYPE17_CHANNEL0;
 
typedef struct {
  SMBIOS_TABLE_TYPE17 Base;
  UINT8               Strings[sizeof (TYPE17_STRINGS_CHANNEL1)];
} ARM_TYPE17_CHANNEL1;
 
typedef struct {
  SMBIOS_TABLE_TYPE19 Base;
  UINT8              Strings[sizeof (TYPE19_STRINGS)];
} ARM_TYPE19;
 
typedef struct {
  SMBIOS_TABLE_TYPE32 Base;
  UINT8              Strings[sizeof (TYPE32_STRINGS)];
} ARM_TYPE32;
 
typedef struct {
  SMBIOS_TABLE_TYPE38 Base;
  UINT8              Strings[sizeof (TYPE38_STRINGS)];
} ARM_TYPE38;
 
typedef struct {
  SMBIOS_TABLE_TYPE39 Base;
  UINT8              Strings[sizeof (TYPE39_STRINGS)];
} ARM_TYPE39;
 
enum SMBIOS_REFRENCE_HANDLES {
  SMBIOS_HANDLE_L1I = 0x1000,
  SMBIOS_HANDLE_L1D,
  SMBIOS_HANDLE_L2,
  SMBIOS_HANDLE_L3,
  SMBIOS_HANDLE_MOTHERBOARD,
  SMBIOS_HANDLE_CHASSIS,
  SMBIOS_HANDLE_CLUSTER,
  SMBIOS_HANDLE_MEMORY,
  SMBIOS_HANDLE_DIMM_0,
  SMBIOS_HANDLE_DIMM_1
};
 
#define SERIAL_LEN 10  //this must be less than the buffer len allocated in the type1 structure
 
#pragma pack()
 
//BIOS Information (Type 0)
ARM_TYPE0  BiosInfo_Type0 = {
    {
      { // SMBIOS_STRUCTURE Hdr
        EFI_SMBIOS_TYPE_BIOS_INFORMATION,        // UINT8 Type
        sizeof (SMBIOS_TABLE_TYPE0),             // UINT8 Length
        SMBIOS_HANDLE_PI_RESERVED
      },
      1,                                           //Vendor
      2,                                           //BiosVersion
      0x8800,                                      //BiosSegment
      3,                                           //BiosReleaseDate
      0xFF,                                        //BiosSize
      {                                            //BiosCharacteristics
        0,                                         // Reserved                          :2
        0,                                         // Unknown                           :1
        0,                                         // BiosCharacteristicsNotSupported   :1
        0,                                         // IsaIsSupported                    :1
        0,                                         // McaIsSupported                    :1
        0,                                         // EisaIsSupported                   :1
        1,                                         // PciIsSupported                    :1
        0,                                         // PcmciaIsSupported                 :1
        0,                                         // PlugAndPlayIsSupported            :1
        0,                                         // ApmIsSupported                    :1
        1,                                         // BiosIsUpgradable                  :1
        0,                                         // BiosShadowingAllowed              :1
        0,                                         // VlVesaIsSupported                 :1
        0,                                         // EscdSupportIsAvailable            :1
        1,                                         // BootFromCdIsSupported             :1
        1,                                         // SelectableBootIsSupported         :1
        0,                                         // RomBiosIsSocketed                 :1
        0,                                         // BootFromPcmciaIsSupported         :1
        0,                                         // EDDSpecificationIsSupported       :1
        0,                                         // JapaneseNecFloppyIsSupported      :1
        0,                                         // JapaneseToshibaFloppyIsSupported  :1
        0,                                         // Floppy525_360IsSupported          :1
        0,                                         // Floppy525_12IsSupported           :1
        0,                                         // Floppy35_720IsSupported           :1
        0,                                         // Floppy35_288IsSupported           :1
        0,                                         // PrintScreenIsSupported            :1
        0,                                         // Keyboard8042IsSupported           :1
        0,                                         // SerialIsSupported                 :1
        0,                                         // PrinterIsSupported                :1
        0,                                         // CgaMonoIsSupported                :1
        0,                                         // NecPc98                           :1
        0                                          // ReservedForVendor                 :3
      },
      {
        0x03,                                      //BIOSCharacteristicsExtensionBytes[0]
        0x0D                                       //BIOSCharacteristicsExtensionBytes[1]
      },
      0xFF,                                        //SystemBiosMajorRelease;
      0xFF,                                        //SystemBiosMinorRelease;
      0xFF,                                        //EmbeddedControllerFirmwareMajorRelease;
      0xFF,                                        //EmbeddedControllerFirmwareMinorRelease;
  },
  TYPE0_STRINGS
};
 
//System Information (Type 1).
ARM_TYPE1 SystemInfo_Type1 = {
    {
      {                                               // Hdr
        EFI_SMBIOS_TYPE_SYSTEM_INFORMATION,           // Type,
        sizeof (SMBIOS_TABLE_TYPE1),                  // UINT8 Length
        SMBIOS_HANDLE_PI_RESERVED                     // Handle
      },
      1,                                              // Manufacturer
      2,                                              // ProductName
      3,                                              // Version
      4,                                              // SerialNumber
      {                                               // Uuid
          0x12345678, 0x1234, 0x5678, {0x90, 0xab, 0xcd, 0xde, 0xef, 0xaa, 0xbb, 0xcc}
      },
      SystemWakeupTypePowerSwitch,                    // SystemWakeupType
      5,                                              // SKUNumber,
      6                                               // Family
  },
  TYPE1_STRINGS
};
 
//Base Board (or Module) Information (Type 2)
ARM_TYPE2 BaseboardInfo_Type2 = {
    {
      {                                                       // Hdr
        EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION,                // Type,
        sizeof (SMBIOS_TABLE_TYPE2),                          // UINT8 Length
        SMBIOS_HANDLE_MOTHERBOARD                             // Handle
      },
      1,                                                      // BaseBoardManufacturer
      2,                                                      // BaseBoardProductName
      3,                                                      // BaseBoardVersion
      4,                                                      // BaseBoardSerialNumber
      5,                                                      // BaseBoardAssetTag
      {                                                       // FeatureFlag
        1,                                                    // Motherboard           :1
        0,                                                    // RequiresDaughterCard  :1
        0,                                                    // Removable             :1
        1,                                                    // Replaceable           :1
        0,                                                    // HotSwappable          :1
        0                                                     // Reserved              :3
      },
      6,                                                      // BaseBoardChassisLocation
      0,                                                      // ChassisHandle;
      BaseBoardTypeMotherBoard,                               // BoardType;
      0,                                                      // NumberOfContainedObjectHandles;
      {
        0
      }                                                       // ContainedObjectHandles[1];
  },
  TYPE2_STRINGS
};
 
//System Enclosure or Chassis (Type 3)
ARM_TYPE3 SystemEnclosure_Type3 = {
    {
      {                                                       // Hdr
        EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE  ,                   // Type,
        sizeof (SMBIOS_TABLE_TYPE3),                          // UINT8 Length
        SMBIOS_HANDLE_CHASSIS                                 // Handle
      },
      1,                                                      // Manufactrurer
      MiscChassisTypeMainServerChassis,                       // Type
      2,                                                      // Version
      3,                                                      // SerialNumber
      4,                                                      // AssetTag
      ChassisStateSafe,                                       // BootupState
      ChassisStateSafe,                                       // PowerSupplyState
      ChassisStateSafe,                                       // ThermalState
      ChassisSecurityStatusNone,                              // SecurityState
      {
        0,                                                    // OemDefined[0]
        0,                                                    // OemDefined[1]
        0,                                                    // OemDefined[2]
        0                                                     // OemDefined[3]
      },
      2,                                                      // Height
      1,                                                      // NumberofPowerCords
      0,                                                      // ContainedElementCount
      0,                                                      // ContainedElementRecordLength
      {                                                       // ContainedElements[0]
        {
            0,                                                // ContainedElementType
            0,                                                // ContainedElementMinimum
            0                                                 // ContainedElementMaximum
        }
      }
  },
  TYPE3_STRINGS
};
 
//Processor Infomation (Type 4)
ARM_TYPE4 ProcessorInfo_Type4 = {
  {
    {                                           //Header
      EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION,    //Type
      sizeof (SMBIOS_TABLE_TYPE4),              //Length
      SMBIOS_HANDLE_CLUSTER                     //Handle
    },
    1,                                          //Socket
    CentralProcessor,                           //ProcessorType
    ProcessorFamilyIndicatorFamily2,            //ProcessorFamily
    2,                                          //ProcessorManufacture
    {                                           //ProcessorId
      {                                         //Signature
        0
      },
      {                                         //FeatureFlags
        0
      }
    },
    3,                                          //ProcessorVersion
    {                                           //Voltage
      0, 0, 0, 1, 0, 1
    },
    1,                                          //ExternalClock
    1,                                          //MaxSpeed
    0,                                          //CurrentSpeed
    0x41,                                       //Status
    ProcessorUpgradeUnknown,                    //ProcessorUpgrade
    SMBIOS_HANDLE_L1D,                          //L1Ins
    SMBIOS_HANDLE_L2,                           //L1Data
    SMBIOS_HANDLE_L3,                           //L2
    4,                                          //SerialNumber
    5,                                          //AssetTag
    6,                                          //PartNumber
 
    4,                                          //CoreCount
    0,                                          //EnabledCoreCount
    0,                                          //ThreadCount
    0x00EC,                                     //ProcessorCharacteristics
 
    ProcessorFamilyARMv8,                       //ProcessorFamily2
 
    0,                                          //CoreCount2
    0,                                          //EnabledCoreCount2
    0                                           //ThreadCount2
  },
  TYPE4_STRINGS
};
 
//Cache Information (Type7) L1 DATA
ARM_TYPE7_L1DATA L1Data_Type7 = {
  {
    {                                               //Header
      EFI_SMBIOS_TYPE_CACHE_INFORMATION,            //Type
      sizeof (SMBIOS_TABLE_TYPE7),                  //Length
      SMBIOS_HANDLE_L1D                             //Handle
    },
    1,                                              //SocketDesignation
    0x0180,                                         //CacheConfiguration
    0,                                              //MaximumCacheSize
    0,                                              //InstalledSize
    {                                               //SupportedSRAMType
      0, 0, 0, 0, 0, 1, 0, 0
    },
    {                                               //CurrentSRAMType
        0, 0, 0, 0, 0, 1, 0, 0
    },
    0,                                              //CacheSpeed
    CacheErrorSingleBit,                            //ErrorCorrectionType
    CacheTypeData,                                  //SystemCacheType
    CacheAssociativity8Way,                         //Associativity
    128,
    128
  },
  TYPE7_L1DATA_STRINGS
};
 
//Cache Information (Type7) L1 INS
ARM_TYPE7_L1INS L1Ins_Type7 = {
  {
    {                                               //Header
      EFI_SMBIOS_TYPE_CACHE_INFORMATION,            //Type
      sizeof (SMBIOS_TABLE_TYPE7),                  //Length
      SMBIOS_HANDLE_L1I                             //Handle
    },
    1,                                              //SocketDesignation
    0x0180,                                         //CacheConfiguration
    0,                                              //MaximumCacheSize
    0,                                              //InstalledSize
    {                                               //SupportedSRAMType
      0, 0, 0, 0, 0, 1, 0, 0
    },
    {                                               //CurrentSRAMType
       0, 0, 0, 0, 0, 1, 0, 0
    },
    0,                                              //CacheSpeed
    CacheErrorParity,                               //ErrorCorrectionType
    CacheTypeInstruction,                           //SystemCacheType
    CacheAssociativity8Way,                         //Associativity
    128,
    128
  },
  TYPE7_L1INS_STRINGS
};
 
//Cache Information (Type7) L2
ARM_TYPE7_L2 L2_Type7 = {
  {
    {                                               //Header
        EFI_SMBIOS_TYPE_CACHE_INFORMATION,          //Type
        sizeof (SMBIOS_TABLE_TYPE7),                //Length
        SMBIOS_HANDLE_L2                            //Handle
    },
    1,                                              //SocketDesignation
    0x0281,                                         //CacheConfiguration
    0,                                              //MaximumCacheSize
    0,                                              //InstalledSize
    {                                               //SupportedSRAMType
       0, 0, 0, 0, 0, 1, 0, 0
    },
    {                                               //CurrentSRAMType
       0, 0, 0, 0, 0, 1, 0, 0
    },
    0,                                              //CacheSpeed
    CacheErrorSingleBit,                            //ErrorCorrectionType
    CacheTypeUnified,                               //SystemCacheType
    CacheAssociativity8Way,                         //Associativity
    4096,
    4096
  },
  TYPE7_L2_STRINGS
};
 
//Cache Information (Type7) L3
ARM_TYPE7_L3 L3_Type7 = {
  {
    {                                               //Header
      EFI_SMBIOS_TYPE_CACHE_INFORMATION,            //Type
      sizeof (SMBIOS_TABLE_TYPE7),                  //Length
      SMBIOS_HANDLE_L3                              //Handle
    },
    1,                                              //SocketDesignation
    0x0281,                                         //CacheConfiguration
    0,                                              //MaximumCacheSize
    0,                                              //InstalledSize
    {                                               //SupportedSRAMType
       0, 0, 0, 0, 0, 1, 0, 0
    },
    {                                               //CurrentSRAMType
       0, 0, 0, 0, 0, 1, 0, 0
    },
    0,                                              //CacheSpeed
    CacheErrorSingleBit,                            //ErrorCorrectionType
    CacheTypeUnified,                               //SystemCacheType
    CacheAssociativity8Way,                         //Associativity
    4096,
    4096
  },
  TYPE7_L3_STRINGS
};
 
//PCIE0_X16   (Type 9)
ARM_TYPE9_PCIE0X16 Pcie0X16_Type9 = {
  {
    {  // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_SYSTEM_SLOTS,        // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE9),         // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    1,
    SlotTypePciX,
    SlotDataBusWidth16X,
    SlotUsageInUse,
    SlotLengthLong,
    0,
    {0, 0, 1, 1, 0, 0, 0, 0}, //unknown
    {1, 0, 0, 0, 0},  //PME and SMBUS
    0,
    0,
    0,
  },
  TYPE9_STRINGS_PCIE0X16
};
 
//PCIE0_X1    (Type 9)
ARM_TYPE9_PCIE0X1 Pcie0X1_Type9 = {
  {
    {  // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_SYSTEM_SLOTS,        // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE9),         // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    1,
    SlotTypePciX,
    SlotDataBusWidth1X,
    SlotUsageAvailable,
    SlotLengthShort,
    1,
    {0, 0, 1, 1, 0, 0, 0, 0}, //unknown
    {1, 0, 0, 0, 0},  //PME and SMBUS
    0xFF,
    0xFF,
    0xFF,
  },
  TYPE9_STRINGS_PCIE0X1
};
 
//PCIE1_X16   (Type 9)
ARM_TYPE9_PCIE1X16 Pcie1X16_Type9 = {
  {
    {  // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_SYSTEM_SLOTS,        // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE9),         // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    1,
    SlotTypePciX,
    SlotDataBusWidth16X,
    SlotUsageAvailable,
    SlotLengthLong,
    2,
    {0, 0, 1, 1, 0, 0, 0, 0}, //unknown
    {1, 0, 0, 0, 0},       //PME and SMBUS
    0xFF,
    0xFF,
    0xFF,
  },
  TYPE9_STRINGS_PCIE1X16
};
 
//PCIE1_X1  (Type 9)
ARM_TYPE9_PCIE1X1 Pcie1X1_Type9 = {
  {
    {  // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE9),  // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    1,
    SlotTypePciX,
    SlotDataBusWidth1X,
    SlotUsageAvailable,
    SlotLengthShort,
    3,
    {0, 0, 1, 1, 0, 0, 0, 0}, //unknown
    {1, 0, 0, 0, 0},       //PME and SMBUS
    0xFF,
    0xFF,
    0xFF,
  },
  TYPE9_STRINGS_PCIE1X1
};
 
//Bios Language Information (Type13)
ARM_TYPE13 BiosLangInfo_Type13 = {
  {
    { // SMBIOS_STRUCTURE Hdr
    EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION, // UINT8 Type
    sizeof (SMBIOS_TABLE_TYPE13),              // UINT8 Length
    SMBIOS_HANDLE_PI_RESERVED
    },
    2,
    0,
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    2
  },
  TYPE13_STRINGS
};
 
//Physical Memory Array (Type 16)
ARM_TYPE16 MemArray_Type16 = {
  {
    { // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE16),          // UINT8 Length
      SMBIOS_HANDLE_MEMORY
    },
    MemoryArrayLocationSystemBoard,
    MemoryArrayUseSystemMemory,
    MemoryErrorCorrectionNone,
    0x1000000,                                 //16G
    0xFFFE,
    2
  },
  TYPE16_STRINGS
};
 
//Memory Device (Type17)
ARM_TYPE17_CHANNEL0 MemDev_Type17_0 = {
  {
    { // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_MEMORY_DEVICE, // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE17),  // UINT8 Length
      SMBIOS_HANDLE_DIMM_0
    },
    SMBIOS_HANDLE_MEMORY, //array to which this module belongs
    0xFFFE,               //no errors
    64,                   //single DIMM, no ECC is 64bits (for ecc this would be 72)
    64,                   //data width of this device (64-bits)
    0x4000,               //16GB
    0x09,                 //FormFactor
    0,                    //not part of a set
    1,                    //right side of board
    2,                    //bank 0
    MemoryTypeDdr4,                    //LP DDR4
    {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, //unbuffered
    2400,                              //2400Mhz DDR
    3, //Manufacturer
    4, //serial
    5, //asset tag
    6, //part number
    0, //attrbute
    0x2000,     //  8G
    2400,       //2400MHz
    1500,       //Max V
    1500,       //Max V
    1500,       //Configure V
  },
  TYPE17_STRINGS_CHANNEL0
};
 
//Memory Device (Type17)
ARM_TYPE17_CHANNEL1 MemDev_Type17_1 = {
  {
    { // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_MEMORY_DEVICE, // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE17),  // UINT8 Length
      SMBIOS_HANDLE_DIMM_1
    },
    SMBIOS_HANDLE_MEMORY, //array to which this module belongs
    0xFFFE,               //no errors
    64,                   //single DIMM, no ECC is 64bits (for ecc this would be 72)
    64,                   //data width of this device (64-bits)
    0x2000,               //8GB
    0x09,                 //FormFactor
    0,                    //not part of a set
    1,                    //right side of board
    2,                    //bank 0
    MemoryTypeDdr4,                    //LP DDR4
    {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, //unbuffered
    2400,                              //2400Mhz DDR
    3, //varies between diffrent production runs
    4, //serial
    5, //asset tag
    6, //part number
    0, //attrbute
    0x4000,     //  16G
    2400,       //2400MHz
    1500,       //Max V
    1500,       //Max V
    1500,       //Configure V
  },
  TYPE17_STRINGS_CHANNEL1
};
 
//Memory Array Mapped Address (Type 19)
ARM_TYPE19 MemArrayMapAddr_Type19 = {
  {
    {  // SMBIOS_STRUCTURE Hdr
      EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, // UINT8 Type
      sizeof (SMBIOS_TABLE_TYPE19),                // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    0,
    0x1000000,  //16G
    SMBIOS_HANDLE_MEMORY, //handle
    2,
    0,      //starting addr of first 2GB
    0,      //ending addr of first 2GB
  },
  TYPE19_STRINGS
};
 
//System Boot Information (Type 32)
ARM_TYPE32 SystemBoot_Type32 = {
  {
    {
      EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,        // Type,
      sizeof (SMBIOS_TABLE_TYPE32),                   // UINT8 Length
      SMBIOS_HANDLE_PI_RESERVED
    },
    {                                                 // Reserved[6]
      0,
      0,
      0,
      0,
      0,
      0
    },
    BootInformationStatusNoError                     // BootInformationStatus
  },
  TYPE32_STRINGS
};
 
VOID *DefaultCommonTables[]=
{
  &BiosInfo_Type0,
  &SystemInfo_Type1,
  &BaseboardInfo_Type2,
  &SystemEnclosure_Type3,
  &ProcessorInfo_Type4,
  &L1Data_Type7,
  &L1Ins_Type7,
  &L2_Type7,
  &L3_Type7,
  &Pcie0X16_Type9,
  &Pcie0X1_Type9,
  &Pcie1X16_Type9,
  &Pcie1X1_Type9,
  &MemArray_Type16,
  &MemDev_Type17_0,
  &MemDev_Type17_1,
  &MemArrayMapAddr_Type19,
  &BiosLangInfo_Type13,
  &SystemBoot_Type32,
  NULL
};
 
 
/**
   Installed a whole table worth of structructures.
 
   @param[in] Smbios      The Pointer of Smbios Protocol.
 
   @retval EFI_SUCCESS    Table data successfully installed.
   @retval Other          Table data was not installed.
 
**/
EFI_STATUS
InstallStructures (
  IN EFI_SMBIOS_PROTOCOL       *Smbios,
  IN VOID *DefaultTables[]
  )
{
  EFI_STATUS                Status;
  EFI_SMBIOS_HANDLE         SmbiosHandle;
  UINT32                    TableEntry;
 
  Status = EFI_SUCCESS;
 
  for ( TableEntry =0; DefaultTables[TableEntry] != NULL; TableEntry++)
  {
    SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)DefaultTables[TableEntry])->Handle;
    Status = Smbios->Add (
    Smbios,
    NULL,
    &SmbiosHandle,
    (EFI_SMBIOS_TABLE_HEADER *) DefaultTables[TableEntry]
    );
    if (EFI_ERROR (Status))
      break;
    }
 
  return Status;
}
 
 
/**
   Installed All SMBIOS information.
 
   @param[in] Smbios      The Pointer of Smbios Protocol.
 
   @retval EFI_SUCCESS    SMBIOS information successfully installed.
   @retval Other          SMBIOS information was not installed.
 
**/
STATIC
EFI_STATUS
InstallAllStructures (
  IN EFI_SMBIOS_PROTOCOL       *Smbios
  )
{
  EFI_STATUS  Status;
 
  Status = EFI_SUCCESS;
 
  Status = InstallStructures (Smbios, DefaultCommonTables);
  ASSERT_EFI_ERROR (Status);
 
  return Status;
}
 
 
/**
   Find the smbios protocol and installed SMBIOS information
   for ARM platforms.
 
   @param[in] ImageHandle     Module's image handle.
   @param[in] SystemTable     Pointer of EFI_SYSTEM_TABLE.
 
   @retval EFI_SUCCESS    Smbios data successfully installed.
   @retval Other          Smbios data was not installed.
 
**/
EFI_STATUS
EFIAPI
SmbiosTablePublishEntry (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS                Status;
  EFI_SMBIOS_PROTOCOL       *Smbios;
 
  //
  // Find the SMBIOS protocol
  //
  Status = gBS->LocateProtocol (
    &gEfiSmbiosProtocolGuid,
    NULL,
    (VOID **)&Smbios
    );
  if (EFI_ERROR (Status)) {
    return Status;
  }
 
  Status = InstallAllStructures (Smbios);
 
  return Status;
}