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
| 277 | |
| 278 | **/ |
| 279 | EFI_STATUS |
| 280 | EFIAPI |
| 281 | DiscoverSdDevice ( |
| 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 | } |
no test coverage detected