/*-1* Copyright (c) 2000, 2001 Michael Smith2* Copyright (c) 2000 BSDi3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627/*28* 6.7 : Hardware Abstraction29*/3031#include <sys/cdefs.h>32#include <contrib/dev/acpica/include/acpi.h>3334#include <machine/iodev.h>35#include <machine/pci_cfgreg.h>3637extern int acpi_susp_bounce;3839ACPI_STATUS40AcpiOsEnterSleep(UINT8 SleepState, UINT32 RegaValue, UINT32 RegbValue)41{4243/* If testing device suspend only, back out of everything here. */44if (acpi_susp_bounce)45return (AE_CTRL_TERMINATE);4647return (AE_OK);48}4950/*51* ACPICA's rather gung-ho approach to hardware resource ownership is a little52* troublesome insofar as there is no easy way for us to know in advance53* exactly which I/O resources it's going to want to use.54*55* In order to deal with this, we ignore resource ownership entirely, and simply56* use the native I/O space accessor functionality. This is Evil, but it works.57*/5859ACPI_STATUS60AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)61{6263switch (Width) {64case 8:65*Value = iodev_read_1(InPort);66break;67case 16:68*Value = iodev_read_2(InPort);69break;70case 32:71*Value = iodev_read_4(InPort);72break;73}7475return (AE_OK);76}7778ACPI_STATUS79AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, UINT32 Value, UINT32 Width)80{8182switch (Width) {83case 8:84iodev_write_1(OutPort, Value);85break;86case 16:87iodev_write_2(OutPort, Value);88break;89case 32:90iodev_write_4(OutPort, Value);91break;92}9394return (AE_OK);95}9697ACPI_STATUS98AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 *Value,99UINT32 Width)100{101102#ifdef __aarch64__103/* ARM64TODO: Add pci support */104return (AE_SUPPORT);105#else106if (Width == 64)107return (AE_SUPPORT);108109if (!pci_cfgregopen())110return (AE_NOT_EXIST);111112*(UINT64 *)Value = pci_cfgregread(PciId->Segment, PciId->Bus, PciId->Device,113PciId->Function, Register, Width / 8);114115return (AE_OK);116#endif117}118119ACPI_STATUS120AcpiOsWritePciConfiguration (ACPI_PCI_ID *PciId, UINT32 Register,121UINT64 Value, UINT32 Width)122{123124#ifdef __aarch64__125/* ARM64TODO: Add pci support */126return (AE_SUPPORT);127#else128if (Width == 64)129return (AE_SUPPORT);130131if (!pci_cfgregopen())132return (AE_NOT_EXIST);133134pci_cfgregwrite(PciId->Segment, PciId->Bus, PciId->Device, PciId->Function,135Register, Value, Width / 8);136137return (AE_OK);138#endif139}140141142