Here's the latest work Patrick and I did on libpayload..
libpayload-config.diff: add default config file libpayload-curses.diff: tinycurses enhancements libpayload-keyboard.diff: keymap support and reset handler libpayload-options.diff: fixes to get_option libpayload-strings.diff: strsep function and comments libpayload-usb.diff: add a prototype libpayload-vgacursor.diff: block cursor support
See patch
Add default config file to libpayload so that one can do make defconfig without errors.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Good catch.
Acked-by: Uwe Hermann uwe@hermann-uwe.de
Uwe.
See patch
On 26/09/08 01:18 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
- factor out serial hardware init
- add reverse color support for serial
- add cursor enable/disable support for serial
- fix tinycurses compilation if serial is disabled
- add functions to query whether serial or vga console is enabled in tinycurses
- initialize uninitialized COLOR_PAIRS variable
- implement has_colors(), wredrawln() functions in curses
Signed-off-by: Stefan Reinauer stepan@coresystems.de
There is a lot going on here - but it looks good, and I asssume you have tested it.
Acked-by: Jordan Crouse jordan.crouse@amd.com
Index: include/libpayload.h
--- include/libpayload.h (revision 3600) +++ include/libpayload.h (working copy) @@ -131,15 +142,19 @@
- @{
*/ void serial_init(void); +void serial_hardware_init(int port, int speed, int word_bits, int parity, int stop_bits); void serial_putchar(unsigned char c); int serial_havechar(void); int serial_getchar(void); void serial_clear(void); void serial_start_bold(void); void serial_end_bold(void); +void serial_start_reverse(void); +void serial_end_reverse(void); void serial_start_altcharset(void); void serial_end_altcharset(void); void serial_set_color(short fg, short bg); +void serial_cursor_enable(int state); void serial_set_cursor(int y, int x); /** @} */
Index: include/curses.h
--- include/curses.h (revision 3600) +++ include/curses.h (working copy) @@ -1673,4 +1673,7 @@ void curses_enable_vga(int); void curses_enable_serial(int);
+int curses_vga_enabled(void); +int curses_serial_enabled(void);
#endif /* _CURSES_H */ Index: curses/keyboard.c =================================================================== --- curses/keyboard.c (revision 3600) +++ curses/keyboard.c (working copy) @@ -44,6 +44,7 @@
/* ============== Serial ==================== */
+#ifdef CONFIG_SERIAL_CONSOLE /* We treat serial like a vt100 terminal. For now we do the cooking in here, but we should probably eventually pass it to dedicated vt100 code */ @@ -135,6 +136,7 @@ return ch; } } +#endif
/* ================ Keyboard ================ */
@@ -215,8 +217,14 @@ else curses_flags &= ~F_ENABLE_CONSOLE; }
+int curses_vga_enabled(void) +{
- return (curses_flags & F_ENABLE_CONSOLE) != 0;
+} #else void curses_enable_vga(int state) { } +int curses_vga_enabled(void) { return 0; } #endif
#ifdef CONFIG_SERIAL_CONSOLE @@ -227,7 +235,14 @@ else curses_flags &= ~F_ENABLE_SERIAL; }
+int curses_serial_enabled(void) +{
- return (curses_flags & F_ENABLE_SERIAL) != 0;
+}
#else void curses_enable_serial(int state) { } +int curses_serial_enabled(void) { return 0; } #endif
Index: curses/tinycurses.c
--- curses/tinycurses.c (revision 3600) +++ curses/tinycurses.c (working copy) @@ -77,7 +77,7 @@
/* Globals */ int COLORS; /* Currently unused? */ -int COLOR_PAIRS; +int COLOR_PAIRS = 255; WINDOW *stdscr; WINDOW *curscr; WINDOW *newscr; @@ -111,6 +111,7 @@ '|', '<', '>', '*', '!', 'f', 'o', ' ', };
+#ifdef CONFIG_SERIAL_CONSOLE #ifdef CONFIG_SERIAL_ACS_FALLBACK chtype serial_acs_map[128]; #else @@ -135,7 +136,9 @@ 'x', 'y', 'z', '{', '|', '}', '~', 0, }; #endif +#endif
+#ifdef CONFIG_VIDEO_CONSOLE /* See acsc of linux. */ chtype console_acs_map[128] = { @@ -156,6 +159,7 @@ '\304', '\304', '\304', '_', '\303', '\264', '\301', '\302', '\263', '\363', '\362', '\343', '\330', '\234', '\376', 0, }; +#endif
// FIXME: Ugly (and insecure!) hack! char sprintf_tmp[1024]; @@ -196,13 +200,16 @@ // int color_content(short color, short *r, short *g, short *b) {} int curs_set(int on) { +#ifdef CONFIG_SERIAL_CONSOLE if (curses_flags & F_ENABLE_SERIAL) {
// TODO
}serial_cursor_enable(on);
+#endif +#ifdef CONFIG_VIDEO_CONSOLE if (curses_flags & F_ENABLE_CONSOLE) { video_console_cursor_enable(on); } +#endif
return OK; } @@ -284,7 +291,7 @@ // int flash(void) {} int flushinp(void) { /* TODO */ return 0; } // WINDOW *getwin (FILE *) {} -bool has_colors (void) { /* TODO */ return(*(bool *)0); } +bool has_colors (void) { return(TRUE); } // bool has_ic (void) {} // bool has_il (void) {} // void idcok (WINDOW *, bool) {} @@ -300,21 +307,23 @@
for (i = 0; i < 128; i++) acs_map[i] = (chtype) i | A_ALTCHARSET;
+#ifdef CONFIG_SERIAL_CONSOLE if (curses_flags & F_ENABLE_SERIAL) { serial_clear(); }
+#endif +#ifdef CONFIG_VIDEO_CONSOLE if (curses_flags & F_ENABLE_CONSOLE) { /* Clear the screen and kill the cursor */
video_console_clear(); video_console_cursor_enable(0);
} +#endif
// Speaker init?
- stdscr = newwin(SCREEN_Y, SCREEN_X, 0, 0);
stdscr = newwin(SCREEN_Y, SCREEN_X + 1, 0, 0); // TODO: curscr, newscr?
werase(stdscr);
@@ -693,18 +702,23 @@ (((c) & 0x4400) >> 2) | ((c) & 0xAA00) | (((c) & 0x1100) << 2) int wnoutrefresh(WINDOW *win) { +#ifdef CONFIG_SERIAL_CONSOLE // FIXME. int serial_is_bold = 0;
int serial_is_reverse = 0; int serial_is_altcharset = 0; int serial_cur_pair = 0;
int need_altcharset;
short fg, bg;
+#endif int x, y; chtype ch;
- int need_altcharset;
- short fg, bg;
+#ifdef CONFIG_SERIAL_CONSOLE serial_end_bold(); serial_end_altcharset(); +#endif
for (y = 0; y <= win->_maxy; y++) {
@@ -713,9 +727,11 @@
/* Position the serial cursor */
+#ifdef CONFIG_SERIAL_CONSOLE if (curses_flags & F_ENABLE_SERIAL) serial_set_cursor(win->_begy + y, win->_begx + win->_line[y].firstchar); +#endif
for (x = win->_line[y].firstchar; x <= win->_line[y].lastchar; x++) { attr_t attr = win->_line[y].text[x].attr;
@@ -723,6 +739,7 @@ unsigned int c = ((int)color_pairs[PAIR_NUMBER(attr)]) << 8;
+#ifdef CONFIG_SERIAL_CONSOLE if (curses_flags & F_ENABLE_SERIAL) { ch = win->_line[y].text[x].chars[0];
@@ -731,15 +748,35 @@ serial_start_bold(); serial_is_bold = 1; }
}
else {
} else { if (serial_is_bold) { serial_end_bold(); serial_is_bold = 0;
/* work around serial.c
* shortcoming:
*/
serial_is_reverse = 0; serial_cur_pair = 0; } }
if (attr & A_REVERSE) {
if (!serial_is_reverse) {
serial_start_reverse();
serial_is_reverse = 1;
}
} else {
if (serial_is_reverse) {
serial_end_reverse();
serial_is_reverse = 0;
/* work around serial.c
* shortcoming:
*/
serial_is_bold = 0;
serial_cur_pair = 0;
}
}
need_altcharset = 0; if (attr & A_ALTCHARSET) { if (serial_acs_map[ch & 0x7f]) {
@@ -767,7 +804,8 @@ serial_putchar(ch);
}
+#endif +#ifdef CONFIG_VIDEO_CONSOLE c = SWAP_RED_BLUE(c);
if (curses_flags & F_ENABLE_CONSOLE) {
@@ -799,16 +837,21 @@ c |= (chtype) (ch & 0xff); video_console_putc(win->_begy + y, win->_begx + x, c); } +#endif } win->_line[y].firstchar = _NOCHANGE; win->_line[y].lastchar = _NOCHANGE; }
+#ifdef CONFIG_SERIAL_CONSOLE if (curses_flags & F_ENABLE_SERIAL) serial_set_cursor(win->_begy + win->_cury, win->_begx + win->_curx); +#endif
+#ifdef CONFIG_VIDEO_CONSOLE if (curses_flags & F_ENABLE_CONSOLE) video_console_set_cursor(win->_begx + win->_curx, win->_begy + win->_cury); +#endif
return OK; } @@ -823,7 +866,19 @@
return code; } -// int wredrawln (WINDOW *,int,int) {}
+int wredrawln (WINDOW *win, int beg_line, int num_lines) +{
- int i;
- for (i = beg_line; i < beg_line + num_lines; i++) {
win->_line[i].firstchar = 0;
win->_line[i].lastchar = win->_maxx;
- }
- return OK;
+}
int wrefresh(WINDOW *win) { // FIXME Index: drivers/serial.c =================================================================== --- drivers/serial.c (revision 3600) +++ drivers/serial.c (working copy) @@ -32,32 +32,36 @@ #include <libpayload.h>
#define IOBASE lib_sysinfo.ser_ioport +#define DIVISOR(x) (115200 / x)
-#ifdef CONFIG_SERIAL_SET_SPEED -#define DIVISOR (115200 / CONFIG_SERIAL_BAUD_RATE) -#endif
-void serial_init(void) +void serial_hardware_init(int port, int speed, int word_bits, int parity, int stop_bits) { -#ifdef CONFIG_SERIAL_SET_SPEED unsigned char reg;
- /* We will assume 8n1 for now. Does anyone use anything else these days? */
- /* Disable interrupts. */
- outb(0, IOBASE + 0x01);
outb(0, port + 0x01);
/* Assert RTS and DTR. */
- outb(3, IOBASE + 0x04);
outb(3, port + 0x04);
/* Set the divisor latch. */
- reg = inb(IOBASE + 0x03);
- outb(reg | 0x80, IOBASE + 0x03);
reg = inb(port + 0x03);
outb(reg | 0x80, port + 0x03);
/* Write the divisor. */
- outb(DIVISOR & 0xFF, IOBASE);
- outb(DIVISOR >> 8 & 0xFF, IOBASE + 1);
outb(DIVISOR(speed) & 0xFF, port);
outb(DIVISOR(speed) >> 8 & 0xFF, port + 1);
/* Restore the previous value of the divisor. */
- outb(reg &= ~0x80, IOBASE + 0x03);
- outb(reg &= ~0x80, port + 0x03);
+}
+void serial_init(void) +{ +#ifdef CONFIG_SERIAL_SET_SPEED
- serial_hardware_init(IOBASE, CONFIG_SERIAL_BAUD_RATE, 8, 0, 1);
#endif }
@@ -81,9 +85,17 @@ /* These are thinly veiled vt100 functions used by curses */
#define VT100_CLEAR "\e[H\e[J" +/* These defines will fail if you use bold and reverse at the same time.
- Switching off one of them will switch off both. tinycurses knows about
- this and does the right thing.
- */
#define VT100_SBOLD "\e[1m" #define VT100_EBOLD "\e[m" +#define VT100_SREVERSE "\e[7m" +#define VT100_EREVERSE "\e[m" #define VT100_CURSOR_ADDR "\e[%d;%dH" +#define VT100_CURSOR_ON "\e[?25l" +#define VT100_CURSOR_OFF "\e[?25h" /* The following smacs/rmacs are actually for xterm; a real vt100 has enacs=\E(B\E)0, smacs=^N, rmacs=^O. */ #define VT100_SMACS "\e(0" @@ -112,6 +124,16 @@ serial_putcmd(VT100_EBOLD); }
+void serial_start_reverse(void) +{
- serial_putcmd(VT100_SREVERSE);
+}
+void serial_end_reverse(void) +{
- serial_putcmd(VT100_EREVERSE);
+}
void serial_start_altcharset(void) { serial_putcmd(VT100_SMACS); @@ -141,3 +163,11 @@ snprintf(buffer, sizeof(buffer), VT100_CURSOR_ADDR, y + 1, x + 1); serial_putcmd(buffer); }
+void serial_cursor_enable(int state) +{
- if (state)
serial_putcmd(VT100_CURSOR_ON);
- else
serial_putcmd(VT100_CURSOR_OFF);
+}
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Jordan Crouse wrote:
- factor out serial hardware init
- add reverse color support for serial
- add cursor enable/disable support for serial
- fix tinycurses compilation if serial is disabled
- add functions to query whether serial or vga console is enabled in tinycurses
- initialize uninitialized COLOR_PAIRS variable
- implement has_colors(), wredrawln() functions in curses
Signed-off-by: Stefan Reinauer stepan@coresystems.de
There is a lot going on here - but it looks good, and I asssume you have tested it.
Acked-by: Jordan Crouse jordan.crouse@amd.com
Yes, sorry this one got so big... It's the result of a lot of incremental work, not all of which would make sense to send in seperate patches. I'll try to bite smaller chunks in the future (I hate big patches myself). But we tested it many times every day for the last couple of days and it works pretty well here. And, if it has bugs, we'll have to fix it anyways :-)
Thanks for the Ack, will catch up with my mail and check all the chunks in.
Stefan
Jordan Crouse wrote:
On 26/09/08 01:18 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
- factor out serial hardware init
- add reverse color support for serial
- add cursor enable/disable support for serial
- fix tinycurses compilation if serial is disabled
- add functions to query whether serial or vga console is enabled in tinycurses
- initialize uninitialized COLOR_PAIRS variable
- implement has_colors(), wredrawln() functions in curses
Signed-off-by: Stefan Reinauer stepan@coresystems.de
There is a lot going on here - but it looks good, and I asssume you have tested it.
Acked-by: Jordan Crouse jordan.crouse@amd.com
r3604
See patch
On 26/09/08 01:19 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
- add keyboard layout support to libpayload
- add a reset handler mechanism (CTRL-ALT-DEL)
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Hehe - the CTRL-ALT-DEL handler makes me laugh. But libpayload doesn't actually have any reset code - that sounds like something we should add.
Jordan
Index: include/libpayload.h
--- include/libpayload.h (revision 3600) +++ include/libpayload.h (working copy) @@ -123,6 +132,8 @@ int keyboard_havechar(void); unsigned char keyboard_get_scancode(void); int keyboard_getchar(void); +int keyboard_set_layout(char *country); +int keyboard_add_reset_handler(void (*new_handler)(void)); /** @} */
/** Index: Config.in =================================================================== --- Config.in (revision 3600) +++ Config.in (working copy) @@ -100,6 +100,16 @@ bool "Allow input from a PC keyboard" default y
+config PC_KEYBOARD_LAYOUT_US
- bool "English (US) keyboard layout"
- depends on PC_KEYBOARD
- default y
+config PC_KEYBOARD_LAYOUT_DE
- bool "German keyboard layout"
- depends on PC_KEYBOARD
- default n
endmenu
menu "Drivers" Index: drivers/keyboard.c =================================================================== --- drivers/keyboard.c (revision 3600) +++ drivers/keyboard.c (working copy) @@ -28,6 +28,7 @@ */
#include <libpayload.h> +#include <config.h> #include <curses.h>
#define I8042_CMD_READ_MODE 0x20 @@ -35,7 +36,18 @@
#define I8042_MODE_XLATE 0x40
-unsigned short map[4][0x57] = { +static void (*reset_handler)(void) = NULL;
+struct layout_maps {
- char *country;
- unsigned short map[4][0x57];
+};
+struct layout_maps *map;
+struct layout_maps keyboard_layouts[] = { +#ifdef CONFIG_PC_KEYBOARD_LAYOUT_US +{ .country = "us", .map = { { /* No modifier */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x08, 0x09, @@ -88,6 +100,65 @@ KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 } +}}, +#endif +#ifdef CONFIG_PC_KEYBOARD_LAYOUT_DE +{ .country = "de", .map = {
- { /* No modifier */
0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x30, 0x00, 0x27, 0x08, 0x09,
0x71, 0x77, 0x65, 0x72, 0x74, 0x7A, 0x75, 0x69,
0x6F, 0x70, 0x00, 0x2B, 0x0A, 0x00, 0x61, 0x73,
0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x00,
0x00, 0x5E, 0x00, 0x23, 0x79, 0x78, 0x63, 0x76,
0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2D, 0x00, 0x2A,
0x00, 0x20, 0x00, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), 0x00, 0x00, KEY_HOME,
KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END,
KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3C
},
- { /* Shift */
0x00, 0x1B, 0x21, 0x22, 0xA7, 0x24, 0x25, 0x26,
0x2F, 0x28, 0x29, 0x3D, 0x3F, 0x60, 0x08, 0x00,
0x51, 0x57, 0x45, 0x52, 0x54, 0x5A, 0x55, 0x49,
0x4F, 0x50, 0x00, 0x2A, 0x0A, 0x00, 0x41, 0x53,
0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x00,
0x00, 0x7E, 0x00, 0x27, 0x59, 0x58, 0x43, 0x56,
0x42, 0x4E, 0x4D, 0x3B, 0x3A, 0x5F, 0x00, 0x2A,
0x00, 0x20, 0x00, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), 0x00, 0x00, KEY_HOME,
KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END,
KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3E
},
- { /* ALT */
0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
0x7B, 0x5B, 0x5D, 0x7D, 0x5C, 0x3D, 0x08, 0x09,
0x40, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69,
0x6F, 0x70, 0x5B, 0x7E, 0x0A, 0x00, 0x61, 0x73,
0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B,
0x27, 0x60, 0x00, 0x5C, 0x7A, 0x78, 0x63, 0x76,
0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A,
0x00, 0x20, 0x00, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), 0x00, 0x00, KEY_HOME,
KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END,
KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x7C
},
- { /* Shift-ALT */
/* copied from US */
0x00, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E,
0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x08, 0x00,
0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49,
0x4F, 0x50, 0x7B, 0x7D, 0x0A, 0x00, 0x41, 0x53,
0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A,
0x22, 0x7E, 0x00, 0x7C, 0x5A, 0x58, 0x43, 0x56,
0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A,
0x00, 0x20, 0x00, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), 0x00, 0x00, KEY_HOME,
KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END,
KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00
}
+}}, +#endif };
#define MOD_SHIFT (1 << 0) @@ -95,6 +166,16 @@ #define MOD_CAPSLOCK (1 << 2) #define MOD_ALT (1 << 3)
+static void keyboard_cmd(unsigned char cmd, unsigned char val) +{
- outb(cmd, 0x60);
- /* wait until keyboard controller accepts cmds: */
- while (inb(0x64) & 2);
- outb(val, 0x60);
- while (inb(0x64) & 2);
+}
int keyboard_havechar(void) { unsigned char c = inb(0x64); @@ -144,10 +225,13 @@ modifier &= ~MOD_CTRL; break; case 0x3a:
if (modifier & MOD_CAPSLOCK)
if (modifier & MOD_CAPSLOCK) { modifier &= ~MOD_CAPSLOCK;
else
keyboard_cmd(0xed, (0 << 2));
} else { modifier |= MOD_CAPSLOCK;
keyboard_cmd(0xed, (1 << 2));
break; }}
@@ -158,12 +242,21 @@ if (modifier & MOD_ALT) shift += 2;
ret = map[shift][ch];
ret = map->map[shift][ch];
if (modifier & MOD_CTRL)
ret = (ret >= 'a' && ret <= 'z') ? ret & 0x1f : 0;
return ret;
if (modifier & MOD_CTRL) {
switch (ret) {
case 'a' ... 'z':
ret &= 0x1f;
break;
case KEY_DC:
/* vulcan nerve pinch */
if ((modifier & MOD_ALT) && reset_handler)
reset_handler();
default:
ret = 0;
}
}
}
return ret;
@@ -203,9 +296,41 @@ outb(mode, 0x60); }
+/**
- Set keyboard layout
- @param country string describing the keyboard layout language.
- Valid values are "en", "de".
- */
+int keyboard_set_layout(char *country) +{
- int i;
- for (i=0; i<ARRAY_SIZE(keyboard_layouts); i++) {
if (strncmp(keyboard_layouts[i].country, country,
strlen(keyboard_layouts[i].country)))
continue;
/* Found, changing keyboard layout */
map = &keyboard_layouts[i];
return 0;
- }
- /* Nothing found, not changed */
- return -1;
+}
+int keyboard_add_reset_handler(void (*new_handler)(void)) +{
- reset_handler = new_handler;
- return 0;
+}
void keyboard_init(void) { u8 mode;
map = &keyboard_layouts[0];
/* Empty keyboard buffer */ while (keyboard_havechar()) keyboard_getchar();
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Jordan Crouse wrote:
On 26/09/08 01:19 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
- add keyboard layout support to libpayload
- add a reset handler mechanism (CTRL-ALT-DEL)
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Hehe - the CTRL-ALT-DEL handler makes me laugh. But libpayload doesn't actually have any reset code - that sounds like something we should add.
Well, the CTRL-ALT-DEL is not really useful in all cases, I admit. It only works as long as the payload is actually reading from the keyboard.
But it's simple enough to not really hurt much... In our FILO tree I added this reset function:
static inline void kbc_wait(void) { int i; for (i = 0; i < 0x10000; i++) { if ((inb(0x64) & 0x02) == 0) break; udelay(2); } }
void platform_reboot(void) { int i;
for (i = 0; i < 10; i++) { kbc_wait();
outb(0x60, 0x64); /* Write controller command */ udelay(50); kbc_wait();
outb(0x14, 0x60); /* Set system flag */ udelay(50); kbc_wait();
outb(0xfe, 0x64); /* Pulse reset low */ udelay(50); }
for (;;) ; }
It resets the machine using the keyboard controller. This works a lot more reliable on the chipset I'm working on than doing the cf9 method.
Rebooting a machine can actually be quite a complex thing, I had to learn. (There's a lot to reboot or leave unrebooted)
Jordan Crouse wrote:
On 26/09/08 01:19 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
- add keyboard layout support to libpayload
- add a reset handler mechanism (CTRL-ALT-DEL)
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Hehe - the CTRL-ALT-DEL handler makes me laugh. But libpayload doesn't actually have any reset code - that sounds like something we should add.
Jordan
r3605
See patch
On 26/09/08 01:20 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
fix option handling in libpayload
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Index: drivers/options.c
--- drivers/options.c (revision 3600) +++ drivers/options.c (working copy) @@ -33,9 +33,9 @@ static int options_checksum_valid(void) { int i;
- int range_start = lib_sysinfo.cmos_range_start;
- int range_end = lib_sysinfo.cmos_range_end;
- int checksum_location = lib_sysinfo.cmos_checksum_location;
int range_start = lib_sysinfo.cmos_range_start / 8;
int range_end = lib_sysinfo.cmos_range_end / 8;
int checksum_location = lib_sysinfo.cmos_checksum_location / 8; u16 checksum = 0, checksum_old;
for(i = range_start; i <= range_end; i++) {
@@ -80,7 +80,7 @@
int get_option(void *dest, char *name) {
- struct cb_cmos_option_table *option_table = lib_sysinfo.option_table;
- struct cb_cmos_option_table *option_table = phys_to_virt(lib_sysinfo.option_table); struct cb_cmos_entries *cmos_entry; int len = strnlen(name, CMOS_MAX_NAME_LENGTH);
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Jordan Crouse wrote:
On 26/09/08 01:20 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
fix option handling in libpayload
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
r3606
See patch
On Fri, Sep 26, 2008 at 01:21:04AM +0200, Stefan Reinauer wrote:
- Add strsep (since strtok is considered obsolete)
- add a bunch of string function doxygen comments.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
With the cosmetic changes listed below this is
Acked-by: Uwe Hermann uwe@hermann-uwe.de
Index: include/libpayload.h
--- include/libpayload.h (revision 3600) +++ include/libpayload.h (working copy) @@ -309,6 +324,7 @@ char *strchr(const char *s, int c); char *strdup(const char *s); char *strstr(const char *h, const char *n); +char *strsep(char **stringp, const char *delim); /** @} */
/** Index: libc/string.c =================================================================== --- libc/string.c (revision 3600) +++ libc/string.c (working copy) @@ -128,6 +128,14 @@ return 0; }
+/**
- Copy a string with a maximum length.
- @param d The destination memory.
- @param s The source string.
- @param n Copy at most n characters as length of the string.
- @return strncpy returns a pointer to the destination memory.
Make this "@return A pointer to the destination memory." please. Doxygen already puts "Returns:" in its output, no need to repeat that with "strncpy returns".
- */
char *strncpy(char *d, const char *s, size_t n) { /* Use +1 to get the NUL terminator. */ @@ -140,11 +148,26 @@ return d; }
+/**
- Copy a string.
- @param d The destination memory.
- @param s The source string.
- @return strcpy returns a pointer to the destination memory.
Ditto, drop "strcpy returns", capitalize to "A pointer"...
- */
char *strcpy(char *d, const char *s) { return strncpy(d, s, strlen(s) + 1); }
+/**
- Concatenates two strings with a maximum length.
- @param d The destination string.
- @param s The source string.
- @param n The target string will have a length of n characters at most.
- @return strncat returns a pointer to the destination string.
Ditto.
- */
char *strncat(char *d, const char *s, size_t n) { char *p = d + strlen(d); @@ -158,6 +181,14 @@ return d; }
+/**
- Find a character in a string.
- @param s The string.
- @param c The character.
- @return strchr returns a pointer to the first occurence of the character in
- the string, or NULL if the character was not encountered within the string.
- */
Ditto.
char *strchr(const char *s, int c) { char *p = (char *)s; @@ -170,6 +201,12 @@ return NULL; }
+/**
- Duplicate a string.
- @param s The string.
"The string to duplicate." may be a bit more readable.
- @return strdup returns a pointer to the copy of the original string.
As above, drop "strdup returns", capitalize to "A pointer...".
- */
char *strdup(const char *s) { int n = strlen(s); @@ -182,6 +219,14 @@ return p; }
+/**
- Find a substring within a string.
- @param h The haystack string.
- @param n The needle string (substring)
Missing fullstop.
- @return strstr returns a pointer to the first occurence of the substring in
See above.
- the string, or NULL if the substring was not encountered within the string.
- */
char *strstr(const char *h, const char *n) { int hn = strlen(h); @@ -194,3 +239,35 @@
return NULL; }
+/**
- Separate strings
Missing full stop.
- @param stringp reference of the string to separate
Ditto.
- @param delim string containing all delimiters
Ditto.
- @return token string.
This could be a bit more verbose, but it's ok for now. Please capitalize the first letter, though.
- */
+char *strsep(char **stringp, const char *delim) +{
- char *walk, *token;
- if (!stringp || !*stringp || !**stringp)
return NULL;
- token = walk = *stringp;
- /* Walk, search for delimiters */
- while(*walk && !strchr(delim, *walk))
walk++;
- if (*walk) {
/* Null terminate */
Null -> NUL ?
*walk = '\0';
walk++;
- }
- *stringp = walk;
- return token;
+}
Uwe.
Uwe Hermann wrote:
On Fri, Sep 26, 2008 at 01:21:04AM +0200, Stefan Reinauer wrote:
- Add strsep (since strtok is considered obsolete)
- add a bunch of string function doxygen comments.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
With the cosmetic changes listed below this is
Acked-by: Uwe Hermann uwe@hermann-uwe.de
r3608 (included the usb prototype patch 6/7 in this commit too since it's almost trivial)
Index: include/libpayload.h
--- include/libpayload.h (revision 3600) +++ include/libpayload.h (working copy) @@ -309,6 +324,7 @@ char *strchr(const char *s, int c); char *strdup(const char *s); char *strstr(const char *h, const char *n); +char *strsep(char **stringp, const char *delim); /** @} */
/** Index: libc/string.c =================================================================== --- libc/string.c (revision 3600) +++ libc/string.c (working copy) @@ -128,6 +128,14 @@ return 0; }
+/**
- Copy a string with a maximum length.
- @param d The destination memory.
- @param s The source string.
- @param n Copy at most n characters as length of the string.
- @return strncpy returns a pointer to the destination memory.
Make this "@return A pointer to the destination memory." please. Doxygen already puts "Returns:" in its output, no need to repeat that with "strncpy returns".
- */
char *strncpy(char *d, const char *s, size_t n) { /* Use +1 to get the NUL terminator. */ @@ -140,11 +148,26 @@ return d; }
+/**
- Copy a string.
- @param d The destination memory.
- @param s The source string.
- @return strcpy returns a pointer to the destination memory.
Ditto, drop "strcpy returns", capitalize to "A pointer"...
- */
char *strcpy(char *d, const char *s) { return strncpy(d, s, strlen(s) + 1); }
+/**
- Concatenates two strings with a maximum length.
- @param d The destination string.
- @param s The source string.
- @param n The target string will have a length of n characters at most.
- @return strncat returns a pointer to the destination string.
Ditto.
- */
char *strncat(char *d, const char *s, size_t n) { char *p = d + strlen(d); @@ -158,6 +181,14 @@ return d; }
+/**
- Find a character in a string.
- @param s The string.
- @param c The character.
- @return strchr returns a pointer to the first occurence of the character in
- the string, or NULL if the character was not encountered within the string.
- */
Ditto.
char *strchr(const char *s, int c) { char *p = (char *)s; @@ -170,6 +201,12 @@ return NULL; }
+/**
- Duplicate a string.
- @param s The string.
"The string to duplicate." may be a bit more readable.
- @return strdup returns a pointer to the copy of the original string.
As above, drop "strdup returns", capitalize to "A pointer...".
- */
char *strdup(const char *s) { int n = strlen(s); @@ -182,6 +219,14 @@ return p; }
+/**
- Find a substring within a string.
- @param h The haystack string.
- @param n The needle string (substring)
Missing fullstop.
- @return strstr returns a pointer to the first occurence of the substring in
See above.
- the string, or NULL if the substring was not encountered within the string.
- */
char *strstr(const char *h, const char *n) { int hn = strlen(h); @@ -194,3 +239,35 @@
return NULL; }
+/**
- Separate strings
Missing full stop.
- @param stringp reference of the string to separate
Ditto.
- @param delim string containing all delimiters
Ditto.
- @return token string.
This could be a bit more verbose, but it's ok for now. Please capitalize the first letter, though.
- */
+char *strsep(char **stringp, const char *delim) +{
- char *walk, *token;
- if (!stringp || !*stringp || !**stringp)
return NULL;
- token = walk = *stringp;
- /* Walk, search for delimiters */
- while(*walk && !strchr(delim, *walk))
walk++;
- if (*walk) {
/* Null terminate */
Null -> NUL ?
*walk = '\0';
walk++;
- }
- *stringp = walk;
- return token;
+}
Uwe.
See patch
On Fri, Sep 26, 2008 at 01:21:59AM +0200, Stefan Reinauer wrote:
Add a missing USB prototype
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Uwe Hermann uwe@hermann-uwe.de
Index: include/libpayload.h
--- include/libpayload.h (revision 3600) +++ include/libpayload.h (working copy) @@ -110,6 +110,15 @@ /** @} */
/**
- @defgroup usb USB functions
- @{
- */
+int usb_initialize(void); +/** @} */
One empty line should be enough.
+/**
- @defgroup input Device functions
- @{ @}
*/
Uwe.
See patch
On 26/09/08 01:23 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
Use a block cursor on VGA console :-)
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Bah - who needs cursors?
Acked-by: Jordan Crouse jordan.crouse@amd.com
Index: drivers/video/vga.c
--- drivers/video/vga.c (revision 3600) +++ drivers/video/vga.c (working copy) @@ -123,8 +123,22 @@ *ptr = (u16) (c & 0xFFFF); }
+static void vga_init_cursor(void) +{
- u8 val;
+#define CURSOR_MSL 0x09 /* cursor maximum scan line */ +#define CURSOR_START 0x0A /* cursor start */ +#define CURSOR_END 0x0B /* cursor end */
- val = crtc_read(CURSOR_MSL) & 0x1f;
- crtc_write(0, CURSOR_START);
- crtc_write(val - 2, CURSOR_END);
+}
static int vga_init(void) {
- vga_init_cursor(); return 0;
}
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Jordan Crouse wrote:
On 26/09/08 01:23 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
Use a block cursor on VGA console :-)
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Bah - who needs cursors?
We're all going to love Ron's splash screen driven coreboot and payloads anyways, but for the few of us who love to edit a command line... :-)
Acked-by: Jordan Crouse jordan.crouse@amd.com
r3607