various fixes

This commit is contained in:
phcoder 2009-10-11 02:07:52 +02:00
parent 65e64ea4b1
commit ffa9860a86
10 changed files with 177 additions and 39 deletions

View file

@ -267,15 +267,12 @@ grub_disk_open (const char *name)
for (dev = grub_disk_dev_list; dev; dev = dev->next)
{
grub_printf ("open: %p\n", dev->open);
grub_getkey ();
if ((dev->open) (raw, disk) == GRUB_ERR_NONE)
break;
else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
grub_errno = GRUB_ERR_NONE;
else
goto fail;
grub_printf ("survived\n");
}
if (! dev)

View file

@ -57,6 +57,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_size_t gp_size = 0;
/* FIXME: suboptimal. */
grub_uint32_t *gp, *gpptr;
grub_uint32_t gp0;
/* Find a symbol table. */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
@ -70,6 +71,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
entsize = s->sh_entsize;
/* Find reginfo. */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_MIPS_REGINFO)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found");
gp0 = ((grub_uint32_t *)((char *) e + s->sh_offset))[5];
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
@ -107,7 +120,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
gpptr = gp = grub_malloc (gp_size);
if (!gp)
return grub_errno;
grub_printf ("gp=%p\n", gp);
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
@ -166,8 +178,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*(grub_uint16_t *) addr += (sym->st_value) & 0xffff;
break;
case R_MIPS_32:
*(grub_uint32_t *) addr = sym->st_value;
*(grub_uint32_t *) addr += sym->st_value;
break;
case R_MIPS_GPREL32:
*(grub_uint32_t *) addr = sym->st_value
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)gp;
break;
case R_MIPS_26:
{
grub_uint32_t value;
@ -189,16 +206,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
= sizeof (grub_uint32_t) * (gpptr - gp);
gpptr++;
break;
case R_MIPS_GPREL32:
grub_printf ("gp32\n");
*gpptr = sym->st_value + *(grub_uint16_t *) addr;
*(grub_uint32_t *) addr
= sizeof (grub_uint32_t) * (gpptr - gp);
gpptr++;
break;
default:
grub_printf ("Unknown relocation type %d\n",
ELF_R_TYPE (rel->r_info));
{
grub_free (gp);
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown relocation type %d\n",
ELF_R_TYPE (rel->r_info));
}
break;
}
}

View file

@ -5,6 +5,7 @@
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/cpu/kernel.h>

View file

@ -48,9 +48,11 @@ struct grub_handler_class grub_term_output_class =
void
grub_putcode (grub_uint32_t code)
{
// int height = grub_getwh () & 255;
int height = grub_getwh () & 255;
if (!grub_cur_term_output)
return;
#if 0
if (code == '\t' && grub_cur_term_output->getxy)
{
int n;
@ -61,15 +63,13 @@ grub_putcode (grub_uint32_t code)
return;
}
#endif
// (grub_cur_term_output->putchar) (code);
*((grub_uint8_t *)0x140003f8) = code;
(grub_cur_term_output->putchar) (code);
if (code == '\n')
{
grub_putcode ('\r');
#if 0
grub_more_lines++;
if (grub_more && grub_more_lines == height - 1)
@ -96,7 +96,6 @@ grub_putcode (grub_uint32_t code)
else
grub_more_lines = 0;
}
#endif
}
}
@ -129,54 +128,66 @@ grub_putchar (int c)
grub_ssize_t
grub_getcharwidth (grub_uint32_t code)
{
if (!grub_cur_term_output)
return 1;
return (grub_cur_term_output->getcharwidth) (code);
}
int
grub_getkey (void)
{
while (!(*((grub_uint8_t *)0x140003f8+5) & 0x01));
return *((grub_uint8_t *)0x140003f8);
// return (grub_cur_term_input->getkey) ();
int c;
if (!grub_cur_term_input)
return 0;
return (grub_cur_term_input->getkey) ();
}
int
grub_checkkey (void)
{
return !!(*((grub_uint8_t *)0x140003f8+5) & 0x01);
//return (grub_cur_term_input->checkkey) ();
if (!grub_cur_term_input)
return 0;
return (grub_cur_term_input->checkkey) ();
}
int
grub_getkeystatus (void)
{
/* if (grub_cur_term_input->getkeystatus)
if (grub_cur_term_input && grub_cur_term_input->getkeystatus)
return (grub_cur_term_input->getkeystatus) ();
else*/
else
return 0;
}
grub_uint16_t
grub_getxy (void)
{
if (!grub_cur_term_output)
return 0;
return (grub_cur_term_output->getxy) ();
}
grub_uint16_t
grub_getwh (void)
{
if (!grub_cur_term_output)
return (80 << 8) | 25;
return (grub_cur_term_output->getwh) ();
}
void
grub_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
(grub_cur_term_output->gotoxy) (x, y);
if (grub_cur_term_output && grub_cur_term_output->gotoxy)
(grub_cur_term_output->gotoxy) (x, y);
}
void
grub_cls (void)
{
if (!grub_cur_term_output)
return;
if ((grub_cur_term_output->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
{
grub_putchar ('\n');
@ -189,20 +200,29 @@ grub_cls (void)
void
grub_setcolorstate (grub_term_color_state state)
{
if (grub_cur_term_output && grub_cur_term_output->setcolorstate)
if (!grub_cur_term_output)
return;
if (grub_cur_term_output->setcolorstate)
(grub_cur_term_output->setcolorstate) (state);
}
void
grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
if (grub_cur_term_output && grub_cur_term_output->setcolor)
if (!grub_cur_term_output)
return;
if (grub_cur_term_output->setcolor)
(grub_cur_term_output->setcolor) (normal_color, highlight_color);
}
void
grub_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
if (!grub_cur_term_output)
return;
if (grub_cur_term_output->getcolor)
(grub_cur_term_output->getcolor) (normal_color, highlight_color);
}
@ -212,7 +232,7 @@ grub_setcursor (int on)
{
int ret = cursor_state;
if (grub_cur_term_output->setcursor)
if (grub_cur_term_output && grub_cur_term_output->setcursor)
{
(grub_cur_term_output->setcursor) (on);
cursor_state = on;
@ -230,7 +250,7 @@ grub_getcursor (void)
void
grub_refresh (void)
{
if (grub_cur_term_output->refresh)
if (grub_cur_term_output && grub_cur_term_output->refresh)
(grub_cur_term_output->refresh) ();
}