1 /*
2  * printk() for use before the final page tables are setup.
3  *
4  * Copyright (C) 2012 Citrix Systems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #ifndef __ARM_EARLY_PRINTK_H__
11 #define __ARM_EARLY_PRINTK_H__
12 
13 #include <xen/page-size.h>
14 #include <asm/fixmap.h>
15 #include <asm/mpu.h>
16 
17 #ifdef CONFIG_EARLY_PRINTK
18 
19 #if defined(CONFIG_MPU)
20 
21 /*
22  * For MPU systems, there is no VMSA support in EL2, so we use VA == PA
23  * for EARLY_UART_VIRTUAL_ADDRESS.
24  */
25 #define EARLY_UART_VIRTUAL_ADDRESS CONFIG_EARLY_UART_BASE_ADDRESS
26 
27 /*
28  * User-defined EARLY_UART_BASE_ADDRESS and EARLY_UART_SIZE must be aligned to
29  * minimum size of MPU region.
30  */
31 #if (CONFIG_EARLY_UART_BASE_ADDRESS % MPU_REGION_ALIGN) != 0
32 #error "EARLY_UART_BASE_ADDRESS must be aligned to minimum MPU region size"
33 #endif
34 
35 #if (CONFIG_EARLY_UART_SIZE % MPU_REGION_ALIGN) != 0
36 #error "EARLY_UART_SIZE must be aligned to minimum MPU region size"
37 #endif
38 
39 #elif defined(CONFIG_MMU)
40 
41 /* need to add the uart address offset in page to the fixmap address */
42 #define EARLY_UART_VIRTUAL_ADDRESS \
43     (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
44 
45 #define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
46     (TEMPORARY_FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
47 
48 #else
49 #error "Unknown Memory management system"
50 #endif
51 
52 #endif /* !CONFIG_EARLY_PRINTK */
53 #endif
54