Module Name:    src
Committed By:   jruoho
Date:           Sun Jun 12 11:31:31 UTC 2011

Modified Files:
        src/sys/arch/ia64/acpi: acpi_machdep.c
        src/sys/arch/ia64/include: acpi_machdep.h
        src/sys/arch/x86/conf: files.x86
        src/sys/arch/x86/include: acpi_machdep.h
        src/sys/dev/acpi/acpica: OsdEnvironment.c
Added Files:
        src/sys/arch/x86/acpi: acpi_machdep.c
Removed Files:
        src/sys/arch/x86/x86: acpi_machdep.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/acpi/acpi_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/include/acpi_machdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/include/acpi_machdep.h
cvs rdiff -u -r1.29 -r0 src/sys/arch/x86/x86/acpi_machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/acpica/OsdEnvironment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ia64/acpi/acpi_machdep.c
diff -u src/sys/arch/ia64/acpi/acpi_machdep.c:1.4 src/sys/arch/ia64/acpi/acpi_machdep.c:1.5
--- src/sys/arch/ia64/acpi/acpi_machdep.c:1.4	Sun Jun 12 10:11:52 2011
+++ src/sys/arch/ia64/acpi/acpi_machdep.c	Sun Jun 12 11:31:30 2011
@@ -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)
 {

Index: src/sys/arch/ia64/include/acpi_machdep.h
diff -u src/sys/arch/ia64/include/acpi_machdep.h:1.4 src/sys/arch/ia64/include/acpi_machdep.h:1.5
--- src/sys/arch/ia64/include/acpi_machdep.h:1.4	Sun Jun 12 10:11:52 2011
+++ src/sys/arch/ia64/include/acpi_machdep.h	Sun Jun 12 11:31:30 2011
@@ -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))

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.70 src/sys/arch/x86/conf/files.x86:1.71
--- src/sys/arch/x86/conf/files.x86:1.70	Sun Jun 12 10:11:52 2011
+++ src/sys/arch/x86/conf/files.x86	Sun Jun 12 11:31:31 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.70 2011/06/12 10:11:52 jruoho Exp $
+#	$NetBSD: files.x86,v 1.71 2011/06/12 11:31:31 jruoho Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -105,10 +105,9 @@
 # MP configuration using ACPI
 file 	arch/x86/x86/mpacpi.c		acpi
 
-file	arch/x86/x86/acpi_machdep.c	acpi
-
 file	arch/x86/acpi/acpi_pdc.c	acpi
 file	arch/x86/acpi/acpi_wakeup.c	acpi
+file	arch/x86/acpi/acpi_machdep.c	acpi
 
 file	arch/x86/isa/isa_machdep.c	isa
 

Index: src/sys/arch/x86/include/acpi_machdep.h
diff -u src/sys/arch/x86/include/acpi_machdep.h:1.9 src/sys/arch/x86/include/acpi_machdep.h:1.10
--- src/sys/arch/x86/include/acpi_machdep.h:1.9	Sun Jun 12 10:11:52 2011
+++ src/sys/arch/x86/include/acpi_machdep.h	Sun Jun 12 11:31:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_machdep.h,v 1.9 2011/06/12 10:11:52 jruoho Exp $	*/
+/*	$NetBSD: acpi_machdep.h,v 1.10 2011/06/12 11:31:31 jruoho Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -46,7 +46,6 @@
 #include <machine/i82489reg.h>
 
 ACPI_STATUS		acpi_md_OsInitialize(void);
-ACPI_STATUS		acpi_md_OsTerminate(void);
 ACPI_PHYSICAL_ADDRESS	acpi_md_OsGetRootPointer(void);
 
 #define	acpi_md_OsIn8(x)	inb((x))

Index: src/sys/dev/acpi/acpica/OsdEnvironment.c
diff -u src/sys/dev/acpi/acpica/OsdEnvironment.c:1.5 src/sys/dev/acpi/acpica/OsdEnvironment.c:1.6
--- src/sys/dev/acpi/acpica/OsdEnvironment.c:1.5	Sun Aug 23 15:16:16 2009
+++ src/sys/dev/acpi/acpica/OsdEnvironment.c	Sun Jun 12 11:31:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: OsdEnvironment.c,v 1.5 2009/08/23 15:16:16 jmcneill Exp $	*/
+/*	$NetBSD: OsdEnvironment.c,v 1.6 2011/06/12 11:31:31 jruoho Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: OsdEnvironment.c,v 1.5 2009/08/23 15:16:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: OsdEnvironment.c,v 1.6 2011/06/12 11:31:31 jruoho Exp $");
 
 #include <sys/types.h>
 
@@ -53,7 +53,7 @@
 #include <machine/acpi_machdep.h>
 
 #define	_COMPONENT	ACPI_OS_SERVICES
-ACPI_MODULE_NAME("ENVIRONMENT");
+ACPI_MODULE_NAME	("ENVIRONMENT");
 
 /*
  * AcpiOsInitialize:
@@ -77,7 +77,7 @@
 ACPI_STATUS
 AcpiOsTerminate(void)
 {
-	return acpi_md_OsTerminate();
+	return AE_OK;
 }
 
 /*

Added files:

Index: src/sys/arch/x86/acpi/acpi_machdep.c
diff -u /dev/null src/sys/arch/x86/acpi/acpi_machdep.c:1.1
--- /dev/null	Sun Jun 12 11:31:31 2011
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Sun Jun 12 11:31:31 2011
@@ -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;
+	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;
+}
+
+void
+acpi_md_OsDisableInterrupt(void)
+{
+	x86_disable_intr();
+}
+
+void
+acpi_md_OsEnableInterrupt(void)
+{
+	x86_enable_intr();
+}
+
+uint32_t
+acpi_md_ncpus(void)
+{
+	return popcount32(cpus_attached);
+}
+
+void
+acpi_md_callback(void)
+{
+#ifdef MPBIOS
+	if (!mpbios_scanned)
+#endif
+	mpacpi_find_interrupts(acpi_softc);
+
+#ifndef XEN
+	acpi_md_sleep_init();
+#endif
+}

Reply via email to