2000-10-28 06:56:15 +00:00
|
|
|
/*-
|
2001-07-21 04:10:01 +00:00
|
|
|
* Copyright (c) 2000, 2001 Michael Smith
|
2000-10-28 06:56:15 +00:00
|
|
|
* Copyright (c) 2000 BSDi
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 6.7 : Hardware Abstraction
|
|
|
|
*/
|
|
|
|
|
2005-07-22 23:10:02 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2009-06-05 18:44:36 +00:00
|
|
|
#include <contrib/dev/acpica/include/acpi.h>
|
2000-10-28 06:56:15 +00:00
|
|
|
|
2010-07-16 04:27:38 +00:00
|
|
|
#include <machine/iodev.h>
|
2000-10-28 06:56:15 +00:00
|
|
|
#include <machine/pci_cfgreg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ACPICA's rather gung-ho approach to hardware resource ownership is a little
|
2006-04-04 02:22:38 +00:00
|
|
|
* troublesome insofar as there is no easy way for us to know in advance
|
2000-10-28 06:56:15 +00:00
|
|
|
* exactly which I/O resources it's going to want to use.
|
2006-04-04 02:22:38 +00:00
|
|
|
*
|
2000-10-28 06:56:15 +00:00
|
|
|
* In order to deal with this, we ignore resource ownership entirely, and simply
|
|
|
|
* use the native I/O space accessor functionality. This is Evil, but it works.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2004-04-14 03:39:08 +00:00
|
|
|
AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)
|
2000-10-28 06:56:15 +00:00
|
|
|
{
|
Add a blacklist for bad IO ports that AML should never touch. It seems
some systems were designed so that AML writes to various resources shared
with OS drivers, including the RTC, PIC, PCI, etc. These writes could
collide with writes by the OS and should never be performed. For now, we
print a message if such an access occurs, but do not block it. To block
the access, the tunable "debug.acpi.block_bad_io" can be set to 1. In the
future, we will flip the switch and this will become the default.
Information about this problem was found in Microsoft KB 283649. They
block IO accesses if the BIOS indicates via _OSI that it is Windows 2001
or higher. They always block accesses to the PIC, cascaded PIC, and ELCRs,
no matter how old the BIOS.
2006-03-29 06:41:56 +00:00
|
|
|
|
2001-07-21 04:10:01 +00:00
|
|
|
switch (Width) {
|
|
|
|
case 8:
|
2010-07-16 04:27:38 +00:00
|
|
|
*Value = iodev_read_1(InPort);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
case 16:
|
2010-07-16 04:27:38 +00:00
|
|
|
*Value = iodev_read_2(InPort);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
case 32:
|
2010-07-16 04:27:38 +00:00
|
|
|
*Value = iodev_read_4(InPort);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
}
|
2000-10-28 06:56:15 +00:00
|
|
|
|
2004-04-14 03:39:08 +00:00
|
|
|
return (AE_OK);
|
2000-10-28 06:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2004-04-14 03:39:08 +00:00
|
|
|
AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, UINT32 Value, UINT32 Width)
|
2000-10-28 06:56:15 +00:00
|
|
|
{
|
Add a blacklist for bad IO ports that AML should never touch. It seems
some systems were designed so that AML writes to various resources shared
with OS drivers, including the RTC, PIC, PCI, etc. These writes could
collide with writes by the OS and should never be performed. For now, we
print a message if such an access occurs, but do not block it. To block
the access, the tunable "debug.acpi.block_bad_io" can be set to 1. In the
future, we will flip the switch and this will become the default.
Information about this problem was found in Microsoft KB 283649. They
block IO accesses if the BIOS indicates via _OSI that it is Windows 2001
or higher. They always block accesses to the PIC, cascaded PIC, and ELCRs,
no matter how old the BIOS.
2006-03-29 06:41:56 +00:00
|
|
|
|
2001-07-21 04:10:01 +00:00
|
|
|
switch (Width) {
|
|
|
|
case 8:
|
2010-07-16 04:27:38 +00:00
|
|
|
iodev_write_1(OutPort, Value);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
case 16:
|
2010-07-16 04:27:38 +00:00
|
|
|
iodev_write_2(OutPort, Value);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
case 32:
|
2010-07-16 04:27:38 +00:00
|
|
|
iodev_write_4(OutPort, Value);
|
2010-07-13 02:48:42 +00:00
|
|
|
break;
|
2001-07-21 04:10:01 +00:00
|
|
|
}
|
2000-10-28 06:56:15 +00:00
|
|
|
|
2004-04-14 03:39:08 +00:00
|
|
|
return (AE_OK);
|
2000-10-28 06:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2010-08-06 23:11:19 +00:00
|
|
|
AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 *Value,
|
2004-04-14 03:39:08 +00:00
|
|
|
UINT32 Width)
|
2000-10-28 06:56:15 +00:00
|
|
|
{
|
2010-07-15 19:52:54 +00:00
|
|
|
|
|
|
|
if (Width == 64)
|
|
|
|
return (AE_SUPPORT);
|
2000-10-28 06:56:15 +00:00
|
|
|
|
|
|
|
if (!pci_cfgregopen())
|
2010-07-13 02:48:42 +00:00
|
|
|
return (AE_NOT_EXIST);
|
2001-07-21 04:10:01 +00:00
|
|
|
|
2010-07-15 19:52:54 +00:00
|
|
|
*(UINT64 *)Value = pci_cfgregread(PciId->Bus, PciId->Device,
|
|
|
|
PciId->Function, Register, Width / 8);
|
2006-04-04 02:22:38 +00:00
|
|
|
|
2004-04-14 03:39:08 +00:00
|
|
|
return (AE_OK);
|
2000-10-28 06:56:15 +00:00
|
|
|
}
|
|
|
|
|
2001-07-21 04:10:01 +00:00
|
|
|
|
2000-10-28 06:56:15 +00:00
|
|
|
ACPI_STATUS
|
2004-04-14 03:39:08 +00:00
|
|
|
AcpiOsWritePciConfiguration (ACPI_PCI_ID *PciId, UINT32 Register,
|
2010-01-21 21:14:28 +00:00
|
|
|
UINT64 Value, UINT32 Width)
|
2000-10-28 06:56:15 +00:00
|
|
|
{
|
2010-07-15 19:52:54 +00:00
|
|
|
|
|
|
|
if (Width == 64)
|
|
|
|
return (AE_SUPPORT);
|
2001-07-21 04:10:01 +00:00
|
|
|
|
2000-10-28 06:56:15 +00:00
|
|
|
if (!pci_cfgregopen())
|
2004-04-14 03:39:08 +00:00
|
|
|
return (AE_NOT_EXIST);
|
2001-07-21 04:10:01 +00:00
|
|
|
|
2004-04-14 03:39:08 +00:00
|
|
|
pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register,
|
2010-07-15 19:52:54 +00:00
|
|
|
Value, Width / 8);
|
2001-07-21 04:10:01 +00:00
|
|
|
|
2004-04-14 03:39:08 +00:00
|
|
|
return (AE_OK);
|
2000-10-28 06:56:15 +00:00
|
|
|
}
|