3 UEFI Miscellaneous boot Services InstallConfigurationTable service
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. 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.
18 #define CONFIG_TABLE_SIZE_INCREASED 0x10
20 UINTN mSystemTableAllocateSize
= 0;
25 Find a config table by name in system table's ConfigurationTable.
27 @param Guid The table name to look for
28 @param Table Pointer of the config table
30 @retval EFI_NOT_FOUND Could not find the table in system table's
32 @retval EFI_SUCCESS Table successfully found.
43 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
44 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
45 *Table
= gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
;
57 Boot Service called to add, modify, or remove a system configuration table from
60 @param Guid Pointer to the GUID for the entry to add, update, or
62 @param Table Pointer to the configuration table for the entry to add,
63 update, or remove, may be NULL.
65 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
66 @return EFI_INVALID_PARAMETER Input GUID not valid.
67 @return EFI_NOT_FOUND Attempted to delete non-existant entry
68 @return EFI_OUT_OF_RESOURCES Not enough memory available
73 CoreInstallConfigurationTable (
79 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
82 // If Guid is NULL, then this operation cannot be performed
85 return EFI_INVALID_PARAMETER
;
88 EfiConfigurationTable
= gDxeCoreST
->ConfigurationTable
;
91 // Search all the table for an entry that matches Guid
93 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
94 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
99 if (Index
< gDxeCoreST
->NumberOfTableEntries
) {
101 // A match was found, so this is either a modify or a delete operation
105 // If Table is not NULL, then this is a modify operation.
106 // Modify the table enty and return.
108 gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
= Table
;
111 // Signal Configuration Table change
113 CoreNotifySignalList (Guid
);
119 // A match was found and Table is NULL, so this is a delete operation.
121 gDxeCoreST
->NumberOfTableEntries
--;
124 // Copy over deleted entry
127 &(EfiConfigurationTable
[Index
]),
128 &(gDxeCoreST
->ConfigurationTable
[Index
+ 1]),
129 (gDxeCoreST
->NumberOfTableEntries
- Index
) * sizeof (EFI_CONFIGURATION_TABLE
)
135 // No matching GUIDs were found, so this is an add operation.
140 // If Table is NULL on an add operation, then return an error.
142 return EFI_NOT_FOUND
;
146 // Assume that Index == gDxeCoreST->NumberOfTableEntries
148 if ((Index
* sizeof (EFI_CONFIGURATION_TABLE
)) >= mSystemTableAllocateSize
) {
150 // Allocate a table with one additional entry.
152 mSystemTableAllocateSize
+= (CONFIG_TABLE_SIZE_INCREASED
* sizeof (EFI_CONFIGURATION_TABLE
));
153 EfiConfigurationTable
= CoreAllocateRuntimePool (mSystemTableAllocateSize
);
154 if (EfiConfigurationTable
== NULL
) {
156 // If a new table could not be allocated, then return an error.
158 return EFI_OUT_OF_RESOURCES
;
161 if (gDxeCoreST
->ConfigurationTable
!= NULL
) {
163 // Copy the old table to the new table.
166 EfiConfigurationTable
,
167 gDxeCoreST
->ConfigurationTable
,
168 Index
* sizeof (EFI_CONFIGURATION_TABLE
)
174 CoreFreePool (gDxeCoreST
->ConfigurationTable
);
178 // Update System Table
180 gDxeCoreST
->ConfigurationTable
= EfiConfigurationTable
;
184 // Fill in the new entry
186 CopyMem ((VOID
*)&EfiConfigurationTable
[Index
].VendorGuid
, Guid
, sizeof (EFI_GUID
));
187 EfiConfigurationTable
[Index
].VendorTable
= Table
;
190 // This is an add operation, so increment the number of table entries
192 gDxeCoreST
->NumberOfTableEntries
++;
196 // Fix up the CRC-32 in the EFI System Table
198 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
201 // Signal Configuration Table change
203 CoreNotifySignalList (Guid
);