]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
various fixes
authorphcoder <phcoder@debian.bg45.phnet>
Sun, 11 Oct 2009 00:07:52 +0000 (02:07 +0200)
committerphcoder <phcoder@debian.bg45.phnet>
Sun, 11 Oct 2009 00:07:52 +0000 (02:07 +0200)
conf/mips.rmk
fs/cpio.c
genmk.rb
include/grub/mips/dl.h [new file with mode: 0644]
include/grub/mips/io.h [new file with mode: 0644]
kern/disk.c
kern/mips/dl.c
kern/mips/qemu-r4k/init.c
kern/term.c
term/serial.c

index 77eaa06cf76bb8cc253b4c661b79d23276242f30..d03b5d8f5c4e5e6e65c01fec006b8a7cf53e5d60 100644 (file)
@@ -91,7 +91,7 @@ kernel_img_SOURCES = kern/mips/qemu-r4k/startup.S \
        kern/rescue_parser.c kern/rescue_reader.c \
        kern/list.c kern/handler.c kern/command.c kern/corecmd.c        \
        kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c       \
-       kern/generic/millisleep.c kern/time.c                            \
+       kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c    \
        symlist.c kern/$(target_cpu)/cache.S
 kernel_img_CFLAGS = $(COMMON_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
@@ -122,4 +122,10 @@ lsmmap_mod_SOURCES = commands/lsmmap.c
 lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
 lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For serial.mod.
+pkglib_MODULES += serial.mod
+serial_mod_SOURCES = term/serial.c
+serial_mod_CFLAGS = $(COMMON_CFLAGS)
+serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
index 1ec4ebeaf4cf482c3c8d7d05f9bae067a4dee4f6..26218c31003c6d9e2d8791b8499a7cef19465bc8 100644 (file)
--- a/fs/cpio.c
+++ b/fs/cpio.c
@@ -280,8 +280,10 @@ grub_cpio_open (grub_file_t file, const char *name)
 
       /* Compare NAME and FN by hand in order to cope with duplicate
         slashes.  */
-      i = 1;
+      i = 0;
       j = 0;
+      while (name[i] == '/')
+       i++;
       while (1)
        {
          if (name[i] != fn[j])
@@ -290,13 +292,16 @@ grub_cpio_open (grub_file_t file, const char *name)
          if (name[i] == '\0')
            break;
 
-         if (name[i] == '/' && name[i+1] == '/')
+         while (name[i] == '/' && name[i+1] == '/')
            i++;
 
          i++;
          j++;
        }
 
+      if (name[i] != fn[j])
+       goto no_match;
+
       file->data = data;
       file->size = data->size;
       grub_free (fn);
index 50bf88fe1c2e0ffac0d54f7a198995179d4be4ce..71b57816fddc8bca75aa071d09375564f4ce80ac 100644 (file)
--- a/genmk.rb
+++ b/genmk.rb
@@ -319,6 +319,7 @@ MOSTLYCLEANFILES += #{deps_str}
 
 #{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
        $(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
+       $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@
 
 " + objs.collect_with_index do |obj, i|
       src = sources[i]
@@ -330,6 +331,7 @@ MOSTLYCLEANFILES += #{deps_str}
 
       "#{obj}: #{src} $(#{src}_DEPENDENCIES)
        $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
+
 -include #{dep}
 
 "
diff --git a/include/grub/mips/dl.h b/include/grub/mips/dl.h
new file mode 100644 (file)
index 0000000..4dbd97c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CPU_DL_H
+#define GRUB_CPU_DL_H  1
+
+/* Dummy __gnu_local_gp. Resolved by linker.  */
+char EXPORT_VAR (__gnu_local_gp);
+
+#endif /* ! GRUB_CPU_DL_H */
diff --git a/include/grub/mips/io.h b/include/grub/mips/io.h
new file mode 100644 (file)
index 0000000..b86452c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef        GRUB_IO_H
+#define        GRUB_IO_H       1
+
+#include <grub/types.h>
+
+typedef grub_addr_t grub_port_t;
+
+static __inline unsigned char
+grub_inb (grub_port_t port)
+{
+  return *(grub_uint8_t *) port;
+}
+
+static __inline unsigned short int
+grub_inw (grub_port_t port)
+{
+  return *(grub_uint16_t *) port;
+}
+
+static __inline unsigned int
+grub_inl (grub_port_t port)
+{
+  return *(grub_uint32_t *) port;
+}
+
+static __inline void
+grub_outb (unsigned char value, grub_port_t port)
+{
+  *(grub_uint8_t *) port = value;
+}
+
+static __inline void
+grub_outw (unsigned short int value, grub_port_t port)
+{
+  *(grub_uint16_t *) port = value;
+}
+
+static __inline void
+grub_outl (unsigned int value, grub_port_t port)
+{
+  *(grub_uint32_t *) port = value;
+}
+
+#endif /* _SYS_IO_H */
index 7fbe2e6a668f7057b23fde44cbeed9dfebfbd249..e463626fb732a35445c580610cb678214d97a164 100644 (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)
index 83af37b75c0eac4e1571d0ddc2847472a25aba26..e25ccce3add90c244b3fc82eddff49d01a411641 100644 (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;
                  }
              }
index f7d3043131280ad4e56b452f94cc36bdb626cd33..085c60bf8bc4dfe661e87f87e8af8c9f261cfa5a 100644 (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>
index 0a99ff318a36eb1adf674536660566dd7f77dad2..789e4651bdb6f7c611ed1883412e62add183d3b2 100644 (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) ();
 }
 
index eac43bf1b291281b83b956321a8741fe5a7a955b..6c2d8ac097c305ceb11078c5335dda0467db426f 100644 (file)
@@ -18,8 +18,8 @@
 
 #include <grub/machine/machine.h>
 #include <grub/machine/memory.h>
-#include <grub/machine/serial.h>
-#include <grub/machine/console.h>
+#include <grub/serial.h>
+//#include <grub/machine/console.h>
 #include <grub/term.h>
 #include <grub/types.h>
 #include <grub/dl.h>
@@ -67,6 +67,9 @@ static struct serial_port serial_settings;
 #ifdef GRUB_MACHINE_PCBIOS
 static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
 #define GRUB_SERIAL_PORT_NUM 4
+#elif defined (GRUB_MACHINE_MIPS_QEMU)
+static const grub_port_t serial_hw_io_addr[] = { 0x140003f8 };
+#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
 #else
 static const grub_port_t serial_hw_io_addr[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
 #define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
@@ -149,7 +152,7 @@ serial_translate_key_sequence (void)
   if (input_buf[0] != '\e' || input_buf[1] != '[')
     return;
 
-  for (i = 0; ARRAY_SIZE (three_code_table); i++)
+  for (i = 0; i < ARRAY_SIZE (three_code_table); i++)
     if (three_code_table[i].key == input_buf[2])
       {
        input_buf[0] = three_code_table[i].ascii;
@@ -254,6 +257,9 @@ grub_serial_getkey (void)
     ;
 
   c = input_buf[0];
+  if (c == 0x7f)
+    c = GRUB_TERM_BACKSPACE;
+
   grub_memmove (input_buf, input_buf + 1, --npending);
 
   return c;