Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APIs for querying and setting bios properties

Let's say I would like to change a setting in the BIOS of my computer in Linux (let's say Ubuntu 11 if it matters.) What types of APIs exist to allow you query and manipulate BIOS setting?

Further, what are good resources for doing this type of development?

like image 645
Karthik Ramachandran Avatar asked Jun 06 '11 23:06

Karthik Ramachandran


2 Answers

The CMOS memory exists outside of the normal address space and cannot contain directly executable code. It is reachable through IN and OUT commands at port number 70h (112d) and 71h (113d). To read a CMOS byte, an OUT to port 70h is executed with the address of the byte to be read and an IN from port 71h will then retrieve the requested information.

You can use the inb and outb macros to read and write from these ports to get the entire BIOS settings stored in the CMOS. For the settings memory format stored have a look at: http://bochs.sourceforge.net/techspec/CMOS-reference.txt

These mappings are actually vendor dependent, but most of them should be common.

Although this is not an API, but with this you can make direct access to the CMOS memory and make your own API. For a quick program i would recommend getting an API. Check out @Nemo's answer in this case.

like image 130
phoxis Avatar answered Sep 28 '22 05:09

phoxis


flashrom is a utility for flashing a new BIOS image from within Linux.

To modify the BIOS settings themselves, you can use the /dev/nvram device.

This page provides good information on both of these.

Note that the meaning of the NVRAM contents depends entirely on the BIOS itself; it will vary from BIOS to BIOS and even between revisions of the same BIOS. So the only thing you can reliably do is save the BIOS settings on one system and restore them onto an identical system.

like image 32
Nemo Avatar answered Sep 28 '22 05:09

Nemo