Skip to content

Commit 7c31963

Browse files
committed
uefi-raw: add more documentation for LoadFileProtocol and LoadFile2Protocol
1 parent 0e7ca18 commit 7c31963

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

uefi-raw/src/protocol/media.rs

+91
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,60 @@ use crate::protocol::device_path::DevicePathProtocol;
22
use crate::{guid, Guid, Status};
33
use core::ffi::c_void;
44

5+
/// Load File Protocol.
6+
///
7+
/// Used to obtain files, that are primarily boot options, from arbitrary
8+
/// devices.
9+
///
10+
/// # UEFI Spec Description
11+
/// The EFI_LOAD_FILE_PROTOCOL is a simple protocol used to obtain files from
12+
/// arbitrary devices.
13+
///
14+
/// When the firmware is attempting to load a file, it first attempts to use the
15+
/// device’s Simple File System protocol to read the file. If the file system
16+
/// protocol is found, the firmware implements the policy of interpreting the
17+
/// File Path value of the file being loaded. If the device does not support the
18+
/// file system protocol, the firmware then attempts to read the file via the
19+
/// EFI_LOAD_FILE_PROTOCOL and the LoadFile() function. In this case the
20+
/// LoadFile() function implements the policy of interpreting the File Path
21+
/// value.
522
#[derive(Debug)]
623
#[repr(C)]
724
pub struct LoadFileProtocol {
25+
/// Causes the driver to load a specified file.
26+
///
27+
/// # Parameters
28+
/// - `this` pointer to self
29+
/// - `file_path` The device specific path of the file to load.
30+
/// - `boot_policy` If TRUE, indicates that the request originates from the
31+
/// boot manager, and that the boot manager is attempting to load FilePath
32+
/// as a boot selection. If FALSE, then FilePath must match an exact file
33+
/// to be loaded.
34+
/// - `buffer_size` On input the size of Buffer in bytes. On output with a
35+
/// return code of EFI_SUCCESS, the amount of data transferred to Buffer.
36+
/// On output with a return code of EFI_BUFFER_TOO_SMALL, the size of
37+
/// Buffer required to retrieve the requested file.
38+
/// - `buffer` The memory buffer to transfer the file to. If Buffer is NULL,
39+
/// then the size of the requested file is returned in BufferSize.
40+
///
41+
/// # Errors
42+
/// - `uefi::status::EFI_SUCCESS` The file was loaded.
43+
/// - `uefi::status::EFI_UNSUPPORTED` The device does not support the
44+
/// provided BootPolicy.
45+
/// - `uefi::status::EFI_INVALID_PARAMETER` FilePath is not a valid device
46+
/// path, or BufferSize is NULL.
47+
/// - `uefi::status::EFI_NO_MEDIA` No medium was present to load the file.
48+
/// - `uefi::status::EFI_DEVICE_ERROR` The file was not loaded due to a
49+
/// device error.
50+
/// - `uefi::status::EFI_NO_RESPONSE` The remote system did not respond.
51+
/// - `uefi::status::EFI_NOT_FOUND` The file was not found.
52+
/// - `uefi::status::EFI_ABORTED` The file load process was manually
53+
/// cancelled.
54+
/// - `uefi::status::EFI_BUFFER_TOO_SMALL` The BufferSize is too small to
55+
/// read the current directory entry. BufferSize has been updated with the
56+
/// size needed to complete the request.
57+
/// - `uefi::status::EFI_WARN_FILE_SYSTEM` The resulting Buffer contains
58+
/// UEFI-compliant file system.
859
pub load_file: unsafe extern "efiapi" fn(
960
this: *mut LoadFileProtocol,
1061
file_path: *const DevicePathProtocol,
@@ -18,9 +69,49 @@ impl LoadFileProtocol {
1869
pub const GUID: Guid = guid!("56ec3091-954c-11d2-8e3f-00a0c969723b");
1970
}
2071

72+
/// Load File2 Protocol.
73+
///
74+
/// The Load File2 protocol is used to obtain files from arbitrary devices that
75+
/// are not boot options.
76+
///
77+
/// # UEFI Spec Description
78+
///
79+
/// The EFI_LOAD_FILE2_PROTOCOL is a simple protocol used to obtain files from
80+
/// arbitrary devices that are not boot options. It is used by LoadImage() when
81+
/// its BootOption parameter is FALSE and the FilePath does not have an instance
82+
/// of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.
2183
#[derive(Debug)]
2284
#[repr(C)]
2385
pub struct LoadFile2Protocol {
86+
/// Causes the driver to load a specified file.
87+
///
88+
/// # Parameters
89+
/// - `this` pointer to self
90+
/// - `file_path` The device specific path of the file to load.
91+
/// - `boot_policy` Should always be FALSE.
92+
/// to be loaded.
93+
/// - `buffer_size` On input the size of Buffer in bytes. On output with a
94+
/// return code of EFI_SUCCESS, the amount of data transferred to Buffer.
95+
/// On output with a return code of EFI_BUFFER_TOO_SMALL, the size of
96+
/// Buffer required to retrieve the requested file.
97+
/// - `buffer` The memory buffer to transfer the file to. If Buffer is NULL,
98+
/// then the size of the requested file is returned in BufferSize.
99+
///
100+
/// # Errors
101+
/// - `uefi::status::EFI_SUCCESS` The file was loaded.
102+
/// - `uefi::status::EFI_UNSUPPORTED` BootPolicy is TRUE.
103+
/// - `uefi::status::EFI_INVALID_PARAMETER` FilePath is not a valid device
104+
/// path, or BufferSize is NULL.
105+
/// - `uefi::status::EFI_NO_MEDIA` No medium was present to load the file.
106+
/// - `uefi::status::EFI_DEVICE_ERROR` The file was not loaded due to a
107+
/// device error.
108+
/// - `uefi::status::EFI_NO_RESPONSE` The remote system did not respond.
109+
/// - `uefi::status::EFI_NOT_FOUND` The file was not found.
110+
/// - `uefi::status::EFI_ABORTED` The file load process was manually
111+
/// cancelled.
112+
/// - `uefi::status::EFI_BUFFER_TOO_SMALL` The BufferSize is too small to
113+
/// read the current directory entry. BufferSize has been updated with the
114+
/// size needed to complete the request.
24115
pub load_file: unsafe extern "efiapi" fn(
25116
this: *mut LoadFile2Protocol,
26117
file_path: *const DevicePathProtocol,

0 commit comments

Comments
 (0)