merge with mainline
authorBVK Chaitanya <bvk@dbook>
Sat, 4 Sep 2010 03:35:21 +0000 (09:05 +0530)
committerBVK Chaitanya <bvk@dbook>
Sat, 4 Sep 2010 03:35:21 +0000 (09:05 +0530)
1  2 
Makefile.util.def
grub-core/Makefile.core.def
grub-core/commands/i386/pc/halt.c
grub-core/loader/i386/bsd.c
grub-core/loader/xnu.c
grub-core/script/lexer.c
grub-core/script/script.c
grub-core/term/gfxterm.c
include/grub/script_sh.h

Simple merge
Simple merge
@@@ -28,8 -29,71 +29,71 @@@ static const struct grub_arg_option opt
      {0, 0, 0, 0, 0, 0}
    };
  
+ static inline void __attribute__ ((noreturn))
+ stop (void)
+ {
+   while (1)
+     {
+       asm volatile ("hlt");
+     }
+ }
+ /*
+  * Halt the system, using APM if possible. If NO_APM is true, don't use
+  * APM even if it is available.
+  */
+ void 
+ grub_halt (int no_apm)
+ {
+   struct grub_bios_int_registers regs;
+   if (no_apm)
+     stop ();
+   /* detect APM */
+   regs.eax = 0x5300;
+   regs.ebx = 0;
+   regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+   grub_bios_interrupt (0x15, &regs);
+   
+   if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+     stop ();
+   /* disconnect APM first */
+   regs.eax = 0x5304;
+   regs.ebx = 0;
+   regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+   grub_bios_interrupt (0x15, &regs);
+   /* connect APM */
+   regs.eax = 0x5301;
+   regs.ebx = 0;
+   regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+   grub_bios_interrupt (0x15, &regs);
+   if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+     stop ();
+   /* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
+   regs.eax = 0x530E;
+   regs.ebx = 0;
+   regs.ecx = 0x0101;
+   regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+   grub_bios_interrupt (0x15, &regs);
+   if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+     stop ();
+   /* set the power state to off */
+   regs.eax = 0x5307;
+   regs.ebx = 1;
+   regs.ecx = 3;
+   regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+   grub_bios_interrupt (0x15, &regs);
+   /* shouldn't reach here */
+   stop ();
+ }
  static grub_err_t
 -grub_cmd_halt (grub_extcmd_t cmd,
 +grub_cmd_halt (grub_extcmd_context_t ctxt,
               int argc __attribute__ ((unused)),
               char **args __attribute__ ((unused)))
  
@@@ -1039,9 -1459,54 +1459,54 @@@ grub_cmd_openbsd (grub_extcmd_context_
    else
      bootdev = 0;
  
 -  if (cmd->state[OPENBSD_SERIAL_ARG].set)
++  if (ctxt->state[OPENBSD_SERIAL_ARG].set)
+     {
+       struct grub_openbsd_bootarg_console serial;
+       char *ptr;
+       unsigned port = 0;
+       unsigned speed = 9600;
+       grub_memset (&serial, 0, sizeof (serial));
 -      if (cmd->state[OPENBSD_SERIAL_ARG].arg)
++      if (ctxt->state[OPENBSD_SERIAL_ARG].arg)
+       {
 -        ptr = cmd->state[OPENBSD_SERIAL_ARG].arg;
++        ptr = ctxt->state[OPENBSD_SERIAL_ARG].arg;
+         if (grub_memcmp (ptr, "com", sizeof ("com") - 1) != 0)
+           return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                              "only com0-com3 are supported");
+         ptr += sizeof ("com") - 1;
+         port = grub_strtoul (ptr, &ptr, 0);
+         if (port >= 4)
+           return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                              "only com0-com3 are supported");
+         if (*ptr == ',')
+           {
+             ptr++; 
+             speed = grub_strtoul (ptr, &ptr, 0);
+             if (grub_errno)
+               return grub_errno;
+           }
+       }
+       serial.device = (GRUB_OPENBSD_COM_MAJOR << 8) | port;
+       serial.speed = speed;
+         
+       grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
+       bootflags |= OPENBSD_RB_SERCONS;
+     }
+   else
+     {
+       struct grub_openbsd_bootarg_console serial;
+       grub_memset (&serial, 0, sizeof (serial));
+       serial.device = (GRUB_OPENBSD_VGA_MAJOR << 8);
+       grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
+       bootflags &= ~OPENBSD_RB_SERCONS;
+     }
    if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
      {
-       grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1);
+       grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 0);
        openbsd_root = bootdev;
      }
  
  }
  
  static grub_err_t
 -grub_cmd_netbsd (grub_extcmd_t cmd, int argc, char *argv[])
 +grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
  {
+   grub_err_t err;
    kernel_type = KERNEL_TYPE_NETBSD;
 -  bootflags = grub_bsd_parse_flags (cmd->state, netbsd_flags);
 +  bootflags = grub_bsd_parse_flags (ctxt->state, netbsd_flags);
  
    if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
      {
-       grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 1);
+       if (is_elf_kernel)
+       {
+         grub_file_t file;
+         file = grub_gzfile_open (argv[0], 1);
+         if (! file)
+           return grub_errno;
+         if (is_64bit)
+           err = grub_netbsd_load_elf_meta64 (relocator, file, &kern_end);
+         else
+           err = grub_netbsd_load_elf_meta32 (relocator, file, &kern_end);
+         if (err)
+           return err;
+       }
+       {
+       char bootpath[GRUB_NETBSD_MAX_BOOTPATH_LEN];
+       char *name;
+       name = grub_strrchr (argv[0], '/');
+       if (name)
+         name++;
+       else
+         name = argv[0];
+       grub_memset (bootpath, 0, sizeof (bootpath));
+       grub_strncpy (bootpath, name, sizeof (bootpath) - 1);
+       grub_bsd_add_meta (NETBSD_BTINFO_BOOTPATH, bootpath, sizeof (bootpath));
+       }
 -      if (cmd->state[NETBSD_ROOT_ARG].set)
 +      if (ctxt->state[NETBSD_ROOT_ARG].set)
-       netbsd_root = grub_strdup (ctxt->state[NETBSD_ROOT_ARG].arg);
+       {
+         char root[GRUB_NETBSD_MAX_ROOTDEVICE_LEN];
+         grub_memset (root, 0, sizeof (root));
 -        grub_strncpy (root, cmd->state[NETBSD_ROOT_ARG].arg,
++        grub_strncpy (root, ctxt->state[NETBSD_ROOT_ARG].arg,
+                       sizeof (root) - 1);
+         grub_bsd_add_meta (NETBSD_BTINFO_ROOTDEVICE, root, sizeof (root));
+       }
 -      if (cmd->state[NETBSD_SERIAL_ARG].set)
++      if (ctxt->state[NETBSD_SERIAL_ARG].set)
+       {
+         struct grub_netbsd_btinfo_serial serial;
+         char *ptr;
+         grub_memset (&serial, 0, sizeof (serial));
+         grub_strcpy (serial.devname, "com");
 -        if (cmd->state[NETBSD_SERIAL_ARG].arg)
++        if (ctxt->state[NETBSD_SERIAL_ARG].arg)
+           {
 -            ptr = cmd->state[NETBSD_SERIAL_ARG].arg;
++            ptr = ctxt->state[NETBSD_SERIAL_ARG].arg;
+             if (grub_memcmp (ptr, "com", sizeof ("com") - 1) == 0)
+               {
+                 ptr += sizeof ("com") - 1;
+                 serial.addr 
+                   = grub_ns8250_hw_get_port (grub_strtoul (ptr, &ptr, 0));
+               }
+             else
+               serial.addr = grub_strtoul (ptr, &ptr, 0);
+             if (grub_errno)
+               return grub_errno;
+             if (*ptr == ',')
+               {
+                 ptr++;
+                 serial.speed = grub_strtoul (ptr, &ptr, 0);
+                 if (grub_errno)
+                   return grub_errno;
+               }
+           }
+         
+         grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &serial, sizeof (serial));
+       }
+       else
+       {
+         struct grub_netbsd_btinfo_serial cons;
+         grub_memset (&cons, 0, sizeof (cons));
+         grub_strcpy (cons.devname, "pc");
+         grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &cons, sizeof (cons));
+       }
+       grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 0);
      }
  
    return grub_errno;
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -302,9 -293,9 +308,9 @@@ struct grub_lexer_param *grub_script_le
  void grub_script_lexer_fini (struct grub_lexer_param *);
  void grub_script_lexer_ref (struct grub_lexer_param *);
  void grub_script_lexer_deref (struct grub_lexer_param *);
 -void grub_script_lexer_record_start (struct grub_parser_param *);
 -char *grub_script_lexer_record_stop (struct grub_parser_param *);
 +unsigned grub_script_lexer_record_start (struct grub_parser_param *);
 +char *grub_script_lexer_record_stop (struct grub_parser_param *, unsigned);
- int  grub_script_lexer_yywrap (struct grub_parser_param *);
+ int  grub_script_lexer_yywrap (struct grub_parser_param *, const char *input);
  void grub_script_lexer_record (struct grub_parser_param *, char *);
  
  /* Functions to track allocated memory.  */