Based on the onportsel patch implement the following grub feature:

onportsel n
    Select entry number n for booting automatically instead of the
    default, if the service button was pressed
    (Note that onportsel loses the last two arguments which specify port
    and mask. We cannot use the original onportsel command anyway, because
    we must initialize the port.

lannerhw FW-7500C|FW-7550B|FW-7656A|FW-7656B
    If this option is given, together with any of the above hardware types,
    switch the status LED to green, when grub starts.


Index: grub/stage2/builtins.c
===================================================================
--- grub.orig/stage2/builtins.c	2009-07-20 09:50:41.000000000 +0200
+++ grub/stage2/builtins.c	2009-07-20 12:31:44.000000000 +0200
@@ -870,44 +870,25 @@ static int
 onportsel_func (char *arg, int flags)
 {
   int i = 0;
+  unsigned char byte;
+
   while (1)
   {
     switch(i) {
     case 0:
       if(!safe_parse_maxint (&arg, &onportsel_entry)) return 1;
       break;
-
-    case 1:
-      if(!safe_parse_maxint (&arg, &onportsel_addr)) {onportsel_entry=-1; return 1;}
-      break;
-
-    case 2:
-      onportsel_mask = onportsel_value = 0;
-      int pos;
-      for(pos=0;pos<8;pos++) {
-        switch(arg[pos]) {
-        case '0':
-	  onportsel_mask |= (0x80>>pos);
-	  break;
-	case '1':
-	  onportsel_value |= (0x80>>pos);
-	  onportsel_mask |= (0x80>>pos);
-	  break;
-	case 'x':case 'X':
-	  //actually nothing to do
-	  break;
-	case '\0':
-	  return 1; //err
-	}
-      }
-      break;
     }
-
     i++;
     arg = skip_to (0, arg);
     if(arg[0]=='\0') break;
   }
 
+  /* initialize the port to be able to detect a button press */
+  byte = portin(0x480 + 0x34);
+  byte |= 0x02;
+  portout(0x480 + 0x34, byte);
+
   return 0;
 }
 
@@ -916,12 +897,75 @@ static struct builtin builtin_onportsel 
   "onportsel",
   onportsel_func,
   BUILTIN_MENU,
-  "onportsel NUM PORT MASK",
-  "Set the selection to entry number NUM if the value"
-  " on PORT matches the MASK"
+  "onportsel NUM",
+  "Set the selection to entry number NUM if the service button"
+  " was pressed."
 };
 
 
+/* lannerhw */
+static int
+lannerhw_func (char *arg, int flags)
+{
+  int i = 0;
+  int port, on, mask;
+  unsigned char byte;
+  char hw[50];
+
+  while(1)
+  {
+    switch(i)
+    {
+      case 0:
+      	if(grub_strlen(arg) > sizeof(hw))
+					return 1;
+				grub_strcpy(hw, arg);
+				break;
+    }
+    i++;
+    arg = skip_to(0, arg);
+    if(arg[0] == '\0') break;
+  }
+
+  if(grub_strcmp(hw, "FW-7500C") == 0 ||
+     grub_strcmp(hw, "FW-7550B") == 0)
+  {
+    port = 0x48f;
+    on   = 0x10;
+    mask = 0xe7;
+  }
+  else if(grub_strcmp(hw, "FW-7656A") == 0 ||
+          grub_strcmp(hw, "FW-7656B") == 0)
+  {
+    port = 0x480 + 0x38;
+    on   = 0x40;
+    mask = 0x9f;
+  }
+  else
+  {
+    return 1;
+  }
+  grub_printf("Lanner-HW: %s\n", hw);
+  byte = portin(port);
+  byte &= mask;
+  byte |= on;
+  portout(port, byte);
+  return 0;
+}
+
+
+static struct builtin builtin_lannerhw =
+{
+  "lannerhw",
+  lannerhw_func,
+  BUILTIN_MENU,
+  "lannerhw HW-TYPE",
+  "Turn status LED of specified Lanner hardware to green."
+};
+
+
+
+
 #ifdef GRUB_UTIL
 /* device */
 static int
@@ -5363,6 +5407,7 @@ struct builtin *builtin_table[] =
   &builtin_install,
   &builtin_ioprobe,
   &builtin_kernel,
+  &builtin_lannerhw,
   &builtin_lock,
   &builtin_makeactive,
   &builtin_map,
Index: grub/stage2/stage2.c
===================================================================
--- grub.orig/stage2/stage2.c	2009-07-20 09:48:54.000000000 +0200
+++ grub/stage2/stage2.c	2009-07-20 12:30:52.000000000 +0200
@@ -249,8 +249,10 @@ restart:
   //check onportsel:
   if(onportsel_entry >= 0)
     {
-      unsigned char portval = portin(onportsel_addr);
-      if( (portval & onportsel_mask) == (onportsel_value & onportsel_mask) )
+      unsigned char byte;
+      /* test if service button was pressed */
+      byte = portin(0x480 + 0x38) & 0x02;
+      if(byte == 0)
         { entryno = onportsel_entry; mbi.lpt_val = 1; }
       else
         mbi.lpt_val = 0;

