Ronak Kanabar | 1ae366f | 2023-06-07 01:21:56 +0530 | [diff] [blame^] | 1 | /** @file |
| 2 | This file defines the EFI Erase Block Protocol. |
| 3 | |
| 4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> |
| 5 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 6 | |
| 7 | @par Revision Reference: |
| 8 | This Protocol is introduced in UEFI Specification 2.6 |
| 9 | |
| 10 | **/ |
| 11 | |
| 12 | #ifndef __EFI_ERASE_BLOCK_PROTOCOL_H__ |
| 13 | #define __EFI_ERASE_BLOCK_PROTOCOL_H__ |
| 14 | |
| 15 | #define EFI_ERASE_BLOCK_PROTOCOL_GUID \ |
| 16 | { \ |
| 17 | 0x95a9a93e, 0xa86e, 0x4926, { 0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87 } \ |
| 18 | } |
| 19 | |
| 20 | typedef struct _EFI_ERASE_BLOCK_PROTOCOL EFI_ERASE_BLOCK_PROTOCOL; |
| 21 | |
| 22 | #define EFI_ERASE_BLOCK_PROTOCOL_REVISION ((2<<16) | (60)) |
| 23 | |
| 24 | /// |
| 25 | /// EFI_ERASE_BLOCK_TOKEN |
| 26 | /// |
| 27 | typedef struct { |
| 28 | // |
| 29 | // If Event is NULL, then blocking I/O is performed. If Event is not NULL and |
| 30 | // non-blocking I/O is supported, then non-blocking I/O is performed, and |
| 31 | // Event will be signaled when the erase request is completed. |
| 32 | // |
| 33 | EFI_EVENT Event; |
| 34 | // |
| 35 | // Defines whether the signaled event encountered an error. |
| 36 | // |
| 37 | EFI_STATUS TransactionStatus; |
| 38 | } EFI_ERASE_BLOCK_TOKEN; |
| 39 | |
| 40 | /** |
| 41 | Erase a specified number of device blocks. |
| 42 | |
| 43 | @param[in] This Indicates a pointer to the calling context. |
| 44 | @param[in] MediaId The media ID that the erase request is for. |
| 45 | @param[in] LBA The starting logical block address to be |
| 46 | erased. The caller is responsible for erasing |
| 47 | only legitimate locations. |
| 48 | @param[in, out] Token A pointer to the token associated with the |
| 49 | transaction. |
| 50 | @param[in] Size The size in bytes to be erased. This must be |
| 51 | a multiple of the physical block size of the |
| 52 | device. |
| 53 | |
| 54 | @retval EFI_SUCCESS The erase request was queued if Event is not |
| 55 | NULL. The data was erased correctly to the |
| 56 | device if the Event is NULL.to the device. |
| 57 | @retval EFI_WRITE_PROTECTED The device cannot be erased due to write |
| 58 | protection. |
| 59 | @retval EFI_DEVICE_ERROR The device reported an error while attempting |
| 60 | to perform the erase operation. |
| 61 | @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not |
| 62 | valid. |
| 63 | @retval EFI_NO_MEDIA There is no media in the device. |
| 64 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. |
| 65 | |
| 66 | **/ |
| 67 | typedef |
| 68 | EFI_STATUS |
| 69 | (EFIAPI *EFI_BLOCK_ERASE)( |
| 70 | IN EFI_ERASE_BLOCK_PROTOCOL *This, |
| 71 | IN UINT32 MediaId, |
| 72 | IN EFI_LBA LBA, |
| 73 | IN OUT EFI_ERASE_BLOCK_TOKEN *Token, |
| 74 | IN UINTN Size |
| 75 | ); |
| 76 | |
| 77 | /// |
| 78 | /// The EFI Erase Block Protocol provides the ability for a device to expose |
| 79 | /// erase functionality. This optional protocol is installed on the same handle |
| 80 | /// as the EFI_BLOCK_IO_PROTOCOL or EFI_BLOCK_IO2_PROTOCOL. |
| 81 | /// |
| 82 | struct _EFI_ERASE_BLOCK_PROTOCOL { |
| 83 | // |
| 84 | // The revision to which the EFI_ERASE_BLOCK_PROTOCOL adheres. All future |
| 85 | // revisions must be backwards compatible. If a future version is not |
| 86 | // backwards compatible, it is not the same GUID. |
| 87 | // |
| 88 | UINT64 Revision; |
| 89 | // |
| 90 | // Returns the erase length granularity as a number of logical blocks. A |
| 91 | // value of 1 means the erase granularity is one logical block. |
| 92 | // |
| 93 | UINT32 EraseLengthGranularity; |
| 94 | EFI_BLOCK_ERASE EraseBlocks; |
| 95 | }; |
| 96 | |
| 97 | extern EFI_GUID gEfiEraseBlockProtocolGuid; |
| 98 | |
| 99 | #endif |