Why are operating systems (usually?) unable to access BIOS settings?

20

5

Does the motherboard not provide a bus between the CPU and BIOS chip after bootup? If so, why not?

If the CPU can control fan speed, I don't see why it shouldn't be able to control the BIOS config.

Dmiters

Posted 2016-01-09T23:18:03.980

Reputation: 375

To my understanding, when the BIOS pulls the bootloader in it ceases to function, expect in cases of an IPMI. – Linef4ult – 2016-01-09T23:21:08.053

Some motherboard manufacturers have utilities to do that but these utilities are specific to that motherboard, windows does not have it built in as this could be bad news if malware used it or an average user poking around in the bios config. – Moab – 2016-01-09T23:21:36.407

As DavidPostill already answered. Windows (and other operating systems) can often access the BIOS. However this depends on the chipset and the motherboard and it might not work 100% off the time. If you move from BIOS firmware to UEFI firmware you get more control though. – Hennes – 2016-01-09T23:29:43.220

It's been a while since I have seen a PC with an actual BIOS. If you mean UEFI, it's right there under /sys/firmware/efi in Linux. – Dmitry Grigoryev – 2016-01-11T11:52:46.630

After control is handed over to the OS, the BIOS isn't used. You can even take the BIOS chip out to program another one in the instance of BIOS recovery/reflashing a corrupted BIOS. – AStopher – 2016-01-11T13:54:39.190

@cybermonkey: How sure are you about this? What if the BIOS has set up an SMM interrupt handler? Wouldn't that possibly need BIOS code to run? – user541686 – 2016-01-11T14:25:35.497

@Mehrdad It's a common method of BIOS recovery where the source BIOS doesn't have a recovery mode. I haven't done this for a while though, newer systems may be different. – AStopher – 2016-01-11T14:38:19.030

Answers

44

Why are operating systems (usually?) unable to access BIOS settings?

The above question cannot be answered as the OS can access the BIOS.

I will answer below the question that could have been asked.


How are operating systems able to access BIOS settings?

On Windows and Unix the OS is able to read the BIOS.

Windows

Example (using wmic):

F:\test>wmic bios /?

BIOS - Basic input/output services (BIOS) management.

HINT: BNF for Alias usage.
(<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb clause>].

USAGE:

BIOS ASSOC [<format specifier>]
BIOS CREATE <assign list>
BIOS DELETE
BIOS GET [<property list>] [<get switches>]
BIOS LIST [<list format>] [<list switches>]


F:\test>wmic bios list brief
Manufacturer              Name                                        SerialNumber      SMBIOSBIOSVersion  Version
American Megatrends Inc.  BIOS Date: 09/05/11 11:20:58 Ver: 04.06.03  27546064-5001600  R1190V3            Sony - 20110905

Windows can also write to the BIOS (some motherboard manufacturers provide a Windows-based BIOS updater.)

See for example How to flash the BIOS if needed through Windows or in the BIOS.

Unix

Unix has similar commands.

  • biosdecode parses the BIOS memory and prints the information about all structures.

  • You can make real-time BIOS calls from the root user using C applications that include embedded ASM (assembly code).

Source How to dump BIOS data to a file


Further Reading

DavidPostill

Posted 2016-01-09T23:18:03.980

Reputation: 118 938

5I want to add that prior to Windows XP, you could do - what at the best of my knowdedge could be described as - pointer trickery to access the setup from debug.com - remember there was a trick to erase the password protection of some bios models. Web searchs on "debug.com" bios password seem to bring some relevant information on the topic. – Theraot – 2016-01-10T07:12:59.467

1still not answering the "Why?".... unsatisfying.... – Zaibis – 2016-01-11T13:08:54.640

@Zaibis It doesn't need to answer the "why". The OS can access the BIOS so asking (and answering) why ... unable ... is a meaningless question. I've clarified the answer a little. – DavidPostill – 2016-01-11T13:13:32.643

1"Unable" should be replaced by "able" as the OS can access the BIOS. If you just meant it to be a phrase you should remove it. Since following your advice their remains a question you aren't even addressing. – Zaibis – 2016-01-11T13:17:42.647

1@Zaibis <sigh> Everybody else understood the answer (including the OP who accepted the answer). I've updated it again especially for you ;) – DavidPostill – 2016-01-11T13:24:03.677

@DavidPostill: Haha, now I have to post it as seperate question. But thanks for the special treatment xP – Zaibis – 2016-01-11T13:26:04.700

So is all of this done by reading and writing to mapped memory? (PIO?) – Dmiters – 2016-01-11T17:37:10.667

@DmitryNarkevich I don't know how the internals of the commands work :/ – DavidPostill – 2016-01-11T17:38:01.923

I haven't looked at anything that low level in ages, but way back (Z80 ...), some computers would map the bios into high memory at boot so it would be accessible. Once booting was done, they would remap those blocks to actual ram so the computer would have just a little bit more of its precious 64k of address space to use. If it did that, then the bios was not in the memory map and could not be accessed without playing with the memory map again. – Joe – 2016-01-12T01:40:52.520

19

They can, but there isn't very much in the way of standardized interface to the settings in there, especially if you mean "BIOS" proper (i.e. pre-UEFI).

Certain parts of the BIOS are governed by software contracts between the BIOS and the OS running on top of it. A long time ago, BIOS routines were used for all kinds of day-to-day tasks like reading and writing disks, displaying things on the screen, and printing to an attached printer, thus the name "basic input/output system". If the BIOS was matched to the hardware, the OS could support different hardware variants without having to have its own routines for all of those things. But as hardware, and OSes, grew more complicated and outgrew the limited set of BIOS facilities, OSes started to provide their own drivers for nearly everything, only relying on the BIOS for bootup, power management, and retrieving system configuration information.

But the BIOS, too, grew more complicated and gained all kinds of settings and abilities that weren't governed by the OS-BIOS interface, and even for the stuff that is in there only specifies the results, not the implementation. That means that every BIOS manufacturer is free to do things how they want, that they're free to change things whenever they like as long as OSes keep running, and that they don't have to tell anyone any of the details. Accessing the data stored by the BIOS is a piece of cake, but if you have a utility that can make sense of the data, or that can modify it in a way that the BIOS will actually understand, then it was probably either made by the BIOS manufacturer themselves, or it's the result of reverse-engineering.

hobbs

Posted 2016-01-09T23:18:03.980

Reputation: 701

It'd be cool if you could describe the "piece of cake" part in some technical detail. For example, assume I know how to make arbitrary C code execute in kernel-mode; now how would I go about dumping the BIOS manually? – user541686 – 2016-01-10T13:34:50.497

6

@Mehrdad The BIOS Data Area and Extended BIOS Data Area are mapped to main memory addresses, and thus can be read and written directly with appropriate privileges. (Usually you don't want to do that...) See for example http://wiki.osdev.org/Memory_Map_%28x86%29#BIOS_Data_Area_.28BDA.29 and http://stanislavs.org/helppc/bios_data_area.html and http://www.bioscentral.com/misc/bda.htm for more information on the BDA layout (the first also gives a brief introduction to one variant of the EBDA layout). Feed "BIOS Data Area" and "Extended BIOS Data Area" into your favorite search engine for more.

– a CVn – 2016-01-10T14:06:53.727