From owner-svn-src-all@FreeBSD.ORG Tue Jul 20 19:43:25 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB48B106566B; Tue, 20 Jul 2010 19:43:25 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D94E08FC08; Tue, 20 Jul 2010 19:43:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6KJhP4U091350; Tue, 20 Jul 2010 19:43:25 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6KJhPCh091347; Tue, 20 Jul 2010 19:43:25 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201007201943.o6KJhPCh091347@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 20 Jul 2010 19:43:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210314 - stable/7/sys/dev/acpica/Osd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2010 19:43:26 -0000 Author: jkim Date: Tue Jul 20 19:43:25 2010 New Revision: 210314 URL: http://svn.freebsd.org/changeset/base/210314 Log: MFC: r209965, r209966, r210129, r210137, r210155 - 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. - Clean up some white spaces. Modified: stable/7/sys/dev/acpica/Osd/OsdHardware.c stable/7/sys/dev/acpica/Osd/OsdMemory.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/acpica/Osd/OsdHardware.c ============================================================================== --- stable/7/sys/dev/acpica/Osd/OsdHardware.c Tue Jul 20 19:38:38 2010 (r210313) +++ stable/7/sys/dev/acpica/Osd/OsdHardware.c Tue Jul 20 19:43:25 2010 (r210314) @@ -53,16 +53,16 @@ __FBSDID("$FreeBSD$"); */ #ifdef __i386__ -#define ACPI_BUS_SPACE_IO I386_BUS_SPACE_IO -#define ACPI_BUS_HANDLE 0 +#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 +#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 +#define ACPI_BUS_SPACE_IO AMD64_BUS_SPACE_IO +#define ACPI_BUS_HANDLE 0 #endif /* @@ -137,19 +137,13 @@ AcpiOsReadPort(ACPI_IO_ADDRESS InPort, U switch (Width) { case 8: - *(u_int8_t *)Value = bus_space_read_1(ACPI_BUS_SPACE_IO, - ACPI_BUS_HANDLE, InPort); - break; + *Value = bus_space_read_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort); + break; case 16: - *(u_int16_t *)Value = bus_space_read_2(ACPI_BUS_SPACE_IO, - ACPI_BUS_HANDLE, InPort); - break; + *Value = bus_space_read_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, 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 = bus_space_read_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort); break; } @@ -172,16 +166,13 @@ AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, switch (Width) { case 8: - bus_space_write_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); - break; + bus_space_write_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); + break; case 16: - bus_space_write_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); - break; + bus_space_write_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); + break; case 32: - bus_space_write_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); - break; - default: - /* debug trap goes here */ + bus_space_write_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, OutPort, Value); break; } @@ -192,28 +183,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); } @@ -223,13 +201,15 @@ ACPI_STATUS AcpiOsWritePciConfiguration (ACPI_PCI_ID *PciId, UINT32 Register, ACPI_INTEGER 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/7/sys/dev/acpica/Osd/OsdMemory.c ============================================================================== --- stable/7/sys/dev/acpica/Osd/OsdMemory.c Tue Jul 20 19:38:38 2010 (r210313) +++ stable/7/sys/dev/acpica/Osd/OsdMemory.c Tue Jul 20 19:43:25 2010 (r210314) @@ -108,29 +108,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); } @@ -140,29 +134,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); }