+++ /dev/null
-/** @file\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_BLOCK_IO_H_\r
-#define _BIOS_BLOCK_IO_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Guid/LegacyBios.h>\r
-#include <Guid/BlockIoVendor.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#include "Edd.h"\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_COMPONENT_NAME_PROTOCOL gBiosBlockIoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gBiosBlockIoComponentName2;\r
-\r
-\r
-//\r
-// Define the I2O class code\r
-//\r
-#define PCI_BASE_CLASS_INTELLIGENT 0x0e\r
-#define PCI_SUB_CLASS_INTELLIGENT 0x00\r
-\r
-//\r
-// Number of pages needed for our buffer under 1MB\r
-//\r
-#define BLOCK_IO_BUFFER_PAGE_SIZE (((sizeof (EDD_DEVICE_ADDRESS_PACKET) + sizeof (BIOS_LEGACY_DRIVE) + MAX_EDD11_XFER) / EFI_PAGE_SIZE) + 1 \\r
- )\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-\r
-/**\r
- Check whether the driver supports this device.\r
-\r
- @param This The Udriver binding protocol.\r
- @param Controller The controller handle to check.\r
- @param RemainingDevicePath The remaining device path.\r
-\r
- @retval EFI_SUCCESS The driver supports this controller.\r
- @retval other This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-\r
-/**\r
- Starts the device with this driver.\r
-\r
- @param This The driver binding instance.\r
- @param Controller Handle of device to bind driver to.\r
- @param RemainingDevicePath Optional parameter use to pick a specific child\r
- device to start.\r
-\r
- @retval EFI_SUCCESS The controller is controlled by the driver.\r
- @retval Other This controller cannot be started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-/**\r
- Stop the device handled by this driver.\r
-\r
- @param This The driver binding protocol.\r
- @param Controller The controller to release.\r
- @param NumberOfChildren The number of handles in ChildHandleBuffer.\r
- @param ChildHandleBuffer The array of child handle.\r
-\r
- @retval EFI_SUCCESS The device was stopped.\r
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
- @retval Others Fail to uninstall protocols attached on the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
- );\r
-\r
-//\r
-// Other internal functions\r
-//\r
-\r
-/**\r
- Build device path for EDD 3.0.\r
-\r
- @param BaseDevicePath Base device path.\r
- @param Drive Legacy drive.\r
- @param DevicePath Device path for output.\r
-\r
- @retval EFI_SUCCESS The device path is built successfully.\r
- @retval EFI_UNSUPPORTED It is failed to built device path.\r
-\r
-**/\r
-EFI_STATUS\r
-BuildEdd30DevicePath (\r
- IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,\r
- IN BIOS_LEGACY_DRIVE *Drive,\r
- IN EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
- );\r
-\r
-/**\r
- Initialize block I/O device instance\r
-\r
- @param Dev Instance of block I/O device instance\r
-\r
- @retval TRUE Initialization succeeds.\r
- @retval FALSE Initialization fails.\r
-\r
-**/\r
-BOOLEAN\r
-BiosInitBlockIo (\r
- IN BIOS_BLOCK_IO_DEV *Dev\r
- );\r
-\r
-/**\r
- Read BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId Id of the media, changes every time the media is replaced.\r
- @param Lba The starting Logical Block Address to read from\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the destination buffer for the data. The caller is\r
- responsible for either having implicit or explicit ownership of the buffer.\r
-\r
- @retval EFI_SUCCESS The data was read correctly from the device.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosReadBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Write BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId The media ID that the write request is for.\r
- @param Lba The starting logical block address to be written. The caller is\r
- responsible for writing to only legitimate locations.\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the source buffer for the data.\r
-\r
- @retval EFI_SUCCESS The data was written correctly to the device.\r
- @retval EFI_WRITE_PROTECTED The device can not be written to.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosWriteBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Flush the Block Device.\r
-\r
- @param This Indicates a pointer to the calling context.\r
-\r
- @retval EFI_SUCCESS All outstanding data was written to the device\r
- @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoFlushBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This\r
- );\r
-\r
-/**\r
- Reset the Block Device.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param ExtendedVerification Driver may perform diagnostics on reset.\r
-\r
- @retval EFI_SUCCESS The device was reset.\r
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
- not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoReset (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN BOOLEAN ExtendedVerification\r
- );\r
-\r
-/**\r
- Read BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId Id of the media, changes every time the media is replaced.\r
- @param Lba The starting Logical Block Address to read from\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the destination buffer for the data. The caller is\r
- responsible for either having implicit or explicit ownership of the buffer.\r
-\r
- @retval EFI_SUCCESS The data was read correctly from the device.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosReadBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Write BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId The media ID that the write request is for.\r
- @param Lba The starting logical block address to be written. The caller is\r
- responsible for writing to only legitimate locations.\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the source buffer for the data.\r
-\r
- @retval EFI_SUCCESS The data was written correctly to the device.\r
- @retval EFI_WRITE_PROTECTED The device can not be written to.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosWriteBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Read BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId Id of the media, changes every time the media is replaced.\r
- @param Lba The starting Logical Block Address to read from\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the destination buffer for the data. The caller is\r
- responsible for either having implicit or explicit ownership of the buffer.\r
-\r
- @retval EFI_SUCCESS The data was read correctly from the device.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosReadLegacyDrive (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Write BufferSize bytes from Lba into Buffer.\r
-\r
- @param This Indicates a pointer to the calling context.\r
- @param MediaId The media ID that the write request is for.\r
- @param Lba The starting logical block address to be written. The caller is\r
- responsible for writing to only legitimate locations.\r
- @param BufferSize Size of Buffer, must be a multiple of device block size.\r
- @param Buffer A pointer to the source buffer for the data.\r
-\r
- @retval EFI_SUCCESS The data was written correctly to the device.\r
- @retval EFI_WRITE_PROTECTED The device can not be written to.\r
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
- @retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
- or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosWriteLegacyDrive (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Gets parameters of block I/O device.\r
-\r
- @param BiosBlockIoDev Instance of block I/O device.\r
- @param Drive Legacy drive.\r
-\r
- @return Result of device parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-Int13GetDeviceParameters (\r
- IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
- IN BIOS_LEGACY_DRIVE *Drive\r
- );\r
-\r
-/**\r
- Extension of INT13 call.\r
-\r
- @param BiosBlockIoDev Instance of block I/O device.\r
- @param Drive Legacy drive.\r
-\r
- @return Result of this extension.\r
-\r
-**/\r
-UINTN\r
-Int13Extensions (\r
- IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
- IN BIOS_LEGACY_DRIVE *Drive\r
- );\r
-\r
-/**\r
- Gets parameters of legacy drive.\r
-\r
- @param BiosBlockIoDev Instance of block I/O device.\r
- @param Drive Legacy drive.\r
-\r
- @return Result of drive parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-GetDriveParameters (\r
- IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
- IN BIOS_LEGACY_DRIVE *Drive\r
- );\r
-\r
-/**\r
- Build device path for device.\r
-\r
- @param BaseDevicePath Base device path.\r
- @param Drive Legacy drive.\r
- @param DevicePath Device path for output.\r
-\r
-**/\r
-VOID\r
-SetBiosInitBlockIoDevicePath (\r
- IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,\r
- IN BIOS_LEGACY_DRIVE *Drive,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
- );\r
-\r
-#endif\r