From: Jeremy Fitzhardinge <jeremy@goop.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: the arch/x86 maintainers <x86@kernel.org>,
Ingo Molnar <mingo@elte.hu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Xen-devel <xen-devel@lists.xensource.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
Juan Quintela <quintela@redhat.com>
Subject: [PATCH 01/15] xen dom0: Make hvc_xen console work for dom0.
Date: Mon, 23 Mar 2009 11:09:45 -0700 [thread overview]
Message-ID: <1237831799-6568-2-git-send-email-jeremy@goop.org> (raw)
In-Reply-To: <49C45238.7050007@zytor.com>
Impact: Add Xen dom0 console
Use the console hypercalls for dom0 console.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
drivers/char/hvc_xen.c | 101 ++++++++++++++++++++++++++++++++----------------
drivers/xen/events.c | 2 +-
include/xen/events.h | 2 +
3 files changed, 70 insertions(+), 35 deletions(-)
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index eba999f..81d9186 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -55,7 +55,7 @@ static inline void notify_daemon(void)
notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
}
-static int write_console(uint32_t vtermno, const char *data, int len)
+static int domU_write_console(uint32_t vtermno, const char *data, int len)
{
struct xencons_interface *intf = xencons_interface();
XENCONS_RING_IDX cons, prod;
@@ -76,7 +76,7 @@ static int write_console(uint32_t vtermno, const char *data, int len)
return sent;
}
-static int read_console(uint32_t vtermno, char *buf, int len)
+static int domU_read_console(uint32_t vtermno, char *buf, int len)
{
struct xencons_interface *intf = xencons_interface();
XENCONS_RING_IDX cons, prod;
@@ -97,28 +97,63 @@ static int read_console(uint32_t vtermno, char *buf, int len)
return recv;
}
-static struct hv_ops hvc_ops = {
- .get_chars = read_console,
- .put_chars = write_console,
+static struct hv_ops domU_hvc_ops = {
+ .get_chars = domU_read_console,
+ .put_chars = domU_write_console,
.notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq,
};
-static int __init xen_init(void)
+static int dom0_read_console(uint32_t vtermno, char *buf, int len)
+{
+ return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
+}
+
+/*
+ * Either for a dom0 to write to the system console, or a domU with a
+ * debug version of Xen
+ */
+static int dom0_write_console(uint32_t vtermno, const char *str, int len)
+{
+ int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
+ if (rc < 0)
+ return 0;
+
+ return len;
+}
+
+static struct hv_ops dom0_hvc_ops = {
+ .get_chars = dom0_read_console,
+ .put_chars = dom0_write_console,
+ .notifier_add = notifier_add_irq,
+ .notifier_del = notifier_del_irq,
+ .notifier_hangup = notifier_hangup_irq,
+};
+
+static int __init xen_hvc_init(void)
{
struct hvc_struct *hp;
+ struct hv_ops *ops;
- if (!xen_pv_domain() ||
- xen_initial_domain() ||
- !xen_start_info->console.domU.evtchn)
- return -ENODEV;
+ if (!xen_pv_domain())
+ return -ENODEV;
+
+ if (xen_initial_domain()) {
+ ops = &dom0_hvc_ops;
+ xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
+ } else {
+ if (!xen_start_info->console.domU.evtchn)
+ return -ENODEV;
+
+ ops = &domU_hvc_ops;
+ xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
+ }
- xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
if (xencons_irq < 0)
xencons_irq = 0; /* NO_IRQ */
- hp = hvc_alloc(HVC_COOKIE, xencons_irq, &hvc_ops, 256);
+ hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
if (IS_ERR(hp))
return PTR_ERR(hp);
@@ -135,7 +170,7 @@ void xen_console_resume(void)
rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq);
}
-static void __exit xen_fini(void)
+static void __exit xen_hvc_fini(void)
{
if (hvc)
hvc_remove(hvc);
@@ -143,29 +178,24 @@ static void __exit xen_fini(void)
static int xen_cons_init(void)
{
+ struct hv_ops *ops;
+
if (!xen_pv_domain())
return 0;
- hvc_instantiate(HVC_COOKIE, 0, &hvc_ops);
+ ops = &domU_hvc_ops;
+ if (xen_initial_domain())
+ ops = &dom0_hvc_ops;
+
+ hvc_instantiate(HVC_COOKIE, 0, ops);
+
return 0;
}
-module_init(xen_init);
-module_exit(xen_fini);
+module_init(xen_hvc_init);
+module_exit(xen_hvc_fini);
console_initcall(xen_cons_init);
-static void raw_console_write(const char *str, int len)
-{
- while(len > 0) {
- int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
- if (rc <= 0)
- break;
-
- str += rc;
- len -= rc;
- }
-}
-
#ifdef CONFIG_EARLY_PRINTK
static void xenboot_write_console(struct console *console, const char *string,
unsigned len)
@@ -173,19 +203,22 @@ static void xenboot_write_console(struct console *console, const char *string,
unsigned int linelen, off = 0;
const char *pos;
- raw_console_write(string, len);
+ dom0_write_console(0, string, len);
+
+ if (xen_initial_domain())
+ return;
- write_console(0, "(early) ", 8);
+ domU_write_console(0, "(early) ", 8);
while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
linelen = pos-string+off;
if (off + linelen > len)
break;
- write_console(0, string+off, linelen);
- write_console(0, "\r\n", 2);
+ domU_write_console(0, string+off, linelen);
+ domU_write_console(0, "\r\n", 2);
off += linelen + 1;
}
if (off < len)
- write_console(0, string+off, len-off);
+ domU_write_console(0, string+off, len-off);
}
struct console xenboot_console = {
@@ -197,7 +230,7 @@ struct console xenboot_console = {
void xen_raw_console_write(const char *str)
{
- raw_console_write(str, strlen(str));
+ dom0_write_console(0, str, strlen(str));
}
void xen_raw_printk(const char *fmt, ...)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 30963af..f46e880 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -404,7 +404,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
}
-static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
+int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
{
struct evtchn_bind_virq bind_virq;
int evtchn, irq;
diff --git a/include/xen/events.h b/include/xen/events.h
index 0d5f1ad..0397ba1 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -12,6 +12,8 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
irq_handler_t handler,
unsigned long irqflags, const char *devname,
void *dev_id);
+int bind_virq_to_irq(unsigned int virq, unsigned int cpu);
+
int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
irq_handler_t handler,
unsigned long irqflags, const char *devname,
--
1.6.0.6
next prev parent reply other threads:[~2009-03-23 18:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <49C28AC2.4010407@goop.org>
[not found] ` <49C29381.9050201@zytor.com>
[not found] ` <49C29983.3040305@goop.org>
[not found] ` <49C2ABCA.6010009@zytor.com>
[not found] ` <49C43D31.7040805@goop.org>
[not found] ` <49C45238.7050007@zytor.com>
2009-03-23 17:38 ` [GIT PULL] x86/paravirt: allow preemption while doing lazy mmu update Jeremy Fitzhardinge
2009-03-23 17:45 ` [GIT PULL] core Xen updates for 2.6.30 Jeremy Fitzhardinge
2009-03-23 17:55 ` [GIT PULL] xen domU control interfaces Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 01/11] xen: add irq_from_evtchn Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 02/11] xen: add /dev/xen/evtchn driver Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 03/11] xen: export ioctl headers to userspace Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 04/11] xen/dev-evtchn: clean up locking in evtchn Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 05/11] xen: add "capabilities" file Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 06/11] xen: add /sys/hypervisor support Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 07/11] xen/sys/hypervisor: change writable_pt to features Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 08/11] xen: drop kexec bits from /sys/hypervisor since kexec isn't implemented yet Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 09/11] xen: remove suspend_cancel hook Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 10/11] xen: use device model for suspending xenbus devices Jeremy Fitzhardinge
2009-03-23 17:55 ` [PATCH 11/11] xen/xenbus: export xenbus_dev_changed Jeremy Fitzhardinge
2009-03-23 18:09 ` [GIT PULL] xen/dom0: core dom0 support Jeremy Fitzhardinge
2009-03-23 18:09 ` Jeremy Fitzhardinge [this message]
2009-03-23 18:09 ` [PATCH 02/15] xen dom0: Initialize xenbus for dom0 Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 03/15] xen dom0: Set up basic IO permissions " Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 04/15] xen dom0: Add support for the platform_ops hypercall Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 05/15] xen mtrr: Add mtrr_ops support for Xen mtrr Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 06/15] xen: disable PAT Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 07/15] xen/dom0: use _PAGE_IOMAP in ioremap to do machine mappings Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 08/15] xen/dom0: Use host E820 map Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 09/15] xen: implement XENMEM_machphys_mapping Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 10/15] xen: clear reserved bits in l3 entries given in the initial pagetables Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 11/15] xen: allow enable use of VGA console on dom0 Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 12/15] xen/dom0: add XEN_DOM0 config option Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 13/15] x86: make /dev/mem mappings _PAGE_IOMAP Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 14/15] paravirtualize IO permission bitmap Jeremy Fitzhardinge
2009-03-23 18:09 ` [PATCH 15/15] x86: don't need "changed" parameter for set_io_bitmap() Jeremy Fitzhardinge
2009-03-13 16:29 [GIT PULL] Xen dom0 core changes Jeremy Fitzhardinge
2009-03-13 16:29 ` [PATCH 01/15] xen dom0: Make hvc_xen console work for dom0 Jeremy Fitzhardinge
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=1237831799-6568-2-git-send-email-jeremy@goop.org \
--to=jeremy@goop.org \
--cc=hpa@zytor.com \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=quintela@redhat.com \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox