xref: /illumos-gate/usr/src/boot/efi/include/Protocol/DiskIo.h (revision f334afcfaebea1b7dc3430015651d8d748fa8a3e)
1 /** @file
2   Disk IO protocol as defined in the UEFI 2.0 specification.
3 
4   The Disk IO 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) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9   SPDX-License-Identifier: BSD-2-Clause-Patent
10 
11 **/
12 
13 #ifndef __DISK_IO_H__
14 #define __DISK_IO_H__
15 
16 #define EFI_DISK_IO_PROTOCOL_GUID \
17   { \
18     0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
19   }
20 
21 ///
22 /// Protocol GUID name defined in EFI1.1.
23 ///
24 #define DISK_IO_PROTOCOL  EFI_DISK_IO_PROTOCOL_GUID
25 
26 typedef struct _EFI_DISK_IO_PROTOCOL EFI_DISK_IO_PROTOCOL;
27 
28 ///
29 /// Protocol defined in EFI1.1.
30 ///
31 typedef EFI_DISK_IO_PROTOCOL EFI_DISK_IO;
32 
33 /**
34   Read BufferSize bytes from Offset into Buffer.
35 
36   @param  This                  Protocol instance pointer.
37   @param  MediaId               Id of the media, changes every time the media is replaced.
38   @param  Offset                The starting byte offset to read from
39   @param  BufferSize            Size of Buffer
40   @param  Buffer                Buffer containing read data
41 
42   @retval EFI_SUCCESS           The data was read correctly from the device.
43   @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.
44   @retval EFI_NO_MEDIA          There is no media in the device.
45   @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.
46   @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
47                                 valid for the device.
48 
49 **/
50 typedef
51 EFI_STATUS
52 (EFIAPI *EFI_DISK_READ)(
53   IN EFI_DISK_IO_PROTOCOL         *This,
54   IN UINT32                       MediaId,
55   IN UINT64                       Offset,
56   IN UINTN                        BufferSize,
57   OUT VOID                        *Buffer
58   );
59 
60 /**
61   Writes a specified number of bytes to a device.
62 
63   @param  This       Indicates a pointer to the calling context.
64   @param  MediaId    ID of the medium to be written.
65   @param  Offset     The starting byte offset on the logical block I/O device to write.
66   @param  BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
67   @param  Buffer     A pointer to the buffer containing the data to be written.
68 
69   @retval EFI_SUCCESS           The data was written correctly to the device.
70   @retval EFI_WRITE_PROTECTED   The device can not be written to.
71   @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.
72   @retval EFI_NO_MEDIA          There is no media in the device.
73   @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.
74   @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
75                                  valid for the device.
76 
77 **/
78 typedef
79 EFI_STATUS
80 (EFIAPI *EFI_DISK_WRITE)(
81   IN EFI_DISK_IO_PROTOCOL         *This,
82   IN UINT32                       MediaId,
83   IN UINT64                       Offset,
84   IN UINTN                        BufferSize,
85   IN VOID                         *Buffer
86   );
87 
88 #define EFI_DISK_IO_PROTOCOL_REVISION  0x00010000
89 
90 ///
91 /// Revision defined in EFI1.1
92 ///
93 #define EFI_DISK_IO_INTERFACE_REVISION  EFI_DISK_IO_PROTOCOL_REVISION
94 
95 ///
96 /// This protocol is used to abstract Block I/O interfaces.
97 ///
98 struct _EFI_DISK_IO_PROTOCOL {
99   ///
100   /// The revision to which the disk I/O interface adheres. All future
101   /// revisions must be backwards compatible. If a future version is not
102   /// backwards compatible, it is not the same GUID.
103   ///
104   UINT64            Revision;
105   EFI_DISK_READ     ReadDisk;
106   EFI_DISK_WRITE    WriteDisk;
107 };
108 
109 extern EFI_GUID  gEfiDiskIoProtocolGuid;
110 
111 #endif
112