+ EFI_STATUS Status;\r
+ EFI_STATUS_CODE_DATA *StatusCodeData;\r
+\r
+ ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
+ ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
+\r
+ if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Allocate space for the Status Code Header and its buffer\r
+ //\r
+ StatusCodeData = NULL;\r
+ gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
+ if (StatusCodeData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // Fill in the extended data header\r
+ //\r
+ StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
+ if (ExtendedDataGuid == NULL) {\r
+ ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
+ }\r
+ CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
+\r
+ //\r
+ // Fill in the extended data buffer\r
+ //\r
+ if (ExtendedData != NULL) {\r
+ CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
+ }\r
+\r
+ //\r
+ // Report the status code\r
+ //\r
+ if (CallerId == NULL) {\r
+ CallerId = &gEfiCallerIdGuid;\r
+ }\r
+ Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
+\r
+ //\r
+ // Free the allocated buffer\r
+ //\r
+ gBS->FreePool (StatusCodeData);\r