1*7eda31b2SLoGin use acpi::sdt::SdtHeader; 2*7eda31b2SLoGin use alloc::{ 3*7eda31b2SLoGin string::{String, ToString}, 4*7eda31b2SLoGin sync::Arc, 5*7eda31b2SLoGin vec::Vec, 6*7eda31b2SLoGin }; 7*7eda31b2SLoGin 8*7eda31b2SLoGin use crate::{ 9*7eda31b2SLoGin driver::{ 10*7eda31b2SLoGin acpi::acpi_manager, 11*7eda31b2SLoGin base::{kobject::KObject, kset::KSet}, 12*7eda31b2SLoGin }, 13*7eda31b2SLoGin filesystem::{ 14*7eda31b2SLoGin sysfs::{file::sysfs_emit_str, sysfs_instance, Attribute, BinAttribute, SysFSOpsSupport}, 15*7eda31b2SLoGin vfs::syscall::ModeType, 16*7eda31b2SLoGin }, 17*7eda31b2SLoGin libs::rwlock::RwLock, 18*7eda31b2SLoGin syscall::SystemError, 19*7eda31b2SLoGin }; 20*7eda31b2SLoGin 21*7eda31b2SLoGin use super::{acpi_kset, AcpiManager}; 22*7eda31b2SLoGin 23*7eda31b2SLoGin static mut __HOTPLUG_KSET_INSTANCE: Option<Arc<KSet>> = None; 24*7eda31b2SLoGin static mut __ACPI_TABLES_KSET_INSTANCE: Option<Arc<KSet>> = None; 25*7eda31b2SLoGin static mut __ACPI_TABLES_DATA_KSET_INSTANCE: Option<Arc<KSet>> = None; 26*7eda31b2SLoGin static mut __ACPI_TABLES_DYNAMIC_KSET_INSTANCE: Option<Arc<KSet>> = None; 27*7eda31b2SLoGin static mut __ACPI_TABLE_ATTR_LIST: Option<RwLock<Vec<Arc<AttrAcpiTable>>>> = None; 28*7eda31b2SLoGin 29*7eda31b2SLoGin const ACPI_MAX_TABLE_INSTANCES: usize = 999; 30*7eda31b2SLoGin 31*7eda31b2SLoGin #[inline(always)] 32*7eda31b2SLoGin #[allow(dead_code)] 33*7eda31b2SLoGin pub fn hotplug_kset() -> Arc<KSet> { 34*7eda31b2SLoGin unsafe { __HOTPLUG_KSET_INSTANCE.clone().unwrap() } 35*7eda31b2SLoGin } 36*7eda31b2SLoGin 37*7eda31b2SLoGin #[inline(always)] 38*7eda31b2SLoGin pub fn acpi_tables_kset() -> Arc<KSet> { 39*7eda31b2SLoGin unsafe { __ACPI_TABLES_KSET_INSTANCE.clone().unwrap() } 40*7eda31b2SLoGin } 41*7eda31b2SLoGin 42*7eda31b2SLoGin #[inline(always)] 43*7eda31b2SLoGin #[allow(dead_code)] 44*7eda31b2SLoGin pub fn acpi_tables_data_kset() -> Arc<KSet> { 45*7eda31b2SLoGin unsafe { __ACPI_TABLES_DATA_KSET_INSTANCE.clone().unwrap() } 46*7eda31b2SLoGin } 47*7eda31b2SLoGin 48*7eda31b2SLoGin #[inline(always)] 49*7eda31b2SLoGin #[allow(dead_code)] 50*7eda31b2SLoGin pub fn acpi_tables_dynamic_kset() -> Arc<KSet> { 51*7eda31b2SLoGin unsafe { __ACPI_TABLES_DYNAMIC_KSET_INSTANCE.clone().unwrap() } 52*7eda31b2SLoGin } 53*7eda31b2SLoGin 54*7eda31b2SLoGin #[inline(always)] 55*7eda31b2SLoGin fn acpi_table_attr_list() -> &'static RwLock<Vec<Arc<AttrAcpiTable>>> { 56*7eda31b2SLoGin unsafe { 57*7eda31b2SLoGin return __ACPI_TABLE_ATTR_LIST.as_ref().unwrap(); 58*7eda31b2SLoGin } 59*7eda31b2SLoGin } 60*7eda31b2SLoGin 61*7eda31b2SLoGin impl AcpiManager { 62*7eda31b2SLoGin pub(super) fn acpi_sysfs_init(&self) -> Result<(), SystemError> { 63*7eda31b2SLoGin unsafe { 64*7eda31b2SLoGin __ACPI_TABLE_ATTR_LIST = Some(RwLock::new(Vec::new())); 65*7eda31b2SLoGin } 66*7eda31b2SLoGin self.acpi_tables_sysfs_init()?; 67*7eda31b2SLoGin 68*7eda31b2SLoGin let hotplug_kset = KSet::new("hotplug".to_string()); 69*7eda31b2SLoGin hotplug_kset.register(Some(acpi_kset()))?; 70*7eda31b2SLoGin 71*7eda31b2SLoGin unsafe { 72*7eda31b2SLoGin __HOTPLUG_KSET_INSTANCE = Some(hotplug_kset.clone()); 73*7eda31b2SLoGin } 74*7eda31b2SLoGin 75*7eda31b2SLoGin let hotplug_kobj = hotplug_kset as Arc<dyn KObject>; 76*7eda31b2SLoGin sysfs_instance().create_file(&hotplug_kobj, &AttrForceRemove)?; 77*7eda31b2SLoGin 78*7eda31b2SLoGin return Ok(()); 79*7eda31b2SLoGin } 80*7eda31b2SLoGin 81*7eda31b2SLoGin /// 在 sysfs 中创建 ACPI 表目录 82*7eda31b2SLoGin /// 83*7eda31b2SLoGin /// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#488 84*7eda31b2SLoGin fn acpi_tables_sysfs_init(&self) -> Result<(), SystemError> { 85*7eda31b2SLoGin // 创建 `/sys/firmware/acpi/tables` 目录 86*7eda31b2SLoGin let acpi_tables_kset = KSet::new("tables".to_string()); 87*7eda31b2SLoGin acpi_tables_kset.register(Some(acpi_kset()))?; 88*7eda31b2SLoGin unsafe { 89*7eda31b2SLoGin __ACPI_TABLES_KSET_INSTANCE = Some(acpi_tables_kset.clone()); 90*7eda31b2SLoGin } 91*7eda31b2SLoGin 92*7eda31b2SLoGin // 创建 `/sys/firmware/acpi/tables/data` 目录 93*7eda31b2SLoGin let acpi_tables_data_kset = KSet::new("data".to_string()); 94*7eda31b2SLoGin acpi_tables_data_kset.register(Some(acpi_tables_kset.clone()))?; 95*7eda31b2SLoGin unsafe { 96*7eda31b2SLoGin __ACPI_TABLES_DATA_KSET_INSTANCE = Some(acpi_tables_data_kset); 97*7eda31b2SLoGin } 98*7eda31b2SLoGin 99*7eda31b2SLoGin // 创建 `/sys/firmware/acpi/tables/dynamic` 目录 100*7eda31b2SLoGin let acpi_tables_dynamic_kset = KSet::new("dynamic".to_string()); 101*7eda31b2SLoGin acpi_tables_dynamic_kset.register(Some(acpi_tables_kset.clone()))?; 102*7eda31b2SLoGin unsafe { 103*7eda31b2SLoGin __ACPI_TABLES_DYNAMIC_KSET_INSTANCE = Some(acpi_tables_dynamic_kset); 104*7eda31b2SLoGin } 105*7eda31b2SLoGin 106*7eda31b2SLoGin // todo: get acpi tables. 107*7eda31b2SLoGin let tables = self.tables().unwrap(); 108*7eda31b2SLoGin let headers = tables.headers(); 109*7eda31b2SLoGin for header in headers { 110*7eda31b2SLoGin kdebug!("ACPI header: {:?}", header); 111*7eda31b2SLoGin let attr = AttrAcpiTable::new(&header)?; 112*7eda31b2SLoGin acpi_table_attr_list().write().push(attr); 113*7eda31b2SLoGin self.acpi_table_data_init(&header)?; 114*7eda31b2SLoGin } 115*7eda31b2SLoGin 116*7eda31b2SLoGin return Ok(()); 117*7eda31b2SLoGin } 118*7eda31b2SLoGin 119*7eda31b2SLoGin /// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#469 120*7eda31b2SLoGin fn acpi_table_data_init(&self, _header: &SdtHeader) -> Result<(), SystemError> { 121*7eda31b2SLoGin // todo!("AcpiManager::acpi_table_data_init()") 122*7eda31b2SLoGin return Ok(()); 123*7eda31b2SLoGin } 124*7eda31b2SLoGin } 125*7eda31b2SLoGin 126*7eda31b2SLoGin #[derive(Debug)] 127*7eda31b2SLoGin struct AttrForceRemove; 128*7eda31b2SLoGin 129*7eda31b2SLoGin impl Attribute for AttrForceRemove { 130*7eda31b2SLoGin fn name(&self) -> &str { 131*7eda31b2SLoGin "force_remove" 132*7eda31b2SLoGin } 133*7eda31b2SLoGin 134*7eda31b2SLoGin fn mode(&self) -> ModeType { 135*7eda31b2SLoGin return ModeType::from_bits_truncate(0o444); 136*7eda31b2SLoGin } 137*7eda31b2SLoGin 138*7eda31b2SLoGin fn support(&self) -> SysFSOpsSupport { 139*7eda31b2SLoGin return SysFSOpsSupport::SHOW; 140*7eda31b2SLoGin } 141*7eda31b2SLoGin 142*7eda31b2SLoGin fn show(&self, _kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { 143*7eda31b2SLoGin return sysfs_emit_str(buf, "0\n"); 144*7eda31b2SLoGin } 145*7eda31b2SLoGin } 146*7eda31b2SLoGin 147*7eda31b2SLoGin /// ACPI 表在 sysfs 中的属性 148*7eda31b2SLoGin #[derive(Debug)] 149*7eda31b2SLoGin struct AttrAcpiTable { 150*7eda31b2SLoGin name: String, 151*7eda31b2SLoGin filename: String, 152*7eda31b2SLoGin instance: isize, 153*7eda31b2SLoGin size: usize, 154*7eda31b2SLoGin } 155*7eda31b2SLoGin 156*7eda31b2SLoGin impl AttrAcpiTable { 157*7eda31b2SLoGin pub fn new(header: &SdtHeader) -> Result<Arc<Self>, SystemError> { 158*7eda31b2SLoGin let mut r = Self { 159*7eda31b2SLoGin name: header.signature.to_string(), 160*7eda31b2SLoGin filename: "".to_string(), 161*7eda31b2SLoGin instance: 0, 162*7eda31b2SLoGin size: header.length as usize, 163*7eda31b2SLoGin }; 164*7eda31b2SLoGin 165*7eda31b2SLoGin for attr in acpi_table_attr_list().read().iter() { 166*7eda31b2SLoGin if attr.name == r.name { 167*7eda31b2SLoGin r.instance = attr.instance; 168*7eda31b2SLoGin } 169*7eda31b2SLoGin } 170*7eda31b2SLoGin // 将当前实例的序号加1 171*7eda31b2SLoGin r.instance += 1; 172*7eda31b2SLoGin if r.instance > ACPI_MAX_TABLE_INSTANCES as isize { 173*7eda31b2SLoGin kwarn!("too many table instances. name: {}", r.name); 174*7eda31b2SLoGin return Err(SystemError::ERANGE); 175*7eda31b2SLoGin } 176*7eda31b2SLoGin 177*7eda31b2SLoGin let mut has_multiple_instances: bool = false; 178*7eda31b2SLoGin let mut tmpcnt = 0; 179*7eda31b2SLoGin for h in acpi_manager().tables().unwrap().headers() { 180*7eda31b2SLoGin if h.signature == header.signature { 181*7eda31b2SLoGin tmpcnt += 1; 182*7eda31b2SLoGin if tmpcnt > 1 { 183*7eda31b2SLoGin has_multiple_instances = true; 184*7eda31b2SLoGin break; 185*7eda31b2SLoGin } 186*7eda31b2SLoGin } 187*7eda31b2SLoGin } 188*7eda31b2SLoGin 189*7eda31b2SLoGin if r.instance > 1 || (r.instance == 1 && has_multiple_instances) { 190*7eda31b2SLoGin r.filename = format!("{}{}", r.name, r.instance); 191*7eda31b2SLoGin } else { 192*7eda31b2SLoGin r.filename = r.name.clone(); 193*7eda31b2SLoGin } 194*7eda31b2SLoGin 195*7eda31b2SLoGin let result = Arc::new(r); 196*7eda31b2SLoGin sysfs_instance().create_bin_file( 197*7eda31b2SLoGin &(acpi_tables_kset() as Arc<dyn KObject>), 198*7eda31b2SLoGin &(result.clone() as Arc<dyn BinAttribute>), 199*7eda31b2SLoGin )?; 200*7eda31b2SLoGin return Ok(result); 201*7eda31b2SLoGin } 202*7eda31b2SLoGin } 203*7eda31b2SLoGin 204*7eda31b2SLoGin impl Attribute for AttrAcpiTable { 205*7eda31b2SLoGin fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> { 206*7eda31b2SLoGin return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP); 207*7eda31b2SLoGin } 208*7eda31b2SLoGin 209*7eda31b2SLoGin fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> { 210*7eda31b2SLoGin return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP); 211*7eda31b2SLoGin } 212*7eda31b2SLoGin 213*7eda31b2SLoGin fn name(&self) -> &str { 214*7eda31b2SLoGin return &self.filename; 215*7eda31b2SLoGin } 216*7eda31b2SLoGin 217*7eda31b2SLoGin fn mode(&self) -> ModeType { 218*7eda31b2SLoGin return ModeType::from_bits_truncate(0o400); 219*7eda31b2SLoGin } 220*7eda31b2SLoGin 221*7eda31b2SLoGin fn support(&self) -> SysFSOpsSupport { 222*7eda31b2SLoGin return SysFSOpsSupport::empty(); 223*7eda31b2SLoGin } 224*7eda31b2SLoGin } 225*7eda31b2SLoGin 226*7eda31b2SLoGin impl BinAttribute for AttrAcpiTable { 227*7eda31b2SLoGin fn support_battr(&self) -> SysFSOpsSupport { 228*7eda31b2SLoGin return SysFSOpsSupport::READ; 229*7eda31b2SLoGin } 230*7eda31b2SLoGin fn write( 231*7eda31b2SLoGin &self, 232*7eda31b2SLoGin _kobj: Arc<dyn KObject>, 233*7eda31b2SLoGin _buf: &[u8], 234*7eda31b2SLoGin _offset: usize, 235*7eda31b2SLoGin ) -> Result<usize, SystemError> { 236*7eda31b2SLoGin return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP); 237*7eda31b2SLoGin } 238*7eda31b2SLoGin 239*7eda31b2SLoGin /// 展示 ACPI 表的内容 240*7eda31b2SLoGin /// 241*7eda31b2SLoGin /// 参考 https://opengrok.ringotek.cn/xref/linux-6.1.9/drivers/acpi/sysfs.c?fi=acpi_sysfs_init#320 242*7eda31b2SLoGin fn read( 243*7eda31b2SLoGin &self, 244*7eda31b2SLoGin _kobj: Arc<dyn KObject>, 245*7eda31b2SLoGin buf: &mut [u8], 246*7eda31b2SLoGin offset: usize, 247*7eda31b2SLoGin ) -> Result<usize, SystemError> { 248*7eda31b2SLoGin macro_rules! copy_data { 249*7eda31b2SLoGin ($table:expr) => { 250*7eda31b2SLoGin let from = unsafe { 251*7eda31b2SLoGin core::slice::from_raw_parts( 252*7eda31b2SLoGin $table.virtual_start().as_ptr() as *const u8, 253*7eda31b2SLoGin $table.region_length(), 254*7eda31b2SLoGin ) 255*7eda31b2SLoGin }; 256*7eda31b2SLoGin if offset >= from.len() { 257*7eda31b2SLoGin return Ok(0); 258*7eda31b2SLoGin } 259*7eda31b2SLoGin let mut count = buf.len(); 260*7eda31b2SLoGin if count > from.len() - offset { 261*7eda31b2SLoGin count = from.len() - offset; 262*7eda31b2SLoGin } 263*7eda31b2SLoGin buf[0..count].copy_from_slice(&from[offset..offset + count]); 264*7eda31b2SLoGin return Ok(count); 265*7eda31b2SLoGin }; 266*7eda31b2SLoGin } 267*7eda31b2SLoGin 268*7eda31b2SLoGin macro_rules! define_struct { 269*7eda31b2SLoGin ($name:ident) => { 270*7eda31b2SLoGin #[repr(transparent)] 271*7eda31b2SLoGin #[allow(non_snake_case)] 272*7eda31b2SLoGin #[allow(non_camel_case_types)] 273*7eda31b2SLoGin struct $name { 274*7eda31b2SLoGin header: SdtHeader, 275*7eda31b2SLoGin } 276*7eda31b2SLoGin 277*7eda31b2SLoGin unsafe impl acpi::AcpiTable for $name { 278*7eda31b2SLoGin const SIGNATURE: acpi::sdt::Signature = acpi::sdt::Signature::$name; 279*7eda31b2SLoGin fn header(&self) -> &acpi::sdt::SdtHeader { 280*7eda31b2SLoGin return &self.header; 281*7eda31b2SLoGin } 282*7eda31b2SLoGin } 283*7eda31b2SLoGin }; 284*7eda31b2SLoGin } 285*7eda31b2SLoGin 286*7eda31b2SLoGin macro_rules! handle { 287*7eda31b2SLoGin ($name: ident, $tables: expr) => { 288*7eda31b2SLoGin define_struct!($name); 289*7eda31b2SLoGin let table = $tables.find_entire_table::<$name>().map_err(|e| { 290*7eda31b2SLoGin kwarn!( 291*7eda31b2SLoGin "AttrAcpiTable::read(): failed to find table. name: {}, error: {:?}", 292*7eda31b2SLoGin self.name, 293*7eda31b2SLoGin e 294*7eda31b2SLoGin ); 295*7eda31b2SLoGin SystemError::ENODEV 296*7eda31b2SLoGin })?; 297*7eda31b2SLoGin 298*7eda31b2SLoGin copy_data!(table); 299*7eda31b2SLoGin }; 300*7eda31b2SLoGin } 301*7eda31b2SLoGin 302*7eda31b2SLoGin let tables = acpi_manager().tables().unwrap(); 303*7eda31b2SLoGin match self.name.as_str() { 304*7eda31b2SLoGin "RSDT" => { 305*7eda31b2SLoGin handle!(RSDT, tables); 306*7eda31b2SLoGin } 307*7eda31b2SLoGin "XSDT" => { 308*7eda31b2SLoGin handle!(XSDT, tables); 309*7eda31b2SLoGin } 310*7eda31b2SLoGin "FACP" => { 311*7eda31b2SLoGin handle!(FADT, tables); 312*7eda31b2SLoGin } 313*7eda31b2SLoGin "HPET" => { 314*7eda31b2SLoGin handle!(HPET, tables); 315*7eda31b2SLoGin } 316*7eda31b2SLoGin "APIC" => { 317*7eda31b2SLoGin handle!(MADT, tables); 318*7eda31b2SLoGin } 319*7eda31b2SLoGin "MCFG" => { 320*7eda31b2SLoGin handle!(MCFG, tables); 321*7eda31b2SLoGin } 322*7eda31b2SLoGin "SSDT" => { 323*7eda31b2SLoGin handle!(SSDT, tables); 324*7eda31b2SLoGin } 325*7eda31b2SLoGin "BERT" => { 326*7eda31b2SLoGin handle!(BERT, tables); 327*7eda31b2SLoGin } 328*7eda31b2SLoGin "BGRT" => { 329*7eda31b2SLoGin handle!(BGRT, tables); 330*7eda31b2SLoGin } 331*7eda31b2SLoGin "CPEP" => { 332*7eda31b2SLoGin handle!(CPEP, tables); 333*7eda31b2SLoGin } 334*7eda31b2SLoGin "DSDT" => { 335*7eda31b2SLoGin handle!(DSDT, tables); 336*7eda31b2SLoGin } 337*7eda31b2SLoGin "ECDT" => { 338*7eda31b2SLoGin handle!(ECDT, tables); 339*7eda31b2SLoGin } 340*7eda31b2SLoGin "EINJ" => { 341*7eda31b2SLoGin handle!(EINJ, tables); 342*7eda31b2SLoGin } 343*7eda31b2SLoGin "ERST" => { 344*7eda31b2SLoGin handle!(ERST, tables); 345*7eda31b2SLoGin } 346*7eda31b2SLoGin "FACS" => { 347*7eda31b2SLoGin handle!(FACS, tables); 348*7eda31b2SLoGin } 349*7eda31b2SLoGin "FPDT" => { 350*7eda31b2SLoGin handle!(FPDT, tables); 351*7eda31b2SLoGin } 352*7eda31b2SLoGin "GTDT" => { 353*7eda31b2SLoGin handle!(GTDT, tables); 354*7eda31b2SLoGin } 355*7eda31b2SLoGin "HEST" => { 356*7eda31b2SLoGin handle!(HEST, tables); 357*7eda31b2SLoGin } 358*7eda31b2SLoGin "MSCT" => { 359*7eda31b2SLoGin handle!(MSCT, tables); 360*7eda31b2SLoGin } 361*7eda31b2SLoGin "MPST" => { 362*7eda31b2SLoGin handle!(MPST, tables); 363*7eda31b2SLoGin } 364*7eda31b2SLoGin "NFIT" => { 365*7eda31b2SLoGin handle!(NFIT, tables); 366*7eda31b2SLoGin } 367*7eda31b2SLoGin "PCCT" => { 368*7eda31b2SLoGin handle!(PCCT, tables); 369*7eda31b2SLoGin } 370*7eda31b2SLoGin "PHAT" => { 371*7eda31b2SLoGin handle!(PHAT, tables); 372*7eda31b2SLoGin } 373*7eda31b2SLoGin "PMTT" => { 374*7eda31b2SLoGin handle!(PMTT, tables); 375*7eda31b2SLoGin } 376*7eda31b2SLoGin "PSDT" => { 377*7eda31b2SLoGin handle!(PSDT, tables); 378*7eda31b2SLoGin } 379*7eda31b2SLoGin "RASF" => { 380*7eda31b2SLoGin handle!(RASF, tables); 381*7eda31b2SLoGin } 382*7eda31b2SLoGin "SBST" => { 383*7eda31b2SLoGin handle!(SBST, tables); 384*7eda31b2SLoGin } 385*7eda31b2SLoGin "SDEV" => { 386*7eda31b2SLoGin handle!(SDEV, tables); 387*7eda31b2SLoGin } 388*7eda31b2SLoGin "SLIT" => { 389*7eda31b2SLoGin handle!(SLIT, tables); 390*7eda31b2SLoGin } 391*7eda31b2SLoGin "SRAT" => { 392*7eda31b2SLoGin handle!(SRAT, tables); 393*7eda31b2SLoGin } 394*7eda31b2SLoGin "AEST" => { 395*7eda31b2SLoGin handle!(AEST, tables); 396*7eda31b2SLoGin } 397*7eda31b2SLoGin "BDAT" => { 398*7eda31b2SLoGin handle!(BDAT, tables); 399*7eda31b2SLoGin } 400*7eda31b2SLoGin "CDIT" => { 401*7eda31b2SLoGin handle!(CDIT, tables); 402*7eda31b2SLoGin } 403*7eda31b2SLoGin "CEDT" => { 404*7eda31b2SLoGin handle!(CEDT, tables); 405*7eda31b2SLoGin } 406*7eda31b2SLoGin "CRAT" => { 407*7eda31b2SLoGin handle!(CRAT, tables); 408*7eda31b2SLoGin } 409*7eda31b2SLoGin "CSRT" => { 410*7eda31b2SLoGin handle!(CSRT, tables); 411*7eda31b2SLoGin } 412*7eda31b2SLoGin "DBGP" => { 413*7eda31b2SLoGin handle!(DBGP, tables); 414*7eda31b2SLoGin } 415*7eda31b2SLoGin "DBG2" => { 416*7eda31b2SLoGin handle!(DBG2, tables); 417*7eda31b2SLoGin } 418*7eda31b2SLoGin "DMAR" => { 419*7eda31b2SLoGin handle!(DMAR, tables); 420*7eda31b2SLoGin } 421*7eda31b2SLoGin "DRTM" => { 422*7eda31b2SLoGin handle!(DRTM, tables); 423*7eda31b2SLoGin } 424*7eda31b2SLoGin "ETDT" => { 425*7eda31b2SLoGin handle!(ETDT, tables); 426*7eda31b2SLoGin } 427*7eda31b2SLoGin "IBFT" => { 428*7eda31b2SLoGin handle!(IBFT, tables); 429*7eda31b2SLoGin } 430*7eda31b2SLoGin "IORT" => { 431*7eda31b2SLoGin handle!(IORT, tables); 432*7eda31b2SLoGin } 433*7eda31b2SLoGin "IVRS" => { 434*7eda31b2SLoGin handle!(IVRS, tables); 435*7eda31b2SLoGin } 436*7eda31b2SLoGin "LPIT" => { 437*7eda31b2SLoGin handle!(LPIT, tables); 438*7eda31b2SLoGin } 439*7eda31b2SLoGin "MCHI" => { 440*7eda31b2SLoGin handle!(MCHI, tables); 441*7eda31b2SLoGin } 442*7eda31b2SLoGin "MPAM" => { 443*7eda31b2SLoGin handle!(MPAM, tables); 444*7eda31b2SLoGin } 445*7eda31b2SLoGin "MSDM" => { 446*7eda31b2SLoGin handle!(MSDM, tables); 447*7eda31b2SLoGin } 448*7eda31b2SLoGin "PRMT" => { 449*7eda31b2SLoGin handle!(PRMT, tables); 450*7eda31b2SLoGin } 451*7eda31b2SLoGin "RGRT" => { 452*7eda31b2SLoGin handle!(RGRT, tables); 453*7eda31b2SLoGin } 454*7eda31b2SLoGin "SDEI" => { 455*7eda31b2SLoGin handle!(SDEI, tables); 456*7eda31b2SLoGin } 457*7eda31b2SLoGin "SLIC" => { 458*7eda31b2SLoGin handle!(SLIC, tables); 459*7eda31b2SLoGin } 460*7eda31b2SLoGin "SPCR" => { 461*7eda31b2SLoGin handle!(SPCR, tables); 462*7eda31b2SLoGin } 463*7eda31b2SLoGin "SPMI" => { 464*7eda31b2SLoGin handle!(SPMI, tables); 465*7eda31b2SLoGin } 466*7eda31b2SLoGin "STAO" => { 467*7eda31b2SLoGin handle!(STAO, tables); 468*7eda31b2SLoGin } 469*7eda31b2SLoGin "SVKL" => { 470*7eda31b2SLoGin handle!(SVKL, tables); 471*7eda31b2SLoGin } 472*7eda31b2SLoGin "TCPA" => { 473*7eda31b2SLoGin handle!(TCPA, tables); 474*7eda31b2SLoGin } 475*7eda31b2SLoGin "TPM2" => { 476*7eda31b2SLoGin handle!(TPM2, tables); 477*7eda31b2SLoGin } 478*7eda31b2SLoGin "UEFI" => { 479*7eda31b2SLoGin handle!(UEFI, tables); 480*7eda31b2SLoGin } 481*7eda31b2SLoGin "WAET" => { 482*7eda31b2SLoGin handle!(WAET, tables); 483*7eda31b2SLoGin } 484*7eda31b2SLoGin "WDAT" => { 485*7eda31b2SLoGin handle!(WDAT, tables); 486*7eda31b2SLoGin } 487*7eda31b2SLoGin "WDRT" => { 488*7eda31b2SLoGin handle!(WDRT, tables); 489*7eda31b2SLoGin } 490*7eda31b2SLoGin "WPBT" => { 491*7eda31b2SLoGin handle!(WPBT, tables); 492*7eda31b2SLoGin } 493*7eda31b2SLoGin "WSMT" => { 494*7eda31b2SLoGin handle!(WSMT, tables); 495*7eda31b2SLoGin } 496*7eda31b2SLoGin "XENV" => { 497*7eda31b2SLoGin handle!(XENV, tables); 498*7eda31b2SLoGin } 499*7eda31b2SLoGin 500*7eda31b2SLoGin _ => { 501*7eda31b2SLoGin kerror!("AttrAcpiTable::read(): unknown table. name: {}", self.name); 502*7eda31b2SLoGin return Err(SystemError::ENODEV); 503*7eda31b2SLoGin } 504*7eda31b2SLoGin }; 505*7eda31b2SLoGin } 506*7eda31b2SLoGin 507*7eda31b2SLoGin fn size(&self) -> usize { 508*7eda31b2SLoGin return self.size; 509*7eda31b2SLoGin } 510*7eda31b2SLoGin } 511