Merge mainline into cleanbuild

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-14 16:01:31 +01:00
commit 016a671b51
89 changed files with 1402 additions and 929 deletions

View file

@ -21,6 +21,7 @@
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/machine/console.h>
#include <grub/ieee1275/ieee1275.h>
@ -77,7 +78,52 @@ grub_ofconsole_writeesc (const char *str)
static void
grub_ofconsole_putchar (grub_uint32_t c)
{
char chr = c;
char chr;
if (c > 0x7F)
{
/* Better than nothing. */
switch (c)
{
case GRUB_TERM_DISP_LEFT:
c = '<';
break;
case GRUB_TERM_DISP_UP:
c = '^';
break;
case GRUB_TERM_DISP_RIGHT:
c = '>';
break;
case GRUB_TERM_DISP_DOWN:
c = 'v';
break;
case GRUB_TERM_DISP_HLINE:
c = '-';
break;
case GRUB_TERM_DISP_VLINE:
c = '|';
break;
case GRUB_TERM_DISP_UL:
case GRUB_TERM_DISP_UR:
case GRUB_TERM_DISP_LL:
case GRUB_TERM_DISP_LR:
c = '+';
break;
default:
c = '?';
break;
}
}
chr = c;
if (c == '\n')
{
grub_curr_y++;
@ -156,42 +202,81 @@ grub_ofconsole_readkey (int *key)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual > 0 && c == '\e')
{
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
if (actual > 0)
switch(c)
{
case 0x7f:
/* Backspace: Ctrl-h. */
c = '\b';
break;
case '\e':
{
*key = '\e';
return 1;
grub_uint64_t start;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
{
*key = '\e';
return 1;
}
if (c != '[')
return 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
switch (c)
{
case 'A':
/* Up: Ctrl-p. */
c = GRUB_TERM_UP;
break;
case 'B':
/* Down: Ctrl-n. */
c = GRUB_TERM_DOWN;
break;
case 'C':
/* Right: Ctrl-f. */
c = GRUB_TERM_RIGHT;
break;
case 'D':
/* Left: Ctrl-b. */
c = GRUB_TERM_LEFT;
break;
case '3':
{
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
/* Delete: Ctrl-d. */
if (c == '~')
c = GRUB_TERM_DC;
else
return 0;
break;
}
break;
}
}
if (c != 91)
return 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
switch (c)
{
case 65:
/* Up: Ctrl-p. */
c = 16;
break;
case 66:
/* Down: Ctrl-n. */
c = 14;
break;
case 67:
/* Right: Ctrl-f. */
c = 6;
break;
case 68:
/* Left: Ctrl-b. */
c = 2;
break;
}
}
}
*key = c;
return actual > 0;

View file

@ -232,7 +232,12 @@ serial_get_divisor (unsigned int speed)
/* Set the baud rate. */
for (i = 0; i < sizeof (divisor_tab) / sizeof (divisor_tab[0]); i++)
if (divisor_tab[i].speed == speed)
/* UART in Yeeloong runs twice the usual rate. */
#ifdef GRUB_MACHINE_MIPS_YEELOONG
return 2 * divisor_tab[i].div;
#else
return divisor_tab[i].div;
#endif
return 0;
}
@ -292,11 +297,14 @@ serial_hw_init (void)
| serial_settings.stop_bits);
grub_outb (status, serial_settings.port + UART_LCR);
/* In Yeeloong serial port has only 3 wires. */
#ifndef GRUB_MACHINE_MIPS_YEELOONG
/* Enable the FIFO. */
grub_outb (UART_ENABLE_FIFO, serial_settings.port + UART_FCR);
/* Turn on DTR, RTS, and OUT2. */
grub_outb (UART_ENABLE_MODEM, serial_settings.port + UART_MCR);
#endif
/* Drain the input buffer. */
while (grub_serial_checkkey () != -1)
@ -613,7 +621,11 @@ GRUB_MOD_INIT(serial)
/* Set default settings. */
serial_settings.port = serial_hw_get_port (0);
#ifdef GRUB_MACHINE_MIPS_YEELOONG
serial_settings.divisor = serial_get_divisor (115200);
#else
serial_settings.divisor = serial_get_divisor (9600);
#endif
serial_settings.word_len = UART_8BITS_WORD;
serial_settings.parity = UART_NO_PARITY;
serial_settings.stop_bits = UART_1_STOP_BIT;