From owner-svn-src-all@FreeBSD.ORG Thu Dec 6 22:33:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D9A0B375; Thu, 6 Dec 2012 22:33:32 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BD0D08FC13; Thu, 6 Dec 2012 22:33:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qB6MXWxJ046173; Thu, 6 Dec 2012 22:33:32 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qB6MXWpP046167; Thu, 6 Dec 2012 22:33:32 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201212062233.qB6MXWpP046167@svn.freebsd.org> From: Jim Harris Date: Thu, 6 Dec 2012 22:33:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243960 - in head/sys: amd64/include i386/include x86/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Thu, 06 Dec 2012 22:33:33 -0000 Author: jimharris Date: Thu Dec 6 22:33:31 2012 New Revision: 243960 URL: http://svnweb.freebsd.org/changeset/base/243960 Log: Add amd64 implementations for 8-byte bus_space routines. Submitted by: Carl Delsey Discussed with: jhb, rwatson Reviewed by: jimharris MFC after: 1 week Modified: head/sys/amd64/include/bus.h head/sys/i386/include/bus.h head/sys/x86/include/bus.h Modified: head/sys/amd64/include/bus.h ============================================================================== --- head/sys/amd64/include/bus.h Thu Dec 6 21:44:53 2012 (r243959) +++ head/sys/amd64/include/bus.h Thu Dec 6 22:33:31 2012 (r243960) @@ -1,6 +1,153 @@ /*- - * This file is in the public domain. + * Copyright (c) 2012 Intel Corporation + * Copyright (c) 2009 Marcel Moolenaar + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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. + * + * $FreeBSD$ */ -/* $FreeBSD$ */ +#ifndef _MACHINE_BUS_H_ +#define _MACHINE_BUS_H_ + +#include #include + +#define KASSERT_BUS_SPACE_MEM_ONLY(tag) \ + KASSERT((tag) == X86_BUS_SPACE_MEM, \ + ("%s: can only handle mem space", __func__)) + +static __inline uint64_t +bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs) +{ + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + return (*(volatile uint64_t *)(bsh + ofs)); +} + +static __inline void +bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t val) +{ + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + *(volatile uint64_t *)(bsh + ofs) = val; +} + +static __inline void +bus_space_read_region_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t *bufp, size_t count) +{ + volatile uint64_t *bsp; + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + bsp = (void *)(bsh + ofs); + while (count-- > 0) + *bufp++ = *bsp++; +} + +static __inline void +bus_space_write_region_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t const *bufp, size_t count) +{ + volatile uint64_t *bsp; + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + bsp = (void *)(bsh + ofs); + while (count-- > 0) + *bsp++ = *bufp++; +} + +static __inline void +bus_space_set_region_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t val, size_t count) +{ + volatile uint64_t *bsp; + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + bsp = (void *)(bsh + ofs); + while (count-- > 0) + *bsp++ = val; +} + +static __inline void +bus_space_copy_region_8(bus_space_tag_t tag, bus_space_handle_t sbsh, + bus_size_t sofs, bus_space_handle_t dbsh, bus_size_t dofs, size_t count) +{ + volatile uint64_t *dst, *src; + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + src = (void *)(sbsh + sofs); + dst = (void *)(dbsh + dofs); + if (src < dst) { + src += count - 1; + dst += count - 1; + while (count-- > 0) + *dst-- = *src--; + } else { + while (count-- > 0) + *dst++ = *src++; + } +} + +static __inline void +bus_space_read_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t *bufp, size_t count) +{ + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + while (count-- > 0) + *bufp++ = *(volatile uint64_t *)(bsh + ofs); +} + +static __inline void +bus_space_write_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t const *bufp, size_t count) +{ + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + while (count-- > 0) + *(volatile uint64_t *)(bsh + ofs) = *bufp++; +} + +static __inline void +bus_space_set_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t ofs, uint64_t val, size_t count) +{ + + KASSERT_BUS_SPACE_MEM_ONLY(tag); + + while (count-- > 0) + *(volatile uint64_t *)(bsh + ofs) = val; +} + +#endif /*_MACHINE_BUS_H_*/ Modified: head/sys/i386/include/bus.h ============================================================================== --- head/sys/i386/include/bus.h Thu Dec 6 21:44:53 2012 (r243959) +++ head/sys/i386/include/bus.h Thu Dec 6 22:33:31 2012 (r243960) @@ -3,4 +3,26 @@ */ /* $FreeBSD$ */ +#ifndef _MACHINE_BUS_H_ +#define _MACHINE_BUS_H_ + #include + +/* + * The functions: + * bus_space_read_8 + * bus_space_read_region_8 + * bus_space_write_8 + * bus_space_write_multi_8 + * bus_space_write_region_8 + * bus_space_set_multi_8 + * bus_space_set_region_8 + * bus_space_copy_region_8 + * bus_space_read_multi_8 + * are unimplemented for i386 because there is no way to do a 64-bit move in + * this architecture. It is possible to do two 32-bit moves, but this is + * not atomic and may have hardware dependencies that should be fully + * understood. + */ + +#endif /*_MACHINE_BUS_H_*/ Modified: head/sys/x86/include/bus.h ============================================================================== --- head/sys/x86/include/bus.h Thu Dec 6 21:44:53 2012 (r243959) +++ head/sys/x86/include/bus.h Thu Dec 6 22:33:31 2012 (r243960) @@ -251,10 +251,6 @@ bus_space_read_4(bus_space_tag_t tag, bu return (*(volatile u_int32_t *)(handle + offset)); } -#if 0 /* Cause a link error for bus_space_read_8 */ -#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! -#endif - /* * Read `count' 1, 2, 4, or 8 byte quantities from bus space * described by tag/handle/offset and copy into buffer provided. @@ -337,10 +333,6 @@ bus_space_read_multi_4(bus_space_tag_t t } } -#if 0 /* Cause a link error for bus_space_read_multi_8 */ -#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! -#endif - /* * Read `count' 1, 2, 4, or 8 byte quantities from bus space * described by tag/handle and starting at `offset' and copy into @@ -458,10 +450,6 @@ bus_space_read_region_4(bus_space_tag_t } } -#if 0 /* Cause a link error for bus_space_read_region_8 */ -#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! -#endif - /* * Write the 1, 2, 4, or 8 byte value `value' to bus space * described by tag/handle/offset. @@ -512,10 +500,6 @@ bus_space_write_4(bus_space_tag_t tag, b *(volatile u_int32_t *)(bsh + offset) = value; } -#if 0 /* Cause a link error for bus_space_write_8 */ -#define bus_space_write_8 !!! bus_space_write_8 not implemented !!! -#endif - /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer * provided to bus space described by tag/handle/offset. @@ -601,11 +585,6 @@ bus_space_write_multi_4(bus_space_tag_t } } -#if 0 /* Cause a link error for bus_space_write_multi_8 */ -#define bus_space_write_multi_8(t, h, o, a, c) \ - !!! bus_space_write_multi_8 unimplemented !!! -#endif - /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided * to bus space described by tag/handle starting at `offset'. @@ -723,11 +702,6 @@ bus_space_write_region_4(bus_space_tag_t } } -#if 0 /* Cause a link error for bus_space_write_region_8 */ -#define bus_space_write_region_8 \ - !!! bus_space_write_region_8 unimplemented !!! -#endif - /* * Write the 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle/offset `count' times. @@ -788,10 +762,6 @@ bus_space_set_multi_4(bus_space_tag_t ta *(volatile u_int32_t *)(addr) = value; } -#if 0 /* Cause a link error for bus_space_set_multi_8 */ -#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!! -#endif - /* * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle starting at `offset'. @@ -852,10 +822,6 @@ bus_space_set_region_4(bus_space_tag_t t *(volatile u_int32_t *)(addr) = value; } -#if 0 /* Cause a link error for bus_space_set_region_8 */ -#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!! -#endif - /* * Copy `count' 1, 2, 4, or 8 byte values from bus space starting * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. @@ -984,10 +950,6 @@ bus_space_copy_region_4(bus_space_tag_t } } -#if 0 /* Cause a link error for bus_space_copy_8 */ -#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!! -#endif - /* * Bus read/write barrier methods. *