1 | /** @file
|
---|
2 | This file defines the Media Sanitize Protocol.
|
---|
3 |
|
---|
4 | Copyright (c) Microsoft Corporation.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef MEDIA_SANITIZE_PROTOCOL_H_
|
---|
10 | #define MEDIA_SANITIZE_PROTOCOL_H_
|
---|
11 |
|
---|
12 | #define MEDIA_SANITIZE_PROTOCOL_GUID \
|
---|
13 | { \
|
---|
14 | 0x0d799a99, 0x25af, 0x429e, { 0x92, 0x72, 0xd0, 0xb2, 0x7d, 0x6d, 0x5f, 0x14 } \
|
---|
15 | }
|
---|
16 |
|
---|
17 | typedef struct _MEDIA_SANITIZE_PROTOCOL MEDIA_SANITIZE_PROTOCOL;
|
---|
18 |
|
---|
19 | #define MEDIA_SANITIZE_PROTOCOL_REVISION 0x00010000
|
---|
20 |
|
---|
21 | ///
|
---|
22 | /// Sanitize actions for purge operation.
|
---|
23 | ///
|
---|
24 | /// NOTE: First four actions (no action, overwrite, block erase, crypto erase) cannot
|
---|
25 | /// be overlapped. All other fields may be overlapped as they apply.
|
---|
26 | ///
|
---|
27 | #define PURGE_ACTION_NO_ACTION 0x00000000 // No purge action requested
|
---|
28 | #define PURGE_ACTION_OVERWRITE 0x00000001 // Overwrite with 32-bit pattern
|
---|
29 | #define PURGE_ACTION_BLOCK_ERASE 0x00000002 // Erase Blocks with indeterminate pattern
|
---|
30 | #define PURGE_ACTION_CRYPTO_ERASE 0x00000004 // Delete encryption keys only
|
---|
31 | #define PURGE_ACTION_RESET_REQUIRED 0x00000008 // Reset required after purge
|
---|
32 | #define PURGE_ACTION_NO_DEALLOCATE 0x00000010 // Do no deallocate (trim) flash medai after sanitize
|
---|
33 | #define PURGE_ACTION_INVERT_OW_PATTERN 0x00000020 // Invert overwrite pattern between passes
|
---|
34 | #define PURGE_ACTION_ALLOW_UNRESTRICTED_SANITIZE_EXIT 0x00000040 // Allow exit without restrictions
|
---|
35 |
|
---|
36 | ///
|
---|
37 | /// Secure erase action for media format operation
|
---|
38 | ///
|
---|
39 | #define FORMAT_SES_NO_SECURE_ERASE_REQUESTED 0x0 // No secure erase operation requested
|
---|
40 | #define FORMAT_SES_USER_DATA_ERASE 0x1 // User Data Erase
|
---|
41 | #define FORMAT_SES_CRYPTOGRAPHIC_ERASE 0x2 // Cryptographic Erase
|
---|
42 |
|
---|
43 | /**
|
---|
44 | Clear Media utilizes transport native WRITE commands to write a fixed pattern
|
---|
45 | of non-sensitive data. The size of the overwrite buffer shall be equal to the
|
---|
46 | one sector/LBA (in bytes).
|
---|
47 |
|
---|
48 | NOTE: This function must be called from TPL aaplication or callback.
|
---|
49 |
|
---|
50 | @param[in] This Indicates a pointer to the calling context.
|
---|
51 | @param[in] MediaId The media ID that the clear request is for.
|
---|
52 | @param[in] PassCount Number of passes to write over the media.
|
---|
53 | @param[in] SectorOwBuffer Pointer to overwrite pattern buffer.
|
---|
54 |
|
---|
55 | @retval EFI_SUCCESS The media clear request completed successfully
|
---|
56 | on the device.
|
---|
57 | @retval EFI_WRITE_PROTECTED The device can't be cleared due to write
|
---|
58 | protection.
|
---|
59 | @retval EFI_DEVICE_ERROR The device reported an error while attempting
|
---|
60 | to perform the clear operation.
|
---|
61 | @retval EFI_INVALID_PARAMETER The clear request contains parameters that
|
---|
62 | are not 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 *BLOCK_MEDIA_CLEAR)(
|
---|
70 | IN MEDIA_SANITIZE_PROTOCOL *This,
|
---|
71 | IN UINT32 MediaId,
|
---|
72 | IN UINT32 PassCount,
|
---|
73 | IN VOID *SectorOwBuffer
|
---|
74 | );
|
---|
75 |
|
---|
76 | /**
|
---|
77 | Purge Media utilizes native Sanitize operations. Transport specific
|
---|
78 | overwrite, block erase, or crypto erase functions shall be invoked based
|
---|
79 | on transport.
|
---|
80 |
|
---|
81 | NOTE: This function must be called from TPL aaplication or callback.
|
---|
82 |
|
---|
83 | @param[in] This Indicates a pointer to the calling context.
|
---|
84 | @param[in] MediaId The media ID that the clear request is for.
|
---|
85 | @param[in] PurgeAction Purge action: overwrite, crypto or block erase.
|
---|
86 | @param[in] OverwritePattern 32-bit pattern to overwrite on media.
|
---|
87 |
|
---|
88 | @retval EFI_SUCCESS The media purge request completed successfully
|
---|
89 | on the device.
|
---|
90 | @retval EFI_WRITE_PROTECTED The device can't be purged due to write
|
---|
91 | protection.
|
---|
92 | @retval EFI_DEVICE_ERROR The device reported an error while attempting
|
---|
93 | to perform the purge operation.
|
---|
94 | @retval EFI_INVALID_PARAMETER The purge request contains parameters that
|
---|
95 | are not valid.
|
---|
96 | @retval EFI_NO_MEDIA There is no media in the device.
|
---|
97 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
---|
98 |
|
---|
99 | **/
|
---|
100 | typedef
|
---|
101 | EFI_STATUS
|
---|
102 | (EFIAPI *BLOCK_MEDIA_PURGE)(
|
---|
103 | IN MEDIA_SANITIZE_PROTOCOL *This,
|
---|
104 | IN UINT32 MediaId,
|
---|
105 | IN UINT32 PurgeAction,
|
---|
106 | IN UINT32 OverwritePattern
|
---|
107 | );
|
---|
108 |
|
---|
109 | /**
|
---|
110 | Format Media utilizes native format operations to modify sector/LBA size.
|
---|
111 | Secure erase actions are used to define how latent user data is erased.
|
---|
112 |
|
---|
113 | NOTE: This function must be called from TPL aaplication or callback.
|
---|
114 |
|
---|
115 | @param[in] This Indicates a pointer to the calling context.
|
---|
116 | @param[in] MediaId The media ID that the clear request is for.
|
---|
117 | @param[in] LbaSize Size of LBA (in terms of power of two: 2^n).
|
---|
118 | @param[in] SecureEraseAction Secure erase action, if any, to apply to format.
|
---|
119 |
|
---|
120 | @retval EFI_SUCCESS The media format request comopleted
|
---|
121 | successfully on the device.
|
---|
122 | @retval EFI_WRITE_PROTECTED The device can't be formatted due to write
|
---|
123 | protection.
|
---|
124 | @retval EFI_DEVICE_ERROR The device reported an error while attempting
|
---|
125 | to perform the format operation.
|
---|
126 | @retval EFI_INVALID_PARAMETER The format request contains parameters that
|
---|
127 | are not valid.
|
---|
128 | @retval EFI_NO_MEDIA There is no media in the device.
|
---|
129 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
---|
130 |
|
---|
131 | **/
|
---|
132 | typedef
|
---|
133 | EFI_STATUS
|
---|
134 | (EFIAPI *BLOCK_MEDIA_FORMAT)(
|
---|
135 | IN MEDIA_SANITIZE_PROTOCOL *This,
|
---|
136 | IN UINT32 MediaId,
|
---|
137 | IN UINT32 LbaSize,
|
---|
138 | IN UINT32 SecureEraseAction
|
---|
139 | );
|
---|
140 |
|
---|
141 | ///
|
---|
142 | /// The Media Sanitize Protocol provides the ability for a device to expose
|
---|
143 | /// sanitize functionality. This optional protocol is installed on the same handle
|
---|
144 | /// as the EFI_BLOCK_IO_PROTOCOL or EFI_BLOCK_IO2_PROTOCOL.
|
---|
145 | ///
|
---|
146 | struct _MEDIA_SANITIZE_PROTOCOL {
|
---|
147 | ///
|
---|
148 | /// The revision to which the MEDIA_SANITIZE_PROTOCOL adheres. All future
|
---|
149 | /// revisions must be backwards compatible. If a future version is not
|
---|
150 | /// backwards compatible, it is not the same GUID.
|
---|
151 | ///
|
---|
152 | UINT64 Revision;
|
---|
153 |
|
---|
154 | ///
|
---|
155 | /// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
|
---|
156 | /// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.
|
---|
157 | ///
|
---|
158 | EFI_BLOCK_IO_MEDIA *Media;
|
---|
159 |
|
---|
160 | ///
|
---|
161 | /// SanitizeCapabilities shall which sanitize operations (crypto erase, block
|
---|
162 | /// erase, overwrite) is supported by this Block Io device.
|
---|
163 | ///
|
---|
164 | UINT32 SanitizeCapabilities;
|
---|
165 |
|
---|
166 | BLOCK_MEDIA_CLEAR MediaClear;
|
---|
167 | BLOCK_MEDIA_PURGE MediaPurge;
|
---|
168 | BLOCK_MEDIA_FORMAT MediaFormat;
|
---|
169 | };
|
---|
170 |
|
---|
171 | extern EFI_GUID gMediaSanitizeProtocolGuid;
|
---|
172 |
|
---|
173 | #endif
|
---|