Friday, 3 July 2009

Understanding Linux Early Resume Hacks

When Linux resumes from a suspend, it can be configured to do some really grim BIOS related hacks while in real mode; these hacks are controlled by the acpi_sleep kernel boot parameter.

The settings are as follows:

This makes the kernel set the video by directly calling into the video BIOS ROM at address 0xc000.

This makes the kernel set the video mode by BIOS interrupt int $10, ax=0x4f02 (select VESA video mode).

This causes the kernel to beep. Depending on the kernel version you either get a beep or a beeped Morse code message "...-" (which is Morse for "V" for some reason).

These acpi_sleep settings map to values:

s3_bios 1
s3_mode 2
s3_beep 4

and can be set by writing these magic values to /proc/sys/kernel/acpi_video_flags before you do the next suspend; this is a little more flexible than setting the kernel boot parameter acpi_sleep.

s3_beep is checked for first - so if you want to make sure your machine is coming out of the BIOS and executing the initial kernel resume code, set this option and you will hear a beep during the very early resume execution as long as you have an internal speaker in your PC.

s3_bios is then next checked and if enabled, the kernel calls directly into the video BIOS ROM to force the video state.

Finally, s3_mode is checked, and if enabled a VESA mode setting BIOS interrupt is executed to set the set video mode.

Some BIOSs just croak and die if you do s3_bios and s3_mode calls - which is understandable as the behaviour for doing such calls during a resume is undefined. It may work, it may not!

No comments:

Post a comment