Skip to contentSkip to conversation

Vendor power-on button

DISCUSSION Vladimir 'φ-coder/phcoder' Serbinenko 2 participants 4 messages May 23, 2010 – Jul 17, 2010

lore
Share & tools
lore
#0 lore raw

Hello, all. I've just merged vendor power-on button support into mainline. Here is extract from manual: <<EOF
Some laptop vendors provide an additional power-on button which boots another OS.
GRUB supports such buttons with GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON, GRUB_HIDDEN_TIMEOUT_BUTTON and GRUB_BUTTON_CMOS_ADDRESS variables in default/grub. GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON and GRUB_HIDDEN_TIMEOUT_BUTTON are used instead of corresponding variables without
_BUTTON suffix when powered using special button. GRUB_BUTTON_CMOS_ADDRESS is vendor specific and partially model-specific. Values known to GRUB team are:

@table @key
@item Dell XPS M1530
85:3
@end table

EOF

If you have a laptop which has a similar feature could you figure your address and contribute?
To discover the address do the following:
1) boot normally
2) sudo modprobe nvram
sudo cat /dev/nvram | xxd > normal_button.txt
3) boot using vendor button
sudo modprobe nvram
sudo cat /dev/nvram | xxd > normal_vendor.txt

Then compare these text files and find where a bit was toggled. E.g. in case of Dell XPS it was:
byte 0x47: 20 --> 28
It's a bit number 3 as seen from following table:
0: 01
1: 02
2: 04
3: 08
4: 10
5: 20
6: 40
7: 80

0x47 is decimal 71. Linux nvram implementation cuts first 14 bytes of CMOS. So the real byte address in CMOS is 71+4=85
So complete address is 85:3

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#1 lore raw
Quoted 2 lines · Vladimir '??-coder/phcoder' Serbinenko

Hello, all. I've just merged vendor power-on button support into mainline. Here is extract from manual:

[snip]

Quoted 2 lines

If you have a laptop which has a similar feature could you figure your address and contribute?

I have a Dell XPS M1330, and GRUB_BUTTON_CMOS_ADDRESS=85:3 works also for me.

However, I do have one question.

I have it set up now to boot directly into Linux when I use the main power-on button, and I use the auxiliary button to get a boot menu, defaulting to Windows. But when I boot Windows using that button, it starts up a MediaDirect setup screen (in addition to regular Windows). Would it be possible to (optionally) clear the vendor power-on button bit in the cmos before booting?

--Paul Vojta, [email protected]

#2 lore raw
Quoted 13 lines · Paul Vojta
Quoted 3 lines · Vladimir '??-coder/phcoder' Serbinenko

Hello, all. I've just merged vendor power-on button support into mainline. Here is extract from manual:

[snip]

Quoted 3 lines

If you have a laptop which has a similar feature could you figure your address and contribute?

I have a Dell XPS M1330, and GRUB_BUTTON_CMOS_ADDRESS=85:3 works also for me.

Quoted 9 lines

However, I do have one question.

I have it set up now to boot directly into Linux when I use the main power-on button, and I use the auxiliary button to get a boot menu, defaulting to Windows. But when I boot Windows using that button, it starts up a MediaDirect setup screen (in addition to regular Windows). Would it be possible to (optionally) clear the vendor power-on button bit in the cmos before booting?

Please try the attached patch. And add:
GRUB_BUTTON_CMOS_CLEAN=yes

Quoted 8 lines

--Paul Vojta, [email protected]

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== modified file 'commands/i386/cmostest.c'

i386/cmostest.c +37 -6
@@ -22,20 +22,32 @@
 #include <grub/cmos.h>
 
 static grub_err_t
-grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
-		   int argc, char *argv[])
+parse_args (int argc, char *argv[], int *byte, int *bit)
 {
-  int byte, bit;
   char *rest;
 
   if (argc != 1)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
 
-  byte = grub_strtoul (argv[0], &rest, 0);
+  *byte = grub_strtoul (argv[0], &rest, 0);
   if (*rest != ':')
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
 
-  bit = grub_strtoul (rest + 1, 0, 0);
+  *bit = grub_strtoul (rest + 1, 0, 0);
+
+  return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
+		   int argc, char *argv[])
+{
+  int byte, bit;
+  grub_err_t err;
+
+  err = parse_args (argc, argv, &byte, &bit);
+  if (err)
+    return err;
 
   if (grub_cmos_read (byte) & (1 << bit))
     return GRUB_ERR_NONE;
@@ -43,7 +55,22 @@
   return grub_error (GRUB_ERR_TEST_FAILURE, "false");
 }
 
-static grub_command_t cmd;
+static grub_err_t
+grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
+		    int argc, char *argv[])
+{
+  int byte, bit;
+  grub_err_t err;
+
+  err = parse_args (argc, argv, &byte, &bit);
+  if (err)
+    return err;
+
+  grub_cmos_write (byte, grub_cmos_read (byte) & (~(1 << bit)));
+  return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd, cmd_clean;
 
 
 GRUB_MOD_INIT(cmostest)
@@ -51,9 +78,13 @@
   cmd = grub_register_command ("cmostest", grub_cmd_cmostest,
 			       "cmostest BYTE:BIT",
 			       "Test bit at BYTE:BIT in CMOS.");
+  cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
+				     "cmosclean BYTE:BIT",
+				     "Clean bit at BYTE:BIT in CMOS.");
 }
 
 GRUB_MOD_FINI(cmostest)
 {
   grub_unregister_command (cmd);
+  grub_unregister_command (cmd_clean);
 }

=== modified file 'util/grub-mkconfig.in'

grub-mkconfig.in +1 -0
@@ -254,6 +254,7 @@
   GRUB_HIDDEN_TIMEOUT_BUTTON \
   GRUB_TIMEOUT_BUTTON \
   GRUB_BUTTON_CMOS_ADDRESS \
+  GRUB_BUTTON_CMOS_CLEAN \
   GRUB_DISTRIBUTOR \
   GRUB_CMDLINE_LINUX \
   GRUB_CMDLINE_LINUX_DEFAULT \

=== modified file 'util/grub.d/00_header.in'

grub.d/00_header.in +6 -0
@@ -253,6 +253,12 @@
 make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
 fi
 
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" != "xyes" ]; then
+    cat <<EOF
+cmosclean $GRUB_BUTTON_CMOS_ADDRESS
+EOF
+fi
+
 # Play an initial tune
 if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
   cat << EOF
#3 lore raw
Quoted 23 lines · Vladimir '?-coder/phcoder' Serbinenko
Quoted 13 lines · Paul Vojta
Quoted 3 lines · Vladimir '??-coder/phcoder' Serbinenko

Hello, all. I've just merged vendor power-on button support into mainline. Here is extract from manual:

[snip]

Quoted 3 lines

If you have a laptop which has a similar feature could you figure your address and contribute?

I have a Dell XPS M1330, and GRUB_BUTTON_CMOS_ADDRESS=85:3 works also for me.

Quoted 9 lines

However, I do have one question.

I have it set up now to boot directly into Linux when I use the main power-on button, and I use the auxiliary button to get a boot menu, defaulting to Windows. But when I boot Windows using that button, it starts up a MediaDirect setup screen (in addition to regular Windows). Would it be possible to (optionally) clear the vendor power-on button bit in the cmos before booting?

Quoted 2 lines

Please try the attached patch. And add:
GRUB_BUTTON_CMOS_CLEAN=yes

That didn't help (and, noticing a typo in your patch, neither did adding GRUB_BUTTON_CMOS_CLEAN=prettyplease).

I don't know how Windows decides to start up Media Direct, but I think the best way to solve my problem is to replace the file MDirect.exe with something innocuous.

Anyway, thanks for trying.

--Paul Vojta, [email protected]