All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel Developers <qemu-devel@nongnu.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 32/40] xenner: emudev
Date: Mon,  1 Nov 2010 16:01:45 +0100	[thread overview]
Message-ID: <1288623713-28062-33-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1288623713-28062-1-git-send-email-agraf@suse.de>

Xenner uses its own special PV device to communicate between qemu and the
guest xenner kernel. This patch implements that device.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xenner_emudev.c |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xenner_emudev.h |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 215 insertions(+), 0 deletions(-)
 create mode 100644 hw/xenner_emudev.c
 create mode 100644 hw/xenner_emudev.h

diff --git a/hw/xenner_emudev.c b/hw/xenner_emudev.c
new file mode 100644
index 0000000..dea617e
--- /dev/null
+++ b/hw/xenner_emudev.c
@@ -0,0 +1,107 @@
+/*
+ *  Copyright (C) Red Hat 2007
+ *  Copyright (C) Novell Inc. 2010
+ *
+ *  Author(s): Gerd Hoffmann <kraxel@redhat.com>
+ *             Alexander Graf <agraf@suse.de>
+ *
+ *  Xenner communication device
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <inttypes.h>
+
+#include "xenner_emudev.h"
+
+void emudev_write_entry(struct emudev_state *e, uint32_t value)
+{
+    e->entry = value;
+}
+
+void emudev_write_value(struct emudev_state *e, uint32_t value)
+{
+    uint16_t type, index;
+    int high_32;
+
+    type = e->entry >> 16;
+    high_32 = type & EMUDEV_CONF_HIGH_32;
+    type &= ~EMUDEV_CONF_HIGH_32;
+    index = e->entry & 0xffff;
+    switch (type) {
+    case EMUDEV_CONF_GRANT_TABLE_PFNS:
+        if (index < EMUDEV_CONF_GRANT_TABLE_COUNT)
+            e->gnttab[index] = value;
+        break;
+    case EMUDEV_CONF_EVTCHN_TO_PIN:
+        if (index < EMUDEV_CONF_EVTCHN_TO_PIN_COUNT)
+            e->evtchn[index] = value;
+        break;
+    case EMUDEV_CONF_COMMAND_RESULT:
+        if (index < EMUDEV_CONF_COMMAND_RESULT_COUNT)
+            e->result[index] = value;
+        break;
+    default:
+        if (type >= EMUDEV_CONF_SIMPLE_COUNT) {
+            break;
+        }
+        if (high_32) {
+            e->config[type] = (e->config[type] & 0x00000000ffffffffULL)
+                            | ((uint64_t)value << 32);
+        } else {
+            e->config[type] = (e->config[type] & 0xffffffff00000000ULL)
+                            | ((uint64_t)value);
+        }
+        break;
+    }
+}
+
+uint32_t emudev_read_value(struct emudev_state *e)
+{
+    uint16_t type, index;
+    int high_32;
+    uint64_t r = -1;
+
+    type = e->entry >> 16;
+    high_32 = type & EMUDEV_CONF_HIGH_32;
+    type &= ~EMUDEV_CONF_HIGH_32;
+    index = e->entry & 0xffff;
+    switch (type) {
+    case EMUDEV_CONF_GRANT_TABLE_PFNS:
+        if (index < EMUDEV_CONF_GRANT_TABLE_COUNT) {
+            r = e->gnttab[index];
+        }
+        break;
+    case EMUDEV_CONF_EVTCHN_TO_PIN:
+        if (index < EMUDEV_CONF_EVTCHN_TO_PIN_COUNT) {
+            r = e->evtchn[index];
+        }
+        break;
+    case EMUDEV_CONF_COMMAND_RESULT:
+        if (index < EMUDEV_CONF_COMMAND_RESULT_COUNT) {
+            r = e->result[index];
+        }
+        break;
+    default:
+        if (type < EMUDEV_CONF_SIMPLE_COUNT) {
+            r = e->config[type];
+        }
+        break;
+    }
+
+    if (high_32) {
+        return (uint32_t)(r >> 32);
+    }
+
+    return (uint32_t)r;
+}
diff --git a/hw/xenner_emudev.h b/hw/xenner_emudev.h
new file mode 100644
index 0000000..e6b8676
--- /dev/null
+++ b/hw/xenner_emudev.h
@@ -0,0 +1,108 @@
+/*
+ *  Copyright (C) Red Hat 2007
+ *  Copyright (C) Novell Inc. 2010
+ *
+ *  Author(s): Gerd Hoffmann <kraxel@redhat.com>
+ *             Alexander Graf <agraf@suse.de>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __XENNER_EMUDEV_H__
+#define __XENNER_EMUDEV_H__ 1
+
+/*
+ * I/O ports for the virtual emu device
+ *     - CONF_ENTRY (write)
+ *       bits 31 .. 16  --  config type
+ *       bits 15 ..  0  --  config index
+ *     - CONF_VALUE (read/write)
+ *       32bit config value
+ *     - COMMAND (write)
+ *       bits 32 .. 16  --  command
+ *       bits 15 ..  0  --  argument
+ */
+#define EMUDEV_REG_BASE                      (0xe0)
+#define EMUDEV_REG_CONF_ENTRY                (EMUDEV_REG_BASE)
+#define EMUDEV_REG_CONF_VALUE                (EMUDEV_REG_BASE+4)
+#define EMUDEV_REG_COMMAND                   (EMUDEV_REG_BASE+8)
+#define EMUDEV_REG_RESERVED                  (EMUDEV_REG_BASE+12)
+
+/* simple entries, read */
+#define EMUDEV_CONF_DEBUG_LEVEL              0x00
+#define EMUDEV_CONF_EMU_START_PFN            0x01
+#define EMUDEV_CONF_EMU_PAGE_COUNT           0x02
+#define EMUDEV_CONF_M2P_START_PFN            0x03
+#define EMUDEV_CONF_M2P_PAGE_COUNT           0x04
+#define EMUDEV_CONF_GUEST_START_PFN          0x05
+#define EMUDEV_CONF_GUEST_PAGE_COUNT         0x06
+#define EMUDEV_CONF_TOTAL_PAGE_COUNT         0x07
+#define EMUDEV_CONF_NR_VCPUS                 0x08
+#define EMUDEV_CONF_HVM_XENSTORE_PFN         0x09
+#define EMUDEV_CONF_HVM_XENSTORE_EVTCHN      0x0a
+#define EMUDEV_CONF_MFN_CONSOLE              0x0b
+#define EMUDEV_CONF_MFN_XENSTORE             0x0c
+#define EMUDEV_CONF_PFN_START_INFO           0x0d
+#define EMUDEV_CONF_PV_VIRT_ENTRY            0x10
+#define EMUDEV_CONF_PV_VIRT_BASE             0x11
+#define EMUDEV_CONF_HYPERCALL_PAGE           0x12
+#define EMUDEV_CONF_EVTCH_CONSOLE            0x13
+#define EMUDEV_CONF_EVTCH_XENSTORE           0x14
+#define EMUDEV_CONF_PFN_INIT_PT              0x15
+#define EMUDEV_CONF_PFN_CMDLINE              0x16
+#define EMUDEV_CONF_PFN_INITRD               0x17
+#define EMUDEV_CONF_INITRD_LEN               0x18
+#define EMUDEV_CONF_PFN_MFN_LIST             0x19
+/* simple entries, write */
+#define EMUDEV_CONF_BOOT_CTXT_PFN            0x40
+#define EMUDEV_CONF_NEXT_SECONDARY_VCPU      0x42
+#define EMUDEV_CONF_HVM_CALLBACK_IRQ         0x43
+#define EMUDEV_CONF_VMINFO_PFN               0x70 /* temporary */
+/* simple count */
+#define EMUDEV_CONF_SIMPLE_COUNT             0x80
+/* high dword marker */
+#define EMUDEV_CONF_HIGH_32                  0x8000
+
+/* indexed config entries */
+#define EMUDEV_CONF_GRANT_TABLE_PFNS         0x80
+#define EMUDEV_CONF_GRANT_TABLE_COUNT        16
+#define EMUDEV_CONF_EVTCHN_TO_PIN            0x81
+#define EMUDEV_CONF_EVTCHN_TO_PIN_COUNT      64
+#define EMUDEV_CONF_COMMAND_RESULT           0x82
+#define EMUDEV_CONF_COMMAND_RESULT_COUNT     64
+
+/* commands */
+#define EMUDEV_CMD_NOP                       1
+#define EMUDEV_CMD_WRITE_CHAR                2
+#define EMUDEV_CMD_CONFIGURATION_DONE        3
+#define EMUDEV_CMD_EVTCHN_ALLOC              4
+#define EMUDEV_CMD_EVTCHN_SEND               5
+#define EMUDEV_CMD_INIT_SECONDARY_VCPU       6
+#define EMUDEV_CMD_GUEST_SHUTDOWN            7
+#define EMUDEV_CMD_EVTCHN_CLOSE              8
+
+/* --------- host side bits --------- */
+
+struct emudev_state {
+    uint32_t   entry;
+    uint64_t   config[EMUDEV_CONF_SIMPLE_COUNT];
+    uint32_t   gnttab[EMUDEV_CONF_GRANT_TABLE_COUNT];
+    uint32_t   evtchn[EMUDEV_CONF_EVTCHN_TO_PIN_COUNT];
+    uint32_t   result[EMUDEV_CONF_COMMAND_RESULT_COUNT];
+};
+
+void emudev_write_entry(struct emudev_state *e, uint32_t value);
+void emudev_write_value(struct emudev_state *e, uint32_t value);
+uint32_t emudev_read_value(struct emudev_state *e);
+
+#endif /* __XENNER_EMUDEV_H__ */
-- 
1.6.0.2

  parent reply	other threads:[~2010-11-01 15:02 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 15:01 [Qemu-devel] [PATCH 00/40] RFC: Xenner Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 01/40] elf: Move translate_fn to helper struct Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 02/40] elf: Add notes implementation Alexander Graf
