summaryrefslogtreecommitdiff
path: root/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
blob: a2be72e754004e3c0456176f0ea610d5bff317d3 (plain)
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
/** @file

  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.

  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#pragma once

#include <Protocol/ConfigurationManagerProtocol.h>
#include <Protocol/DynamicTableFactoryProtocol.h>

/**
  A SMBIOS Table Type from the OEM range reserved for terminating
  the SMBIOS table dispatch dependency.

  Note: According to the SMBIOS specification, Table Types 0
  through 127 (7Fh) are reserved for and defined by the
  SMBIOS specification.
  Types 128 through 256 (80h to FFh) are available for system and
  OEM-specific information.

  This Dynamic SMBIOS table generation implementation defines
  TableType FFh as a NULL table which is used by the Dynamic
  SMBIOS table dispatcher to terminate the dependency list.
*/
#define SMTT_NULL  0xFF

/**
  A macro defining the maximum number of dependendant SMBIOS tables
  represented by the SMBIOS table dispatcher.
*/
#define MAX_SMBIOS_DEPENDENCY  6

/**
  A macro defining the maximum table types handled by the SMBIOS
  table dispatcher.
*/
#define MAX_SMBIOS_TABLES  (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION + 1)

/**
  A helper macro to populate the SMBIOS table dispatcher table
*/
#define SMBIOS_TABLE_DEP(TableId, Order, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6) \
  { \
    TableId, \
    Order, \
    StNotPresent, \
    { Dep1, Dep2, Dep3, Dep4, Dep5, Dep6 } \
  }

/**
  An enum describing the states of the SMBIOS table dispatcher.
*/
typedef enum SmbiosTableState {
  StNotPresent,   ///< SMBIOS table is not present for installation.
  StPresent,      ///< SMBIOS table is present for installation.
  StDispatched    ///< SMBIOS table generators have been dispatched.
} SMBIOS_TABLE_STATE;

/**
  An enum describing the dispatch order for the SMBIOS tables.
*/
typedef enum DispatchOrder {
  OrderDef = 0,   ///< Default dispatch order.
  OrderL1,        ///< Dispatch order 1.
  OrderL2,        ///< Dispatch order 2.
  OrderL3,        ///< Dispatch order 3.
  OrderL4,        ///< Dispatch order 4.
  OrderL5,        ///< Dispatch order 5.
  OrderMax        ///< Dispatch order Max.
} DISPATCH_ORDER;

/**
  A structure describing the dependencies for a SMBIOS table and
  the dispatcher state information.
*/
typedef struct SmBiosTableDispatcher {
  /// SMBIOS Structure/Table Type
  SMBIOS_TABLE_TYPE     TableType;
  /// SMBIOS table dispatch order
  DISPATCH_ORDER        Order;
  /// SMBIOS dispatcher state
  SMBIOS_TABLE_STATE    State;
  /// SMBIOS Structure/Table dependency list
  /// The list is terminated using SMTT_NULL.
  SMBIOS_TABLE_TYPE     Dependency[MAX_SMBIOS_DEPENDENCY];
} SMBIOS_TABLE_DISPATCHER;

/**
  A helper function to build and install a SMBIOS table.

  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol
                                    interface.
  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager
                                    Protocol Interface.
  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.
  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

  @retval EFI_SUCCESS           Success.
  @retval EFI_INVALID_PARAMETER A parameter is invalid.
  @retval EFI_NOT_FOUND         Required object is not found.
  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager
                                is less than the Object size for the
                                requested object.
**/
EFI_STATUS
EFIAPI
BuildAndInstallSmbiosTable (
  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,
  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,
  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo
  );

/**
  Initialise the SMBIOS table dispatcher.

  @param SmbiosTableInfo  Pointer to the list of SMBIOS tables to be installed.
  @param SmbiosTableCount Count of SMBIOS tables to be installed.
**/
VOID
EFIAPI
InitSmbiosTableDispatcher (
  IN  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo,
  IN  UINT32                        SmbiosTableCount
  );

/** Schedule the dispatch of SMBIOS tables.

  The SMBIOS dispatcher state table is used to establish the dependency
  order in which the SMBIOS tables are installed. This allows the SMBIOS
  dispatcher to dispatch the dependent tables for installation before the
  parent table is installed.
  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish the
  dependency list.
  Elements in the Dependency list are resolved by increasing index. However,
  all orders are equivalent as:
  - the Parent SMBIOS table will only be installed once all dependencies
    have been satisfied.
  - no cyclic dependency is allowed.
  The dependency list is terminated by SMTT_NULL.

  The SMBIOS dispatcher dispatches the tables that have the default
  order (OrderDef) set before the ordered SMBIOS tables are dispatched.
  The SMBIOS_TABLE_DISPATCHER.Order field is used to establish the
  dispatch order.

  The order specified in the SMBIOS dispatcher table must be unique for all
  orders other than OrderDef. The dependency walk is only done for tables
  that have the default dispatch order.

  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol
                                    interface.
  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager
                                    Protocol Interface.
  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.
  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.
  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

  @retval EFI_SUCCESS           Success.
  @retval EFI_INVALID_PARAMETER A parameter is invalid.
  @retval EFI_NOT_FOUND         Required object is not found.
  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager
                                is less than the Object size for the
                                requested object.
**/
EFI_STATUS
EFIAPI
DispatchSmbiosTables (
  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,
  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,
  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,
  IN CONST UINT32                                        SmbiosTableCount
  );