• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Header file for SdDxe Driver.
3 
4   This file defines common data structures, macro definitions and some module
5   internal function header files.
6 
7   Copyright (c) 2015 - 2016, Intel Corporation. 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 _SD_BLOCK_IO_H_
19 #define _SD_BLOCK_IO_H_
20 
21 /**
22   Reset the Block Device.
23 
24   @param  This                 Indicates a pointer to the calling context.
25   @param  ExtendedVerification Driver may perform diagnostics on reset.
26 
27   @retval EFI_SUCCESS          The device was reset.
28   @retval EFI_DEVICE_ERROR     The device is not functioning properly and could
29                                not be reset.
30 
31 **/
32 EFI_STATUS
33 EFIAPI
34 SdReset (
35   IN  EFI_BLOCK_IO_PROTOCOL   *This,
36   IN  BOOLEAN                 ExtendedVerification
37   );
38 
39 /**
40   Read BufferSize bytes from Lba into Buffer.
41 
42   @param  This       Indicates a pointer to the calling context.
43   @param  MediaId    Id of the media, changes every time the media is replaced.
44   @param  Lba        The starting Logical Block Address to read from
45   @param  BufferSize Size of Buffer, must be a multiple of device block size.
46   @param  Buffer     A pointer to the destination buffer for the data. The caller is
47                      responsible for either having implicit or explicit ownership of the buffer.
48 
49   @retval EFI_SUCCESS           The data was read correctly from the device.
50   @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.
51   @retval EFI_NO_MEDIA          There is no media in the device.
52   @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.
53   @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.
54   @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
55                                 or the buffer is not on proper alignment.
56 
57 **/
58 EFI_STATUS
59 EFIAPI
60 SdReadBlocks (
61   IN     EFI_BLOCK_IO_PROTOCOL  *This,
62   IN     UINT32                 MediaId,
63   IN     EFI_LBA                Lba,
64   IN     UINTN                  BufferSize,
65      OUT VOID                   *Buffer
66   );
67 
68 /**
69   Write BufferSize bytes from Lba into Buffer.
70 
71   @param  This       Indicates a pointer to the calling context.
72   @param  MediaId    The media ID that the write request is for.
73   @param  Lba        The starting logical block address to be written. The caller is
74                      responsible for writing to only legitimate locations.
75   @param  BufferSize Size of Buffer, must be a multiple of device block size.
76   @param  Buffer     A pointer to the source buffer for the data.
77 
78   @retval EFI_SUCCESS           The data was written correctly to the device.
79   @retval EFI_WRITE_PROTECTED   The device can not be written to.
80   @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.
81   @retval EFI_NO_MEDIA          There is no media in the device.
82   @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.
83   @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.
84   @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
85                                 or the buffer is not on proper alignment.
86 
87 **/
88 EFI_STATUS
89 EFIAPI
90 SdWriteBlocks (
91   IN  EFI_BLOCK_IO_PROTOCOL   *This,
92   IN  UINT32                  MediaId,
93   IN  EFI_LBA                 Lba,
94   IN  UINTN                   BufferSize,
95   IN  VOID                    *Buffer
96   );
97 
98 /**
99   Flush the Block Device.
100 
101   @param  This              Indicates a pointer to the calling context.
102 
103   @retval EFI_SUCCESS       All outstanding data was written to the device
104   @retval EFI_DEVICE_ERROR  The device reported an error while writing back the data
105   @retval EFI_NO_MEDIA      There is no media in the device.
106 
107 **/
108 EFI_STATUS
109 EFIAPI
110 SdFlushBlocks (
111   IN  EFI_BLOCK_IO_PROTOCOL   *This
112   );
113 
114 /**
115   Reset the Block Device.
116 
117   @param[in]  This                 Indicates a pointer to the calling context.
118   @param[in]  ExtendedVerification Driver may perform diagnostics on reset.
119 
120   @retval EFI_SUCCESS              The device was reset.
121   @retval EFI_DEVICE_ERROR         The device is not functioning properly and could
122                                    not be reset.
123 
124 **/
125 EFI_STATUS
126 EFIAPI
127 SdResetEx (
128   IN  EFI_BLOCK_IO2_PROTOCOL  *This,
129   IN  BOOLEAN                 ExtendedVerification
130   );
131 
132 /**
133   Read BufferSize bytes from Lba into Buffer.
134 
135   @param[in]       This         Indicates a pointer to the calling context.
136   @param[in]       MediaId      Id of the media, changes every time the media is replaced.
137   @param[in]       Lba          The starting Logical Block Address to read from.
138   @param[in, out]  Token        A pointer to the token associated with the transaction.
139   @param[in]       BufferSize   Size of Buffer, must be a multiple of device block size.
140   @param[out]      Buffer       A pointer to the destination buffer for the data. The caller is
141                                 responsible for either having implicit or explicit ownership of the buffer.
142 
143   @retval EFI_SUCCESS           The read request was queued if Event is not NULL.
144                                 The data was read correctly from the device if
145                                 the Event is NULL.
146   @retval EFI_DEVICE_ERROR      The device reported an error while performing
147                                 the read.
148   @retval EFI_NO_MEDIA          There is no media in the device.
149   @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.
150   @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the
151                                 intrinsic block size of the device.
152   @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
153                                 or the buffer is not on proper alignment.
154   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack
155                                 of resources.
156 
157 **/
158 EFI_STATUS
159 EFIAPI
160 SdReadBlocksEx (
161   IN     EFI_BLOCK_IO2_PROTOCOL *This,
162   IN     UINT32                 MediaId,
163   IN     EFI_LBA                Lba,
164   IN OUT EFI_BLOCK_IO2_TOKEN    *Token,
165   IN     UINTN                  BufferSize,
166      OUT VOID                   *Buffer
167   );
168 
169 /**
170   Write BufferSize bytes from Lba into Buffer.
171 
172   @param[in]       This         Indicates a pointer to the calling context.
173   @param[in]       MediaId      The media ID that the write request is for.
174   @param[in]       Lba          The starting logical block address to be written. The
175                                 caller is responsible for writing to only legitimate
176                                 locations.
177   @param[in, out]  Token        A pointer to the token associated with the transaction.
178   @param[in]       BufferSize   Size of Buffer, must be a multiple of device block size.
179   @param[in]       Buffer       A pointer to the source buffer for the data.
180 
181   @retval EFI_SUCCESS           The data was written correctly to the device.
182   @retval EFI_WRITE_PROTECTED   The device can not be written to.
183   @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.
184   @retval EFI_NO_MEDIA          There is no media in the device.
185   @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.
186   @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.
187   @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
188                                 or the buffer is not on proper alignment.
189 
190 **/
191 EFI_STATUS
192 EFIAPI
193 SdWriteBlocksEx (
194   IN     EFI_BLOCK_IO2_PROTOCOL *This,
195   IN     UINT32                 MediaId,
196   IN     EFI_LBA                Lba,
197   IN OUT EFI_BLOCK_IO2_TOKEN    *Token,
198   IN     UINTN                  BufferSize,
199   IN     VOID                   *Buffer
200   );
201 
202 /**
203   Flush the Block Device.
204 
205   @param[in]       This     Indicates a pointer to the calling context.
206   @param[in, out]  Token    A pointer to the token associated with the transaction.
207 
208   @retval EFI_SUCCESS       All outstanding data was written to the device
209   @retval EFI_DEVICE_ERROR  The device reported an error while writing back the data
210   @retval EFI_NO_MEDIA      There is no media in the device.
211 
212 **/
213 EFI_STATUS
214 EFIAPI
215 SdFlushBlocksEx (
216   IN     EFI_BLOCK_IO2_PROTOCOL  *This,
217   IN OUT EFI_BLOCK_IO2_TOKEN     *Token
218   );
219 
220 /**
221   Erase a specified number of device blocks.
222 
223   @param[in]       This           Indicates a pointer to the calling context.
224   @param[in]       MediaId        The media ID that the erase request is for.
225   @param[in]       Lba            The starting logical block address to be
226                                   erased. The caller is responsible for erasing
227                                   only legitimate locations.
228   @param[in, out]  Token          A pointer to the token associated with the
229                                   transaction.
230   @param[in]       Size           The size in bytes to be erased. This must be
231                                   a multiple of the physical block size of the
232                                   device.
233 
234   @retval EFI_SUCCESS             The erase request was queued if Event is not
235                                   NULL. The data was erased correctly to the
236                                   device if the Event is NULL.to the device.
237   @retval EFI_WRITE_PROTECTED     The device cannot be erased due to write
238                                   protection.
239   @retval EFI_DEVICE_ERROR        The device reported an error while attempting
240                                   to perform the erase operation.
241   @retval EFI_INVALID_PARAMETER   The erase request contains LBAs that are not
242                                   valid.
243   @retval EFI_NO_MEDIA            There is no media in the device.
244   @retval EFI_MEDIA_CHANGED       The MediaId is not for the current media.
245 
246 **/
247 EFI_STATUS
248 EFIAPI
249 SdEraseBlocks (
250   IN     EFI_ERASE_BLOCK_PROTOCOL      *This,
251   IN     UINT32                        MediaId,
252   IN     EFI_LBA                       Lba,
253   IN OUT EFI_ERASE_BLOCK_TOKEN         *Token,
254   IN     UINTN                         Size
255   );
256 
257 #endif
258 
259