Add configuration table iterator
This commit is contained in:
@@ -77,6 +77,7 @@ impl<T> Termination for Result<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub struct Guid {
|
||||
pub data1: u32,
|
||||
pub data2: u16,
|
||||
|
||||
+56
-1
@@ -41,7 +41,62 @@ pub struct SystemTable {
|
||||
pub runtime_services: &'static mut RuntimeServices,
|
||||
pub boot_services: &'static mut BootServices,
|
||||
number_of_table_entries: usize,
|
||||
configuration_table: *mut c_void // TODO
|
||||
configuration_table: *mut ConfigurationTableRaw
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct ConfigurationTableRaw {
|
||||
vendor_guid: Guid,
|
||||
vendor_table: *mut c_void
|
||||
}
|
||||
|
||||
pub enum ConfigurationTableEntry {
|
||||
Acpi10Table(*mut c_void), // RSDP
|
||||
NotImplemented(*mut c_void)
|
||||
}
|
||||
|
||||
pub struct ConfigurationTableIterator<'a> {
|
||||
index: usize,
|
||||
st: &'a SystemTable
|
||||
}
|
||||
|
||||
const EFI_ACPI_10_TABLE_GUID: Guid = Guid {
|
||||
data1: 0xeb9d2d30,
|
||||
data2: 0x2d88,
|
||||
data3: 0x11d3,
|
||||
data4: [0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d]
|
||||
};
|
||||
impl From<&ConfigurationTableRaw> for ConfigurationTableEntry {
|
||||
fn from(raw: &ConfigurationTableRaw) -> Self {
|
||||
use ConfigurationTableEntry::*;
|
||||
match &raw.vendor_guid {
|
||||
&EFI_ACPI_10_TABLE_GUID => Acpi10Table(raw.vendor_table),
|
||||
_ => NotImplemented(raw.vendor_table)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for ConfigurationTableIterator<'a> {
|
||||
type Item = ConfigurationTableEntry;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.index >= self.st.number_of_table_entries {
|
||||
None
|
||||
} else {
|
||||
let raw = unsafe {&*self.st.configuration_table.offset(self.index as isize)};
|
||||
self.index += 1;
|
||||
Some(ConfigurationTableEntry::from(raw))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SystemTable {
|
||||
pub fn config_iter(&self) -> ConfigurationTableIterator {
|
||||
ConfigurationTableIterator {
|
||||
st: self,
|
||||
index: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static mut SYSTEM_TABLE: *mut SystemTable = null_mut();
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
extern crate efi;
|
||||
extern crate core_rt;
|
||||
|
||||
use efi::{Status, Handle, SystemTable, system_table};
|
||||
use efi::{Status, Handle, SystemTable, ConfigurationTableEntry, system_table};
|
||||
|
||||
#[macro_use]
|
||||
mod println;
|
||||
|
||||
Reference in New Issue
Block a user