From patchwork Mon Aug 3 15:35:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 30613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id DE042B7067 for ; Tue, 4 Aug 2009 03:39:22 +1000 (EST) Received: from localhost ([127.0.0.1]:35516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY1VH-0002JY-26 for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2009 13:39:19 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXza4-0002Am-5b for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:36:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXzZt-0001zL-BL for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:36:02 -0400 Received: from [199.232.76.173] (port=39437 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXzZs-0001xj-FB for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:35:56 -0400 Received: from mx2.redhat.com ([66.187.237.31]:42764) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXzZr-0004dw-Nu for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:35:56 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n73FZsng001370 for ; Mon, 3 Aug 2009 11:35:54 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n73FZrEp015363; Mon, 3 Aug 2009 11:35:53 -0400 Received: from zweiblum.home.kraxel.org (vpn2-8-59.ams2.redhat.com [10.36.8.59]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with SMTP id n73FZoqP014157; Mon, 3 Aug 2009 11:35:51 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 100AD700D6; Mon, 3 Aug 2009 17:35:48 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2009 17:35:18 +0200 Message-Id: <1249313748-6459-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1249313748-6459-1-git-send-email-kraxel@redhat.com> References: <1249313748-6459-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 02/32] qdev/prop: add CharDriverState property. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- hw/qdev-properties.c | 20 ++++++++++++++++++++ hw/qdev.h | 6 ++++++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 0e4878e..7edb6b7 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -141,6 +141,21 @@ PropertyInfo qdev_prop_hex64 = { .print = print_hex64, }; +/* --- character device --- */ + +static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len) +{ + CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); + return snprintf(dest, len, "%s", (*ptr)->label); +} + +PropertyInfo qdev_prop_chr = { + .name = "chr", + .type = PROP_TYPE_CHR, + .size = sizeof(CharDriverState*), + .print = print_chr, +}; + /* --- pointer --- */ static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len) @@ -325,6 +340,11 @@ void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value) qdev_prop_set(dev, name, &value, PROP_TYPE_UINT64); } +void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value) +{ + qdev_prop_set(dev, name, &value, PROP_TYPE_CHR); +} + void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) { qdev_prop_set(dev, name, &value, PROP_TYPE_PTR); diff --git a/hw/qdev.h b/hw/qdev.h index e2703f4..bff13fa 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -3,6 +3,7 @@ #include "hw.h" #include "sys-queue.h" +#include "qemu-char.h" typedef struct Property Property; @@ -62,6 +63,7 @@ enum PropertyType { PROP_TYPE_UINT64, PROP_TYPE_TADDR, PROP_TYPE_MACADDR, + PROP_TYPE_CHR, PROP_TYPE_PTR, }; @@ -152,6 +154,7 @@ extern PropertyInfo qdev_prop_uint32; extern PropertyInfo qdev_prop_uint64; extern PropertyInfo qdev_prop_hex32; extern PropertyInfo qdev_prop_hex64; +extern PropertyInfo qdev_prop_chr; extern PropertyInfo qdev_prop_ptr; extern PropertyInfo qdev_prop_macaddr; extern PropertyInfo qdev_prop_pci_devfn; @@ -188,6 +191,8 @@ extern PropertyInfo qdev_prop_pci_devfn; #define DEFINE_PROP_PTR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*) +#define DEFINE_PROP_CHR(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*) #define DEFINE_PROP_MACADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, uint8_t[6]) @@ -201,6 +206,7 @@ void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyT void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value); void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value); void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value); +void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); /* FIXME: Remove opaque pointer properties. */ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); void qdev_prop_set_defaults(DeviceState *dev, Property *props);