From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCH 6/7] arm: add early_printk() Date: Fri, 3 Feb 2012 19:15:14 +0000 Message-ID: <1328296515-25876-7-git-send-email-david.vrabel@citrix.com> References: <1328296515-25876-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1328296515-25876-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: David Vrabel List-Id: xen-devel@lists.xenproject.org From: David Vrabel 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 --- 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..1d9787b --- /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 +#include +#include +#include +#include +#include + +#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)); + + /* FIXME: 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 + +#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