summaryrefslogtreecommitdiffstats
path: root/meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch')
-rw-r--r--meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch127
1 files changed, 127 insertions, 0 deletions
diff --git a/meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch b/meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch
new file mode 100644
index 0000000000..2ac5b75dee
--- /dev/null
+++ b/meta/packages/uboot/u-boot-mkimage-openmoko-native/console-ansi.patch
@@ -0,0 +1,127 @@
1drivers/cfb_console.c: added processing of ANSI escape sequences \e[2J, \e[m,
2 \e[7m, and \e[row;colH
3drivers/cfb_console.c (video_putc): make \r return to the beginning of the line
4
5- Werner Almesberger <werner@openmoko.org>
6
7Index: u-boot/drivers/cfb_console.c
8===================================================================
9--- u-boot.orig/drivers/cfb_console.c
10+++ u-boot/drivers/cfb_console.c
11@@ -181,6 +181,7 @@ CONFIG_VIDEO_HW_CURSOR: - Uses the
12
13 #include <version.h>
14 #include <linux/types.h>
15+#include <linux/ctype.h>
16 #include <devices.h>
17 #include <video_font.h>
18 #ifdef CFG_CMD_DATE
19@@ -676,10 +677,96 @@ static void console_newline (void)
20
21 /*****************************************************************************/
22
23+static enum {
24+ CS_NORMAL = 0,
25+ CS_ESC,
26+ CS_NUM1,
27+ CS_NUM2,
28+} state = 0;
29+
30+static int num1, num2;
31+
32+
33+static void swap_drawing_colors(void)
34+{
35+ eorx = fgx;
36+ fgx = bgx;
37+ bgx = eorx;
38+ eorx = fgx ^ bgx;
39+}
40+
41+
42+static void process_sequence(char c)
43+{
44+ static int inverted = 0;
45+ int i, inv;
46+
47+ switch (c) {
48+ case 'J':
49+ /* assume num1 == 2 */
50+ for (i = 0; i != CONSOLE_ROWS; i++)
51+ console_scrollup();
52+ break;
53+ case 'H':
54+ if (num1 > CONSOLE_ROWS || num2 > CONSOLE_COLS)
55+ break;
56+ console_col = num2 ? num2-1 : 0;
57+ console_row = num1 ? num1-1 : 0;
58+ break;
59+ case 'm':
60+ inv = num1 == 7;
61+ if (num1 && !inv)
62+ break;
63+ if (inverted != inv)
64+ swap_drawing_colors();
65+ inverted = inv;
66+ break;
67+ }
68+}
69+
70+
71+static void escape_sequence(char c)
72+{
73+ switch (state) {
74+ case CS_ESC:
75+ state = c == '[' ? CS_NUM1 : CS_NORMAL;
76+ num1 = num2 = 0;
77+ break;
78+ case CS_NUM1:
79+ if (isdigit(c))
80+ num1 = num1*10+c-'0';
81+ else if (c == ';')
82+ state = CS_NUM2;
83+ else {
84+ process_sequence(c);
85+ state = CS_NORMAL;
86+ }
87+ break;
88+ case CS_NUM2:
89+ if (isdigit(c))
90+ num2 = num2*10+c-'0';
91+ else {
92+ process_sequence(c);
93+ state = CS_NORMAL;
94+ }
95+ default:
96+ /* can't happen */;
97+ }
98+}
99+
100+
101 void video_putc (const char c)
102 {
103+ if (state) {
104+ escape_sequence(c);
105+ CURSOR_SET;
106+ return;
107+ }
108+
109 switch (c) {
110- case 13: /* ignore */
111+ case 13: /* return to beginning of line */
112+ CURSOR_OFF;
113+ console_col = 0;
114 break;
115
116 case '\n': /* next line */
117@@ -698,6 +785,10 @@ void video_putc (const char c)
118 console_back ();
119 break;
120
121+ case '\e':
122+ state = CS_ESC;
123+ break;
124+
125 default: /* draw the char */
126 video_putchar (console_col * VIDEO_FONT_WIDTH,
127 console_row * VIDEO_FONT_HEIGHT,