1
2
3
4
5
6
7
8
9
10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/console.h>
13#include <linux/string.h>
14#include <asm/blackfin.h>
15#include <asm/irq_handler.h>
16#include <asm/early_printk.h>
17
18#define SHADOW_CONSOLE_START (CONFIG_PHY_RAM_BASE_ADDRESS + 0x500)
19#define SHADOW_CONSOLE_END (CONFIG_PHY_RAM_BASE_ADDRESS + 0x1000)
20#define SHADOW_CONSOLE_MAGIC_LOC (CONFIG_PHY_RAM_BASE_ADDRESS + 0x4F0)
21#define SHADOW_CONSOLE_MAGIC (0xDEADBEEF)
22
23static __initdata char *shadow_console_buffer = (char *)SHADOW_CONSOLE_START;
24
25__init void early_shadow_write(struct console *con, const char *s,
26 unsigned int n)
27{
28 unsigned int i;
29
30
31
32
33 if ((shadow_console_buffer + n) <= (char *)(SHADOW_CONSOLE_END - 2)) {
34
35 for (i = 0; i <= n; i++)
36 shadow_console_buffer[i] = s[i];
37 shadow_console_buffer += n;
38 shadow_console_buffer[0] = 0;
39 shadow_console_buffer[1] = 0;
40 } else
41 shadow_console_buffer = (char *)SHADOW_CONSOLE_END;
42}
43
44static __initdata struct console early_shadow_console = {
45 .name = "early_shadow",
46 .write = early_shadow_write,
47 .flags = CON_BOOT | CON_PRINTBUFFER,
48 .index = -1,
49 .device = 0,
50};
51
52__init int shadow_console_enabled(void)
53{
54 return early_shadow_console.flags & CON_ENABLED;
55}
56
57__init void mark_shadow_error(void)
58{
59 int *loc = (int *)SHADOW_CONSOLE_MAGIC_LOC;
60 loc[0] = SHADOW_CONSOLE_MAGIC;
61 loc[1] = SHADOW_CONSOLE_START;
62}
63
64__init void enable_shadow_console(void)
65{
66 if (!shadow_console_enabled()) {
67 register_console(&early_shadow_console);
68
69 mark_shadow_error();
70 }
71}
72
73static __init int disable_shadow_console(void)
74{
75
76
77
78
79
80
81 int *loc = (int *)SHADOW_CONSOLE_MAGIC_LOC;
82
83 loc[0] = 0;
84
85 return 0;
86}
87pure_initcall(disable_shadow_console);
88
89
90
91
92__init void early_shadow_reg(unsigned long reg, unsigned int n)
93{
94
95
96
97
98 int i;
99 char ascii[11] = " 0x";
100
101 n = n / 4;
102 reg = reg << ((8 - n) * 4);
103 n += 3;
104
105 for (i = 3; i <= n ; i++) {
106 ascii[i] = hex_asc_lo(reg >> 28);
107 reg <<= 4;
108 }
109 early_shadow_write(NULL, ascii, n);
110
111}
112