From: David Vrabel Date: Mon, 13 Feb 2012 14:24:49 +0000 (+0000) Subject: arm: add early_printk() X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c5a41f505852d764e96cbbbd17cfee460c822278;p=xen.git arm: add early_printk() 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 Acked-by: Tim Deegan Committed-by: Ian Campbell --- diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index b4dd3b1268..168716e16a 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -1,6 +1,7 @@ subdir-y += lib 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 0000000000..3e51252dc1 --- /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)); + + /* 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 0000000000..f45f21e655 --- /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