Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Follow IA-64 with the x86-specific ACPI MD functions and...



details:   https://anonhg.NetBSD.org/src/rev/e2e095afa61e
branches:  trunk
changeset: 765989:e2e095afa61e
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Jun 12 11:31:30 2011 +0000

description:
Follow IA-64 with the x86-specific ACPI MD functions and move these where
they belong to. Remove an unused function. Minor KNF. No functional change.

diffstat:

 sys/arch/ia64/acpi/acpi_machdep.c    |   13 +-
 sys/arch/ia64/include/acpi_machdep.h |    7 +-
 sys/arch/x86/acpi/acpi_machdep.c     |  297 ++++++++++++++++++++++++++++++++++
 sys/arch/x86/conf/files.x86          |    5 +-
 sys/arch/x86/include/acpi_machdep.h  |    3 +-
 sys/arch/x86/x86/acpi_machdep.c      |  305 -----------------------------------
 sys/dev/acpi/acpica/OsdEnvironment.c |    8 +-
 7 files changed, 309 insertions(+), 329 deletions(-)

diffs (truncated from 733 to 300 lines):

diff -r cc11540f0aae -r e2e095afa61e sys/arch/ia64/acpi/acpi_machdep.c
--- a/sys/arch/ia64/acpi/acpi_machdep.c Sun Jun 12 10:11:52 2011 +0000
+++ b/sys/arch/ia64/acpi/acpi_machdep.c Sun Jun 12 11:31:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_machdep.c,v 1.4 2011/06/12 10:11:52 jruoho Exp $  */
+/*     $NetBSD: acpi_machdep.c,v 1.5 2011/06/12 11:31:30 jruoho Exp $  */
 /*
  * Copyright (c) 2009 KIYOHARA Takashi
  * All rights reserved.
@@ -28,7 +28,7 @@
  * Machine-dependent routines for ACPICA.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.4 2011/06/12 10:11:52 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.5 2011/06/12 11:31:30 jruoho Exp $");
 
 #include <sys/param.h>
 
@@ -59,15 +59,6 @@
        return AE_OK;
 }
 
-ACPI_STATUS
-acpi_md_OsTerminate(void)
-{
-
-       /* nothing to do. */
-printf("%s\n", __func__);
-       return AE_OK;
-}
-
 ACPI_PHYSICAL_ADDRESS
 acpi_md_OsGetRootPointer(void)
 {
diff -r cc11540f0aae -r e2e095afa61e sys/arch/ia64/include/acpi_machdep.h
--- a/sys/arch/ia64/include/acpi_machdep.h      Sun Jun 12 10:11:52 2011 +0000
+++ b/sys/arch/ia64/include/acpi_machdep.h      Sun Jun 12 11:31:30 2011 +0000
@@ -1,8 +1,7 @@
-/*     $NetBSD: acpi_machdep.h,v 1.4 2011/06/12 10:11:52 jruoho Exp $  */
+/*     $NetBSD: acpi_machdep.h,v 1.5 2011/06/12 11:31:30 jruoho Exp $  */
 
-ACPI_STATUS acpi_md_OsInitialize(void);
-ACPI_STATUS acpi_md_OsTerminate(void);
-ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void);
+ACPI_STATUS            acpi_md_OsInitialize(void);
+ACPI_PHYSICAL_ADDRESS  acpi_md_OsGetRootPointer(void);
 
 #define acpi_md_OsIn8(x)       inb((x))
 #define acpi_md_OsIn16(x)      inw((x))
