]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/DiskIo2.h
Add DiskIo2 protocol definition to MdePkg.
[mirror_edk2.git] / MdePkg / Include / Protocol / DiskIo2.h
1 /** @file
2 Disk IO protocol as defined in the UEFI 2.0 specification.
3
4 The Disk IO2 protocol is used to convert block oriented devices into byte
5 oriented devices. The Disk IO protocol is intended to layer on top of the
6 Block IO protocol.
7
8 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19 #ifndef __DISK_IO2_H__
20 #define __DISK_IO2_H__
21
22 #define EFI_DISK_IO2_PROTOCOL_GUID \
23 { \
24 0x151c8eae, 0x7f2c, 0x472c, 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 \
25 }
26
27 typedef struct _EFI_DISK_IO2_PROTOCOL EFI_DISK_IO2_PROTOCOL;
28
29 /**
30 The struct of Disk IO2 Token.
31 **/
32 typedef struct {
33 //
34 // If Event is NULL, then blocking I/O is performed.
35 // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,
36 // and Event will be signaled when the I/O request is completed.
37 // The caller must be prepared to handle the case where the callback associated with Event occurs
38 // before the original asynchronous I/O request call returns.
39 //
40 EFI_EVENT Event;
41
42 //
43 // Defines whether or not the signaled event encountered an error.
44 //
45 EFI_STATUS TransactionStatus;
46 } EFI_DISK_IO2_TOKEN;
47
48 /**
49 Terminate outstanding asynchronous requests to a device.
50
51 @param This Indicates a pointer to the calling context.
52
53 @retval EFI_SUCCESS All outstanding requests were successfully terminated.
54 @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel
55 operation.
56 **/
57 typedef
58 EFI_STATUS
59 (EFIAPI *EFI_DISK_CANCEL_EX) (
60 IN EFI_DISK_IO2_PROTOCOL *This
61 );
62
63 /**
64 Reads a specified number of bytes from a device.
65
66 @param This Indicates a pointer to the calling context.
67 @param MediaId ID of the medium to be read.
68 @param Offset The starting byte offset on the logical block I/O device to read from.
69 @param Token A pointer to the token associated with the transaction.
70 If this field is NULL, synchronous/blocking IO is performed.
71 @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
72 @param Buffer A pointer to the destination buffer for the data.
73 The caller is responsible either having implicit or explicit ownership of the buffer.
74
75 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.
76 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
77 Event will be signaled upon completion.
78 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
79 @retval EFI_NO_MEDIA There is no medium in the device.
80 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
81 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.
82 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
83
84 **/
85 typedef
86 EFI_STATUS
87 (EFIAPI *EFI_DISK_READ_EX) (
88 IN EFI_DISK_IO2_PROTOCOL *This,
89 IN UINT32 MediaId,
90 IN UINT64 Offset,
91 IN OUT EFI_DISK_IO2_TOKEN *Token,
92 IN UINTN BufferSize,
93 OUT VOID *Buffer
94 );
95
96 /**
97 Writes a specified number of bytes to a device.
98
99 @param This Indicates a pointer to the calling context.
100 @param MediaId ID of the medium to be written.
101 @param Offset The starting byte offset on the logical block I/O device to write to.
102 @param Token A pointer to the token associated with the transaction.
103 If this field is NULL, synchronous/blocking IO is performed.
104 @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
105 @param Buffer A pointer to the buffer containing the data to be written.
106
107 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.
108 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
109 Event will be signaled upon completion.
110 @retval EFI_WRITE_PROTECTED The device cannot be written to.
111 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
112 @retval EFI_NO_MEDIA There is no medium in the device.
113 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
114 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.
115 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
116
117 **/
118 typedef
119 EFI_STATUS
120 (EFIAPI *EFI_DISK_WRITE_EX) (
121 IN EFI_DISK_IO2_PROTOCOL *This,
122 IN UINT32 MediaId,
123 IN UINT64 Offset,
124 IN OUT EFI_DISK_IO2_TOKEN *Token,
125 IN UINTN BufferSize,
126 IN VOID *Buffer
127 );
128
129 /**
130 Flushes all modified data to the physical device.
131
132 @param This Indicates a pointer to the calling context.
133 @param MediaId ID of the medium to be written.
134 @param Token A pointer to the token associated with the transaction.
135 If this field is NULL, synchronous/blocking IO is performed.
136
137 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.
138 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
139 Event will be signaled upon completion.
140 @retval EFI_WRITE_PROTECTED The device cannot be written to.
141 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
142 @retval EFI_NO_MEDIA There is no medium in the device.
143 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
144 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
145 **/
146 typedef
147 EFI_STATUS
148 (EFIAPI *EFI_DISK_FLUSH_EX) (
149 IN EFI_DISK_IO2_PROTOCOL *This,
150 IN OUT EFI_DISK_IO2_TOKEN *Token
151 );
152
153 #define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000
154
155 ///
156 /// This protocol is used to abstract Block I/O interfaces.
157 ///
158 struct _EFI_DISK_IO2_PROTOCOL {
159 ///
160 /// The revision to which the disk I/O interface adheres. All future
161 /// revisions must be backwards compatible. If a future version is not
162 /// backwards compatible, it is not the same GUID.
163 ///
164 UINT64 Revision;
165 EFI_DISK_CANCEL_EX Cancel;
166 EFI_DISK_READ_EX ReadDiskEx;
167 EFI_DISK_WRITE_EX WriteDiskEx;
168 EFI_DISK_FLUSH_EX FlushDiskEx;
169 };
170
171 extern EFI_GUID gEfiDiskIo2ProtocolGuid;
172
173 #endif