X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=payloads%2Flibpayload%2Fcurses%2Ftinycurses.c;h=fb492b6cea73889eed5004c3e7bc7dd74b1d3db9;hb=23b6c8f7caa09ed714bce9b6572b6067ae0498c6;hp=329c45c055d4b71fb230e5ed3f951dc005cf39ac;hpb=902ed76ec4372d163a89d490ac0ab20732d65062;p=coreboot.git diff --git a/payloads/libpayload/curses/tinycurses.c b/payloads/libpayload/curses/tinycurses.c index 329c45c05..fb492b6ce 100644 --- a/payloads/libpayload/curses/tinycurses.c +++ b/payloads/libpayload/curses/tinycurses.c @@ -3,7 +3,7 @@ * * Copyright (C) 2007 Uwe Hermann * Copyright (C) 2008 Ulf Jordan - * Copyright (C) 2008 coresystems GmbH + * Copyright (C) 2008-2009 coresystems GmbH * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -77,7 +77,7 @@ static int linebuf_count = 0; /* Globals */ int COLORS; /* Currently unused? */ -int COLOR_PAIRS; +int COLOR_PAIRS = 255; WINDOW *stdscr; WINDOW *curscr; WINDOW *newscr; @@ -111,6 +111,7 @@ chtype fallback_acs_map[128] = '|', '<', '>', '*', '!', 'f', 'o', ' ', }; +#ifdef CONFIG_SERIAL_CONSOLE #ifdef CONFIG_SERIAL_ACS_FALLBACK chtype serial_acs_map[128]; #else @@ -135,7 +136,9 @@ chtype serial_acs_map[128] = 'x', 'y', 'z', '{', '|', '}', '~', 0, }; #endif +#endif +#ifdef CONFIG_VIDEO_CONSOLE /* See acsc of linux. */ chtype console_acs_map[128] = { @@ -156,6 +159,7 @@ chtype console_acs_map[128] = '\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]; @@ -187,7 +191,9 @@ NCURSES_CH_T _nc_render(WINDOW *win, NCURSES_CH_T ch) int beep(void) { /* TODO: Flash the screen if beeping fails? */ +#ifdef CONFIG_SPEAKER speaker_tone(1760, 500); /* 1760 == note A6 */ +#endif return OK; } // bool can_change_color(void) {} @@ -196,13 +202,16 @@ int cbreak(void) { /* TODO */ return 0; } // 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; } @@ -225,6 +234,7 @@ int delwin(WINDOW *win) } WINDOW *derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) { +#if 0 WINDOW *win = NULL; int i; int flags = _SUBWIN; @@ -248,9 +258,9 @@ WINDOW *derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) flags |= _ISPAD; // FIXME - //// if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, - //// orig->_begx + begx, flags)) == 0) - //// return NULL; + if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, + orig->_begx + begx, flags)) == 0) + return NULL; win->_pary = begy; win->_parx = begx; @@ -263,6 +273,9 @@ WINDOW *derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) win->_parent = orig; return win; +#else + return NULL; +#endif } int doupdate(void) { /* TODO */ return(0); } // WINDOW * dupwin (WINDOW *) {} @@ -284,7 +297,7 @@ int endwin(void) // 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,17 +313,19 @@ WINDOW *initscr(void) 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? @@ -486,7 +501,7 @@ int waddch(WINDOW *win, const chtype ch) // NCURSES_CH_T wch; // SetChar2(wch, ch); - if (win->_line[win->_cury].firstchar == _NOCHANGE || + if (win->_line[win->_cury].firstchar == _NOCHANGE || win->_line[win->_cury].firstchar > win->_curx) win->_line[win->_cury].firstchar = win->_curx; @@ -497,7 +512,7 @@ int waddch(WINDOW *win, const chtype ch) win->_line[win->_cury].text[win->_curx].attr |= ((ch) & (chtype)A_ATTRIBUTES); - if (win->_line[win->_cury].lastchar == _NOCHANGE || + if (win->_line[win->_cury].lastchar == _NOCHANGE || win->_line[win->_cury].lastchar < win->_curx) win->_line[win->_cury].lastchar = win->_curx; @@ -522,7 +537,7 @@ int waddnstr(WINDOW *win, const char *astr, int n) if (n < 0) n = strlen(astr); - if (win->_line[win->_cury].firstchar == _NOCHANGE || + if (win->_line[win->_cury].firstchar == _NOCHANGE || win->_line[win->_cury].firstchar > win->_curx) win->_line[win->_cury].firstchar = win->_curx; @@ -541,7 +556,7 @@ int waddnstr(WINDOW *win, const char *astr, int n) // } } - if (win->_line[win->_cury].lastchar == _NOCHANGE || + if (win->_line[win->_cury].lastchar == _NOCHANGE || win->_line[win->_cury].lastchar < win->_curx) win->_line[win->_cury].lastchar = win->_curx; @@ -569,6 +584,15 @@ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, { int x, y; + if (ls == 0) ls = ACS_VLINE; + if (rs == 0) rs = ACS_VLINE; + if (ts == 0) ts = ACS_HLINE; + if (bs == 0) bs = ACS_HLINE; + if (tl == 0) tl = ACS_ULCORNER; + if (tr == 0) tr = ACS_URCORNER; + if (bl == 0) bl = ACS_LLCORNER; + if (br == 0) br = ACS_LRCORNER; + for(y = 0; y <= win->_maxy; y++) { if (y == 0) { @@ -605,7 +629,7 @@ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, return OK; } // int wclrtobot (WINDOW *) {} -int wclrtoeol(WINDOW *win) { /* TODO */ return(*(int *)0); } +int wclrtoeol(WINDOW *win) { /* TODO */ return ERR; } int wcolor_set(WINDOW *win, short color_pair_number, void *opts) { if (!opts && (color_pair_number >= 0) @@ -693,18 +717,23 @@ int whline(WINDOW *win, chtype ch, int n) (((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 x, y; - chtype ch; int need_altcharset; short fg, bg; +#endif + int x, y; + chtype ch; +#ifdef CONFIG_SERIAL_CONSOLE serial_end_bold(); serial_end_altcharset(); +#endif for (y = 0; y <= win->_maxy; y++) { @@ -713,16 +742,16 @@ int wnoutrefresh(WINDOW *win) /* 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; - 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,11 +760,31 @@ int wnoutrefresh(WINDOW *win) 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; } } @@ -767,6 +816,10 @@ int wnoutrefresh(WINDOW *win) serial_putchar(ch); } +#endif +#ifdef CONFIG_VIDEO_CONSOLE + unsigned int c = + ((int)color_pairs[PAIR_NUMBER(attr)]) << 8; c = SWAP_RED_BLUE(c); @@ -799,16 +852,21 @@ int wnoutrefresh(WINDOW *win) 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 +881,19 @@ int wprintw(WINDOW *win, const char *fmt, ...) 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 @@ -865,7 +935,7 @@ int wscrl(WINDOW *win, int n) win->_line[y].firstchar = win->_line[y + n].firstchar; win->_line[y].lastchar = win->_line[y + n].lastchar; for (x = 0; x <= win->_maxx; x++) { - if ((win->_line[y].text[x].chars[0] != win->_line[y + n].text[x].chars[0]) || + if ((win->_line[y].text[x].chars[0] != win->_line[y + n].text[x].chars[0]) || (win->_line[y].text[x].attr != win->_line[y + n].text[x].attr)) { if (win->_line[y].firstchar == _NOCHANGE) win->_line[y].firstchar = x; @@ -880,7 +950,7 @@ int wscrl(WINDOW *win, int n) for (y = (win->_maxy+1 - n); y <= win->_maxy; y++) { for (x = 0; x <= win->_maxx; x++) { - if ((win->_line[y].text[x].chars[0] != ' ') || + if ((win->_line[y].text[x].chars[0] != ' ') || (win->_line[y].text[x].attr != A_NORMAL)) { if (win->_line[y].firstchar == _NOCHANGE) win->_line[y].firstchar = x; @@ -910,7 +980,7 @@ int wsetscrreg(WINDOW *win, int top, int bottom) } // void wsyncdown (WINDOW *) {} // void wsyncup (WINDOW *) {} -/* D */ void wtimeout(WINDOW *win, int delay) { win->_delay = delay; } +/* D */ void wtimeout(WINDOW *win, int _delay) { win->_delay = _delay; } /* D */ int wtouchln(WINDOW *win, int y, int n, int changed) { int i;