MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / DiscoverSdDevice

Function DiscoverSdDevice

MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c:279–414  ·  view source on GitHub ↗

Scan SD Bus to discover the device. @param[in] Private The SD driver private data structure. @param[in] Slot The slot number to check device present. @retval EFI_SUCCESS Successfully to discover the device and attach SdMmcIoProtocol to it. @retval EFI_OUT_OF_RESOURCES The request could not be completed d

Source from the content-addressed store, hash-verified

277
278**/
279EFI_STATUS
280EFIAPI
281DiscoverSdDevice (
282 IN SD_DRIVER_PRIVATE_DATA *Private,
283 IN UINT8 Slot
284 )
285{
286 EFI_STATUS Status;
287 SD_DEVICE *Device;
288 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
289 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
290 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
291 EFI_HANDLE DeviceHandle;
292 EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;
293
294 Device = NULL;
295 DevicePath = NULL;
296 NewDevicePath = NULL;
297 RemainingDevicePath = NULL;
298 PassThru = Private->PassThru;
299
300 //
301 // Build Device Path
302 //
303 Status = PassThru->BuildDevicePath (
304 PassThru,
305 Slot,
306 &DevicePath
307 );
308 if (EFI_ERROR(Status)) {
309 return Status;
310 }
311
312 if (DevicePath->SubType != MSG_SD_DP) {
313 Status = EFI_UNSUPPORTED;
314 goto Error;
315 }
316
317 NewDevicePath = AppendDevicePathNode (
318 Private->ParentDevicePath,
319 DevicePath
320 );
321
322 if (NewDevicePath == NULL) {
323 Status = EFI_OUT_OF_RESOURCES;
324 goto Error;
325 }
326
327 DeviceHandle = NULL;
328 RemainingDevicePath = NewDevicePath;
329 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
330 if (!EFI_ERROR(Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {
331 //
332 // The device has been started, directly return to fast boot.
333 //
334 Status = EFI_ALREADY_STARTED;
335 goto Error;
336 }

Callers 1

SdDxeDriverBindingStartFunction · 0.85

Calls 6

AppendDevicePathNodeFunction · 0.85
AllocateCopyPoolFunction · 0.85
DiscoverUserAreaFunction · 0.85
AddUnicodeString2Function · 0.85
IsDevicePathEndFunction · 0.50
FreePoolFunction · 0.50

Tested by

no test coverage detected