use core::time::Duration;

use crate::AcpiHandlerImpl;

impl aml::Handler for AcpiHandlerImpl {
    fn read_io_u8(&self, port: u16) -> u8 {
        <Self as acpi_system::Handler>::io_read_u8(port)
    }

    fn read_io_u16(&self, port: u16) -> u16 {
        <Self as acpi_system::Handler>::io_read_u16(port)
    }

    fn read_io_u32(&self, port: u16) -> u32 {
        <Self as acpi_system::Handler>::io_read_u32(port)
    }

    fn write_io_u8(&self, port: u16, value: u8) {
        <Self as acpi_system::Handler>::io_write_u8(port, value)
    }

    fn write_io_u16(&self, port: u16, value: u16) {
        <Self as acpi_system::Handler>::io_write_u16(port, value)
    }

    fn write_io_u32(&self, port: u16, value: u32) {
        <Self as acpi_system::Handler>::io_write_u32(port, value)
    }

    fn read_u8(&self, address: usize) -> u8 {
        <Self as acpi_system::Handler>::mem_read_u8(address as u64)
    }

    fn read_u16(&self, address: usize) -> u16 {
        <Self as acpi_system::Handler>::mem_read_u16(address as u64)
    }

    fn read_u32(&self, address: usize) -> u32 {
        <Self as acpi_system::Handler>::mem_read_u32(address as u64)
    }

    fn read_u64(&self, address: usize) -> u64 {
        <Self as acpi_system::Handler>::mem_read_u64(address as u64)
    }

    fn write_u8(&self, address: usize, value: u8) {
        <Self as acpi_system::Handler>::mem_write_u8(address as u64, value)
    }

    fn write_u16(&self, address: usize, value: u16) {
        <Self as acpi_system::Handler>::mem_write_u16(address as u64, value)
    }

    fn write_u32(&self, address: usize, value: u32) {
        <Self as acpi_system::Handler>::mem_write_u32(address as u64, value)
    }

    fn write_u64(&self, address: usize, value: u64) {
        <Self as acpi_system::Handler>::mem_write_u64(address as u64, value)
    }

    fn read_pci_u8(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16) -> u8 {
        0xFF
    }

    fn read_pci_u16(
        &self,
        _segment: u16,
        _bus: u8,
        _device: u8,
        _function: u8,
        _offset: u16,
    ) -> u16 {
        0xFFFF
    }

    fn read_pci_u32(
        &self,
        _segment: u16,
        _bus: u8,
        _device: u8,
        _function: u8,
        _offset: u16,
    ) -> u32 {
        0xFFFFFFFF
    }

    fn write_pci_u8(
        &self,
        _segment: u16,
        _bus: u8,
        _device: u8,
        _function: u8,
        _offset: u16,
        _value: u8,
    ) {
    }

    fn write_pci_u16(
        &self,
        _segment: u16,
        _bus: u8,
        _device: u8,
        _function: u8,
        _offset: u16,
        _value: u16,
    ) {
    }

    fn write_pci_u32(
        &self,
        _segment: u16,
        _bus: u8,
        _device: u8,
        _function: u8,
        _offset: u16,
        _value: u32,
    ) {
    }

    fn read_ec_u8(&self, _address: u64) -> u8 {
        0x00
    }

    fn write_ec_u8(&self, _address: u64, _value: u8) {}

    fn sleep(&self, _duration: Duration) {
        todo!()
        // util::polling_sleep(duration).unwrap();
    }
}
