June 6th, 2004

Since I've gotten my X40, I've been conversing with markus@ about OpenBSD support since he also owns one. I've since ported a driver for the TCPA/TPM security chip and one thing I always wanted to do was hook into the blue "Access IBM" button to run xautolock -locknow for one-touch locking. The tpb program can hook into this button on Linux, but all of the work is handled by an NVRAM driver in the Linux kernel. Apparently the X40's BIOS toggles various bits in the CMOS RAM (NVRAM) when certain buttons are pushed, like the volume buttons, ThinkLight, and of course, the blue "Access IBM" button.

Last night I started looking into making an NVRAM driver for OpenBSD, which turned out to be relatively easy, since the i386's clock code already has functions for reading and writing to the NVRAM. I put together a simple driver to provide user-land read-only access to the NVRAM through a /dev/nvram device:

jcs@hypotenuse:~> ls -l /dev/nvram
crw-r--r--  1 root  wheel   85,   0 Jun 26 12:05 /dev/nvram
jcs@hypotenuse:~> hexdump /dev/nvram
0000000 0000 0000 00f0 8003 0002 01fc 0000 1f00
0000010 000e 0200 0000 0000 0001 bb00 00bb 0000
0000020 1804 fc00 c820 86c1 0b70 0000 0000 0000
0000030 0000 0400 bb80 6300 d4bb 072f 00d0 0080
0000040 0000 0000 05c0 0052 b6ed 5b6d 0203 0003
0000050 0400 0000 0000 20f0 7200 7000 0200 0087
0000060 0007 fe80 8000 0c40 1185 00fc 0000 5349
0000070 00b2

With that loaded, tpb now works on OpenBSD without any modifications required:

jcs@hypotenuse:~> tpb -v
Volume changed: Level 42
Volume changed: Level 50
Mute on
Mute off
ThinkLight is on
ThinkLight is off
ThinkPad button pressed

And with a ~/.tpbrc of "THINKPAD xautolock -locknow", the "Access IBM" button now locks my X11 session.

The source for my NVRAM driver is here and the tpb port is here.

Questions or comments?
Please feel free to contact me.