From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNUM5-0006P9-2c for qemu-devel@nongnu.org; Sun, 24 Jan 2016 18:46:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNUM1-0000pT-0l for qemu-devel@nongnu.org; Sun, 24 Jan 2016 18:46:00 -0500 Date: Mon, 25 Jan 2016 10:10:57 +1100 From: David Gibson Message-ID: <20160124231057.GN27454@voom.redhat.com> References: <1453581610-23179-1-git-send-email-hpoussin@reactos.org> <1453581610-23179-2-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pjk796cY0SfIo9Z2" Content-Disposition: inline In-Reply-To: <1453581610-23179-2-git-send-email-hpoussin@reactos.org> Subject: Re: [Qemu-devel] [PATCH 01/13] cuda: add a framework to handle commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Herv=E9?= Poussineau Cc: qemu-ppc@nongnu.org, Alyssa Milburn , Mark Cave-Ayland , qemu-devel@nongnu.org, Alexander Graf --Pjk796cY0SfIo9Z2 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 23, 2016 at 09:39:58PM +0100, Herv=E9 Poussineau wrote: > Next commits will port existing CUDA commands to this framework. >=20 > Signed-off-by: Herv=E9 Poussineau Reviewed-by: David Gibson > --- > hw/misc/macio/cuda.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) >=20 > diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c > index 9db4c64..69f69c2 100644 > --- a/hw/misc/macio/cuda.c > +++ b/hw/misc/macio/cuda.c > @@ -534,13 +534,47 @@ static void cuda_adb_poll(void *opaque) > (get_ticks_per_sec() / CUDA_ADB_POLL_FREQ)); > } > =20 > +/* description of commands */ > +typedef struct CudaCommand { > + uint8_t command; > + const char *name; > + bool (*handler)(CUDAState *s, > + const uint8_t *in_args, int in_len, > + uint8_t *out_args, int *out_len); > +} CudaCommand; > + > +static const CudaCommand handlers[] =3D { > +}; > + > static void cuda_receive_packet(CUDAState *s, > const uint8_t *data, int len) > { > uint8_t obuf[16] =3D { CUDA_PACKET, 0, data[0] }; > int autopoll; > + int i, out_len =3D 0; > uint32_t ti; > =20 > + for (i =3D 0; i < ARRAY_SIZE(handlers); i++) { > + const CudaCommand *desc =3D &handlers[i]; > + if (desc->command =3D=3D data[0]) { > + CUDA_DPRINTF("handling command %s\n", desc->name); > + out_len =3D 0; > + if (desc->handler(s, data + 1, len - 1, obuf + 3, &out_len))= { > + cuda_send_packet_to_host(s, obuf, 3 + out_len); > + } else { > + qemu_log_mask(LOG_GUEST_ERROR, > + "CUDA: %s: wrong parameters %d\n", > + desc->name, len); > + obuf[0] =3D ERROR_PACKET; > + obuf[1] =3D 0x5; /* bad parameters */ > + obuf[2] =3D CUDA_PACKET; > + obuf[3] =3D data[0]; > + cuda_send_packet_to_host(s, obuf, 4); > + } > + return; > + } > + } > + > switch(data[0]) { > case CUDA_AUTOPOLL: > autopoll =3D (data[1] !=3D 0); --=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 --Pjk796cY0SfIo9Z2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWpVoBAAoJEGw4ysog2bOSXq4QALw6ddmuqf1QPmROHCGmeVTK 99NaBPXkJddDeCoI4Vn5SSAZZO1u9MBP5Te1O3dJv4Zwq9jGUQV+Dh/2WzJ3a5kB pLXu49dFp3kil1gBo78ai9mxmjOsNjPwtWQR5Pa97CDV8YERyclBjopwtU82QuX0 jGV0FvzLSuHM9CA6kisoTwBEoinaBfihtsmnWvW8zEO1ZODkIQILQx6/igCPXHtH g1o1fQVtUXB4ThShOMq3l1s6llysqa2GD4eGqBZfzWwAqDHmRtg1fL9UnWIa1/6Y F1TvLeXBuDtT5lp+loo275LmDW1QPKo5BdmiMCQ0i/tSEZxRwLh0kQEdR+VU4gqz C9sbaxb1zYtDWGvxAFZvGmxKBvu52qGOVpqvpvFgm9IlGeuX2+U1bhYYdJK5mD0u K9RrhkyDAkX5PBITfx806ZtLt4EqBbIxK6XtokwfPJNRrb4ueRSKqExdFla1Y9+3 1hrBPjK+i2/cLMfTggKnilu34ysSyGoigfTCmRg+KKpbAfIuHQ3w9js6XD/h5cI7 kN3GkjCSaafdEJ0Da3DRPAKmz/+kLckKORSjxiKIt01Omm7bWbyWhJ8eHytv2tAy i6ENSgB/fX69ttUzX7Iw/4xnxjXcbzDIQKPT81cq1qKsrV43ialj0Y1mLZb3iD1G p0iEpceBrXVe6KdlOZ/l =EM4f -----END PGP SIGNATURE----- --Pjk796cY0SfIo9Z2--