2 UEFI Miscellaneous boot Services InstallConfigurationTable service
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5 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;
22 Boot Service called to add, modify, or remove a system configuration table from
25 @param Guid Pointer to the GUID for the entry to add, update, or
27 @param Table Pointer to the configuration table for the entry to add,
28 update, or remove, may be NULL.
30 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
31 @return EFI_INVALID_PARAMETER Input GUID is NULL.
32 @return EFI_NOT_FOUND Attempted to delete non-existant entry
33 @return EFI_OUT_OF_RESOURCES Not enough memory available
38 CoreInstallConfigurationTable (
44 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
47 // If Guid is NULL, then this operation cannot be performed
50 return EFI_INVALID_PARAMETER
;
53 EfiConfigurationTable
= gDxeCoreST
->ConfigurationTable
;
56 // Search all the table for an entry that matches Guid
58 for (Index
= 0; Index
< gDxeCoreST
->NumberOfTableEntries
; Index
++) {
59 if (CompareGuid (Guid
, &(gDxeCoreST
->ConfigurationTable
[Index
].VendorGuid
))) {
64 if (Index
< gDxeCoreST
->NumberOfTableEntries
) {
66 // A match was found, so this is either a modify or a delete operation
70 // If Table is not NULL, then this is a modify operation.
71 // Modify the table enty and return.
73 gDxeCoreST
->ConfigurationTable
[Index
].VendorTable
= Table
;
76 // Signal Configuration Table change
78 CoreNotifySignalList (Guid
);
84 // A match was found and Table is NULL, so this is a delete operation.
86 gDxeCoreST
->NumberOfTableEntries
--;
89 // Copy over deleted entry
92 &(EfiConfigurationTable
[Index
]),
93 &(gDxeCoreST
->ConfigurationTable
[Index
+ 1]),
94 (gDxeCoreST
->NumberOfTableEntries
- Index
) * sizeof (EFI_CONFIGURATION_TABLE
)
100 // No matching GUIDs were found, so this is an add operation.
105 // If Table is NULL on an add operation, then return an error.
107 return EFI_NOT_FOUND
;
111 // Assume that Index == gDxeCoreST->NumberOfTableEntries
113 if ((Index
* sizeof (EFI_CONFIGURATION_TABLE
)) >= mSystemTableAllocateSize
) {
115 // Allocate a table with one additional entry.
117 mSystemTableAllocateSize
+= (CONFIG_TABLE_SIZE_INCREASED
* sizeof (EFI_CONFIGURATION_TABLE
));
118 EfiConfigurationTable
= AllocateRuntimePool (mSystemTableAllocateSize
);
119 if (EfiConfigurationTable
== NULL
) {
121 // If a new table could not be allocated, then return an error.
123 return EFI_OUT_OF_RESOURCES
;
126 if (gDxeCoreST
->ConfigurationTable
!= NULL
) {
128 // Copy the old table to the new table.
131 EfiConfigurationTable
,
132 gDxeCoreST
->ConfigurationTable
,
133 Index
* sizeof (EFI_CONFIGURATION_TABLE
)
139 CoreFreePool (gDxeCoreST
->ConfigurationTable
);
143 // Update System Table
145 gDxeCoreST
->ConfigurationTable
= EfiConfigurationTable
;
149 // Fill in the new entry
151 CopyGuid ((VOID
*)&EfiConfigurationTable
[Index
].VendorGuid
, Guid
);
152 EfiConfigurationTable
[Index
].VendorTable
= Table
;
155 // This is an add operation, so increment the number of table entries
157 gDxeCoreST
->NumberOfTableEntries
++;
161 // Fix up the CRC-32 in the EFI System Table
163 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
166 // Signal Configuration Table change
168 CoreNotifySignalList (Guid
);