FreeBSD-specific OSD (operating system dependant) modules for the Intel
ACPICA code.
This commit is contained in:
parent
54b1161b73
commit
fd660059d9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67760
56
sys/amd64/acpica/OsdEnvironment.c
Normal file
56
sys/amd64/acpica/OsdEnvironment.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.1 : Environmental support
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#ifdef __i386__
|
||||
#include <machine/pc/bios.h>
|
||||
#endif
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsInitialize(void)
|
||||
{
|
||||
#ifdef __i386__
|
||||
/*
|
||||
* Prevent the PnP BIOS code from interfering with our own scan of ISA devices.
|
||||
*/
|
||||
PnPBIOStable = NULL;
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsTerminate(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
147
sys/dev/acpica/Osd/OsdBusMgr.c
Normal file
147
sys/dev/acpica/Osd/OsdBusMgr.c
Normal file
@ -0,0 +1,147 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* OSD interfaces for the BusMgr module
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
#include "bmosd.h"
|
||||
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
struct osd_eventhandle {
|
||||
eventhandler_tag tag;
|
||||
OSD_IDLE_HANDLER Function;
|
||||
void *Context;
|
||||
};
|
||||
|
||||
#define NUM_IDLEHANDLERS 10
|
||||
struct osd_eventhandle idlehandlers[NUM_IDLEHANDLERS] = {{0, 0}};
|
||||
#define NUM_SHUTDOWNHANDLERS 20
|
||||
struct osd_eventhandle shutdownhandlers[NUM_SHUTDOWNHANDLERS] = {{0, 0}};
|
||||
|
||||
static void
|
||||
osd_idlehandler(void *arg, int junk)
|
||||
{
|
||||
struct osd_eventhandle *oh = (struct osd_eventhandle *)arg;
|
||||
|
||||
oh->Function(oh->Context);
|
||||
}
|
||||
|
||||
static void
|
||||
osd_shutdownhandler(void *arg, int howto)
|
||||
{
|
||||
struct osd_eventhandle *oh = (struct osd_eventhandle *)arg;
|
||||
|
||||
oh->Function(oh->Context);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsInstallIdleHandler(OSD_IDLE_HANDLER Function, void *Context)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (Function == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
for (i = 0; i < NUM_IDLEHANDLERS; i++) {
|
||||
if (idlehandlers[i].Function == NULL) {
|
||||
idlehandlers[i].Function = Function;
|
||||
idlehandlers[i].Context = Context;
|
||||
idlehandlers[i].tag = EVENTHANDLER_FAST_REGISTER(idle_event, osd_idlehandler,
|
||||
&idlehandlers[i], IDLE_PRI_FIRST);
|
||||
return(AE_OK);
|
||||
}
|
||||
}
|
||||
return(AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsRemoveIdleHandler(OSD_IDLE_HANDLER Function)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (Function == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
for (i = 0; i < NUM_IDLEHANDLERS; i++) {
|
||||
if (idlehandlers[i].Function == Function) {
|
||||
EVENTHANDLER_FAST_DEREGISTER(idle_event, idlehandlers[i].tag);
|
||||
idlehandlers[i].Function = NULL;
|
||||
return(AE_OK);
|
||||
}
|
||||
}
|
||||
return(AE_NOT_EXIST);
|
||||
}
|
||||
|
||||
/*
|
||||
* It's not clear where exactly in the shutdown order these should be
|
||||
* queued.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
AcpiOsInstallShutdownHandler(OSD_SHUTDOWN_HANDLER Function, void *Context)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (Function == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
for (i = 0; i < NUM_SHUTDOWNHANDLERS; i++) {
|
||||
if (shutdownhandlers[i].Function == NULL) {
|
||||
shutdownhandlers[i].Function = Function;
|
||||
shutdownhandlers[i].Context = Context;
|
||||
shutdownhandlers[i].tag = EVENTHANDLER_REGISTER(shutdown_final, osd_shutdownhandler,
|
||||
&shutdownhandlers[i], SHUTDOWN_PRI_LAST);
|
||||
return(AE_OK);
|
||||
}
|
||||
}
|
||||
return(AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsRemoveShutdownHandler(OSD_SHUTDOWN_HANDLER Function)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (Function == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
for (i = 0; i < NUM_SHUTDOWNHANDLERS; i++) {
|
||||
if (shutdownhandlers[i].Function == Function) {
|
||||
EVENTHANDLER_DEREGISTER(shutdown_final, shutdownhandlers[i].tag);
|
||||
shutdownhandlers[i].Function = NULL;
|
||||
return(AE_OK);
|
||||
}
|
||||
}
|
||||
return(AE_NOT_EXIST);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsShutdown (void)
|
||||
{
|
||||
shutdown_nice(0);
|
||||
}
|
99
sys/dev/acpica/Osd/OsdDebug.c
Normal file
99
sys/dev/acpica/Osd/OsdDebug.c
Normal file
@ -0,0 +1,99 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.8 : Debugging support
|
||||
*/
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/cons.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <ddb/ddb.h>
|
||||
#include <ddb/db_output.h>
|
||||
|
||||
#include "acpi.h"
|
||||
#include "acdebug.h"
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsBreakpoint(NATIVE_CHAR *Message)
|
||||
{
|
||||
Debugger(Message);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
UINT32
|
||||
AcpiOsGetLine(NATIVE_CHAR *Buffer)
|
||||
{
|
||||
#ifdef DDB
|
||||
char *cp;
|
||||
|
||||
db_readline(Buffer, 80);
|
||||
for (cp = Buffer; *cp != 0; cp++)
|
||||
if (*cp == '\n')
|
||||
*cp = 0;
|
||||
return(AE_OK);
|
||||
#else
|
||||
printf("AcpiOsGetLine called but no input support");
|
||||
return(AE_NOT_EXIST);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, NATIVE_CHAR *Message)
|
||||
{
|
||||
printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
|
||||
printf("ACPI: assertion %s\n", (char *)FailedAssertion);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUGGER
|
||||
void
|
||||
acpi_EnterDebugger(void)
|
||||
{
|
||||
ACPI_PARSE_OBJECT obj;
|
||||
static int initted = 0;
|
||||
|
||||
if (!initted) {
|
||||
printf("Initialising ACPICA debugger...\n");
|
||||
AcpiDbInitialize();
|
||||
initted = 1;
|
||||
}
|
||||
|
||||
printf("Entering ACPICA debugger...\n");
|
||||
AcpiDbUserCommands('A', &obj);
|
||||
}
|
||||
#endif
|
56
sys/dev/acpica/Osd/OsdEnvironment.c
Normal file
56
sys/dev/acpica/Osd/OsdEnvironment.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.1 : Environmental support
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#ifdef __i386__
|
||||
#include <machine/pc/bios.h>
|
||||
#endif
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsInitialize(void)
|
||||
{
|
||||
#ifdef __i386__
|
||||
/*
|
||||
* Prevent the PnP BIOS code from interfering with our own scan of ISA devices.
|
||||
*/
|
||||
PnPBIOStable = NULL;
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsTerminate(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
148
sys/dev/acpica/Osd/OsdHardware.c
Normal file
148
sys/dev/acpica/Osd/OsdHardware.c
Normal file
@ -0,0 +1,148 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.7 : Hardware Abstraction
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#include <machine/bus_pio.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/pci_cfgreg.h>
|
||||
|
||||
/*
|
||||
* ACPICA's rather gung-ho approach to hardware resource ownership is a little
|
||||
* troublesome insofar as there is no easy way for us to know in advance
|
||||
* exactly which I/O resources it's going to want to use.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* XXX use an intermediate #define for the tag/handle
|
||||
*/
|
||||
|
||||
#define ACPI_BUS_SPACE_IO I386_BUS_SPACE_IO
|
||||
#define ACPI_BUS_HANDLE 0
|
||||
|
||||
UINT8
|
||||
AcpiOsIn8(ACPI_IO_ADDRESS InPort)
|
||||
{
|
||||
return(bus_space_read_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort));
|
||||
}
|
||||
|
||||
UINT16
|
||||
AcpiOsIn16(ACPI_IO_ADDRESS InPort)
|
||||
{
|
||||
return(bus_space_read_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort));
|
||||
}
|
||||
|
||||
UINT32
|
||||
AcpiOsIn32(ACPI_IO_ADDRESS InPort)
|
||||
{
|
||||
return(bus_space_read_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort));
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsOut8(ACPI_IO_ADDRESS OutPort, UINT8 Value)
|
||||
{
|
||||
bus_space_write_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsOut16(ACPI_IO_ADDRESS OutPort, UINT16 Value)
|
||||
{
|
||||
bus_space_write_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsOut32(ACPI_IO_ADDRESS OutPort, UINT32 Value)
|
||||
{
|
||||
bus_space_write_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsReadPciCfgByte (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT8 *Value)
|
||||
{
|
||||
u_int32_t result;
|
||||
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
result = pci_cfgregread(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, 1);
|
||||
*Value = (UINT8)result;
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsReadPciCfgWord (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT16 *Value)
|
||||
{
|
||||
u_int32_t result;
|
||||
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
result = pci_cfgregread(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, 2);
|
||||
*Value = (UINT16)result;
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsReadPciCfgDword (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT32 *Value)
|
||||
{
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
*Value = pci_cfgregread(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, 4);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsWritePciCfgByte (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT8 Value)
|
||||
{
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
pci_cfgregwrite(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, (u_int32_t)Value, 1);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsWritePciCfgWord (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT16 Value)
|
||||
{
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
pci_cfgregwrite(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, (u_int32_t)Value, 2);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsWritePciCfgDword (UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT32 Value)
|
||||
{
|
||||
if (!pci_cfgregopen())
|
||||
return(AE_NOT_EXIST);
|
||||
pci_cfgregwrite(Bus, DeviceFunction >> 16, DeviceFunction & 0xff, Register, (u_int32_t)Value, 4);
|
||||
return(AE_OK);
|
||||
}
|
110
sys/dev/acpica/Osd/OsdInterrupt.c
Normal file
110
sys/dev/acpica/Osd/OsdInterrupt.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.5 : Interrupt handling
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
/*
|
||||
* XXX this does not correctly free resources in the case of partically successful
|
||||
* attachment.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
AcpiOsInstallInterruptHandler(UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine, void *Context)
|
||||
{
|
||||
struct acpi_softc *sc;
|
||||
|
||||
if ((InterruptNumber < 0) || (InterruptNumber > 255))
|
||||
return(AE_BAD_PARAMETER);
|
||||
if (ServiceRoutine == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
|
||||
panic("can't find ACPI device to register interrupt");
|
||||
if (sc->acpi_dev == NULL)
|
||||
panic("acpi softc has invalid device");
|
||||
|
||||
/*
|
||||
* This isn't strictly true, as we ought to be able to handle > 1 interrupt. The ACPI
|
||||
* spec doesn't call for this though.
|
||||
*/
|
||||
if (sc->acpi_irq != NULL) {
|
||||
device_printf(sc->acpi_dev, "attempt to register more than one interrupt handler\n");
|
||||
return(AE_EXIST);
|
||||
}
|
||||
sc->acpi_irq_rid = 0;
|
||||
bus_set_resource(sc->acpi_dev, SYS_RES_IRQ, 0, InterruptNumber, 1);
|
||||
if ((sc->acpi_irq = bus_alloc_resource(sc->acpi_dev, SYS_RES_IRQ, &sc->acpi_irq_rid, 0, ~0, 1,
|
||||
RF_SHAREABLE | RF_ACTIVE)) == NULL) {
|
||||
device_printf(sc->acpi_dev, "could not allocate SCI interrupt\n");
|
||||
return(AE_EXIST);
|
||||
}
|
||||
if (bus_setup_intr(sc->acpi_dev, sc->acpi_irq, INTR_TYPE_MISC, (driver_intr_t *)ServiceRoutine, Context,
|
||||
&sc->acpi_irq_handle)) {
|
||||
device_printf(sc->acpi_dev, "could not set up SCI interrupt\n");
|
||||
return(AE_EXIST);
|
||||
}
|
||||
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsRemoveInterruptHandler (UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine)
|
||||
{
|
||||
struct acpi_softc *sc;
|
||||
|
||||
if ((InterruptNumber < 0) || (InterruptNumber > 255))
|
||||
return(AE_BAD_PARAMETER);
|
||||
if (ServiceRoutine == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
|
||||
panic("can't find ACPI device to deregister interrupt");
|
||||
|
||||
if (sc->acpi_irq == NULL)
|
||||
return(AE_NOT_EXIST);
|
||||
|
||||
bus_teardown_intr(sc->acpi_dev, sc->acpi_irq, sc->acpi_irq_handle);
|
||||
bus_release_resource(sc->acpi_dev, SYS_RES_IRQ, 0, sc->acpi_irq);
|
||||
bus_delete_resource(sc->acpi_dev, SYS_RES_IRQ, 0);
|
||||
|
||||
sc->acpi_irq = NULL;
|
||||
|
||||
return(AE_OK);
|
||||
}
|
||||
|
96
sys/dev/acpica/Osd/OsdMemory.c
Normal file
96
sys/dev/acpica/Osd/OsdMemory.c
Normal file
@ -0,0 +1,96 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.2 : Memory Management
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
|
||||
|
||||
void *
|
||||
AcpiOsAllocate(UINT32 Size)
|
||||
{
|
||||
return(malloc(Size, M_ACPICA, M_NOWAIT));
|
||||
}
|
||||
|
||||
void *
|
||||
AcpiOsCallocate (UINT32 Size)
|
||||
{
|
||||
void *alloc;
|
||||
|
||||
alloc = malloc(Size, M_ACPICA, M_NOWAIT);
|
||||
if (alloc != NULL)
|
||||
bzero(alloc, Size);
|
||||
return(alloc);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsFree (void *Memory)
|
||||
{
|
||||
free(Memory, M_ACPICA);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsMapMemory (void *PhysicalAddress, UINT32 Length, void **LogicalAddress)
|
||||
{
|
||||
*LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length);
|
||||
if (*LogicalAddress == NULL)
|
||||
return(AE_BAD_ADDRESS);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsUnmapMemory (void *LogicalAddress, UINT32 Length)
|
||||
{
|
||||
pmap_unmapdev((vm_offset_t)LogicalAddress, Length);
|
||||
}
|
||||
|
||||
/*
|
||||
* There is no clean way to do this. We make the charitable assumption
|
||||
* that callers will not pass garbage to us.
|
||||
*/
|
||||
BOOLEAN
|
||||
AcpiOsReadable (void *Pointer, UINT32 Length)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
AcpiOsWritable (void *Pointer, UINT32 Length)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
132
sys/dev/acpica/Osd/OsdSchedule.c
Normal file
132
sys/dev/acpica/Osd/OsdSchedule.c
Normal file
@ -0,0 +1,132 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.3 : Scheduling services
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <machine/clock.h>
|
||||
|
||||
/*
|
||||
* This is a little complicated due to the fact that we need to build and then
|
||||
* free a 'struct task' for each task we enqueue.
|
||||
*
|
||||
* We use the default taskqueue_swi queue, since it really doesn't matter what
|
||||
* else we're queued along with.
|
||||
*/
|
||||
|
||||
MALLOC_DEFINE(M_ACPITASK, "acpitask", "ACPI deferred task");
|
||||
|
||||
static void AcpiOsExecuteQueue(void *arg, int pending);
|
||||
|
||||
struct acpi_task {
|
||||
struct task at_task;
|
||||
OSD_EXECUTION_CALLBACK at_function;
|
||||
void *at_context;
|
||||
};
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsQueueForExecution(UINT32 Priority, OSD_EXECUTION_CALLBACK Function, void *Context)
|
||||
{
|
||||
struct acpi_task *at;
|
||||
|
||||
if (Function == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
/* XXX is it OK to block here? */
|
||||
at = malloc(sizeof(*at), M_ACPITASK, M_WAITOK);
|
||||
bzero(at, sizeof(*at));
|
||||
|
||||
at->at_function = Function;
|
||||
at->at_context = Context;
|
||||
at->at_task.ta_func = AcpiOsExecuteQueue;
|
||||
at->at_task.ta_context = at;
|
||||
switch (Priority) {
|
||||
case OSD_PRIORITY_HIGH:
|
||||
at->at_task.ta_priority = 3;
|
||||
break;
|
||||
case OSD_PRIORITY_MED:
|
||||
at->at_task.ta_priority = 2;
|
||||
break;
|
||||
case OSD_PRIORITY_LO:
|
||||
at->at_task.ta_priority = 1;
|
||||
break;
|
||||
default:
|
||||
free(at, M_ACPITASK);
|
||||
return(AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
taskqueue_enqueue(taskqueue_swi, (struct task *)at);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
AcpiOsExecuteQueue(void *arg, int pending)
|
||||
{
|
||||
struct acpi_task *at = (struct acpi_task *)arg;
|
||||
OSD_EXECUTION_CALLBACK Function;
|
||||
void *Context;
|
||||
|
||||
Function = (OSD_EXECUTION_CALLBACK)at->at_function;
|
||||
Context = at->at_context;
|
||||
|
||||
free(at, M_ACPITASK);
|
||||
|
||||
Function(Context);
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't have any sleep granularity better than hz, so
|
||||
* make do with that.
|
||||
*/
|
||||
void
|
||||
AcpiOsSleep (UINT32 Seconds, UINT32 Milliseconds)
|
||||
{
|
||||
int timo;
|
||||
|
||||
timo = (Seconds * hz) + Milliseconds / (1000 * hz);
|
||||
if (timo == 0)
|
||||
timo = 1;
|
||||
tsleep(NULL, 0, "acpislp", timo);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsSleepUsec (UINT32 Microseconds)
|
||||
{
|
||||
if (Microseconds > 1000) { /* long enough to be worth the overhead of sleeping */
|
||||
AcpiOsSleep(0, Microseconds / 1000);
|
||||
} else {
|
||||
DELAY(Microseconds);
|
||||
}
|
||||
}
|
53
sys/dev/acpica/Osd/OsdStream.c
Normal file
53
sys/dev/acpica/Osd/OsdStream.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.6 : Stream I/O
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
INT32
|
||||
AcpiOsPrintf (const NATIVE_CHAR *Format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int retval;
|
||||
|
||||
va_start(ap, Format);
|
||||
retval = vprintf(Format, ap);
|
||||
va_end(ap);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
INT32
|
||||
AcpiOsVprintf (const NATIVE_CHAR *Format, va_list Args)
|
||||
{
|
||||
return(vprintf(Format, Args));
|
||||
}
|
||||
|
131
sys/dev/acpica/Osd/OsdSynch.c
Normal file
131
sys/dev/acpica/Osd/OsdSynch.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.1 : Mutual Exclusion and Synchronisation
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore");
|
||||
|
||||
/*
|
||||
* Simple counting semaphore implemented using a mutex. (Subsequently used
|
||||
* in the OSI code to implement a mutex. Go figure.)
|
||||
*/
|
||||
struct acpi_semaphore {
|
||||
struct mtx as_mtx;
|
||||
UINT32 as_units;
|
||||
UINT32 as_maxunits;
|
||||
};
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHandle)
|
||||
{
|
||||
struct acpi_semaphore *as;
|
||||
|
||||
if (OutHandle == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
if (InitialUnits > MaxUnits)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
if ((as = malloc(sizeof(*as), M_ACPISEM, M_NOWAIT)) == NULL)
|
||||
return(AE_NO_MEMORY);
|
||||
|
||||
mtx_init(&as->as_mtx, "ACPI semaphore", MTX_DEF);
|
||||
as->as_units = InitialUnits;
|
||||
as->as_maxunits = MaxUnits;
|
||||
|
||||
*OutHandle = (ACPI_HANDLE)as;
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsDeleteSemaphore (ACPI_HANDLE Handle)
|
||||
{
|
||||
free(Handle, M_ACPISEM);
|
||||
return(AE_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* This implementation has a bug, in that it has to stall for the entire
|
||||
* timeout before it will return AE_TIME. A better implementation would
|
||||
* use getmicrotime() to correctly adjust the timeout after being woken up.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout)
|
||||
{
|
||||
struct acpi_semaphore *as = (struct acpi_semaphore *)Handle;
|
||||
int result;
|
||||
|
||||
if (as == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
mtx_enter(&as->as_mtx, MTX_DEF);
|
||||
for (;;) {
|
||||
if (as->as_units >= Units) {
|
||||
as->as_units -= Units;
|
||||
result = AE_OK;
|
||||
break;
|
||||
}
|
||||
if (Timeout < 0) {
|
||||
result = AE_TIME;
|
||||
break;
|
||||
}
|
||||
if (msleep(as, &as->as_mtx, 0, "acpisem", Timeout / (1000 * hz)) == EWOULDBLOCK) {
|
||||
result = AE_TIME;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mtx_exit(&as->as_mtx, MTX_DEF);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units)
|
||||
{
|
||||
struct acpi_semaphore *as = (struct acpi_semaphore *)Handle;
|
||||
|
||||
if (as == NULL)
|
||||
return(AE_BAD_PARAMETER);
|
||||
|
||||
mtx_enter(&as->as_mtx, MTX_DEF);
|
||||
as->as_units += Units;
|
||||
if (as->as_units > as->as_maxunits)
|
||||
as->as_units = as->as_maxunits;
|
||||
wakeup(as);
|
||||
mtx_exit(&as->as_mtx, MTX_DEF);
|
||||
|
||||
return(AE_OK);
|
||||
}
|
56
sys/i386/acpica/OsdEnvironment.c
Normal file
56
sys/i386/acpica/OsdEnvironment.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Michael Smith
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* 6.1 : Environmental support
|
||||
*/
|
||||
|
||||
#include "acpi.h"
|
||||
|
||||
#ifdef __i386__
|
||||
#include <machine/pc/bios.h>
|
||||
#endif
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsInitialize(void)
|
||||
{
|
||||
#ifdef __i386__
|
||||
/*
|
||||
* Prevent the PnP BIOS code from interfering with our own scan of ISA devices.
|
||||
*/
|
||||
PnPBIOStable = NULL;
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsTerminate(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
Loading…
Reference in New Issue
Block a user