48 ASSERT (Instance !=
NULL);
49 if (Instance ==
NULL) {
50 return EFI_OUT_OF_RESOURCES;
54 Status =
gBS->HandleProtocol (
56 &gEdk2JedecSfdpSpiDxeDriverGuid,
57 (VOID **)&Instance->SpiIo
60 if (EFI_ERROR (Status)) {
61 DEBUG ((DEBUG_ERROR,
"%a: Fail to locate SPI I/O protocol\n", __func__));
66 if (EFI_ERROR (Status)) {
67 DEBUG ((DEBUG_ERROR,
"%a: Fail to initial SPI_NOR_FLASH_INSTANCE.\n", __func__));
71 Status =
gBS->InstallProtocolInterface (
73 &gEfiSpiNorFlashProtocolGuid,
77 if (EFI_ERROR (Status)) {
78 DEBUG ((DEBUG_ERROR,
"%a: Fail to Install gEfiSpiNorFlashProtocolGuid protocol.\n", __func__));
103 UINTN InstanceBufferSize;
106 DEBUG ((DEBUG_INFO,
"%a: Entry.\n", __func__));
108 Status =
gBS->LocateHandle (
115 if (EFI_ERROR (Status)) {
116 DEBUG ((DEBUG_ERROR,
"Can't locate SPI I/O protocol.\n"));
117 DEBUG ((DEBUG_INFO,
"%a: Exit.\n", __func__));
122 DEBUG ((DEBUG_INFO,
"%a: Exit.\n", __func__));
142 Status =
gBS->CreateEvent (
149 if (EFI_ERROR (Status)) {
150 DEBUG ((DEBUG_ERROR,
"%a: Fail to create event for the SPI I/O Protocol installation.", __func__));
154 Status =
gBS->RegisterProtocolNotify (
155 &gEdk2JedecSfdpSpiDxeDriverGuid,
159 if (EFI_ERROR (Status)) {
160 DEBUG ((DEBUG_ERROR,
"%a: Fail to register event for the SPI I/O Protocol installation.", __func__));
162 DEBUG ((DEBUG_INFO,
"%a: Notification for SPI I/O Protocol installation was registered.", __func__));
191 UINTN InstanceBufferSize;
193 DEBUG ((DEBUG_INFO,
"%a - ENTRY\n", __func__));
199 DEBUG ((DEBUG_INFO,
"Check if there were already some gEdk2JedecSfdpSpiDxeDriverGuid handles installed.\n"));
208 InstanceBufferSize = 0;
209 InstanceBuffer =
NULL;
210 Status =
gBS->LocateHandle (
212 &gEdk2JedecSfdpSpiDxeDriverGuid,
217 if (Status == EFI_NOT_FOUND) {
220 "No gEdk2JedecSfdpSpiSmmDriverGuid handles found at the moment, wait for the notification of SPI I/O protocol installation.\n"
222 DEBUG ((DEBUG_INFO,
"%a: EXIT - Status=%r\n", __func__, Status));
224 }
else if (Status == EFI_BUFFER_TOO_SMALL) {
226 ASSERT (InstanceBuffer !=
NULL);
227 if (InstanceBuffer ==
NULL) {
228 DEBUG ((DEBUG_ERROR,
"Not enough resource for gEdk2JedecSfdpSpiDxeDriverGuid handles.\n"));
229 DEBUG ((DEBUG_INFO,
"%a: EXIT - Status=%r\n", __func__, Status));
230 return EFI_OUT_OF_RESOURCES;
232 }
else if (EFI_ERROR (Status)) {
233 DEBUG ((DEBUG_ERROR,
"Error to locate gEdk2JedecSfdpSpiDxeDriverGuid - Status = %r.\n", Status));
234 DEBUG ((DEBUG_INFO,
"%a: EXIT - Status=%r\n", __func__, Status));
238 Status =
gBS->LocateHandle (
240 &gEdk2JedecSfdpSpiDxeDriverGuid,
245 if (EFI_ERROR (Status)) {
246 DEBUG ((DEBUG_ERROR,
"Fail to locate all gEdk2JedecSfdpSpiDxeDriverGuid handles.\n"));
247 DEBUG ((DEBUG_INFO,
"%a: EXIT - Status=%r\n", __func__, Status));
251 DEBUG ((DEBUG_INFO,
"%d of gEdk2JedecSfdpSpiDxeDriverGuid are found.\n", InstanceBufferSize /
sizeof (
EFI_HANDLE)));
252 for (InstanceIndex = 0; InstanceIndex < InstanceBufferSize /
sizeof (
EFI_HANDLE); InstanceIndex++) {
254 if (EFI_ERROR (Status)) {
255 DEBUG ((DEBUG_ERROR,
"Fail to create SPI NOR Flash SFDP instance #%d.\n", InstanceIndex));
259 DEBUG ((DEBUG_INFO,
"%a: EXIT - Status=%r\n", __func__, Status));
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS InitialSpiNorFlashSfdpInstance(IN SPI_NOR_FLASH_INSTANCE *Instance)
EFI_STATUS RegisterSpioProtocolNotification(VOID)
EFI_STATUS CreateSpiNorFlashSfdpInstance(IN EFI_HANDLE SpiIoHandle)
VOID EFIAPI SpiIoProtocolInstalledCallback(IN EFI_EVENT Event, OUT VOID *Context)
EFI_STATUS EFIAPI SpiNorFlashJedecSfdpDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)