merge with mainline

This commit is contained in:
BVK Chaitanya 2010-05-07 11:24:17 +05:30
commit 4a2ec49233
6 changed files with 141 additions and 63 deletions

View file

@ -1,3 +1,39 @@
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
* video/readers/jpeg.c: Indented.
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
Various jpeg cleanups.
* video/readers/jpeg.c (grub_jpeg_get_huff_code): Use ARRAY_SIZE.
(grub_jpeg_decode_quan_table): Use sizeof.
(grub_jpeg_decode_du): Use ARRAY_SIZE.
2010-05-05 Peter Hurley <No e-mail available> (tiny change)
* video/readers/jpeg.c (grub_jpeg_decode_huff_table): Loop over all
tables. Ignore non-last ac bit.
(grub_jpeg_decode_quan_table): Likewise.
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New value
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM.
* kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM on qemu.
* kern/ieee1275/init.c (grub_claim_heap): Don0t allocate below
1.5MiB if GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM is set.
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_getkey): Fix off-by-one
error.
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Support C0 code.
2010-05-03 Vladimir Serbinenko <phcoder@gmail.com>
* commands/parttool.c (grub_cmd_parttool): Fix #if !GRUB_NO_MODULES

View file

@ -100,6 +100,9 @@ enum grub_ieee1275_flag
/* Open Hack'Ware don't support the ANSI sequence. */
GRUB_IEEE1275_FLAG_NO_ANSI,
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);

View file

@ -59,6 +59,7 @@ grub_ieee1275_find_options (void)
char tmp[32];
int is_smartfirmware = 0;
int is_olpc = 0;
int is_qemu = 0;
grub_ieee1275_finddevice ("/", &root);
grub_ieee1275_finddevice ("/options", &options);
@ -79,6 +80,11 @@ grub_ieee1275_find_options (void)
if (rc >= 0 && !grub_strcmp (tmp, "OLPC"))
is_olpc = 1;
rc = grub_ieee1275_get_property (root, "model",
tmp, sizeof (tmp), 0);
if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC"))
is_qemu = 1;
if (is_smartfirmware)
{
/* Broken in all versions */
@ -135,6 +141,10 @@ grub_ieee1275_find_options (void)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY);
}
if (is_qemu)
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM);
if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom))
{
rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0);

View file

@ -133,6 +133,17 @@ static void grub_claim_heap (void)
if (type != 1)
return 0;
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
{
if (addr + len <= 0x180000)
return 0;
if (addr < 0x180000)
{
len = addr + len - 0x180000;
addr = 0x180000;
}
}
len -= 1; /* Required for some firmware. */
/* Never exceed HEAP_MAX_SIZE */

View file

@ -194,14 +194,15 @@ grub_ofconsole_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_col
*highlight_color = grub_ofconsole_highlight_color;
}
#define ANSI_C0 0x9b
static int
grub_ofconsole_readkey (int *key)
{
char c;
grub_uint8_t c;
grub_ssize_t actual = 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual > 0)
switch(c)
{
@ -209,9 +210,13 @@ grub_ofconsole_readkey (int *key)
/* Backspace: Ctrl-h. */
c = '\b';
break;
case ANSI_C0:
case '\e':
{
grub_uint64_t start;
if (c == '\e')
{
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
@ -227,6 +232,7 @@ grub_ofconsole_readkey (int *key)
if (c != '[')
return 0;
}
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
@ -321,7 +327,7 @@ grub_ofconsole_getkey (void)
static grub_uint16_t
grub_ofconsole_getxy (void)
{
return ((grub_curr_x - 1) << 8) | grub_curr_y;
return (grub_curr_x << 8) | grub_curr_y;
}
static void

View file

@ -153,10 +153,11 @@ grub_jpeg_get_number (struct grub_jpeg_data *data, int num)
static int
grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
{
int code, i;
int code;
unsigned i;
code = 0;
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_SIZE (data->huff_maxval[id]); i++)
{
code <<= 1;
if (grub_jpeg_get_bit (data))
@ -171,15 +172,18 @@ grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
static grub_err_t
grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
{
int id, ac, i, n, base, ofs;
int id, ac, n, base, ofs;
grub_uint32_t next_marker;
grub_uint8_t count[16];
unsigned i;
next_marker = data->file->offset;
next_marker += grub_jpeg_get_word (data);
while (data->file->offset + sizeof (count) + 1 <= next_marker)
{
id = grub_jpeg_get_byte (data);
ac = (id >> 4);
ac = (id >> 4) & 1;
id &= 0xF;
if (id > 1)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
@ -190,7 +194,7 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
return grub_errno;
n = 0;
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_SIZE (count); i++)
n += count[i];
id += ac * 2;
@ -203,7 +207,7 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
base = 0;
ofs = 0;
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_SIZE (count); i++)
{
base += count[i];
ofs += count[i];
@ -213,6 +217,7 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
base <<= 1;
}
}
if (data->file->offset != next_marker)
grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in huffman table");
@ -229,6 +234,9 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
next_marker = data->file->offset;
next_marker += grub_jpeg_get_word (data);
while (data->file->offset + sizeof (data->quan_table[id]) + 1
<= next_marker)
{
id = grub_jpeg_get_byte (data);
if (id >= 0x10) /* Upper 4-bit is precision. */
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
@ -238,9 +246,13 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: too many quantization tables");
if (grub_file_read (data->file, &data->quan_table[id], 64) != 64)
if (grub_file_read (data->file, &data->quan_table[id],
sizeof (data->quan_table[id]))
!= sizeof (data->quan_table[id]))
return grub_errno;
}
if (data->file->offset != next_marker)
grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: extra byte in quantization table");
@ -444,7 +456,8 @@ grub_jpeg_idct_transform (jpeg_data_unit_t du)
static void
grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
{
int pos, h1, h2, qt;
int h1, h2, qt;
unsigned pos;
grub_memset (du, 0, sizeof (jpeg_data_unit_t));
@ -457,7 +470,7 @@ grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
du[0] = data->dc_value[id] * (int) data->quan_table[qt][0];
pos = 1;
while (pos < 64)
while (pos < ARRAY_SIZE (data->quan_table[qt]))
{
int num, val;
@ -735,8 +748,7 @@ GRUB_MOD_INIT (jpeg)
grub_video_bitmap_reader_register (&jpeg_reader);
#if defined(JPEG_DEBUG)
cmd = grub_register_command ("jpegtest", grub_cmd_jpegtest,
"FILE",
"Tests loading of JPEG bitmap.");
"FILE", "Tests loading of JPEG bitmap.");
#endif
}