xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xensource.com
Cc: David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH 6/8] arm: add early_printk()
Date: Fri, 10 Feb 2012 13:03:42 +0000	[thread overview]
Message-ID: <1328879024-5621-7-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1328879024-5621-1-git-send-email-david.vrabel@citrix.com>

From: David Vrabel <david.vrabel@citrix.com>

Add early_printk() which can be used before setup_pagetables().  This
will be used when doing the early parsing of the DTB.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 xen/arch/arm/Makefile              |    1 +
 xen/arch/arm/early_printk.c        |   72 ++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/early_printk.h |   27 +++++++++++++
 3 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 xen/arch/arm/early_printk.c
 create mode 100644 xen/include/asm-arm/early_printk.h

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index ac346a5..4794cfc 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -2,6 +2,7 @@ subdir-y += lib
 
 obj-y += dtb.o
 obj-y += dummy.o
+obj-y += early_printk.o
 obj-y += entry.o
 obj-y += domain.o
 obj-y += domain_build.o
diff --git a/xen/arch/arm/early_printk.c b/xen/arch/arm/early_printk.c
new file mode 100644
index 0000000..3e51252
--- /dev/null
+++ b/xen/arch/arm/early_printk.c
@@ -0,0 +1,72 @@
+/*
+ * printk() for use before the final page tables are setup.
+ *
+ * Copyright (C) 2012 Citrix Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/stdarg.h>
+#include <xen/string.h>
+#include <asm/early_printk.h>
+
+#ifdef EARLY_UART_ADDRESS
+
+static void __init early_putch(char c)
+{
+    volatile uint32_t *r;
+
+    r = (uint32_t *)((EARLY_UART_ADDRESS & 0x001fffff)
+                     + XEN_VIRT_START + (1 << 21));
+
+    /* XXX: assuming a PL011 UART. */
+    while(*(r + 0x6) & 0x8)
+        ;
+    *r = c;
+}
+
+static void __init early_puts(const char *s)
+{
+    while (*s != '\0') {
+        if (*s == '\n')
+            early_putch('\r');
+        early_putch(*s);
+        s++;
+    }
+}
+
+static void __init early_vprintk(const char *fmt, va_list args)
+{
+    char buf[80];
+
+    vsnprintf(buf, sizeof(buf), fmt, args);
+    early_puts(buf);
+}
+
+void __init early_printk(const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    early_vprintk(fmt, args);
+    va_end(args);
+}
+
+void __attribute__((noreturn)) __init
+early_panic(const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    early_vprintk(fmt, args);
+    va_end(args);
+
+    while(1);
+}
+
+#endif /* #ifdef EARLY_UART_ADDRESS */
diff --git a/xen/include/asm-arm/early_printk.h b/xen/include/asm-arm/early_printk.h
new file mode 100644
index 0000000..f45f21e
--- /dev/null
+++ b/xen/include/asm-arm/early_printk.h
@@ -0,0 +1,27 @@
+/*
+ * printk() for use before the final page tables are setup.
+ *
+ * Copyright (C) 2012 Citrix Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __ARM_EARLY_PRINTK_H__
+#define __ARM_EARLY_PRINTK_H__
+
+#include <xen/config.h>
+
+#ifdef EARLY_UART_ADDRESS
+
+void early_printk(const char *fmt, ...);
+void early_panic(const char *fmt, ...);
+
+#else
+
+static inline void early_printk(const char *fmt, ...) {}
+static inline void early_panic(const char *fmt, ...) {}
+
+#endif
+
+#endif
-- 
1.7.2.5

  parent reply	other threads:[~2012-02-10 13:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10 13:03 [PATCH 0/8] arm: initial device tree support (#2) David Vrabel
2012-02-10 13:03 ` [PATCH 1/8] libfdt: add version 1.3.0 David Vrabel
2012-02-10 13:38   ` Ian Campbell
2012-02-10 13:03 ` [PATCH 2/8] libfdt: fixup libfdt_env.h for xen David Vrabel
2012-02-10 13:03 ` [PATCH 3/8] libfdt: add to build David Vrabel
2012-02-10 13:03 ` [PATCH 4/8] arm: link a device tree blob into the xen image David Vrabel
2012-02-10 13:35   ` Ian Campbell
2012-02-10 13:40     ` David Vrabel
2012-02-10 13:52       ` Ian Campbell
2012-02-10 16:50         ` Tim Deegan
2012-02-10 17:38           ` David Vrabel
2012-02-10 17:46             ` Ian Campbell
2012-02-10 13:03 ` [PATCH 5/8] arm: map device tree blob in initial page tables David Vrabel
2012-02-10 13:03 ` David Vrabel [this message]
2012-02-10 13:03 ` [PATCH 7/8] arm, device tree: parse the DTB for RAM location and size David Vrabel
2012-02-10 13:25   ` Tim Deegan
2012-02-10 13:03 ` [PATCH 8/8] arm: setup MM using information from the device tree David Vrabel
  -- strict thread matches above, loose matches on Subject: below --
2012-02-13 13:18 [PATCH 0/8] arm: initial device tree support (#3) David Vrabel
2012-02-13 13:18 ` [PATCH 6/8] arm: add early_printk() David Vrabel

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=1328879024-5621-7-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@citrix.com \
    --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;
as well as URLs for NNTP newsgroup(s).