acpi/fadt: fix pre-existing usize/u32 type mismatch on x86_64
The FADT_MIN_SIZE_ACPI_2_0 and FADT_MIN_SIZE_ACPI_1_0 constants were defined as usize, but the Sdt::length() method they are compared against returns u32. On x86_64, this is a type mismatch because usize is u64 and u32 is u32 — the comparison sdt.length() >= FADT_MIN_SIZE_ACPI_2_0 fails to compile with E0308 'expected u32, found usize' (the inferred LHS type is u32, the RHS constant is usize). Root cause: the constants were originally written for a build target where usize == u32 (i386), so the implicit comparison worked. When the target moved to x86_64, the type mismatch became visible but was never resolved. Fix: change both constants to u32. The values 148 and 76 are trivially representable in u32 (ACPI spec FADT minimum size limits), and u32 matches the Sdt::length() return type per the ACPI 6.5 spec which defines the SDT length field as a 32-bit integer. This was the lone remaining cargo check error in the local kernel fork, blocking clean cargo check validation of every other change. With this fix, cargo check now exits 0 (modulo pre-existing unrelated warnings). The fadt.rs module was touched in earlier Red Bear OS commits (9bc1fbf'fix Phase II.X.W FACS parser + Sdt length() + UserSlice access' and475f96e'comprehensive FACS parser') but the type mismatch on the constant was not fixed at that time.
This commit is contained in:
+6
-4
@@ -53,10 +53,12 @@ mod offsets {
|
||||
/// Structure address. ACPI 2.0+.
|
||||
pub const X_FIRMWARE_CTRL_64: usize = 140;
|
||||
/// FADT minimum size for ACPI 2.0+ (i.e., enough to
|
||||
/// include `x_firmware_ctrl` at offset 140).
|
||||
pub const FADT_MIN_SIZE_ACPI_2_0: usize = 148;
|
||||
/// FADT minimum size for ACPI 1.0.
|
||||
pub const FADT_MIN_SIZE_ACPI_1_0: usize = 76;
|
||||
/// include `x_firmware_ctrl` at offset 140). Stored as
|
||||
/// `u32` to match `Sdt::length()` (which is `u32` per
|
||||
/// ACPI spec) and avoid a usize/u32 comparison on x86_64.
|
||||
pub const FADT_MIN_SIZE_ACPI_2_0: u32 = 148;
|
||||
/// FADT minimum size for ACPI 1.0. Same rationale.
|
||||
pub const FADT_MIN_SIZE_ACPI_1_0: u32 = 76;
|
||||
}
|
||||
|
||||
/// Parse the FADT from the given SDT bytes and extract the
|
||||
|
||||
Reference in New Issue
Block a user