Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jul 2010 19:38:39 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r210313 - stable/8/sys/dev/acpica/Osd
Message-ID:  <201007201938.o6KJcd2E090222@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Tue Jul 20 19:38:38 2010
New Revision: 210313
URL: http://svn.freebsd.org/changeset/base/210313

Log:
  MFC:	r209965, r209966, r210129, r210137, r210155, r210157
  
  - According to ACPICA User Guide and Programmer Reference, the read data
  must be zero extended to fill the 32-bit or 64-bit return value even if
  the bit width of the port or location is less than 32 or 64.
  - Use pmap_mapdev()/pmap_unmapdev() to map device memory instead of using
  AcpiOsMapMemory()/AcpiOsUnmapMemory() (-> pmap_mapbios()/pmap_unmapbios())
  for AcpiOsReadMemory() and AcpiOsWriteMemory().  Although they do not sound
  too obvious, these functions are exclusively used to access memory mapped
  IO in ACPICA.
  - Remove 64-bit access from AcpiOsReadMemory() and AcpiOsWriteMemory().
  These functions do not support 64-bit access.  Likewise, return error when
  64-bit access is requested for PCI configuration space.
  - Simplify AcpiOsReadPort() and AcpiOsWritePort() with iodev_read_*() and
  iodev_write_*().  This removes unnecessary uses of temporary macros as well.
  There is no functional change after this (verified with md5(1) on amd64).

Modified:
  stable/8/sys/dev/acpica/Osd/OsdHardware.c
  stable/8/sys/dev/acpica/Osd/OsdMemory.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/acpica/Osd/OsdHardware.c
==============================================================================
--- stable/8/sys/dev/acpica/Osd/OsdHardware.c	Tue Jul 20 19:32:25 2010	(r210312)
+++ stable/8/sys/dev/acpica/Osd/OsdHardware.c	Tue Jul 20 19:38:38 2010	(r210313)
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/bus.h>
 #include <sys/kernel.h>
-#include <machine/bus.h>
+#include <machine/iodev.h>
 #include <machine/pci_cfgreg.h>
 #include <dev/acpica/acpivar.h>
 #include <dev/pci/pcireg.h>
@@ -48,42 +48,21 @@ __FBSDID("$FreeBSD$");
  *
  * 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
  */
 
-#ifdef __i386__
-#define ACPI_BUS_SPACE_IO	I386_BUS_SPACE_IO
-#define ACPI_BUS_HANDLE		0
-#endif
-#ifdef __ia64__
-#define ACPI_BUS_SPACE_IO	IA64_BUS_SPACE_IO
-#define ACPI_BUS_HANDLE		0
-#endif
-#ifdef __amd64__
-#define ACPI_BUS_SPACE_IO	AMD64_BUS_SPACE_IO
-#define ACPI_BUS_HANDLE		0
-#endif
-
 ACPI_STATUS
 AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)
 {
 
     switch (Width) {
     case 8:
-        *(u_int8_t *)Value = bus_space_read_1(ACPI_BUS_SPACE_IO,
-	    ACPI_BUS_HANDLE, InPort);
-        break;
+	*Value = iodev_read_1(InPort);
+	break;
     case 16:
-        *(u_int16_t *)Value = bus_space_read_2(ACPI_BUS_SPACE_IO,
-	    ACPI_BUS_HANDLE, InPort);
-        break;
+	*Value = iodev_read_2(InPort);
+	break;
     case 32:
-        *(u_int32_t *)Value = bus_space_read_4(ACPI_BUS_SPACE_IO,
-	    ACPI_BUS_HANDLE, InPort);
-        break;
-    default:
-        /* debug trap goes here */
+	*Value = iodev_read_4(InPort);
 	break;
     }
 
@@ -96,16 +75,13 @@ AcpiOsWritePort(ACPI_IO_ADDRESS OutPort,
 
     switch (Width) {
     case 8:
-        bus_space_write_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
-        break;
+	iodev_write_1(OutPort, Value);
+	break;
     case 16:
-        bus_space_write_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
-        break;
+	iodev_write_2(OutPort, Value);
+	break;
     case 32:
-        bus_space_write_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value);
-        break;
-    default:
-        /* debug trap goes here */
+	iodev_write_4(OutPort, Value);
 	break;
     }
 
@@ -116,28 +92,15 @@ ACPI_STATUS
 AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, void *Value,
     UINT32 Width)
 {
-    u_int32_t	byte_width = Width / 8;
-    u_int32_t	val;
+
+    if (Width == 64)
+	return (AE_SUPPORT);
 
     if (!pci_cfgregopen())
-        return (AE_NOT_EXIST);
+	return (AE_NOT_EXIST);
 
-    val = pci_cfgregread(PciId->Bus, PciId->Device, PciId->Function, Register,
-	byte_width);
-    switch (Width) {
-    case 8:
-	*(u_int8_t *)Value = val & 0xff;
-	break;
-    case 16:
-	*(u_int16_t *)Value = val & 0xffff;
-	break;
-    case 32:
-	*(u_int32_t *)Value = val;
-	break;
-    default:
-	/* debug trap goes here */
-	break;
-    }
+    *(UINT64 *)Value = pci_cfgregread(PciId->Bus, PciId->Device,
+	PciId->Function, Register, Width / 8);
 
     return (AE_OK);
 }