2010-11-01 18:29   ` Blue Swirl
2010-11-01 18:42     ` Stefan Weil
2010-11-01 19:51       ` Alexander Graf
2010-11-01 20:19         ` Stefan Weil
2010-11-01 21:17           ` Alexander Graf
2010-11-01 21:28             ` [Qemu-devel] " Paolo Bonzini
2010-11-01 21:31             ` [Qemu-devel] " Stefan Weil
2010-11-02 10:17             ` Michael Matz
2010-11-01 18:41   ` [Qemu-devel] " Paolo Bonzini
2010-11-01 18:52     ` Alexander Graf
2010-11-01 19:43       ` Paolo Bonzini
2010-11-01 19:48         ` Alexander Graf
2010-11-01 21:23           ` Paolo Bonzini
2010-11-01 15:01 ` [Qemu-devel] [PATCH 03/40] elf: add header notification Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 04/40] elf: add section analyzer Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 05/40] xen-disk: disable aio Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 06/40] qdev-ify: xen backends Alexander Graf
2010-11-02 10:08   ` Markus Armbruster
2010-11-02 10:43     ` Gerd Hoffmann
2010-11-02 13:26       ` Markus Armbruster
2010-11-01 15:01 ` [Qemu-devel] [PATCH 07/40] xenner: kernel: 32 bit files Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 08/40] xenner: kernel: 64-bit files Alexander Graf
2010-11-01 15:44   ` Anthony Liguori
2010-11-01 15:47     ` Alexander Graf
2010-11-01 15:59       ` Anthony Liguori
2010-11-01 19:00       ` Blue Swirl
2010-11-01 19:02         ` Anthony Liguori
2010-11-01 19:05           ` Alexander Graf
2010-11-01 19:23             ` Blue Swirl
2010-11-01 19:37             ` Anthony Liguori
2010-11-01 15:01 ` [Qemu-devel] [PATCH 09/40] xenner: kernel: Global data Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 10/40] xenner: kernel: Hypercall handler (i386) Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 11/40] xenner: kernel: Hypercall handler (x86_64) Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 12/40] xenner: kernel: Hypercall handler (generic) Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 13/40] xenner: kernel: Headers Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 14/40] xenner: kernel: Instruction emulator Alexander Graf
2010-11-01 15:41   ` malc
2010-11-01 18:46   ` [Qemu-devel] " Paolo Bonzini
2010-11-01 15:01 ` [Qemu-devel] [PATCH 15/40] xenner: kernel: lapic code Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 16/40] xenner: kernel: Main (i386) Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 17/40] xenner: kernel: Main (x86_64) Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 18/40] xenner: kernel: Main Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 19/40] xenner: kernel: Makefile Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 20/40] xenner: kernel: mmu support for 32-bit PAE Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 21/40] xenner: kernel: mmu support for 32-bit normal Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 22/40] xenner: kernel: mmu support for 64-bit Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 23/40] xenner: kernel: generic MM functionality Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 24/40] xenner: kernel: printk Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 25/40] xenner: kernel: KVM PV code Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 26/40] xenner: kernel: xen-names Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 27/40] xenner: add xc_dom.h Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 28/40] xenner: libxc emu: evtchn Alexander Graf
2010-11-01 15:45   ` Anthony Liguori
2010-11-01 15:49     ` Alexander Graf
2010-11-01 16:01       ` Anthony Liguori
2010-11-01 16:07         ` Alexander Graf
2010-11-01 16:14           ` Anthony Liguori
2010-11-01 16:15             ` Alexander Graf
2010-11-01 19:39         ` [Qemu-devel] " Paolo Bonzini
2010-11-01 19:41           ` Anthony Liguori
2010-11-01 19:47             ` Alexander Graf
2010-11-01 20:32               ` Anthony Liguori
2010-11-01 21:47                 ` Paolo Bonzini
2010-11-01 22:00                   ` Anthony Liguori
2010-11-01 22:08                     ` Paolo Bonzini
2010-11-01 22:29                       ` Anthony Liguori
2010-11-02  4:33                 ` Stefano Stabellini
2010-11-02 10:06                   ` Paolo Bonzini
2010-11-02 10:31                     ` Gerd Hoffmann
2010-11-02 10:38                       ` Paolo Bonzini
2010-11-02 13:55                     ` Stefano Stabellini
2010-11-02 15:48                       ` Alexander Graf
2010-11-02 19:20                         ` Stefano Stabellini
2010-11-01 15:01 ` [Qemu-devel] [PATCH 29/40] xenner: libxc emu: grant tables Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 30/40] xenner: libxc emu: memory mapping Alexander Graf
2010-11-01 15:12   ` malc
2010-11-01 15:15     ` Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 31/40] xenner: libxc emu: xenstore Alexander Graf
2010-11-01 18:36   ` Blue Swirl
2010-11-01 15:01 ` Alexander Graf [this message]
2010-11-01 15:01 ` [Qemu-devel] [PATCH 33/40] xenner: core Alexander Graf
2010-11-01 15:13   ` malc
2010-11-01 15:01 ` [Qemu-devel] [PATCH 34/40] xenner: PV machine Alexander Graf
2010-11-01 15:01 ` [Qemu-devel] [PATCH 35/40] xenner: Domain Builder Alexander Graf
2010-11-02 10:09   ` [Qemu-devel] " Paolo Bonzini
2010-11-02 15:36     ` Alexander Graf
2010-11-02 15:51       ` Paolo Bonzini
2010-11-02 16:28         ` Alexander Graf
2010-11-01 15:21 ` [Qemu-devel] [PATCH 00/40] RFC: Xenner Alexander Graf
2010-11-02 16:26 ` [Qemu-devel] [PATCH 36/40] xen: only create dummy env when necessary Alexander Graf
2010-11-02 16:26 ` [Qemu-devel] [PATCH 38/40] xenner: integrate into build system Alexander Graf
2010-11-02 16:26 ` [Qemu-devel] [PATCH 39/40] xenner: integrate into xen pv machine Alexander Graf
2010-11-02 16:26 ` [Qemu-devel] [PATCH 40/40] xen: add sysrq support Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288623713-28062-33-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.