diff -r cc11540f0aae -r e2e095afa61e sys/arch/x86/acpi/acpi_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86/acpi/acpi_machdep.c  Sun Jun 12 11:31:30 2011 +0000
@@ -0,0 +1,297 @@
+/* $NetBSD: acpi_machdep.c,v 1.1 2011/06/12 11:31:31 jruoho 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.1 2011/06/12 11:31:31 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/cpufunc.h>
+
+#include <dev/acpi/acpica.h>
+#include <dev/acpi/acpivar.h>
+
+#include <machine/acpi_machdep.h>
+#include <machine/mpbiosvar.h>
+#include <machine/mpacpi.h>
+#include <machine/i82093reg.h>
+#include <machine/i82093var.h>
+#include <machine/pic.h>
+
+#include <dev/pci/pcivar.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+#include "ioapic.h"
+
+#include "acpica.h"
+#include "opt_mpbios.h"
+#include "opt_acpi.h"
+
+extern uint32_t cpus_attached;
+
+ACPI_STATUS
+acpi_md_OsInitialize(void)
+{
+       return AE_OK;
+}
+
+ACPI_PHYSICAL_ADDRESS
+acpi_md_OsGetRootPointer(void)
+{
+       ACPI_PHYSICAL_ADDRESS PhysicalAddress;
+       ACPI_STATUS Status;
+
+       Status = AcpiFindRootPointer(&PhysicalAddress);
+
+       if (ACPI_FAILURE(Status))
+               PhysicalAddress = 0;
+
+       return PhysicalAddress;
+}
+
+ACPI_STATUS
+acpi_md_OsInstallInterruptHandler(uint32_t InterruptNumber,
+    ACPI_OSD_HANDLER ServiceRoutine, void *Context, void **cookiep)
+{
+       void *ih;
+       struct pic *pic;
+#if NIOAPIC > 0
+       struct ioapic_softc *sc;
+#endif
+       int irq, pin, trigger;
+
+#if NIOAPIC > 0
+       /*
+        * Can only match on ACPI global interrupt numbers if the ACPI
+        * interrupt info was extracted, which is in the ACPI case.
+        */
+       if (mpacpi_sci_override != NULL) {
+               pic = mpacpi_sci_override->ioapic;
+               pin = mpacpi_sci_override->ioapic_pin;
+               if (mpacpi_sci_override->redir & IOAPIC_REDLO_LEVEL)
+                       trigger = IST_LEVEL;
+               else
+                       trigger = IST_EDGE;
+               if (pic->pic_type == PIC_IOAPIC)
+                       irq = -1;
+               else
+                       irq = (int)InterruptNumber;
+               goto sci_override;
+       }
+#endif
+
+       /*
+        * There was no ACPI interrupt source override,
+        *
+        * If the interrupt is handled via IOAPIC, mark it
+        * as level-triggered, active low in the table.
+        */
+
+#if NIOAPIC > 0
+       sc = ioapic_find_bybase(InterruptNumber);
+       if (sc != NULL) {
+               pic = &sc->sc_pic;
+               struct mp_intr_map *mip;
+
+               if (pic->pic_type == PIC_IOAPIC) {
+                       pin = (int)InterruptNumber - pic->pic_vecbase;
+                       irq = -1;
+               } else {
+                       irq = pin = (int)InterruptNumber;
+               }
+
+               mip = sc->sc_pins[pin].ip_map;
+               if (mip) {
+                       mip->flags &= ~3;
+                       mip->flags |= MPS_INTPO_ACTLO;
+                       mip->redir |= IOAPIC_REDLO_ACTLO;
+               }
+       } else
+#endif
+       {
+               pic = &i8259_pic;
+               irq = pin = (int)InterruptNumber;
+       }
+
+       trigger = IST_LEVEL;
+
+#if NIOAPIC > 0
+sci_override:
+#endif
+
+       /*
+        * XXX probably, IPL_BIO is enough.
+        */
+       ih = intr_establish(irq, pic, pin, trigger, IPL_TTY,
+           (int (*)(void *)) ServiceRoutine, Context, false);
+
+       if (ih == NULL)
+               return AE_NO_MEMORY;
+
+       *cookiep = ih;
+
+       return AE_OK;
+}
+
+void
+acpi_md_OsRemoveInterruptHandler(void *cookie)
+{
+       intr_disestablish(cookie);
+}
+
+ACPI_STATUS
+acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+    uint32_t Length, void **LogicalAddress)
+{
+       int rv;
+
+       rv = _x86_memio_map(x86_bus_space_mem, PhysicalAddress,
+           Length, 0, (bus_space_handle_t *)LogicalAddress);
+
+       return (rv != 0) ? AE_NO_MEMORY : AE_OK;
+}
+
+void
+acpi_md_OsUnmapMemory(void *LogicalAddress, uint32_t Length)
+{
+       (void) _x86_memio_unmap(x86_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_t 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_t Length)
+{
+       BOOLEAN rv = FALSE;



Home | Main Index | Thread Index | Old Index