hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
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
/** @file
  SMBIOS Type 3 (System enclosure) table for ARM RD platforms.
 
  This file installs SMBIOS Type 3 (System enclosure) table for Arm Reference
  Design platforms. SMBIOS Type 3 table (System Enclosure) includes information
  about manufacturer, type, serial number and other information related to
  system enclosure.
 
  Copyright (c) 2021, ARM Limited. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
  @par Specification Reference:
    - SMBIOS Reference Specification 3.4.0, Chapter 7.4
**/
 
#include <Library/DebugLib.h>
#include <Protocol/Smbios.h>
 
#include "SmbiosPlatformDxe.h"
 
#define TYPE3_STRINGS                                   \
  "ARM LTD\0"                   /* Manufacturer */      \
  "Version not set\0"           /* Version */           \
  "Serial not set\0"            /* Serial */            \
  "Asset Tag not set\0"         /* Asset Tag */
 
typedef enum {
  ManufacturerName = 1,
  Version,
  SerialNumber,
  AssetTag
} TYPE3_STRING_ELEMENTS;
 
/* SMBIOS Type3 structure */
#pragma pack(1)
typedef struct {
  SMBIOS_TABLE_TYPE3  Base;
  CHAR8               Strings[sizeof (TYPE3_STRINGS)];
} ARM_RD_SMBIOS_TYPE3;
#pragma pack()
 
/* System information */
STATIC ARM_RD_SMBIOS_TYPE3 mArmRdSmbiosType3 = {
  {
    {
      // SMBIOS header
      EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE,   // Type 3
      sizeof (SMBIOS_TABLE_TYPE1),        // Length
      SMBIOS_HANDLE_ENCLOSURE,            // Assign an unused handle number
    },
    ManufacturerName,               // Manufacturer
    2,                              // Enclosure type unknown
    Version,                        // Version
    SerialNumber,                   // Serial
    AssetTag,                       // Asset Tag
    ChassisStateSafe,               // Boot chassis state
    ChassisStateSafe,               // Power supply state
    ChassisStateSafe,               // Thermal state
    ChassisSecurityStatusUnknown,   // Security Status
    {0},                            // BIOS vendor specific Information
  },
  // Text strings (unformatted)
  TYPE3_STRINGS
};
 
/**
  Install SMBIOS System Enclosure Table
 
  Install the SMBIOS System Enclosure (type 3) table for Arm's Reference Design
  platforms.
 
  @param[in]  Smbios   SMBIOS protocol.
 
  @retval EFI_SUCCESS           Record was added.
  @retval EFI_OUT_OF_RESOURCES  Record was not added.
  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed is already in use.
**/
EFI_STATUS
InstallType3SystemEnclosure (
  IN     EFI_SMBIOS_PROTOCOL    *Smbios
  )
{
  EFI_STATUS Status;
  EFI_SMBIOS_HANDLE SmbiosHandle;
 
  SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType3)->Handle;
 
  /* Install type 3 table */
  Status = Smbios->Add (
                     Smbios,
                     NULL,
                     &SmbiosHandle,
                     (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType3
                     );
  if (EFI_ERROR (Status)) {
    DEBUG ((
      DEBUG_ERROR,
      "SMBIOS: Failed to install Type3 SMBIOS table.\n"
      ));
  }
 
  return Status;
}