]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Misc/InstallConfigurationTable.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / InstallConfigurationTable.c
... / ...
CommitLineData
1/** @file\r
2 UEFI Miscellaneous boot Services InstallConfigurationTable service\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "DxeMain.h"\r
16\r
17#define CONFIG_TABLE_SIZE_INCREASED 0x10\r
18\r
19UINTN mSystemTableAllocateSize = 0;\r
20\r
21/**\r
22 Boot Service called to add, modify, or remove a system configuration table from\r
23 the EFI System Table.\r
24\r
25 @param Guid Pointer to the GUID for the entry to add, update, or\r
26 remove\r
27 @param Table Pointer to the configuration table for the entry to add,\r
28 update, or remove, may be NULL.\r
29\r
30 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.\r
31 @return EFI_INVALID_PARAMETER Input GUID not valid.\r
32 @return EFI_NOT_FOUND Attempted to delete non-existant entry\r
33 @return EFI_OUT_OF_RESOURCES Not enough memory available\r
34\r
35**/\r
36EFI_STATUS\r
37EFIAPI\r
38CoreInstallConfigurationTable (\r
39 IN EFI_GUID *Guid,\r
40 IN VOID *Table\r
41 )\r
42{\r
43 UINTN Index;\r
44 EFI_CONFIGURATION_TABLE *EfiConfigurationTable;\r
45\r
46 //\r
47 // If Guid is NULL, then this operation cannot be performed\r
48 //\r
49 if (Guid == NULL) {\r
50 return EFI_INVALID_PARAMETER;\r
51 }\r
52\r
53 EfiConfigurationTable = gDxeCoreST->ConfigurationTable;\r
54\r
55 //\r
56 // Search all the table for an entry that matches Guid\r
57 //\r
58 for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {\r
59 if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {\r
60 break;\r
61 }\r
62 }\r
63\r
64 if (Index < gDxeCoreST->NumberOfTableEntries) {\r
65 //\r
66 // A match was found, so this is either a modify or a delete operation\r
67 //\r
68 if (Table != NULL) {\r
69 //\r
70 // If Table is not NULL, then this is a modify operation.\r
71 // Modify the table enty and return.\r
72 //\r
73 gDxeCoreST->ConfigurationTable[Index].VendorTable = Table;\r
74\r
75 //\r
76 // Signal Configuration Table change\r
77 //\r
78 CoreNotifySignalList (Guid);\r
79\r
80 return EFI_SUCCESS;\r
81 }\r
82\r
83 //\r
84 // A match was found and Table is NULL, so this is a delete operation.\r
85 //\r
86 gDxeCoreST->NumberOfTableEntries--;\r
87\r
88 //\r
89 // Copy over deleted entry\r
90 //\r
91 CopyMem (\r
92 &(EfiConfigurationTable[Index]),\r
93 &(gDxeCoreST->ConfigurationTable[Index + 1]),\r
94 (gDxeCoreST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)\r
95 );\r
96\r
97 } else {\r
98\r
99 //\r
100 // No matching GUIDs were found, so this is an add operation.\r
101 //\r
102\r
103 if (Table == NULL) {\r
104 //\r
105 // If Table is NULL on an add operation, then return an error.\r
106 //\r
107 return EFI_NOT_FOUND;\r
108 }\r
109\r
110 //\r
111 // Assume that Index == gDxeCoreST->NumberOfTableEntries\r
112 //\r
113 if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {\r
114 //\r
115 // Allocate a table with one additional entry.\r
116 //\r
117 mSystemTableAllocateSize += (CONFIG_TABLE_SIZE_INCREASED * sizeof (EFI_CONFIGURATION_TABLE));\r
118 EfiConfigurationTable = AllocateRuntimePool (mSystemTableAllocateSize);\r
119 if (EfiConfigurationTable == NULL) {\r
120 //\r
121 // If a new table could not be allocated, then return an error.\r
122 //\r
123 return EFI_OUT_OF_RESOURCES;\r
124 }\r
125\r
126 if (gDxeCoreST->ConfigurationTable != NULL) {\r
127 //\r
128 // Copy the old table to the new table.\r
129 //\r
130 CopyMem (\r
131 EfiConfigurationTable,\r
132 gDxeCoreST->ConfigurationTable,\r
133 Index * sizeof (EFI_CONFIGURATION_TABLE)\r
134 );\r
135\r
136 //\r
137 // Free Old Table\r
138 //\r
139 CoreFreePool (gDxeCoreST->ConfigurationTable);\r
140 }\r
141\r
142 //\r
143 // Update System Table\r
144 //\r
145 gDxeCoreST->ConfigurationTable = EfiConfigurationTable;\r
146 }\r
147\r
148 //\r
149 // Fill in the new entry\r
150 //\r
151 CopyGuid ((VOID *)&EfiConfigurationTable[Index].VendorGuid, Guid);\r
152 EfiConfigurationTable[Index].VendorTable = Table;\r
153\r
154 //\r
155 // This is an add operation, so increment the number of table entries\r
156 //\r
157 gDxeCoreST->NumberOfTableEntries++;\r
158 }\r
159\r
160 //\r
161 // Fix up the CRC-32 in the EFI System Table\r
162 //\r
163 CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
164\r
165 //\r
166 // Signal Configuration Table change\r
167 //\r
168 CoreNotifySignalList (Guid);\r
169\r
170 return EFI_SUCCESS;\r
171}\r