Skip to content

Commit 19c2eda

Browse files
Merge pull request #1962 from rust-osdev/ai-spec-fixes
uefi-raw: various spec fixes
2 parents fb11d8c + ad867db commit 19c2eda

12 files changed

Lines changed: 54 additions & 23 deletions

File tree

uefi-raw/src/firmware_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bitflags! {
7474
const ALIGNMENT_64 = 0x0006_0000;
7575
const ALIGNMENT_128 = 0x0007_0000;
7676
const ALIGNMENT_256 = 0x0008_0000;
77-
const ALIGNMENT_512 = 0x0008_0000;
77+
const ALIGNMENT_512 = 0x0009_0000;
7878
const ALIGNMENT_1K = 0x000a_0000;
7979
const ALIGNMENT_2K = 0x000b_0000;
8080
const ALIGNMENT_4K = 0x000c_0000;

uefi-raw/src/net.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl MacAddress {
261261
#[must_use]
262262
pub fn into_ethernet_addr(self) -> [u8; 6] {
263263
let mut buffer = [0; 6];
264-
buffer.copy_from_slice(&self.octets()[6..]);
264+
buffer.copy_from_slice(&self.octets()[..6]);
265265
buffer
266266
}
267267
}
@@ -328,6 +328,29 @@ mod tests {
328328
assert_eq!(unsafe { uefi_addr.v6.0 }, TEST_IPV6);
329329
}
330330

331+
/// Test conversions between `MacAddress` and octet arrays.
332+
#[test]
333+
fn test_mac_addr_conversion() {
334+
let ethernet_octets = [0, 1, 2, 3, 4, 5];
335+
let mut padded_octets = [0; 32];
336+
padded_octets[..6].copy_from_slice(&ethernet_octets);
337+
338+
let efi_mac_addr = MacAddress::from(ethernet_octets);
339+
assert_eq!(efi_mac_addr.octets(), padded_octets);
340+
assert_eq!(<[u8; 6]>::from(efi_mac_addr), ethernet_octets);
341+
assert_eq!(efi_mac_addr.into_ethernet_addr(), ethernet_octets);
342+
343+
let efi_octets = [
344+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
345+
24, 25, 26, 27, 28, 29, 30, 31,
346+
];
347+
348+
let efi_mac_addr = MacAddress::from(efi_octets);
349+
assert_eq!(efi_mac_addr.octets(), efi_octets);
350+
assert_eq!(<[u8; 6]>::from(efi_mac_addr), ethernet_octets);
351+
assert_eq!(efi_mac_addr.into_ethernet_addr(), ethernet_octets);
352+
}
353+
331354
// Ensure that our IpAddress type can be put into a packed struct,
332355
// even when it is normally 4 byte aligned.
333356
#[test]

uefi-raw/src/protocol/console.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ pub struct SimplePointerMode {
184184
pub resolution_x: u64,
185185
pub resolution_y: u64,
186186
pub resolution_z: u64,
187-
pub left_button: u8,
188-
pub right_button: u8,
187+
pub left_button: Boolean,
188+
pub right_button: Boolean,
189189
}
190190

191191
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]

uefi-raw/src/protocol/hii/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub struct HiiConfigRoutingProtocol {
172172
pub config_to_block: unsafe extern "efiapi" fn(
173173
this: *const Self,
174174
config_resp: *const Char16,
175-
block: *mut *const u8,
175+
block: *mut u8,
176176
block_size: *mut usize,
177177
progress: *mut *const Char16,
178178
) -> Status,

uefi-raw/src/protocol/hii/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct HiiStringProtocol {
2424
language: *const Char8,
2525
package_list: HiiHandle,
2626
string_id: StringId,
27-
string: *mut *mut Char16,
27+
string: *mut Char16,
2828
string_size: *mut usize,
2929
string_font_info: *mut *mut FontInfo,
3030
) -> Status,

uefi-raw/src/protocol/network/snp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,6 @@ newtype_enum! {
403403
/// The interface has been initialized
404404
INITIALIZED = 2,
405405
/// No state can have a number higher than this
406-
MAX_STATE = 4,
406+
MAX_STATE = 3,
407407
}
408408
}

uefi-raw/src/protocol/shell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct ShellFileInfo {
2929
pub full_name: *mut Char16,
3030
pub file_name: *mut Char16,
3131
pub handle: ShellFileHandle,
32-
pub info: FileInfo,
32+
pub info: *mut FileInfo,
3333
}
3434

3535
bitflags! {

uefi-raw/src/protocol/tcg/v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module
1414
1515
use super::EventType;
16-
use crate::{Guid, PhysicalAddress, Status, guid};
16+
use crate::{Boolean, Guid, PhysicalAddress, Status, guid};
1717
use bitflags::bitflags;
1818
use core::ffi::c_void;
1919

@@ -151,7 +151,7 @@ pub struct Tcg2Protocol {
151151
event_log_format: Tcg2EventLogFormat,
152152
event_log_location: *mut PhysicalAddress,
153153
event_log_last_entry: *mut PhysicalAddress,
154-
event_log_truncated: *mut u8,
154+
event_log_truncated: *mut Boolean,
155155
) -> Status,
156156

157157
pub hash_log_extend_event: unsafe extern "efiapi" fn(

uefi-raw/src/protocol/usb/host_controller.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ pub struct Usb2HostControllerProtocol {
111111
this: *const Self,
112112
max_speed: *mut Speed,
113113
port_number: *mut u8,
114+
// [`Boolean::TRUE`] if the controller supports 64-bit memory
115+
// addressing, [`Boolean::false`] otherwise.
116+
//
117+
// Effectively this is treated like a [`Boolean`] but the spec types it
118+
// as `u8`.
114119
is_64_bit_capable: *mut u8,
115120
) -> Status,
116121
pub reset: unsafe extern "efiapi" fn(this: *mut Self, attributes: ResetAttributes) -> Status,

uefi-raw/src/table/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Header {
1212
pub revision: Revision,
1313
/// The size in bytes of the entire table.
1414
pub size: u32,
15-
/// 32-bit CRC-32-Castagnoli of the entire table,
15+
/// 32-bit CRC of the entire table using polynomial `0x04c11db7`,
1616
/// calculated with this field set to 0.
1717
pub crc: u32,
1818
/// Reserved field that must be set to 0.

0 commit comments

Comments
 (0)