3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 InstallConfigurationTable.c
19 Tiano Miscellaneous Services InstallConfigurationTable service
25 #define CONFIG_TABLE_SIZE_INCREASED 0x10
27 UINTN mSystemTableAllocateSize
= 0;
39 Find a config table by name in system table's ConfigurationTable.
43 Guid - The table name to look for
45 Table - Pointer of the config table
49 EFI_NOT_FOUND - Could not find the table in system table's ConfigurationTable.
51 EFI_SUCCESS - Table successfully found.
57 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
58 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
59 *Table
= gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
;
71 CoreInstallConfigurationTable (
79 Boot Service called to add, modify, or remove a system configuration table from
84 Guid - Pointer to the GUID for the entry to add, update, or remove
85 Table - Pointer to the configuration table for the entry to add, update, or
90 EFI_SUCCESS Guid, Table pair added, updated, or removed.
91 EFI_INVALID_PARAMETER Input GUID not valid.
92 EFI_NOT_FOUND Attempted to delete non-existant entry
93 EFI_OUT_OF_RESOURCES Not enough memory available
98 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
101 // If Guid is NULL, then this operation cannot be performed
104 return EFI_INVALID_PARAMETER
;
107 EfiConfigurationTable
= gDxeCoreST
->ConfigurationTable
;
110 // Search all the table for an entry that matches Guid
112 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
113 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
118 if (Index
< gDxeCoreST
->NumberOfTableEntries
) {
120 // A match was found, so this is either a modify or a delete operation
124 // If Table is not NULL, then this is a modify operation.
125 // Modify the table enty and return.
127 gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
= Table
;
130 // Signal Configuration Table change
132 CoreNotifySignalList (Guid
);
138 // A match was found and Table is NULL, so this is a delete operation.
140 gDxeCoreST
->NumberOfTableEntries
--;
143 // Copy over deleted entry
146 &(EfiConfigurationTable
[Index
]),
147 &(gDxeCoreST
->ConfigurationTable
[Index
+ 1]),
148 (gDxeCoreST
->NumberOfTableEntries
- Index
) * sizeof (EFI_CONFIGURATION_TABLE
)
154 // No matching GUIDs were found, so this is an add operation.
159 // If Table is NULL on an add operation, then return an error.
161 return EFI_NOT_FOUND
;
165 // Assume that Index == gDxeCoreST->NumberOfTableEntries
167 if ((Index
* sizeof (EFI_CONFIGURATION_TABLE
)) >= mSystemTableAllocateSize
) {
169 // Allocate a table with one additional entry.
171 mSystemTableAllocateSize
+= (CONFIG_TABLE_SIZE_INCREASED
* sizeof (EFI_CONFIGURATION_TABLE
));
172 EfiConfigurationTable
= CoreAllocateRuntimePool (mSystemTableAllocateSize
);
173 if (EfiConfigurationTable
== NULL
) {
175 // If a new table could not be allocated, then return an error.
177 return EFI_OUT_OF_RESOURCES
;
180 if (gDxeCoreST
->ConfigurationTable
!= NULL
) {
182 // Copy the old table to the new table.
185 EfiConfigurationTable
,
186 gDxeCoreST
->ConfigurationTable
,
187 Index
* sizeof (EFI_CONFIGURATION_TABLE
)
193 CoreFreePool (gDxeCoreST
->ConfigurationTable
);
197 // Update System Table
199 gDxeCoreST
->ConfigurationTable
= EfiConfigurationTable
;
203 // Fill in the new entry
205 CopyMem ((VOID
*)&EfiConfigurationTable
[Index
].VendorGuid
, Guid
, sizeof (EFI_GUID
));
206 EfiConfigurationTable
[Index
].VendorTable
= Table
;
209 // This is an add operation, so increment the number of table entries
211 gDxeCoreST
->NumberOfTableEntries
++;
215 // Fix up the CRC-32 in the EFI System Table
217 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
220 // Signal Configuration Table change
222 CoreNotifySignalList (Guid
);