summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi_support/acpi_aiboost.c4
-rw-r--r--sys/dev/acpi_support/acpi_asus.c4
-rw-r--r--sys/dev/acpi_support/acpi_fujitsu.c4
-rw-r--r--sys/dev/acpi_support/acpi_ibm.c5
-rw-r--r--sys/dev/acpi_support/acpi_panasonic.c3
-rw-r--r--sys/dev/acpi_support/acpi_sony.c4
-rw-r--r--sys/dev/acpi_support/acpi_toshiba.c3
-rw-r--r--sys/dev/acpica/Osd/OsdDebug.c6
-rw-r--r--sys/dev/acpica/Osd/OsdHardware.c78
-rw-r--r--sys/dev/acpica/Osd/OsdInterrupt.c4
-rw-r--r--sys/dev/acpica/Osd/OsdMemory.c15
-rw-r--r--sys/dev/acpica/Osd/OsdSchedule.c4
-rw-r--r--sys/dev/acpica/Osd/OsdStream.c2
-rw-r--r--sys/dev/acpica/Osd/OsdSynch.c5
-rw-r--r--sys/dev/acpica/Osd/OsdTable.c25
-rw-r--r--sys/dev/acpica/acpi.c22
-rw-r--r--sys/dev/acpica/acpi_acad.c3
-rw-r--r--sys/dev/acpica/acpi_battery.c3
-rw-r--r--sys/dev/acpica/acpi_button.c4
-rw-r--r--sys/dev/acpica/acpi_cmbat.c3
-rw-r--r--sys/dev/acpica/acpi_cpu.c26
-rw-r--r--sys/dev/acpica/acpi_dock.c5
-rw-r--r--sys/dev/acpica/acpi_ec.c4
-rw-r--r--sys/dev/acpica/acpi_hpet.c4
-rw-r--r--sys/dev/acpica/acpi_if.m3
-rw-r--r--sys/dev/acpica/acpi_isab.c4
-rw-r--r--sys/dev/acpica/acpi_lid.c4
-rw-r--r--sys/dev/acpica/acpi_package.c3
-rw-r--r--sys/dev/acpica/acpi_pci.c4
-rw-r--r--sys/dev/acpica/acpi_pci_link.c3
-rw-r--r--sys/dev/acpica/acpi_pcib.c4
-rw-r--r--sys/dev/acpica/acpi_pcib_acpi.c4
-rw-r--r--sys/dev/acpica/acpi_pcib_pci.c4
-rw-r--r--sys/dev/acpica/acpi_perf.c3
-rw-r--r--sys/dev/acpica/acpi_powerres.c4
-rw-r--r--sys/dev/acpica/acpi_quirk.c3
-rw-r--r--sys/dev/acpica/acpi_resource.c4
-rw-r--r--sys/dev/acpica/acpi_smbat.c3
-rw-r--r--sys/dev/acpica/acpi_thermal.c4
-rw-r--r--sys/dev/acpica/acpi_throttle.c3
-rw-r--r--sys/dev/acpica/acpi_timer.c4
-rw-r--r--sys/dev/acpica/acpi_video.c3
-rw-r--r--sys/dev/asmc/asmc.c4
-rw-r--r--sys/dev/fdc/fdc_acpi.c3
-rw-r--r--sys/dev/ipmi/ipmi_acpi.c3
-rw-r--r--sys/dev/kbd/kbd.c74
-rw-r--r--sys/dev/kbdmux/kbdmux.c64
-rw-r--r--sys/dev/pci/pci.c2
-rw-r--r--sys/dev/sound/usb/uaudio.c4
-rw-r--r--sys/dev/usb/input/ukbd.c1
50 files changed, 264 insertions, 195 deletions
diff --git a/sys/dev/acpi_support/acpi_aiboost.c b/sys/dev/acpi_support/acpi_aiboost.c
index 8fff872..00bf9cb 100644
--- a/sys/dev/acpi_support/acpi_aiboost.c
+++ b/sys/dev/acpi_support/acpi_aiboost.c
@@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include "acpi_if.h"
#include <sys/module.h>
#include <dev/acpica/acpivar.h>
diff --git a/sys/dev/acpi_support/acpi_asus.c b/sys/dev/acpi_support/acpi_asus.c
index 51ca6fa..28f9e7c 100644
--- a/sys/dev/acpi_support/acpi_asus.c
+++ b/sys/dev/acpi_support/acpi_asus.c
@@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/sbuf.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/led/led.h>
diff --git a/sys/dev/acpi_support/acpi_fujitsu.c b/sys/dev/acpi_support/acpi_fujitsu.c
index 6628135..5de365a 100644
--- a/sys/dev/acpi_support/acpi_fujitsu.c
+++ b/sys/dev/acpi_support/acpi_fujitsu.c
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/sysctl.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c
index 0bf340d..ca67716 100644
--- a/sys/dev/acpi_support/acpi_ibm.c
+++ b/sys/dev/acpi_support/acpi_ibm.c
@@ -42,10 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/bus.h>
#include <machine/cpufunc.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include "acpi_if.h"
#include <sys/module.h>
#include <dev/acpica/acpivar.h>
diff --git a/sys/dev/acpi_support/acpi_panasonic.c b/sys/dev/acpi_support/acpi_panasonic.c
index 595ca08..f922233 100644
--- a/sys/dev/acpi_support/acpi_panasonic.c
+++ b/sys/dev/acpi_support/acpi_panasonic.c
@@ -37,8 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/power.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#define _COMPONENT ACPI_OEM
diff --git a/sys/dev/acpi_support/acpi_sony.c b/sys/dev/acpi_support/acpi_sony.c
index 905461d..88195c2 100644
--- a/sys/dev/acpi_support/acpi_sony.c
+++ b/sys/dev/acpi_support/acpi_sony.c
@@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include "acpi_if.h"
#include <sys/module.h>
#include <dev/acpica/acpivar.h>
diff --git a/sys/dev/acpi_support/acpi_toshiba.c b/sys/dev/acpi_support/acpi_toshiba.c
index 343d3ae..d15fe7e 100644
--- a/sys/dev/acpi_support/acpi_toshiba.c
+++ b/sys/dev/acpi_support/acpi_toshiba.c
@@ -34,8 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#define _COMPONENT ACPI_OEM
diff --git a/sys/dev/acpica/Osd/OsdDebug.c b/sys/dev/acpica/Osd/OsdDebug.c
index 8425357..27b94a0 100644
--- a/sys/dev/acpica/Osd/OsdDebug.c
+++ b/sys/dev/acpica/Osd/OsdDebug.c
@@ -41,10 +41,8 @@ __FBSDID("$FreeBSD$");
#include <ddb/ddb.h>
#include <ddb/db_output.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acdebug.h>
-
+#include <contrib/dev/acpica/acpi.h>
+#include <contrib/dev/acpica/acdebug.h>
#include <dev/acpica/acpivar.h>
UINT32
diff --git a/sys/dev/acpica/Osd/OsdHardware.c b/sys/dev/acpica/Osd/OsdHardware.c
index cf3cdd7..6e3beea 100644
--- a/sys/dev/acpica/Osd/OsdHardware.c
+++ b/sys/dev/acpica/Osd/OsdHardware.c
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/acpi.h>
#include <sys/bus.h>
#include <sys/kernel.h>
@@ -65,9 +65,75 @@ __FBSDID("$FreeBSD$");
#define ACPI_BUS_HANDLE 0
#endif
+/*
+ * Some BIOS vendors use AML to read/write directly to IO space. This
+ * can cause a problem if such accesses interfere with the OS's access to
+ * the same ports. Windows XP and newer systems block accesses to certain
+ * IO ports. We print a message or block accesses based on a tunable.
+ */
+static int illegal_bios_ports[] = {
+ 0x000, 0x00f, /* DMA controller 1 */
+ 0x020, 0x021, /* PIC */
+ 0x040, 0x043, /* Timer 1 */
+ 0x048, 0x04b, /* Timer 2 failsafe */
+ 0x070, 0x071, /* CMOS and RTC */
+ 0x074, 0x076, /* Extended CMOS */
+ 0x081, 0x083, /* DMA1 page registers */
+ 0x087, 0x087, /* DMA1 ch0 low page */
+ 0x089, 0x08b, /* DMA2 ch2 (0x89), ch3 low page (0x8a, 0x8b) */
+ 0x08f, 0x091, /* DMA2 low page refresh (0x8f) */
+ /* Arb ctrl port, card select feedback (0x90, 0x91) */
+ 0x093, 0x094, /* System board setup */
+ 0x096, 0x097, /* POS channel select */
+ 0x0a0, 0x0a1, /* PIC (cascaded) */
+ 0x0c0, 0x0df, /* ISA DMA */
+ 0x4d0, 0x4d1, /* PIC ELCR (edge/level control) */
+ 0xcf8, 0xcff, /* PCI config space. Microsoft adds 0xd00 also but
+ that seems incorrect. */
+ -1, -1
+};
+
+/* Block accesses to bad IO port addresses or just print a warning. */
+static int block_bad_io;
+TUNABLE_INT("debug.acpi.block_bad_io", &block_bad_io);
+
+/*
+ * Look up bad ports in our table. Returns 0 if ok, 1 if marked bad but
+ * access is still allowed, or -1 to deny access.
+ */
+static int
+acpi_os_check_port(UINT32 addr, UINT32 width)
+{
+ int error, *port;
+
+ error = 0;
+ for (port = illegal_bios_ports; *port != -1; port += 2) {
+ if ((addr >= port[0] && addr <= port[1]) ||
+ (addr < port[0] && addr + (width / 8) > port[0])) {
+ if (block_bad_io)
+ error = -1;
+ else
+ error = 1;
+ break;
+ }
+ }
+
+ return (error);
+}
+
ACPI_STATUS
AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)
{
+ int error;
+
+ error = acpi_os_check_port(InPort, Width);
+ if (error != 0) {
+ if (bootverbose)
+ printf("acpi: bad read from port 0x%03x (%d)\n",
+ (int)InPort, Width);
+ if (error == -1)
+ return (AE_BAD_PARAMETER);
+ }
switch (Width) {
case 8:
@@ -93,6 +159,16 @@ AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)
ACPI_STATUS
AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, UINT32 Value, UINT32 Width)
{
+ int error;
+
+ error = acpi_os_check_port(OutPort, Width);
+ if (error != 0) {
+ if (bootverbose)
+ printf("acpi: bad write to port 0x%03x (%d), val %#x\n",
+ (int)OutPort, Width, Value);
+ if (error == -1)
+ return (AE_BAD_PARAMETER);
+ }
switch (Width) {
case 8:
diff --git a/sys/dev/acpica/Osd/OsdInterrupt.c b/sys/dev/acpica/Osd/OsdInterrupt.c
index 158a2b9..c973124 100644
--- a/sys/dev/acpica/Osd/OsdInterrupt.c
+++ b/sys/dev/acpica/Osd/OsdInterrupt.c
@@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#define _COMPONENT ACPI_OS_SERVICES
diff --git a/sys/dev/acpica/Osd/OsdMemory.c b/sys/dev/acpica/Osd/OsdMemory.c
index 8ed7a90..3804bb6 100644
--- a/sys/dev/acpica/Osd/OsdMemory.c
+++ b/sys/dev/acpica/Osd/OsdMemory.c
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/acpi.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -55,7 +55,7 @@ AcpiOsFree(void *Memory)
}
void *
-AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length)
+AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_NATIVE_UINT Length)
{
return (pmap_mapbios((vm_offset_t)PhysicalAddress, Length));
}
@@ -80,6 +80,17 @@ AcpiOsValidateInterface (char *Interface)
return (AE_SUPPORT);
}
+/*
+ * There is no clean way to do this. We make the charitable assumption
+ * that callers will not pass garbage to us.
+ */
+ACPI_STATUS
+AcpiOsValidateAddress (UINT8 SpaceId, ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_SIZE Length)
+{
+ return (AE_OK);
+}
+
BOOLEAN
AcpiOsReadable (void *Pointer, ACPI_SIZE Length)
{
diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c
index fa91ed8..795de93 100644
--- a/sys/dev/acpica/Osd/OsdSchedule.c
+++ b/sys/dev/acpica/Osd/OsdSchedule.c
@@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/taskqueue.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#define _COMPONENT ACPI_OS_SERVICES
diff --git a/sys/dev/acpica/Osd/OsdStream.c b/sys/dev/acpica/Osd/OsdStream.c
index 81181db..8d1291a 100644
--- a/sys/dev/acpica/Osd/OsdStream.c
+++ b/sys/dev/acpica/Osd/OsdStream.c
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/acpi.h>
void
AcpiOsPrintf(const char *Format, ...)
diff --git a/sys/dev/acpica/Osd/OsdSynch.c b/sys/dev/acpica/Osd/OsdSynch.c
index 68fdcaa..b15b1ea 100644
--- a/sys/dev/acpica/Osd/OsdSynch.c
+++ b/sys/dev/acpica/Osd/OsdSynch.c
@@ -32,8 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/acpi.h>
#include "opt_acpi.h"
#include <sys/kernel.h>
@@ -368,7 +367,7 @@ AcpiOsDeleteLock (ACPI_SPINLOCK Handle)
* (and thus can't block) but since we have ithreads, we don't worry
* about potentially blocking.
*/
-ACPI_CPU_FLAGS
+ACPI_NATIVE_UINT
AcpiOsAcquireLock (ACPI_SPINLOCK Handle)
{
struct acpi_spinlock *h = (struct acpi_spinlock *)Handle;
diff --git a/sys/dev/acpica/Osd/OsdTable.c b/sys/dev/acpica/Osd/OsdTable.c
index 55f674d..d9b29eb 100644
--- a/sys/dev/acpica/Osd/OsdTable.c
+++ b/sys/dev/acpica/Osd/OsdTable.c
@@ -36,8 +36,8 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/linker.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/actables.h>
+#include <contrib/dev/acpica/acpi.h>
+#include <contrib/dev/acpica/actables.h>
#undef _COMPONENT
#define _COMPONENT ACPI_TABLES
@@ -67,30 +67,17 @@ ACPI_STATUS
AcpiOsTableOverride(ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable)
{
- char modname[] = "acpi_dsdt";
- caddr_t acpi_table, p, s;
+ caddr_t acpi_dsdt, p;
if (ExistingTable == NULL || NewTable == NULL)
return (AE_BAD_PARAMETER);
-#ifdef notyet
- for (int i = 0; i < ACPI_NAME_SIZE; i++)
- modname[i + 5] = tolower(ExistingTable->Signature[i]);
-#else
/* If we're not overriding the DSDT, just return. */
- if (strncmp(ExistingTable->Signature, ACPI_SIG_DSDT, ACPI_NAME_SIZE) != 0) {
+ if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) == NULL ||
+ (p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) == NULL) {
*NewTable = NULL;
- return (AE_OK);
- }
-#endif
-
- if ((acpi_table = preload_search_by_type(modname)) != NULL &&
- (p = preload_search_info(acpi_table, MODINFO_ADDR)) != NULL &&
- (s = preload_search_info(acpi_table, MODINFO_SIZE)) != NULL &&
- *(size_t *)s != 0)
+ } else
*NewTable = *(ACPI_TABLE_HEADER **)p;
- else
- *NewTable = NULL;
return (AE_OK);
}
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 63f95d3..4bc059b 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -61,12 +61,11 @@ __FBSDID("$FreeBSD$");
#include <isa/isavar.h>
#include <isa/pnpvar.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
+#include <contrib/dev/acpica/achware.h>
+#include <contrib/dev/acpica/acnamesp.h>
#include "pci_if.h"
#include <dev/pci/pcivar.h>
@@ -417,6 +416,7 @@ static int
acpi_attach(device_t dev)
{
struct acpi_softc *sc;
+ ACPI_TABLE_FACS *facs;
ACPI_STATUS status;
int error, state;
UINT32 flags;
@@ -593,7 +593,14 @@ acpi_attach(device_t dev)
}
/* Only enable S4BIOS by default if the FACS says it is available. */
- if (AcpiGbl_FACS->Flags & ACPI_FACS_S4_BIOS_PRESENT)
+ status = AcpiGetTable(ACPI_SIG_FACS, 0, (ACPI_TABLE_HEADER **)&facs);
+ if (ACPI_FAILURE(status)) {
+ device_printf(dev, "couldn't get FACS: %s\n",
+ AcpiFormatException(status));
+ error = ENXIO;
+ goto out;
+ }
+ if (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT)
sc->acpi_s4bios = 1;
/* Probe all supported sleep states. */
@@ -1841,7 +1848,8 @@ acpi_shutdown_final(void *arg, int howto)
(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) &&
sc->acpi_handle_reboot) {
/* Reboot using the reset register. */
- status = AcpiWrite(
+ status = AcpiHwLowLevelWrite(
+ AcpiGbl_FADT.ResetRegister.BitWidth,
AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister);
if (ACPI_FAILURE(status))
device_printf(sc->acpi_dev, "reset failed - %s\n",
@@ -3383,6 +3391,8 @@ static struct debugtag dbg_layer[] = {
};
static struct debugtag dbg_level[] = {
+ {"ACPI_LV_ERROR", ACPI_LV_ERROR},
+ {"ACPI_LV_WARN", ACPI_LV_WARN},
{"ACPI_LV_INIT", ACPI_LV_INIT},
{"ACPI_LV_DEBUG_OBJECT", ACPI_LV_DEBUG_OBJECT},
{"ACPI_LV_INFO", ACPI_LV_INFO},
diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c
index 638c09b..0ea69e8 100644
--- a/sys/dev/acpica/acpi_acad.c
+++ b/sys/dev/acpica/acpi_acad.c
@@ -40,8 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/power.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
#include <isa/isavar.h>
diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c
index dd2b3fa..2e8c7a4 100644
--- a/sys/dev/acpica/acpi_battery.c
+++ b/sys/dev/acpica/acpi_battery.c
@@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ioccom.h>
#include <sys/sysctl.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c
index 7814c0e..197af4f 100644
--- a/sys/dev/acpica/acpi_button.c
+++ b/sys/dev/acpica/acpi_button.c
@@ -35,9 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c
index dde3ad5..24ab5f8 100644
--- a/sys/dev/acpica/acpi_cmbat.c
+++ b/sys/dev/acpica/acpi_cmbat.c
@@ -41,8 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <sys/malloc.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 5d8ad53..a65faee 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/*
@@ -899,9 +897,9 @@ acpi_cpu_idle()
* time if USB is loaded.
*/
if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
- AcpiReadBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active);
+ AcpiGetRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active);
if (bm_active != 0) {
- AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1);
+ AcpiSetRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1);
cx_next_idx = min(cx_next_idx, sc->cpu_non_c3);
}
}
@@ -928,8 +926,8 @@ acpi_cpu_idle()
*/
if (cx_next->type == ACPI_STATE_C3) {
if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
- AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1);
- AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
+ AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 1);
+ AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
} else
ACPI_FLUSH_CPU_CACHE();
}
@@ -940,7 +938,7 @@ acpi_cpu_idle()
* get the time very close to the CPU start/stop clock logic, this
* is the only reliable time source.
*/
- AcpiRead(&start_time, &AcpiGbl_FADT.XPmTimerBlock);
+ AcpiHwLowLevelRead(32, &start_time, &AcpiGbl_FADT.XPmTimerBlock);
CPU_GET_REG(cx_next->p_lvlx, 1);
/*
@@ -949,14 +947,14 @@ acpi_cpu_idle()
* the processor has stopped. Doing it again provides enough
* margin that we are certain to have a correct value.
*/
- AcpiRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
- AcpiRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
+ AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
+ AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
/* Enable bus master arbitration and disable bus master wakeup. */
if (cx_next->type == ACPI_STATE_C3 &&
(cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
- AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0);
- AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
+ AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 0);
+ AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
}
ACPI_ENABLE_IRQS();
@@ -1071,11 +1069,11 @@ acpi_cpu_quirks(void)
val |= PIIX4_STOP_BREAK_MASK;
pci_write_config(acpi_dev, PIIX4_DEVACTB_REG, val, 4);
}
- AcpiReadBitRegister(ACPI_BITREG_BUS_MASTER_RLD, &val);
+ AcpiGetRegister(ACPI_BITREG_BUS_MASTER_RLD, &val);
if (val) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"acpi_cpu: PIIX4: reset BRLD_EN_BM\n"));
- AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
+ AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
}
break;
default:
diff --git a/sys/dev/acpica/acpi_dock.c b/sys/dev/acpica/acpi_dock.c
index b7d2e3e..fc59b53 100644
--- a/sys/dev/acpica/acpi_dock.c
+++ b/sys/dev/acpica/acpi_dock.c
@@ -32,9 +32,8 @@
#include <sys/kernel.h>
#include <sys/module.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
+#include <contrib/dev/acpica/acnamesp.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c
index a5a81dc..696542c 100644
--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c
index a418695..17022bb 100644
--- a/sys/dev/acpica/acpi_hpet.c
+++ b/sys/dev/acpica/acpi_hpet.c
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/timetc.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpi_hpet.h>
diff --git a/sys/dev/acpica/acpi_if.m b/sys/dev/acpica/acpi_if.m
index 4d90109..2ae19f4 100644
--- a/sys/dev/acpica/acpi_if.m
+++ b/sys/dev/acpica/acpi_if.m
@@ -28,8 +28,7 @@
#include <sys/bus.h>
#include <sys/types.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/acpi.h>
INTERFACE acpi;
diff --git a/sys/dev/acpica/acpi_isab.c b/sys/dev/acpica/acpi_isab.c
index 0da0182..382d1c6 100644
--- a/sys/dev/acpica/acpi_isab.c
+++ b/sys/dev/acpica/acpi_isab.c
@@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/module.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <isa/isavar.h>
diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c
index 47d5b45..0bb4a9f 100644
--- a/sys/dev/acpica/acpi_lid.c
+++ b/sys/dev/acpica/acpi_lid.c
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/proc.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpica/acpi_package.c b/sys/dev/acpica/acpi_package.c
index 55eaf93..d7be257 100644
--- a/sys/dev/acpica/acpi_package.c
+++ b/sys/dev/acpica/acpi_package.c
@@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/*
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index 7c1bd86..607691c 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/module.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <sys/pciio.h>
diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c
index dcf101d..b39e8e2 100644
--- a/sys/dev/acpica/acpi_pci_link.c
+++ b/sys/dev/acpica/acpi_pci_link.c
@@ -35,8 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/module.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpi_pcibvar.h>
diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c
index cc9bcbe..96c9253 100644
--- a/sys/dev/acpica/acpi_pcib.c
+++ b/sys/dev/acpica/acpi_pcib.c
@@ -34,9 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/kernel.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpi_pcibvar.h>
diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c
index d9827ab..495ae20 100644
--- a/sys/dev/acpica/acpi_pcib_acpi.c
+++ b/sys/dev/acpica/acpi_pcib_acpi.c
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/sysctl.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <machine/pci_cfgreg.h>
diff --git a/sys/dev/acpica/acpi_pcib_pci.c b/sys/dev/acpica/acpi_pcib_pci.c
index 0da89c4..f0f2d76 100644
--- a/sys/dev/acpica/acpi_pcib_pci.c
+++ b/sys/dev/acpica/acpi_pcib_pci.c
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/module.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpi_pcibvar.h>
diff --git a/sys/dev/acpica/acpi_perf.c b/sys/dev/acpica/acpi_perf.c
index 31b1c63..e517ad3 100644
--- a/sys/dev/acpica/acpi_perf.c
+++ b/sys/dev/acpica/acpi_perf.c
@@ -44,8 +44,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include "cpufreq_if.h"
diff --git a/sys/dev/acpica/acpi_powerres.c b/sys/dev/acpica/acpi_powerres.c
index 0988871..3a64e3a 100644
--- a/sys/dev/acpica/acpi_powerres.c
+++ b/sys/dev/acpica/acpi_powerres.c
@@ -33,9 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/*
diff --git a/sys/dev/acpica/acpi_quirk.c b/sys/dev/acpica/acpi_quirk.c
index fe0a06f..b75a527 100644
--- a/sys/dev/acpica/acpi_quirk.c
+++ b/sys/dev/acpica/acpi_quirk.c
@@ -30,8 +30,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
enum ops_t {
diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c
index d9132b0..2a81e54 100644
--- a/sys/dev/acpica/acpi_resource.c
+++ b/sys/dev/acpica/acpi_resource.c
@@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpica/acpi_smbat.c b/sys/dev/acpica/acpi_smbat.c
index 145e240..3935a9f 100644
--- a/sys/dev/acpica/acpi_smbat.c
+++ b/sys/dev/acpica/acpi_smbat.c
@@ -33,8 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
#include <dev/acpica/acpi_smbus.h>
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index 962fdb7..08cd15b 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$");
#include "cpufreq_if.h"
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/acpica/acpi_throttle.c b/sys/dev/acpica/acpi_throttle.c
index 40476e0..d79d7ae 100644
--- a/sys/dev/acpica/acpi_throttle.c
+++ b/sys/dev/acpica/acpi_throttle.c
@@ -39,8 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/pci/pcivar.h>
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index cfbeea4..73bd5ed 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -40,9 +40,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/pci/pcivar.h>
diff --git a/sys/dev/acpica/acpi_video.c b/sys/dev/acpica/acpi_video.c
index c095a40..b9fccfc 100644
--- a/sys/dev/acpica/acpi_video.c
+++ b/sys/dev/acpica/acpi_video.c
@@ -38,8 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/queue.h>
#include <sys/sysctl.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* ACPI video extension driver. */
diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index d4e835d..a2722c0 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <machine/resource.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/asmc/asmcvar.h>
diff --git a/sys/dev/fdc/fdc_acpi.c b/sys/dev/fdc/fdc_acpi.c
index 79fa66b..c3cb9b9 100644
--- a/sys/dev/fdc/fdc_acpi.c
+++ b/sys/dev/fdc/fdc_acpi.c
@@ -35,8 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/proc.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
#include <dev/fdc/fdcvar.h>
diff --git a/sys/dev/ipmi/ipmi_acpi.c b/sys/dev/ipmi/ipmi_acpi.c
index 4281002..1bd3a64 100644
--- a/sys/dev/ipmi/ipmi_acpi.c
+++ b/sys/dev/ipmi/ipmi_acpi.c
@@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <sys/selinfo.h>
-#include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/acpi.h>
#include <dev/acpica/acpivar.h>
/* Hooks for the ACPI CA debugging infrastructure */
diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c
index 753269a..851f677 100644
--- a/sys/dev/kbd/kbd.c
+++ b/sys/dev/kbd/kbd.c
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
-#include <sys/clist.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/poll.h>
@@ -50,11 +49,16 @@ __FBSDID("$FreeBSD$");
#define KBD_INDEX(dev) dev2unit(dev)
+#define KB_QSIZE 512
+#define KB_BUFSIZE 64
+
typedef struct genkbd_softc {
int gkb_flags; /* flag/status bits */
#define KB_ASLEEP (1 << 0)
- struct clist gkb_q; /* input queue */
struct selinfo gkb_rsel;
+ char gkb_q[KB_QSIZE]; /* input queue */
+ unsigned int gkb_q_start;
+ unsigned int gkb_q_length;
} genkbd_softc_t;
static SLIST_HEAD(, keyboard_driver) keyboard_drivers =
@@ -521,8 +525,38 @@ kbd_detach(keyboard_t *kbd)
* driver functions.
*/
-#define KB_QSIZE 512
-#define KB_BUFSIZE 64
+static void
+genkbd_putc(genkbd_softc_t *sc, char c)
+{
+ unsigned int p;
+
+ if (sc->gkb_q_length == KB_QSIZE)
+ return;
+
+ p = (sc->gkb_q_start + sc->gkb_q_length) % KB_QSIZE;
+ sc->gkb_q[p] = c;
+ sc->gkb_q_length++;
+}
+
+static size_t
+genkbd_getc(genkbd_softc_t *sc, char *buf, size_t len)
+{
+
+ /* Determine copy size. */
+ if (sc->gkb_q_length == 0)
+ return (0);
+ if (len >= sc->gkb_q_length)
+ len = sc->gkb_q_length;
+ if (len >= KB_QSIZE - sc->gkb_q_start)
+ len = KB_QSIZE - sc->gkb_q_start;
+
+ /* Copy out data and progress offset. */
+ memcpy(buf, sc->gkb_q + sc->gkb_q_start, len);
+ sc->gkb_q_start = (sc->gkb_q_start + len) % KB_QSIZE;
+ sc->gkb_q_length -= len;
+
+ return (len);
+}
static kbd_callback_func_t genkbd_event;
@@ -555,10 +589,7 @@ genkbdopen(struct cdev *dev, int mode, int flag, struct thread *td)
* the device may still be missing (!KBD_HAS_DEVICE(kbd)).
*/
-#if 0
- bzero(&sc->gkb_q, sizeof(sc->gkb_q));
-#endif
- clist_alloc_cblocks(&sc->gkb_q, KB_QSIZE, KB_QSIZE/2); /* XXX */
+ sc->gkb_q_length = 0;
splx(s);
return (0);
@@ -582,9 +613,6 @@ genkbdclose(struct cdev *dev, int mode, int flag, struct thread *td)
/* XXX: we shall be forgiving and don't report error... */
} else {
kbd_release(kbd, (void *)sc);
-#if 0
- clist_free_cblocks(&sc->gkb_q);
-#endif
}
splx(s);
return (0);
@@ -608,7 +636,7 @@ genkbdread(struct cdev *dev, struct uio *uio, int flag)
splx(s);
return (ENXIO);
}
- while (sc->gkb_q.c_cc == 0) {
+ while (sc->gkb_q_length == 0) {
if (flag & O_NONBLOCK) {
splx(s);
return (EWOULDBLOCK);
@@ -632,7 +660,7 @@ genkbdread(struct cdev *dev, struct uio *uio, int flag)
error = 0;
while (uio->uio_resid > 0) {
len = imin(uio->uio_resid, sizeof(buffer));
- len = q_to_b(&sc->gkb_q, buffer, len);
+ len = genkbd_getc(sc, buffer, len);
if (len <= 0)
break;
error = uiomove(buffer, len, uio);
@@ -684,7 +712,7 @@ genkbdpoll(struct cdev *dev, int events, struct thread *td)
if ((sc == NULL) || (kbd == NULL) || !KBD_IS_VALID(kbd)) {
revents = POLLHUP; /* the keyboard has gone */
} else if (events & (POLLIN | POLLRDNORM)) {
- if (sc->gkb_q.c_cc > 0)
+ if (sc->gkb_q_length > 0)
revents = events & (POLLIN | POLLRDNORM);
else
selrecord(td, &sc->gkb_rsel);
@@ -738,7 +766,7 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
/* store the byte as is for K_RAW and K_CODE modes */
if (mode != K_XLATE) {
- putc(KEYCHAR(c), &sc->gkb_q);
+ genkbd_putc(sc, KEYCHAR(c));
continue;
}
@@ -753,9 +781,9 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
/* ignore them... */
continue;
case BTAB: /* a backtab: ESC [ Z */
- putc(0x1b, &sc->gkb_q);
- putc('[', &sc->gkb_q);
- putc('Z', &sc->gkb_q);
+ genkbd_putc(sc, 0x1b);
+ genkbd_putc(sc, '[');
+ genkbd_putc(sc, 'Z');
continue;
}
}
@@ -763,24 +791,24 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
/* normal chars, normal chars with the META, function keys */
switch (KEYFLAGS(c)) {
case 0: /* a normal char */
- putc(KEYCHAR(c), &sc->gkb_q);
+ genkbd_putc(sc, KEYCHAR(c));
break;
case MKEY: /* the META flag: prepend ESC */
- putc(0x1b, &sc->gkb_q);
- putc(KEYCHAR(c), &sc->gkb_q);
+ genkbd_putc(sc, 0x1b);
+ genkbd_putc(sc, KEYCHAR(c));
break;
case FKEY | SPCLKEY: /* a function key, return string */
cp = kbdd_get_fkeystr(kbd, KEYCHAR(c), &len);
if (cp != NULL) {
while (len-- > 0)
- putc(*cp++, &sc->gkb_q);
+ genkbd_putc(sc, *cp++);
}
break;
}
}
/* wake up sleeping/polling processes */
- if (sc->gkb_q.c_cc > 0) {
+ if (sc->gkb_q_length > 0) {
if (sc->gkb_flags & KB_ASLEEP) {
sc->gkb_flags &= ~KB_ASLEEP;
wakeup(sc);
diff --git a/sys/dev/kbdmux/kbdmux.c b/sys/dev/kbdmux/kbdmux.c
index ac6095c..0f1fe42 100644
--- a/sys/dev/kbdmux/kbdmux.c
+++ b/sys/dev/kbdmux/kbdmux.c
@@ -36,7 +36,6 @@
#include <sys/param.h>
#include <sys/bus.h>
-#include <sys/clist.h>
#include <sys/conf.h>
#include <sys/consio.h>
#include <sys/fcntl.h>
@@ -134,7 +133,9 @@ typedef struct kbdmux_kbd kbdmux_kbd_t;
*/
struct kbdmux_state
{
- struct clist ks_inq; /* input chars queue */
+ char ks_inq[KBDMUX_Q_SIZE]; /* input chars queue */
+ unsigned int ks_inq_start;
+ unsigned int ks_inq_length;
struct task ks_task; /* interrupt task */
struct callout ks_timo; /* timeout handler */
#define TICKS (hz) /* rate */
@@ -167,6 +168,34 @@ static task_fn_t kbdmux_kbd_intr;
static timeout_t kbdmux_kbd_intr_timo;
static kbd_callback_func_t kbdmux_kbd_event;
+static void
+kbdmux_kbd_putc(kbdmux_state_t *state, char c)
+{
+ unsigned int p;
+
+ if (state->ks_inq_length == KBDMUX_Q_SIZE)
+ return;
+
+ p = (state->ks_inq_start + state->ks_inq_length) % KBDMUX_Q_SIZE;
+ state->ks_inq[p] = c;
+ state->ks_inq_length++;
+}
+
+static char
+kbdmux_kbd_getc(kbdmux_state_t *state)
+{
+ char c;
+
+ if (state->ks_inq_length == 0)
+ return (-1);
+
+ c = state->ks_inq[state->ks_inq_start];
+ state->ks_inq_start = (state->ks_inq_start + 1) % KBDMUX_Q_SIZE;
+ state->ks_inq_length--;
+
+ return (c);
+}
+
/*
* Interrupt handler task
*/
@@ -205,7 +234,7 @@ kbdmux_kbd_intr_timo(void *xstate)
callout_deactivate(&state->ks_timo);
/* queue interrupt task if needed */
- if (state->ks_inq.c_cc > 0 && !(state->ks_flags & TASK) &&
+ if (state->ks_inq_length > 0 && !(state->ks_flags & TASK) &&
KBDMUX_QUEUE_INTR(state) == 0)
state->ks_flags |= TASK;
@@ -246,11 +275,11 @@ kbdmux_kbd_event(keyboard_t *kbd, int event, void *arg)
if (!KBD_IS_BUSY(kbd))
continue; /* not open - discard the input */
- putc(c, &state->ks_inq);
+ kbdmux_kbd_putc(state, c);
}
/* queue interrupt task if needed */
- if (state->ks_inq.c_cc > 0 && !(state->ks_flags & TASK) &&
+ if (state->ks_inq_length > 0 && !(state->ks_flags & TASK) &&
KBDMUX_QUEUE_INTR(state) == 0)
state->ks_flags |= TASK;
@@ -384,8 +413,6 @@ kbdmux_init(int unit, keyboard_t **kbdp, void *arg, int flags)
}
KBDMUX_LOCK_INIT(state);
- clist_alloc_cblocks(&state->ks_inq,
- KBDMUX_Q_SIZE, KBDMUX_Q_SIZE / 2);
TASK_INIT(&state->ks_task, 0, kbdmux_kbd_intr, (void *) kbd);
KBDMUX_CALLOUT_INIT(state);
SLIST_INIT(&state->ks_kbds);
@@ -448,10 +475,8 @@ kbdmux_init(int unit, keyboard_t **kbdp, void *arg, int flags)
return (0);
bad:
if (needfree) {
- if (state != NULL) {
- clist_free_cblocks(&state->ks_inq);
+ if (state != NULL)
free(state, M_KBDMUX);
- }
if (keymap != NULL)
free(keymap, M_KBDMUX);
if (accmap != NULL)
@@ -495,10 +520,6 @@ kbdmux_term(keyboard_t *kbd)
free(k, M_KBDMUX);
}
- /* flush input queue */
- ndflush(&state->ks_inq, state->ks_inq.c_cc);
- clist_free_cblocks(&state->ks_inq);
-
KBDMUX_UNLOCK(state);
kbd_unregister(kbd);
@@ -577,7 +598,7 @@ kbdmux_read(keyboard_t *kbd, int wait)
int c;
KBDMUX_LOCK(state);
- c = getc(&state->ks_inq);
+ c = kbdmux_kbd_getc(state);
KBDMUX_UNLOCK(state);
if (c != -1)
@@ -599,7 +620,7 @@ kbdmux_check(keyboard_t *kbd)
return (FALSE);
KBDMUX_LOCK(state);
- ready = (state->ks_inq.c_cc > 0)? TRUE : FALSE;
+ ready = (state->ks_inq_length > 0) ? TRUE : FALSE;
KBDMUX_UNLOCK(state);
return (ready);
@@ -635,7 +656,7 @@ next_code:
}
/* see if there is something in the keyboard queue */
- scancode = getc(&state->ks_inq);
+ scancode = kbdmux_kbd_getc(state);
if (scancode == -1) {
if (state->ks_flags & POLLING) {
kbdmux_kbd_t *k;
@@ -650,11 +671,11 @@ next_code:
if (!KBD_IS_BUSY(k->kbd))
continue;
- putc(scancode, &state->ks_inq);
+ kbdmux_kbd_putc(state, scancode);
}
}
- if (state->ks_inq.c_cc > 0)
+ if (state->ks_inq_length > 0)
goto next_code;
}
@@ -895,7 +916,7 @@ kbdmux_check_char(keyboard_t *kbd)
if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char != 0))
ready = TRUE;
else
- ready = (state->ks_inq.c_cc > 0)? TRUE : FALSE;
+ ready = (state->ks_inq_length > 0) ? TRUE : FALSE;
KBDMUX_UNLOCK(state);
@@ -1219,8 +1240,7 @@ kbdmux_clear_state_locked(kbdmux_state_t *state)
state->ks_accents = 0;
state->ks_composed_char = 0;
/* state->ks_prefix = 0; XXX */
-
- ndflush(&state->ks_inq, state->ks_inq.c_cc);
+ state->ks_inq_length = 0;
}
static void
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 667072f..63d9cee 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$");
#include "pci_if.h"
#ifdef __HAVE_ACPI
-#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/acpi.h>
#include "acpi_if.h"
#else
#define ACPI_PWR_FOR_SLEEP(x, y, z)
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index c2f3b80..cff13f6 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -97,7 +97,7 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW,
#define MAKE_WORD(h,l) (((h) << 8) | (l))
#define BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
-#define UAUDIO_MAX_CHAN(x) (((x) < 2) ? (x) : 2) /* XXX fixme later */
+#define UAUDIO_MAX_CHAN(x) (x)
struct uaudio_mixer_node {
int32_t minval;
@@ -940,6 +940,8 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
bChannels = UAUDIO_MAX_CHAN(asf1d->bNrChannels);
bBitResolution = asf1d->bBitResolution;
+ DPRINTFN(9, "bChannels=%u\n", bChannels);
+
if (asf1d->bSamFreqType == 0) {
DPRINTFN(16, "Sample rate: %d-%dHz\n",
UA_SAMP_LO(asf1d), UA_SAMP_HI(asf1d));
diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c
index 836cedf..2f98ebd 100644
--- a/sys/dev/usb/input/ukbd.c
+++ b/sys/dev/usb/input/ukbd.c
@@ -706,7 +706,6 @@ ukbd_attach(device_t dev)
sc->sc_iface_index = uaa->info.bIfaceIndex;
sc->sc_iface_no = uaa->info.bIfaceNum;
sc->sc_mode = K_XLATE;
- sc->sc_iface = uaa->iface;
usb2_callout_init_mtx(&sc->sc_callout, &Giant, 0);
OpenPOWER on IntegriCloud