@@ -147,13 +110,15 @@ ACPI_STATUS
 AcpiOsWritePciConfiguration (ACPI_PCI_ID *PciId, UINT32 Register,
     UINT64 Value, UINT32 Width)
 {
-    u_int32_t	byte_width = Width / 8;
+
+    if (Width == 64)
+	return (AE_SUPPORT);
 
     if (!pci_cfgregopen())
     	return (AE_NOT_EXIST);
 
     pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register,
-	Value, byte_width);
+	Value, Width / 8);
 
     return (AE_OK);
 }

Modified: stable/8/sys/dev/acpica/Osd/OsdMemory.c
==============================================================================
--- stable/8/sys/dev/acpica/Osd/OsdMemory.c	Tue Jul 20 19:32:25 2010	(r210312)
+++ stable/8/sys/dev/acpica/Osd/OsdMemory.c	Tue Jul 20 19:38:38 2010	(r210313)
@@ -97,29 +97,23 @@ AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS A
 {
     void	*LogicalAddress;
 
-    LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
+    LogicalAddress = pmap_mapdev(Address, Width / 8);
     if (LogicalAddress == NULL)
 	return (AE_NOT_EXIST);
 
     switch (Width) {
     case 8:
-	*(u_int8_t *)Value = (*(volatile u_int8_t *)LogicalAddress);
+	*Value = *(volatile uint8_t *)LogicalAddress;
 	break;
     case 16:
-	*(u_int16_t *)Value = (*(volatile u_int16_t *)LogicalAddress);
+	*Value = *(volatile uint16_t *)LogicalAddress;
 	break;
     case 32:
-	*(u_int32_t *)Value = (*(volatile u_int32_t *)LogicalAddress);
-	break;
-    case 64:
-	*(u_int64_t *)Value = (*(volatile u_int64_t *)LogicalAddress);
-	break;
-    default:
-	/* debug trap goes here */
+	*Value = *(volatile uint32_t *)LogicalAddress;
 	break;
     }
 
-    AcpiOsUnmapMemory(LogicalAddress, Width / 8);
+    pmap_unmapdev((vm_offset_t)LogicalAddress, Width / 8);
 
     return (AE_OK);
 }
@@ -129,29 +123,23 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS 
 {
     void	*LogicalAddress;
 
-    LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
+    LogicalAddress = pmap_mapdev(Address, Width / 8);
     if (LogicalAddress == NULL)
 	return (AE_NOT_EXIST);
 
     switch (Width) {
     case 8:
-	(*(volatile u_int8_t *)LogicalAddress) = Value & 0xff;
+	*(volatile uint8_t *)LogicalAddress = Value;
 	break;
     case 16:
-	(*(volatile u_int16_t *)LogicalAddress) = Value & 0xffff;
+	*(volatile uint16_t *)LogicalAddress = Value;
 	break;
     case 32:
-	(*(volatile u_int32_t *)LogicalAddress) = Value & 0xffffffff;
-	break;
-    case 64:
-	(*(volatile u_int64_t *)LogicalAddress) = Value;
-	break;
-    default:
-	/* debug trap goes here */
+	*(volatile uint32_t *)LogicalAddress = Value;
 	break;
     }
 
-    AcpiOsUnmapMemory(LogicalAddress, Width / 8);
+    pmap_unmapdev((vm_offset_t)LogicalAddress, Width / 8);
 
     return (AE_OK);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007201938.o6KJcd2E090222>