From patchwork Mon Sep 17 10:00:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Voevodin X-Patchwork-Id: 184375 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 8F4672C0095 for ; Mon, 17 Sep 2012 20:45:24 +1000 (EST) Received: from localhost ([::1]:35979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY9K-0007zV-0Q for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 06:01:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY8T-0006Bt-VX for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDY8M-00052L-WA for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:01:01 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:24506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY8M-00050P-Q0 for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:00:54 -0400 Received: from eusync3.samsung.com (mailout4.w1.samsung.com [210.118.77.14]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAH00BJ6NUHLK70@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:01:29 +0100 (BST) Received: from evvoevodinPC.rnd.samsung.ru ([106.109.8.14]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0MAH00DV7NT8FQ90@eusync3.samsung.com> for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:00:54 +0100 (BST) From: Evgeny Voevodin To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2012 14:00:37 +0400 Message-id: <1347876042-22609-8-git-send-email-e.voevodin@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1347876042-22609-1-git-send-email-e.voevodin@samsung.com> References: <1347876042-22609-1-git-send-email-e.voevodin@samsung.com> X-TM-AS-MML: No X-detected-operating-system: by eggs.gnu.org: Solaris 10 (1203?) X-Received-From: 210.118.77.14 Cc: peter.maydell@linaro.org, kyungmin.park@samsung.com, aliguori@us.ibm.com, Evgeny Voevodin Subject: [Qemu-devel] [RFC v2 07/12] hw/virtio-serial-bus.c: Add virtio-serial device. 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 Signed-off-by: Evgeny Voevodin --- hw/virtio-serial-bus.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-serial.h | 11 +++++++++++ 2 files changed, 55 insertions(+) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 82073f5..699a485 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -24,6 +24,7 @@ #include "sysbus.h" #include "trace.h" #include "virtio-serial.h" +#include "virtio-transport.h" /* The virtio-serial bus on top of which the ports will ride as devices */ struct VirtIOSerialBus { @@ -1014,3 +1015,46 @@ static void virtio_serial_register_types(void) } type_init(virtio_serial_register_types) + +/******************** VirtIOSer Device **********************/ + +static int virtio_serialdev_init(DeviceState *dev) +{ + VirtIODevice *vdev; + VirtIOSerState *s = VIRTIO_SERIAL_FROM_QDEV(dev); + vdev = virtio_serial_init(dev, &s->serial); + if (!vdev) { + return -1; + } + + assert(s->trl != NULL); + + return virtio_call_backend_init_cb(dev, s->trl, vdev); +} + +static Property virtio_serial_properties[] = { + DEFINE_PROP_UINT32("max_ports", VirtIOSerState, + serial.max_virtserial_ports, 31), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_serial_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + dc->init = virtio_serialdev_init; + dc->props = virtio_serial_properties; +} + +static TypeInfo virtio_serial_info = { + .name = "virtio-serial", + .parent = TYPE_DEVICE, + .instance_size = sizeof(VirtIOSerState), + .class_init = virtio_serial_class_init, +}; + +static void virtio_ser_register_types(void) +{ + type_register_static(&virtio_serial_info); +} + +type_init(virtio_ser_register_types) diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h index 16e3982..c6b916a 100644 --- a/hw/virtio-serial.h +++ b/hw/virtio-serial.h @@ -15,8 +15,10 @@ #ifndef _QEMU_VIRTIO_SERIAL_H #define _QEMU_VIRTIO_SERIAL_H +#include "sysbus.h" #include "qdev.h" #include "virtio.h" +#include "virtio-transport.h" /* == Interface shared between the guest kernel and qemu == */ @@ -173,6 +175,15 @@ struct VirtIOSerialPort { bool throttled; }; +typedef struct { + DeviceState qdev; + /* virtio-serial */ + virtio_serial_conf serial; + VirtIOTransportLink *trl; +} VirtIOSerState; + +#define VIRTIO_SERIAL_FROM_QDEV(dev) DO_UPCAST(VirtIOSerState, qdev, dev) + /* Interface to the virtio-serial bus */ /*