Machine-dependent ACPI CA Osd routines for i386.

This commit is contained in:
thorpej 2001-09-28 01:46:56 +00:00
parent 46f84eb8d0
commit abd2c67167
2 changed files with 256 additions and 0 deletions

View File

@ -0,0 +1,189 @@
/* $NetBSD: acpi_machdep.c,v 1.1 2001/09/28 01:46:56 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
/*
* Machine-dependent routines for ACPICA.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <uvm/uvm_extern.h>
#include <machine/bus.h>
#include <dev/acpi/acpica.h>
#include <dev/acpi/acpivar.h>
#include <machine/acpi_machdep.h>
#include <dev/pci/pcivar.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
ACPI_STATUS
acpi_md_OsInitialize(void)
{
/* Nothing to do, yet. */
return (AE_OK);
}
ACPI_STATUS
acpi_md_OsTerminate(void)
{
/* Nothing to do, yet. */
return (AE_OK);
}
ACPI_STATUS
acpi_md_OsGetRootPointer(UINT32 Flags, ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
{
return (AcpiFindRootPointer(Flags, PhysicalAddress));
}
ACPI_STATUS
acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber,
OSD_HANDLER ServiceRoutine, void *Context, void **cookiep)
{
void *ih;
/*
* XXX We currently just use InterruptNumber as a
* "pre-mapped" PCI IRQ -- double-check that this
* is OK (talk to Sommerfeld).
*/
ih = pci_intr_establish(NULL, InterruptNumber, IPL_HIGH /* XXX */,
(int (*)(void *)) ServiceRoutine, Context);
if (ih == NULL)
return (AE_NO_MEMORY);
*cookiep = ih;
return (AE_OK);
}
void
acpi_md_OsRemoveInterruptHandler(void *cookie)
{
pci_intr_disestablish(NULL, cookie);
}
ACPI_STATUS
acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress,
UINT32 Length, void **LogicalAddress)
{
if (_i386_memio_map(I386_BUS_SPACE_MEM, PhysicalAddress, Length,
0, (bus_space_handle_t *) LogicalAddress) == 0)
return (AE_OK);
return (AE_NO_MEMORY);
}
void
acpi_md_OsUnmapMemory(void *LogicalAddress, UINT32 Length)
{
(void) _i386_memio_unmap(I386_BUS_SPACE_MEM,
(bus_space_handle_t) LogicalAddress, Length, NULL);
}
ACPI_STATUS
acpi_md_OsGetPhysicalAddress(void *LogicalAddress,
ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
{
paddr_t pa;
if (pmap_extract(pmap_kernel(), (vaddr_t) LogicalAddress, &pa)) {
*PhysicalAddress = pa;
return (AE_OK);
}
return (AE_ERROR);
}
BOOLEAN
acpi_md_OsReadable(void *Pointer, UINT32 Length)
{
BOOLEAN rv = TRUE;
vaddr_t sva, eva;
pt_entry_t *pte;
sva = trunc_page((vaddr_t) Pointer);
eva = round_page((vaddr_t) Pointer + Length);
if (sva < VM_MIN_KERNEL_ADDRESS)
return (FALSE);
for (; sva < eva; sva += PAGE_SIZE) {
pte = kvtopte(sva);
if ((*pte & PG_V) == 0) {
rv = FALSE;
break;
}
}
return (rv);
}
BOOLEAN
acpi_md_OsWritable(void *Pointer, UINT32 Length)
{
BOOLEAN rv = FALSE;
vaddr_t sva, eva;
pt_entry_t *pte;
sva = trunc_page((vaddr_t) Pointer);
eva = round_page((vaddr_t) Pointer + Length);
if (sva < VM_MIN_KERNEL_ADDRESS)
return (FALSE);
for (; sva < eva; sva += PAGE_SIZE) {
pte = kvtopte(sva);
if ((*pte & (PG_V|PG_W)) != (PG_V|PG_W)) {
rv = FALSE;
break;
}
}
return (rv);
}

View File

@ -0,0 +1,67 @@
/* $NetBSD: acpi_machdep.h,v 1.1 2001/09/28 01:47:00 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
/*
* Machine-dependent code for ACPI. This is provided to the Osd
* portion of the ACPICA.
*/
#include <machine/pio.h>
ACPI_STATUS acpi_md_OsInitialize(void);
ACPI_STATUS acpi_md_OsTerminate(void);
ACPI_STATUS acpi_md_OsGetRootPointer(UINT32, ACPI_PHYSICAL_ADDRESS *);
#define acpi_md_OsIn8(x) inb((x))
#define acpi_md_OsIn16(x) inw((x))
#define acpi_md_OsIn32(x) inl((x))
#define acpi_md_OsOut8(x, v) outb((x), (v))
#define acpi_md_OsOut16(x, v) outw((x), (v))
#define acpi_md_OsOut32(x, v) outl((x), (v))
ACPI_STATUS acpi_md_OsInstallInterruptHandler(UINT32, OSD_HANDLER, void *,
void **);
void acpi_md_OsRemoveInterruptHandler(void *);
ACPI_STATUS acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS, UINT32, void **);
void acpi_md_OsUnmapMemory(void *, UINT32);
ACPI_STATUS acpi_md_OSGetPhysicalAddress(void *LogicalAddress,
ACPI_PHYSICAL_ADDRESS *PhysicalAddress);
BOOLEAN acpi_md_OsReadable(void *, UINT32);
BOOLEAN acpi_md_OsWritable(void *, UINT32);