From patchwork Thu Jan 24 09:04:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 215273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9746D2C007C for ; Thu, 24 Jan 2013 20:05:07 +1100 (EST) Received: from localhost ([::1]:35005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyIk4-0006EJ-Ns for incoming@patchwork.ozlabs.org; Thu, 24 Jan 2013 04:05:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:32920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyIje-0005sh-Qw for qemu-devel@nongnu.org; Thu, 24 Jan 2013 04:04:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyIja-0001XY-97 for qemu-devel@nongnu.org; Thu, 24 Jan 2013 04:04:38 -0500 Received: from cantor2.suse.de ([195.135.220.15]:57856 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyIjZ-0001XK-VN; Thu, 24 Jan 2013 04:04:34 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 80E1DA3A4A; Thu, 24 Jan 2013 10:04:33 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 24 Jan 2013 10:04:03 +0100 Message-Id: <1359018245-24344-11-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359018245-24344-1-git-send-email-afaerber@suse.de> References: <1359018245-24344-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: qemu-ppc@nongnu.org, agraf@suse.de, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH for-1.4 v4 10/12] adb: QOM'ify Apple Desktop Bus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It was not a qbus before, turn it into a first-class bus and initialize it properly from CUDA. Leave it a global variable as long as devices are not QOM'ified yet. Signed-off-by: Andreas Färber --- hw/adb.c | 14 ++++++++++++++ hw/adb.h | 16 +++++++++++++--- hw/cuda.c | 3 +++ 3 Dateien geändert, 30 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) diff --git a/hw/adb.c b/hw/adb.c index cc8ad8e..5d46f59 100644 --- a/hw/adb.c +++ b/hw/adb.c @@ -126,6 +126,12 @@ static ADBDevice *adb_register_device(ADBBusState *s, int devaddr, return d; } +static const TypeInfo adb_bus_type_info = { + .name = TYPE_ADB_BUS, + .parent = TYPE_BUS, + .instance_size = sizeof(ADBBusState), +}; + /***************************************************************/ /* Keyboard ADB device */ @@ -453,3 +459,11 @@ void adb_mouse_init(ADBBusState *bus) qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse"); vmstate_register(NULL, -1, &vmstate_adb_mouse, s); } + + +static void adb_register_types(void) +{ + type_register_static(&adb_bus_type_info); +} + +type_init(adb_register_types) diff --git a/hw/adb.h b/hw/adb.h index 5b27da2..c23f804 100644 --- a/hw/adb.h +++ b/hw/adb.h @@ -26,10 +26,13 @@ #if !defined(__ADB_H__) #define __ADB_H__ +#include "qdev.h" + #define MAX_ADB_DEVICES 16 #define ADB_MAX_OUT_LEN 16 +typedef struct ADBBusState ADBBusState; typedef struct ADBDevice ADBDevice; /* buf = NULL means polling */ @@ -38,7 +41,7 @@ typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out, typedef int ADBDeviceReset(ADBDevice *d); struct ADBDevice { - struct ADBBusState *bus; + ADBBusState *bus; int devaddr; int handler; ADBDeviceRequest *devreq; @@ -46,11 +49,18 @@ struct ADBDevice { void *opaque; }; -typedef struct ADBBusState { +#define TYPE_ADB_BUS "apple-desktop-bus" +#define ADB_BUS(obj) OBJECT_CHECK(ADBBusState, (obj), TYPE_ADB_BUS) + +struct ADBBusState { + /*< private >*/ + BusState parent_obj; + /*< public >*/ + ADBDevice devices[MAX_ADB_DEVICES]; int nb_devices; int poll_index; -} ADBBusState; +}; int adb_request(ADBBusState *s, uint8_t *buf_out, const uint8_t *buf, int len); diff --git a/hw/cuda.c b/hw/cuda.c index f863c38..b3a875c 100644 --- a/hw/cuda.c +++ b/hw/cuda.c @@ -712,6 +712,9 @@ static void cuda_initfn(Object *obj) for (i = 0; i < ARRAY_SIZE(s->timers); i++) { s->timers[i].index = i; } + + qbus_create_inplace((BusState *)&adb_bus, TYPE_ADB_BUS, DEVICE(obj), + "adb.0"); } static void cuda_class_init(ObjectClass *oc, void *data)