From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpU0o-0005hF-FF for qemu-devel@nongnu.org; Thu, 29 Sep 2016 01:36:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpU0k-0007sg-L1 for qemu-devel@nongnu.org; Thu, 29 Sep 2016 01:36:02 -0400 Date: Thu, 29 Sep 2016 15:33:27 +1000 From: David Gibson Message-ID: <20160929053327.GU8390@umbus.fritz.box> References: <1475088693-29091-1-git-send-email-lvivier@redhat.com> <1475088693-29091-6-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0iexB5Bk8cF8G6DP" Content-Disposition: inline In-Reply-To: <1475088693-29091-6-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 5/6] qtest: define target cpu endianness conversion functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: qemu-devel@nongnu.org, thuth@redhat.com, Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , dgibson@redhat.com --0iexB5Bk8cF8G6DP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 28, 2016 at 08:51:32PM +0200, Laurent Vivier wrote: > Signed-off-by: Laurent Vivier So, I think the right place to do the necessary endianness conversion is the PCI accessor helpers, as noted elsewhere. However, even ignoring that, I can't actually see anything in your series that uses these new functions. > --- > tests/libqtest.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 57 insertions(+) >=20 > diff --git a/tests/libqtest.h b/tests/libqtest.h > index 4be1f77..b3ac7d8 100644 > --- a/tests/libqtest.h > +++ b/tests/libqtest.h > @@ -17,6 +17,7 @@ > #ifndef LIBQTEST_H > #define LIBQTEST_H > =20 > +#include "qemu/bswap.h" > #include "qapi/qmp/qdict.h" > =20 > typedef struct QTestState QTestState; > @@ -891,6 +892,62 @@ static inline bool target_big_endian(void) > return qtest_big_endian(global_qtest); > } > =20 > +/* Endianness conversion function between target cpu and specified endia= ness > + * > + * uint16_t target_le16_to_cpu(uint16_t v); > + * uint32_t target_le32_to_cpu(uint32_t v); > + * uint64_t target_le64_to_cpu(uint64_t v); > + * uint16_t target_be16_to_cpu(uint16_t v); > + * uint32_t target_be32_to_cpu(uint32_t v); > + * uint64_t target_be64_to_cpu(uint64_t v); > + * > + * Convert the value @v from the specified format to the native > + * endianness of the target CPU by byteswapping if necessary, and > + * return the converted value. > + * > + * uint16_t target_cpu_to_le16(uint16_t v); > + * uint32_t target_cpu_to_le32(uint32_t v); > + * uint64_t target_cpu_to_le64(uint64_t v); > + * uint16_t target_cpu_to_be16(uint16_t v); > + * uint32_t target_cpu_to_be32(uint32_t v); > + * uint64_t target_cpu_to_be64(uint64_t v); > + * > + * Convert the value @v from the native endianness of the target CPU to > + * the specified format by byteswapping if necessary, and return > + * the converted value. > + * > + * Both target_X_to_cpu() and target_cpu_to_X() perform the same operati= on; you > + * should use whichever one is better documenting of the function your > + * code is performing. > + * > + */ > + > +#define le_bswap(s, v, size) (qtest_big_endian(s) ? bswap ## size(v) : (= v)) > +#define be_bswap(s, v, size) (qtest_big_endian(s) ? (v) : bswap ## size(= v)) > + > +#define TARGET_CPU_CONVERT(endian, size, type)\ > +static inline type target_ ## endian ## size ## _to_cpu(type v)\ > +{\ > + return glue(endian, _bswap)(global_qtest, v, size);\ > +} \ > +\ > +static inline type target_cpu_to_ ## endian ## size(type v)\ > +{\ > + return glue(endian, _bswap)(global_qtest, v, size);\ > +} > + > +TARGET_CPU_CONVERT(be, 16, uint16_t) > +TARGET_CPU_CONVERT(be, 32, uint32_t) > +TARGET_CPU_CONVERT(be, 64, uint64_t) > + > +TARGET_CPU_CONVERT(le, 16, uint16_t) > +TARGET_CPU_CONVERT(le, 32, uint32_t) > +TARGET_CPU_CONVERT(le, 64, uint64_t) > + > +#undef TARGET_CPU_CONVERT > +#undef be_bswap > +#undef le_bswap > + > QDict *qmp_fd_receive(int fd); > void qmp_fd_sendv(int fd, const char *fmt, va_list ap); > void qmp_fd_send(int fd, const char *fmt, ...); --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --0iexB5Bk8cF8G6DP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX7KemAAoJEGw4ysog2bOSPOcP+gNzpuyCgOeZNOP1sxEmp0ns e1tZLLlZFylKCxdXD38wn8IyTv0KhuK4lAQHZvTSCezZXN9zcdTADxtvRM1+cBVV q6EuPel8ykShsc2Wocj0ZKLf8UgKGKSWZjTsKbhUHqax6BLhGTICwM2rexCNGFEI KcNOOrHgKiXg7pb2M1upsXtW+YEqvN0uuJIdsAXMeuYxBLdGtJqADBEUMcc7D5Mb mk7RXO0NvjJj33w2RU1am5k1mOi2yxMzEbmFv9JSehSZqmEtjEZVF2pOWlVPgtnh gz0neVeKrsMSvPq2zToWnc0F/Bvw1n85OWUtoMLoqJkpDTf2vmAoSbaso4nH989V f/pqZd6jb0fGNKdBkZUUI9hInUmcDs4A65XIDA5pyY1rBaScxbs9Va7Ha09cmIOZ rjLZrVor+4nYRNLc3fP8Bj/6CUHKT7Anel4ASgUnyDXUBr4cDyG8qCgq7/3Evcxg DMAt0i5XyPt49wwpRhCzZPuXlVpOsD4M780wnOZe/fZTEXXLk/ib5S6jsx33yzCp ZT6wMgv+25vMdEP/lADb1Q5wgHuXpbvhoDmS8wT4T7cvBUb7ZN1GTCYebLOrkz1p tPOP+4m2ne6cgxXEKqTOZUu0jk5TOzA1Lv+DWuAmoHyiDYpcBSW2Nj6OX8UcCTc8 aQjlxL21e4gdPfsatDKP =/1CL -----END PGP SIGNATURE----- --0iexB5Bk8cF8G6DP--