merge mainline into newreloc
This commit is contained in:
commit
e96ee4339f
6 changed files with 141 additions and 63 deletions
36
ChangeLog
36
ChangeLog
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -58,6 +58,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);
|
||||
|
@ -78,6 +79,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 */
|
||||
|
@ -134,6 +140,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);
|
||||
|
|
|
@ -132,6 +132,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 */
|
||||
|
|
|
@ -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,25 +210,30 @@ grub_ofconsole_readkey (int *key)
|
|||
/* Backspace: Ctrl-h. */
|
||||
c = '\b';
|
||||
break;
|
||||
case ANSI_C0:
|
||||
case '\e':
|
||||
{
|
||||
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)
|
||||
if (c == '\e')
|
||||
{
|
||||
*key = '\e';
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
|
||||
if (c != '[')
|
||||
return 0;
|
||||
|
||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
|
||||
/* On 9600 we have to wait up to 12 milliseconds. */
|
||||
|
@ -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
|
||||
|
|
|
@ -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,47 +172,51 @@ 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);
|
||||
|
||||
id = grub_jpeg_get_byte (data);
|
||||
ac = (id >> 4);
|
||||
id &= 0xF;
|
||||
if (id > 1)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||
"jpeg: too many huffman tables");
|
||||
|
||||
if (grub_file_read (data->file, &count, sizeof (count)) !=
|
||||
sizeof (count))
|
||||
return grub_errno;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
n += count[i];
|
||||
|
||||
id += ac * 2;
|
||||
data->huff_value[id] = grub_malloc (n);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_file_read (data->file, data->huff_value[id], n) != n)
|
||||
return grub_errno;
|
||||
|
||||
base = 0;
|
||||
ofs = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
while (data->file->offset + sizeof (count) + 1 <= next_marker)
|
||||
{
|
||||
base += count[i];
|
||||
ofs += count[i];
|
||||
id = grub_jpeg_get_byte (data);
|
||||
ac = (id >> 4) & 1;
|
||||
id &= 0xF;
|
||||
if (id > 1)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||
"jpeg: too many huffman tables");
|
||||
|
||||
data->huff_maxval[id][i] = base;
|
||||
data->huff_offset[id][i] = ofs - base;
|
||||
if (grub_file_read (data->file, &count, sizeof (count)) !=
|
||||
sizeof (count))
|
||||
return grub_errno;
|
||||
|
||||
base <<= 1;
|
||||
n = 0;
|
||||
for (i = 0; i < ARRAY_SIZE (count); i++)
|
||||
n += count[i];
|
||||
|
||||
id += ac * 2;
|
||||
data->huff_value[id] = grub_malloc (n);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_file_read (data->file, data->huff_value[id], n) != n)
|
||||
return grub_errno;
|
||||
|
||||
base = 0;
|
||||
ofs = 0;
|
||||
for (i = 0; i < ARRAY_SIZE (count); i++)
|
||||
{
|
||||
base += count[i];
|
||||
ofs += count[i];
|
||||
|
||||
data->huff_maxval[id][i] = base;
|
||||
data->huff_offset[id][i] = ofs - base;
|
||||
|
||||
base <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->file->offset != next_marker)
|
||||
|
@ -229,17 +234,24 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
|
|||
next_marker = data->file->offset;
|
||||
next_marker += grub_jpeg_get_word (data);
|
||||
|
||||
id = grub_jpeg_get_byte (data);
|
||||
if (id >= 0x10) /* Upper 4-bit is precision. */
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||
"jpeg: only 8-bit precision is supported");
|
||||
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,
|
||||
"jpeg: only 8-bit precision is supported");
|
||||
|
||||
if (id > 1)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||
"jpeg: too many quantization tables");
|
||||
if (id > 1)
|
||||
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)
|
||||
return grub_errno;
|
||||
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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -700,7 +713,7 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
|
|||
#if defined(JPEG_DEBUG)
|
||||
static grub_err_t
|
||||
grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
int argc, char **args)
|
||||
{
|
||||
struct grub_video_bitmap *bitmap = 0;
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue