Skip to content

Commit 83e99f2

Browse files
relicensing: Rewrite PR "uefi: Fix wrong install_configuration_table() signature"
The signature fix itself is trivial, just adding a `&`. The test changes had already been partially rewritten during the freestanding table function refactor. Now alter constants and variable names, remove a use of `as`, and free the memory at the end. The PR originally included a cleanup commit ("uefi-test-runner: Fix buffer alignment on ia32") that ended up being cherry-picked and merged in a separate PR: #844. Rewrite that fix here as well. This covers these commits: d7697c3 9609873
1 parent 6d93e1f commit 83e99f2

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

uefi-test-runner/src/boot/misc.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,31 @@ fn test_uninstall_protocol_interface() {
184184

185185
fn test_install_configuration_table() {
186186
// Get the current number of entries.
187-
let count = system::with_config_table(|t| t.len());
187+
let initial_table_count = system::with_config_table(|t| t.len());
188188

189189
// Create the entry data.
190-
let config = boot::allocate_pool(MemoryType::RUNTIME_SERVICES_DATA, 1)
191-
.unwrap()
192-
.as_ptr();
193-
unsafe { config.write(42) };
190+
let config: NonNull<u8> = boot::allocate_pool(MemoryType::RUNTIME_SERVICES_DATA, 1).unwrap();
191+
unsafe { config.write(123u8) };
194192

195193
// Install the table.
196-
const ID: Guid = guid!("4bec53c4-5fc1-48a1-ab12-df214907d29f");
194+
const TABLE_GUID: Guid = guid!("4bec53c4-5fc1-48a1-ab12-df214907d29f");
197195
unsafe {
198-
boot::install_configuration_table(&ID, config.cast()).unwrap();
196+
boot::install_configuration_table(&TABLE_GUID, config.as_ptr().cast()).unwrap();
199197
}
200198

201199
// Verify the installation.
202-
assert_eq!(count + 1, system::with_config_table(|t| t.len()));
200+
assert_eq!(
201+
initial_table_count + 1,
202+
system::with_config_table(|t| t.len())
203+
);
203204
system::with_config_table(|t| {
204-
let config_entry = t.iter().find(|ct| ct.guid == ID).unwrap();
205-
assert_eq!(unsafe { *(config_entry.address as *const u8) }, 42);
205+
let config_entry = t.iter().find(|ct| ct.guid == TABLE_GUID).unwrap();
206+
assert_eq!(unsafe { *config_entry.address.cast::<u8>() }, 123);
206207
});
207208

208-
// Uninstall the table.
209+
// Uninstall the table and free the memory.
209210
unsafe {
210-
boot::install_configuration_table(&ID, ptr::null()).unwrap();
211+
boot::install_configuration_table(&TABLE_GUID, ptr::null()).unwrap();
212+
boot::free_pool(config).unwrap();
211213
}
212214
}

uefi-test-runner/src/proto/media.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use uefi::proto::media::fs::SimpleFileSystem;
1515
use uefi::proto::media::partition::{MbrOsType, PartitionInfo};
1616
use uefi::runtime::{Daylight, Time, TimeParams};
1717

18+
#[repr(align(8))]
19+
struct AlignedBuf([u8; 256]);
20+
1821
/// Test directory entry iteration.
1922
fn test_existing_dir(directory: &mut Directory) {
2023
info!("Testing existing directory");
@@ -31,11 +34,9 @@ fn test_existing_dir(directory: &mut Directory) {
3134
let dir = RefCell::new(dir);
3235

3336
assert_eq!(FileInfo::alignment(), 8);
34-
#[repr(align(8))]
35-
struct Buf([u8; 200]);
3637

3738
// Backing memory to read the file info data into.
38-
let mut stack_buf = Buf([0; 200]);
39+
let mut stack_buf = AlignedBuf([0; 256]);
3940

4041
// The file names that the test read from the directory.
4142
let entry_names = RefCell::new(vec![]);

0 commit comments

Comments
 (0)