3 Copyright (c) 2006, 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
< gST
->NumberOfTableEntries
; Index
++) {
58 if (CompareGuid (Guid
, &(gST
->ConfigurationTable
[Index
].VendorGuid
))) {
59 *Table
= gST
->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
= gST
->ConfigurationTable
;
110 // Search all the table for an entry that matches Guid
112 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
113 if (CompareGuid (Guid
, &(gST
->ConfigurationTable
[Index
].VendorGuid
))) {
118 if (Index
< gST
->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 gST
->ConfigurationTable
[Index
].VendorTable
= Table
;
132 // A match was found and Table is NULL, so this is a delete operation.
134 gST
->NumberOfTableEntries
--;
137 // Copy over deleted entry
140 &(EfiConfigurationTable
[Index
]),
141 &(gST
->ConfigurationTable
[Index
+ 1]),
142 (gST
->NumberOfTableEntries
- Index
) * sizeof (EFI_CONFIGURATION_TABLE
)
148 // No matching GUIDs were found, so this is an add operation.
153 // If Table is NULL on an add operation, then return an error.
155 return EFI_NOT_FOUND
;
159 // Assume that Index == gST->NumberOfTableEntries
161 if ((Index
* sizeof (EFI_CONFIGURATION_TABLE
)) >= mSystemTableAllocateSize
) {
163 // Allocate a table with one additional entry.
165 mSystemTableAllocateSize
+= (CONFIG_TABLE_SIZE_INCREASED
* sizeof (EFI_CONFIGURATION_TABLE
));
166 EfiConfigurationTable
= CoreAllocateRuntimePool (mSystemTableAllocateSize
);
167 if (EfiConfigurationTable
== NULL
) {
169 // If a new table could not be allocated, then return an error.
171 return EFI_OUT_OF_RESOURCES
;
174 if (gST
->ConfigurationTable
!= NULL
) {
176 // Copy the old table to the new table.
179 EfiConfigurationTable
,
180 gST
->ConfigurationTable
,
181 Index
* sizeof (EFI_CONFIGURATION_TABLE
)
187 CoreFreePool (gST
->ConfigurationTable
);
191 // Update System Table
193 gST
->ConfigurationTable
= EfiConfigurationTable
;
197 // Fill in the new entry
199 CopyMem ((VOID
*)&EfiConfigurationTable
[Index
].VendorGuid
, Guid
, sizeof (EFI_GUID
));
200 EfiConfigurationTable
[Index
].VendorTable
= Table
;
203 // This is an add operation, so increment the number of table entries
205 gST
->NumberOfTableEntries
++;
209 // Fix up the CRC-32 in the EFI System Table
211 CalculateEfiHdrCrc (&gST
->Hdr
);