summaryrefslogtreecommitdiffstats
path: root/vendor/r-efi/src/protocols/file.rs
blob: 4a66ce294988d0986a42a0a4b3e15301f56696f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//! File Protocol
//!
//! Provides an interface to interact with both files and directories. This protocol is typically
//! obtained via an EFI_SIMPLE_FILE_SYSTEM protocol or via another EFI_FILE_PROTOCOL.

pub const REVISION: u64 = 0x0000_0000_0001_0000u64;
pub const REVISION2: u64 = 0x0000_0000_0002_0000u64;
pub const LATEST_REVISION: u64 = REVISION2;

pub const MODE_READ: u64 = 0x0000000000000001u64;
pub const MODE_WRITE: u64 = 0x0000000000000002u64;
pub const MODE_CREATE: u64 = 0x8000000000000000u64;

pub const READ_ONLY: u64 = 0x0000000000000001u64;
pub const HIDDEN: u64 = 0x0000000000000002u64;
pub const SYSTEM: u64 = 0x0000000000000004u64;
pub const RESERVED: u64 = 0x0000000000000008u64;
pub const DIRECTORY: u64 = 0x0000000000000010u64;
pub const ARCHIVE: u64 = 0x0000000000000020u64;
pub const VALID_ATTR: u64 = 0x0000000000000037u64;

pub const INFO_ID: crate::base::Guid = crate::base::Guid::from_fields(
    0x09576e92,
    0x6d3f,
    0x11d2,
    0x8e,
    0x39,
    &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b],
);
pub const SYSTEM_INFO_ID: crate::base::Guid = crate::base::Guid::from_fields(
    0x09576e93,
    0x6d3f,
    0x11d2,
    0x8e,
    0x39,
    &[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b],
);
pub const SYSTEM_VOLUME_LABEL_ID: crate::base::Guid = crate::base::Guid::from_fields(
    0xdb47d7d3,
    0xfe81,
    0x11d3,
    0x9a,
    0x35,
    &[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d],
);

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IoToken {
    pub event: crate::base::Event,
    pub status: crate::base::Status,
    pub buffer_size: usize,
    pub buffer: *mut core::ffi::c_void,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Info<const N: usize = 0> {
    pub size: u64,
    pub file_size: u64,
    pub physical_size: u64,
    pub create_time: crate::system::Time,
    pub last_access_time: crate::system::Time,
    pub modification_time: crate::system::Time,
    pub attribute: u64,
    pub file_name: [crate::base::Char16; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct SystemInfo<const N: usize = 0> {
    pub size: u64,
    pub read_only: crate::base::Boolean,
    pub volume_size: u64,
    pub free_space: u64,
    pub block_size: u32,
    pub volume_label: [crate::base::Char16; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct SystemVolumeLabel<const N: usize = 0> {
    pub volume_label: [crate::base::Char16; N],
}

pub type ProtocolOpen = eficall! {fn(
    *mut Protocol,
    *mut *mut Protocol,
    *mut crate::base::Char16,
    u64,
    u64,
) -> crate::base::Status};

pub type ProtocolClose = eficall! {fn(
    *mut Protocol,
) -> crate::base::Status};

pub type ProtocolDelete = eficall! {fn(
    *mut Protocol,
) -> crate::base::Status};

pub type ProtocolRead = eficall! {fn(
    *mut Protocol,
    *mut usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type ProtocolWrite = eficall! {fn(
    *mut Protocol,
    *mut usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type ProtocolGetPosition = eficall! {fn(
    *mut Protocol,
    *mut u64,
) -> crate::base::Status};

pub type ProtocolSetPosition = eficall! {fn(
    *mut Protocol,
    u64,
) -> crate::base::Status};

pub type ProtocolGetInfo = eficall! {fn(
    *mut Protocol,
    *mut crate::base::Guid,
    *mut usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type ProtocolSetInfo = eficall! {fn(
    *mut Protocol,
    *mut crate::base::Guid,
    usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type ProtocolFlush = eficall! {fn(
    *mut Protocol,
) -> crate::base::Status};

pub type ProtocolOpenEx = eficall! {fn(
    *mut Protocol,
    *mut *mut Protocol,
    *mut crate::base::Char16,
    u64,
    u64,
    *mut IoToken,
) -> crate::base::Status};

pub type ProtocolReadEx = eficall! {fn(
    *mut Protocol,
    *mut IoToken,
) -> crate::base::Status};

pub type ProtocolWriteEx = eficall! {fn(
    *mut Protocol,
    *mut IoToken,
) -> crate::base::Status};

pub type ProtocolFlushEx = eficall! {fn(
    *mut Protocol,
    *mut IoToken,
) -> crate::base::Status};

#[repr(C)]
pub struct Protocol {
    pub revision: u64,
    pub open: ProtocolOpen,
    pub close: ProtocolClose,
    pub delete: ProtocolDelete,
    pub read: ProtocolRead,
    pub write: ProtocolWrite,
    pub get_position: ProtocolGetPosition,
    pub set_position: ProtocolSetPosition,
    pub get_info: ProtocolGetInfo,
    pub set_info: ProtocolSetInfo,
    pub flush: ProtocolFlush,
    pub open_ex: ProtocolOpenEx,
    pub read_ex: ProtocolReadEx,
    pub write_ex: ProtocolWriteEx,
    pub flush_ex: ProtocolFlushEx,
}