1 /** @file
2   Erase Block Protocol as defined in the UEFI 2.6 specification.
3 
4   The Erase Block Protocol is optional provides the ability for a device to expose
5   erase functionality.
6 
7   Copyright (c) 2016 - 2017, Linaro Limited. All rights reserved.<BR>
8   This program and the accompanying materials
9   are licensed and made available under the terms and conditions of the BSD License
10   which accompanies this distribution.  The full text of the license may be found at
11   http://opensource.org/licenses/bsd-license.php
12 
13   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 
16 **/
17 
18 #ifndef __ERASE_BLOCK_H__
19 #define __ERASE_BLOCK_H__
20 
21 #define EFI_ERASE_BLOCK_PROTOCOL_GUID \
22   { \
23     0x95A9A93E, 0xA86E, 0x4926, {0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87} \
24   }
25 
26 typedef struct _EFI_ERASE_BLOCK_PROTOCOL EFI_ERASE_BLOCK_PROTOCOL;
27 
28 
29 #define EFI_ERASE_BLOCK_PROTOCOL_REVISION ((2<<16) | (60))
30 
31 typedef struct {
32   EFI_EVENT       Event;
33   EFI_STATUS      TransactionStatus;
34 } EFI_ERASE_BLOCK_TOKEN;
35 
36 /**
37   Erase a specified number of device blocks.
38 
39   @param  This       Indicates a pointer to the calling context.
40   @param  MediaId    The media ID that the erase request is for.
41   @param  Lba        The starting logical block address to be erased. The caller is
42                      responsible for erasing only legitimate locations.
43   @param  Token      A pointer to the token associated with the transaction.
44   @param  Size       The size in bytes to be erased. This must be a multiple of the
45                      physical block size of the device.
46 
47   @retval EFI_SUCCESS           The erase request was queued if Event is not NULL. The data was
48                                 erased correctly to the device if the Event is NULL.
49   @retval EFI_WRITE_PROTECTED   The device cannot be erased due to write protection.
50   @retval EFI_DEVICE_ERROR      The device reported an error while attempting to perform the erase operation.
51   @retval EFI_INVALID_PARAMETER The erase request contain LBAs that are not valid.
52   @retval EFI_NO_MEDIA          There is no media in the device.
53   @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.
54 
55 **/
56 
57 typedef
58 EFI_STATUS
59 (EFIAPI *EFI_BLOCK_ERASE)(
60   IN EFI_BLOCK_IO_PROTOCOL          *This,
61   IN UINT32                         MediaId,
62   IN EFI_LBA                        Lba,
63   IN OUT EFI_ERASE_BLOCK_TOKEN      *Token,
64   IN UINTN                          Size
65   );
66 
67 ///
68 ///  This protocol provides erase functionality
69 ///
70 struct _EFI_ERASE_BLOCK_PROTOCOL {
71   ///
72   /// The revision to which the erase block interface adheres. All future
73   /// revisions must be backwards compatible. If a future version is not
74   /// back wards compatible, it is not the same GUID.
75   ///
76   UINT64              Revision;
77   ///
78   /// Returns the erase length granularity as a number of logical
79   /// blocks. A value of 1 means the erase granularity is one logical
80   /// block.
81   ///
82   UINT32              EraseLengthGranularity;
83   ///
84   /// Erase the requested number of blocks from the device.
85   ///
86   EFI_BLOCK_ERASE     EraseBlocks;
87 };
88 
89 
90 extern EFI_GUID gEfiEraseBlockProtocolGuid;
91 
92 #endif // __ERASE_BLOCK_H__
93