Skip to content

Commit c6f3327

Browse files
A0lsonIsaacWoods
authored andcommitted
acpi: Allow Madt and Mcfg fields to be accessed without allocator_api
In the absence of the allocator_api feature being enabled and/or other situtations it is useful to be able to access ACPI table fields directly. This also allows the low-level use of the tables, especially when higher-level processing is not yet implemented. Thus, this revision makes them and the Mcfg 'entries()' method public.
1 parent 2d4f81c commit c6f3327

File tree

2 files changed

+94
-94
lines changed

2 files changed

+94
-94
lines changed

acpi/src/madt.rs

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub enum MadtError {
3434
#[repr(C, packed)]
3535
#[derive(Debug, Clone, Copy)]
3636
pub struct Madt {
37-
header: SdtHeader,
38-
local_apic_address: u32,
39-
flags: u32,
37+
pub header: SdtHeader,
38+
pub local_apic_address: u32,
39+
pub flags: u32,
4040
}
4141

4242
/// ### Safety: Implementation properly represents a valid MADT.
@@ -415,86 +415,86 @@ impl<'a> Iterator for MadtEntryIter<'a> {
415415
#[derive(Clone, Copy, Debug)]
416416
#[repr(C, packed)]
417417
pub struct EntryHeader {
418-
entry_type: u8,
419-
length: u8,
418+
pub entry_type: u8,
419+
pub length: u8,
420420
}
421421

422422
#[derive(Clone, Copy, Debug)]
423423
#[repr(C, packed)]
424424
pub struct LocalApicEntry {
425-
header: EntryHeader,
426-
processor_id: u8,
427-
apic_id: u8,
428-
flags: u32,
425+
pub header: EntryHeader,
426+
pub processor_id: u8,
427+
pub apic_id: u8,
428+
pub flags: u32,
429429
}
430430

431431
#[derive(Clone, Copy, Debug)]
432432
#[repr(C, packed)]
433433
pub struct IoApicEntry {
434-
header: EntryHeader,
435-
io_apic_id: u8,
434+
pub header: EntryHeader,
435+
pub io_apic_id: u8,
436436
_reserved: u8,
437-
io_apic_address: u32,
438-
global_system_interrupt_base: u32,
437+
pub io_apic_address: u32,
438+
pub global_system_interrupt_base: u32,
439439
}
440440

441441
#[derive(Clone, Copy, Debug)]
442442
#[repr(C, packed)]
443443
pub struct InterruptSourceOverrideEntry {
444-
header: EntryHeader,
445-
bus: u8, // 0 - ISA bus
446-
irq: u8, // This is bus-relative
447-
global_system_interrupt: u32,
448-
flags: u16,
444+
pub header: EntryHeader,
445+
pub bus: u8, // 0 - ISA bus
446+
pub irq: u8, // This is bus-relative
447+
pub global_system_interrupt: u32,
448+
pub flags: u16,
449449
}
450450

451451
#[derive(Clone, Copy, Debug)]
452452
#[repr(C, packed)]
453453
pub struct NmiSourceEntry {
454-
header: EntryHeader,
455-
flags: u16,
456-
global_system_interrupt: u32,
454+
pub header: EntryHeader,
455+
pub flags: u16,
456+
pub global_system_interrupt: u32,
457457
}
458458

459459
#[derive(Clone, Copy, Debug)]
460460
#[repr(C, packed)]
461461
pub struct LocalApicNmiEntry {
462-
header: EntryHeader,
463-
processor_id: u8,
464-
flags: u16,
465-
nmi_line: u8, // Describes which LINTn is the NMI connected to
462+
pub header: EntryHeader,
463+
pub processor_id: u8,
464+
pub flags: u16,
465+
pub nmi_line: u8, // Describes which LINTn is the NMI connected to
466466
}
467467

468468
#[derive(Clone, Copy, Debug)]
469469
#[repr(C, packed)]
470470
pub struct LocalApicAddressOverrideEntry {
471-
header: EntryHeader,
471+
pub header: EntryHeader,
472472
_reserved: u16,
473-
local_apic_address: u64,
473+
pub local_apic_address: u64,
474474
}
475475

476476
/// If this entry is present, the system has an I/O SAPIC, which must be used instead of the I/O
477477
/// APIC.
478478
#[derive(Clone, Copy, Debug)]
479479
#[repr(C, packed)]
480480
pub struct IoSapicEntry {
481-
header: EntryHeader,
482-
io_apic_id: u8,
481+
pub header: EntryHeader,
482+
pub io_apic_id: u8,
483483
_reserved: u8,
484-
global_system_interrupt_base: u32,
485-
io_sapic_address: u64,
484+
pub global_system_interrupt_base: u32,
485+
pub io_sapic_address: u64,
486486
}
487487

488488
#[derive(Clone, Copy, Debug)]
489489
#[repr(C, packed)]
490490
pub struct LocalSapicEntry {
491-
header: EntryHeader,
492-
processor_id: u8,
493-
local_sapic_id: u8,
494-
local_sapic_eid: u8,
491+
pub header: EntryHeader,
492+
pub processor_id: u8,
493+
pub local_sapic_id: u8,
494+
pub local_sapic_eid: u8,
495495
_reserved: [u8; 3],
496-
flags: u32,
497-
processor_uid: u32,
496+
pub flags: u32,
497+
pub processor_uid: u32,
498498

499499
/// This string can be used to associate this local SAPIC to a processor defined in the
500500
/// namespace when the `_UID` object is a string. It is a null-terminated ASCII string, and so
@@ -506,33 +506,33 @@ pub struct LocalSapicEntry {
506506
#[derive(Clone, Copy, Debug)]
507507
#[repr(C, packed)]
508508
pub struct PlatformInterruptSourceEntry {
509-
header: EntryHeader,
510-
flags: u16,
511-
interrupt_type: u8,
512-
processor_id: u8,
513-
processor_eid: u8,
514-
io_sapic_vector: u8,
515-
global_system_interrupt: u32,
516-
platform_interrupt_source_flags: u32,
509+
pub header: EntryHeader,
510+
pub flags: u16,
511+
pub interrupt_type: u8,
512+
pub processor_id: u8,
513+
pub processor_eid: u8,
514+
pub io_sapic_vector: u8,
515+
pub global_system_interrupt: u32,
516+
pub platform_interrupt_source_flags: u32,
517517
}
518518

519519
#[derive(Clone, Copy, Debug)]
520520
#[repr(C, packed)]
521521
pub struct LocalX2ApicEntry {
522-
header: EntryHeader,
522+
pub header: EntryHeader,
523523
_reserved: u16,
524-
x2apic_id: u32,
525-
flags: u32,
526-
processor_uid: u32,
524+
pub x2apic_id: u32,
525+
pub flags: u32,
526+
pub processor_uid: u32,
527527
}
528528

529529
#[derive(Clone, Copy, Debug)]
530530
#[repr(C, packed)]
531531
pub struct X2ApicNmiEntry {
532-
header: EntryHeader,
533-
flags: u16,
534-
processor_uid: u32,
535-
nmi_line: u8,
532+
pub header: EntryHeader,
533+
pub flags: u16,
534+
pub processor_uid: u32,
535+
pub nmi_line: u8,
536536
_reserved: [u8; 3],
537537
}
538538

@@ -542,38 +542,38 @@ pub struct X2ApicNmiEntry {
542542
#[derive(Clone, Copy, Debug)]
543543
#[repr(C, packed)]
544544
pub struct GiccEntry {
545-
header: EntryHeader,
545+
pub header: EntryHeader,
546546
_reserved1: u16,
547-
cpu_interface_number: u32,
548-
processor_uid: u32,
549-
flags: u32,
550-
parking_protocol_version: u32,
551-
performance_interrupt_gsiv: u32,
552-
parked_address: u64,
553-
gic_registers_address: u64,
554-
gic_virtual_registers_address: u64,
555-
gic_hypervisor_registers_address: u64,
556-
vgic_maintenance_interrupt: u32,
557-
gicr_base_address: u64,
558-
mpidr: u64,
559-
processor_power_efficiency_class: u8,
547+
pub cpu_interface_number: u32,
548+
pub processor_uid: u32,
549+
pub flags: u32,
550+
pub parking_protocol_version: u32,
551+
pub performance_interrupt_gsiv: u32,
552+
pub parked_address: u64,
553+
pub gic_registers_address: u64,
554+
pub gic_virtual_registers_address: u64,
555+
pub gic_hypervisor_registers_address: u64,
556+
pub vgic_maintenance_interrupt: u32,
557+
pub gicr_base_address: u64,
558+
pub mpidr: u64,
559+
pub processor_power_efficiency_class: u8,
560560
_reserved2: u8,
561561
/// SPE overflow Interrupt.
562562
///
563563
/// ACPI 6.3 defined this field. It is zero in prior versions or
564564
/// if this processor does not support SPE.
565-
spe_overflow_interrupt: u16,
566-
trbe_interrupt: ExtendedField<u16, 6>,
565+
pub spe_overflow_interrupt: u16,
566+
pub trbe_interrupt: ExtendedField<u16, 6>,
567567
}
568568

569569
#[derive(Clone, Copy, Debug)]
570570
#[repr(C, packed)]
571571
pub struct GicdEntry {
572-
header: EntryHeader,
572+
pub header: EntryHeader,
573573
_reserved1: u16,
574-
gic_id: u32,
575-
physical_base_address: u64,
576-
system_vector_base: u32,
574+
pub gic_id: u32,
575+
pub physical_base_address: u64,
576+
pub system_vector_base: u32,
577577

578578
/// The GIC version
579579
/// 0x00: Fall back to hardware discovery
@@ -582,48 +582,48 @@ pub struct GicdEntry {
582582
/// 0x03: GICv3
583583
/// 0x04: GICv4
584584
/// 0x05-0xff: Reserved for future use
585-
gic_version: u8,
585+
pub gic_version: u8,
586586
_reserved2: [u8; 3],
587587
}
588588

589589
#[derive(Clone, Copy, Debug)]
590590
#[repr(C, packed)]
591591
pub struct GicMsiFrameEntry {
592-
header: EntryHeader,
592+
pub header: EntryHeader,
593593
_reserved: u16,
594-
frame_id: u32,
595-
physical_base_address: u64,
596-
flags: u32,
597-
spi_count: u16,
598-
spi_base: u16,
594+
pub frame_id: u32,
595+
pub physical_base_address: u64,
596+
pub flags: u32,
597+
pub spi_count: u16,
598+
pub spi_base: u16,
599599
}
600600

601601
#[derive(Clone, Copy, Debug)]
602602
#[repr(C, packed)]
603603
pub struct GicRedistributorEntry {
604-
header: EntryHeader,
604+
pub header: EntryHeader,
605605
_reserved: u16,
606-
discovery_range_base_address: u64,
607-
discovery_range_length: u32,
606+
pub discovery_range_base_address: u64,
607+
pub discovery_range_length: u32,
608608
}
609609

610610
#[derive(Clone, Copy, Debug)]
611611
#[repr(C, packed)]
612612
pub struct GicInterruptTranslationServiceEntry {
613-
header: EntryHeader,
613+
pub header: EntryHeader,
614614
_reserved1: u16,
615-
id: u32,
616-
physical_base_address: u64,
615+
pub id: u32,
616+
pub physical_base_address: u64,
617617
_reserved2: u32,
618618
}
619619

620620
#[derive(Clone, Copy, Debug)]
621621
#[repr(C, packed)]
622622
pub struct MultiprocessorWakeupEntry {
623-
header: EntryHeader,
624-
mailbox_version: u16,
623+
pub header: EntryHeader,
624+
pub mailbox_version: u16,
625625
_reserved: u32,
626-
mailbox_address: u64,
626+
pub mailbox_address: u64,
627627
}
628628

629629
#[cfg(feature = "allocator_api")]

acpi/src/mcfg.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ unsafe impl AcpiTable for Mcfg {
108108
impl Mcfg {
109109
/// Returns a slice containing each of the entries in the MCFG table. Where possible, `PlatformInfo.interrupt_model` should
110110
/// be enumerated instead.
111-
fn entries(&self) -> &[McfgEntry] {
111+
pub fn entries(&self) -> &[McfgEntry] {
112112
let length = self.header.length as usize - mem::size_of::<Mcfg>();
113113

114114
// Intentionally round down in case length isn't an exact multiple of McfgEntry size
@@ -131,9 +131,9 @@ impl core::fmt::Debug for Mcfg {
131131
#[derive(Clone, Copy, Debug)]
132132
#[repr(C, packed)]
133133
pub struct McfgEntry {
134-
base_address: u64,
135-
pci_segment_group: u16,
136-
bus_number_start: u8,
137-
bus_number_end: u8,
134+
pub base_address: u64,
135+
pub pci_segment_group: u16,
136+
pub bus_number_start: u8,
137+
pub bus_number_end: u8,
138138
_reserved: u32,
139139
}

0 commit comments

Comments
 (0)