/** Get the parameters for the USB mass storage media. This function get the parameters for the USB mass storage media, It is used both to initialize the media during the Start() phase of Driver Binding Protocol and to re-initialize it when the media is changed. Althought the RemoveableMedia is unlikely to change, it is also included here. @param UsbMass The device to retrieve disk gemotric. @retval EFI_SUCCESS The disk gemotric is successfully retrieved. @retval Other Failed to get the parameters. **/ EFI_STATUS UsbBootGetParams ( IN USB_MASS_DEVICE *UsbMass ) { EFI_BLOCK_IO_MEDIA *Media; EFI_STATUS Status; Media = &(UsbMass->BlockIoMedia); Status = UsbBootInquiry (UsbMass); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status)); return Status; } // // Don't use the Removable bit in inquiry data to test whether the media // is removable because many flash disks wrongly set this bit. // if ((UsbMass->Pdt == USB_PDT_CDROM) || (UsbMass->Pdt == USB_PDT_OPTICAL)) { // // CD-Rom device and Non-CD optical device // UsbMass->OpticalStorage = TRUE; // // Default value 2048 Bytes, in case no media present at first time // Media->BlockSize = 0x0800; } Status = UsbBootDetectMedia (UsbMass); return Status; }
/** Get the parameters for the USB mass storage media. This function get the parameters for the USB mass storage media, It is used both to initialize the media during the Start() phase of Driver Binding Protocol and to re-initialize it when the media is changed. Althought the RemoveableMedia is unlikely to change, it is also included here. @param UsbMass The device to retrieve disk gemotric. @retval EFI_SUCCESS The disk gemotric is successfully retrieved. @retval Other Failed to get the parameters. **/ EFI_STATUS UsbBootGetParams ( IN USB_MASS_DEVICE *UsbMass ) { EFI_BLOCK_IO_MEDIA *Media; EFI_STATUS Status; Media = &(UsbMass->BlockIoMedia); Status = UsbBootInquiry (UsbMass); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status)); return Status; } // // According to USB Mass Storage Specification for Bootability, only following // 4 Peripheral Device Types are in spec. // if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && (UsbMass->Pdt != USB_PDT_CDROM) && (UsbMass->Pdt != USB_PDT_OPTICAL) && (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) { DEBUG ((EFI_D_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt)); return EFI_UNSUPPORTED; } // // Don't use the Removable bit in inquiry data to test whether the media // is removable because many flash disks wrongly set this bit. // if ((UsbMass->Pdt == USB_PDT_CDROM) || (UsbMass->Pdt == USB_PDT_OPTICAL)) { // // CD-Rom device and Non-CD optical device // UsbMass->OpticalStorage = TRUE; // // Default value 2048 Bytes, in case no media present at first time // Media->BlockSize = 0x0800; } Status = UsbBootDetectMedia (UsbMass); return Status; }