2 UEFI Miscellaneous boot Services InstallConfigurationTable service
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #define CONFIG_TABLE_SIZE_INCREASED 0x10
19 UINTN mSystemTableAllocateSize
= 0;
24 Find a config table by name in system table's ConfigurationTable.
26 @param Guid The table name to look for
27 @param Table Pointer of the config table
29 @retval EFI_NOT_FOUND Could not find the table in system table's
31 @retval EFI_SUCCESS Table successfully found.
42 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
43 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
44 *Table
= gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
;
56 Boot Service called to add, modify, or remove a system configuration table from
59 @param Guid Pointer to the GUID for the entry to add, update, or
61 @param Table Pointer to the configuration table for the entry to add,
62 update, or remove, may be NULL.
64 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
65 @return EFI_INVALID_PARAMETER Input GUID not valid.
66 @return EFI_NOT_FOUND Attempted to delete non-existant entry
67 @return EFI_OUT_OF_RESOURCES Not enough memory available
72 CoreInstallConfigurationTable (
78 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
81 // If Guid is NULL, then this operation cannot be performed
84 return EFI_INVALID_PARAMETER
;
87 EfiConfigurationTable
= gDxeCoreST
->ConfigurationTable
;
90 // Search all the table for an entry that matches Guid
92 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
93 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
98 if (Index
< gDxeCoreST
->NumberOfTableEntries
) {
100 // A match was found, so this is either a modify or a delete operation
104 // If Table is not NULL, then this is a modify operation.
105 // Modify the table enty and return.
107 gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
= Table
;
110 // Signal Configuration Table change
112 CoreNotifySignalList (Guid
);
118 // A match was found and Table is NULL, so this is a delete operation.
120 gDxeCoreST
->NumberOfTableEntries
--;
123 // Copy over deleted entry
126 &(EfiConfigurationTable
[Index
]),
127 &(gDxeCoreST
->ConfigurationTable
[Index
+ 1]),
128 (gDxeCoreST
->NumberOfTableEntries
- Index
) * sizeof (EFI_CONFIGURATION_TABLE
)
134 // No matching GUIDs were found, so this is an add operation.
139 // If Table is NULL on an add operation, then return an error.
141 return EFI_NOT_FOUND
;
145 // Assume that Index == gDxeCoreST->NumberOfTableEntries
147 if ((Index
* sizeof (EFI_CONFIGURATION_TABLE
)) >= mSystemTableAllocateSize
) {
149 // Allocate a table with one additional entry.
151 mSystemTableAllocateSize
+= (CONFIG_TABLE_SIZE_INCREASED
* sizeof (EFI_CONFIGURATION_TABLE
));
152 EfiConfigurationTable
= CoreAllocateRuntimePool (mSystemTableAllocateSize
);
153 if (EfiConfigurationTable
== NULL
) {
155 // If a new table could not be allocated, then return an error.
157 return EFI_OUT_OF_RESOURCES
;
160 if (gDxeCoreST
->ConfigurationTable
!= NULL
) {
162 // Copy the old table to the new table.
165 EfiConfigurationTable
,
166 gDxeCoreST
->ConfigurationTable
,
167 Index
* sizeof (EFI_CONFIGURATION_TABLE
)
173 CoreFreePool (gDxeCoreST
->ConfigurationTable
);
177 // Update System Table
179 gDxeCoreST
->ConfigurationTable
= EfiConfigurationTable
;
183 // Fill in the new entry
185 CopyGuid ((VOID
*)&EfiConfigurationTable
[Index
].VendorGuid
, Guid
);
186 EfiConfigurationTable
[Index
].VendorTable
= Table
;
189 // This is an add operation, so increment the number of table entries
191 gDxeCoreST
->NumberOfTableEntries
++;
195 // Fix up the CRC-32 in the EFI System Table
197 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
200 // Signal Configuration Table change
202 CoreNotifySignalList (Guid
);