Why must a computer have a BIOS?

34

15

The BIOS software is built into the PC, and is the first code run by a PC when powered on ('boot firmware'). When the PC starts up, the first job for the BIOS is the power-on self-test, which initializes and identifies system devices such as the CPU, RAM, video display card, keyboard and mouse, hard disk drive, optical disc drive and other hardware. The BIOS then locates boot loader software held on a peripheral device (designated as a 'boot device'), such as a hard disk or a CD/DVD, and loads and executes that software, giving it control of the PC.[2] This process is known as booting, or booting up, which is short for bootstrapping.

Which requisites determine that a computer system must have a BIOS installed on it?

Why can't the Operational System actually do all of the BIOS work?

Diogo

Posted 2012-02-29T13:06:23.580

Reputation: 28 202

40Why does a car engine need a starter? Shouldn't the engine be powerful enough to start itself? – Der Hochstapler – 2012-02-29T13:42:13.067

4@OliverSalzburg this will be possible in the near future, gas engines without starters. With direct injection and computers its a snap. – Moab – 2012-02-29T16:44:54.833

2They already have self-starting engines, but they're mostly 12+ cylinder or rotary engines. Most engines can't self-start simply because they can't produce enough power in a single powerstroke to overcome its moment of inertia. Direct injection and better timing might help a little, but really you need lighter engines to increase the ratio between the energy generated in a powerstroke to moment of intertia created by the flywheel, crankshaft, gears, etc. – Lèse majesté – 2012-02-29T22:43:33.207

5Actually, a BIOS in the PC sense is NOT necessary. IBM System/360 and /370 computers (and maybe more recent versions) started up with a single hard-wired instruction that read a single record from a device selected by dials on the console. That record contained a bootstrap program (it had to fit in 80 bytes - one punched card) that loaded a more complex bootstrap program, which loaded the OS from disk. I guess the 'BIOS' was that single instruction hardwired to execute when you pressed the right button (called IPL or initial program load). – Ex Umbris – 2012-03-01T07:25:55.367

2You are confusing "computer" and "PC" in your question. That's why the answers are confusing and sometimes contradictory. – rds – 2012-03-01T11:16:00.413

@ExUmbris Yes, by definition of "IBM PC", BIOS is mandatory for a PC (soon to be surperseeded by UEFI). IBM System/360 is a mainframe and not a PC. – rds – 2012-03-01T11:18:52.437

1@rds the question said "computer" not "PC" – Ex Umbris – 2012-03-01T18:04:51.677

Having BIOS is simpler than having an array of switches and lights where you key in the bootstrap loader every time you start up. (Which is what you used to have to do.) – Daniel R Hicks – 2013-10-08T22:40:39.203

Answers

41

A BIOS is a hardware dependent piece of code stored on the motherboard itself. Every different motherboard needs a custom BIOS written for it, so it would be impossible to have a generic BIOS/OS all-in-one (although the BIOS is technically just stored code, so you could theoretically write an OS for one particular motherboard). As you mentioned, the purpose of the BIOS is to do the following:

When the PC starts up, the first job for the BIOS is the power-on self-test, which initializes and identifies system devices such as the CPU, RAM, video display card, keyboard and mouse, hard disk drive, optical disc drive and other hardware.

Note that you can still start a computer without any external storage - which is why the BIOS is a requirement for a computer. In other terms, the BIOS provides a common software interface to allow a stored computer program to communicate with various hardware devices connected to the motherboard.

For example, if I have two different motherboards with two different SATA controllers, the BIOS allows me to write a piece of code that can work with both, without my knowledge of how the motherboard actually sends commands to the SATA device. I just have to tell the computer "read sector X from this SATA device", and the BIOS is responsible for actually sending those commands to the hardware.

Where it actually gets the "read sector X" information from is a stored program contained within the BIOS, which usually directs the computer to start reading from a bootloader stored in a common location. These common locations are agreed upon by various software and hardware developers, and usually provided to the public to allow for more compatibility between systems.

Once a basic level of interfacing (again, logical interfacing through software) is established, the operating system itself builds a common interface with your various hardware devices (usually by using "device drivers"), and the operating system can then control the hardware.


Finally, it should be noted that the BIOS is also used to make modifications to the computer hardware configurations, and store them in the on-board EEPROM (so your computer remembers the changes next time you start it up). However, as I previously stated, once the operating system is loaded, it has full control of the computer.

This allows for motherboard manufacturers to develop software allowing you to make these changes from within your operating system, as opposed to having to reboot into the BIOS. Again, this is very hardware and software dependent, but goes to show that all computer interfacing is relative. The BIOS is exactly what it's name implies - a basic input/output system, to allow a common software interface for a more advanced program ("operating system") to take control of the machine.

Breakthrough

Posted 2012-02-29T13:06:23.580

Reputation: 32 927

Just another doubt... The BIOS keeps active while OS is running?? Or it is turned off afeter BIOS pass the "token to OS on OSLoader boot phase? – Diogo – 2012-02-29T13:39:21.073

2When you start the computer, the BIOS is running as machine code on the processor. You can think of it like that but it's not really "turned off" in a sense - it simply switches to run the OS. When you start the computer, the BIOS tells the computer to start executing the machine code stored at location X. Put in more common terms, the BIOS just initializes your hardware, and directs the computer where to continue running code from. – Breakthrough – 2012-02-29T13:47:27.797

13BIOS/OS all-in-one is NOT impossible. I don't know why everyone here keeps saying this. Having each part on separate devices/storage doesn't mean they're not part of the same logical entity. Computers before the IBM PC had all-in-one, that is, BIOS was manufactured and developed by the same one that developed the OS kernel. In fact OS updates sometimes included BIOS updates. – m0skit0 – 2012-02-29T15:01:47.397

The BIOS keeps active. It's in ROM, so you can't remove it anyway. Usually the BIOS functions are no longer used by the OS after boot, since they are too basic and slow compared to what a similar function in a modern OS can do. – Oliver – 2012-02-29T15:54:09.153

@m0skit0: It IS impossible nowadays, see how fast a vendor lock-out is stopped. ;) – Tamara Wijsman – 2012-02-29T18:19:33.673

3@Oliver Actually, with ACPI, BIOS functions are routinely used after OS boot. – derobert – 2012-02-29T19:05:41.913

1The BIOS allows the OS (software layer) to interact with the hardware. The BIOS and OS serve different purposes. They are two parts of a whole. One does not supersede another. – Ben Richards – 2012-02-29T19:37:26.760

The question is not just about impossibility. It is possible to write each and every software in machine code and not using any programming language. It would be possible, that a programmer, instead of using a scanf() function, would need to spend months to write the code which can read from any datastream on any hardware. But is it worth it? – vsz – 2012-03-01T05:33:46.747

BIOS code can function after an OS is loaded. System Management Mode allows for that. For example, that's how USB mice work with legacy OS's like DOS, even if the software iteracts directly with PS/2 port (which may be just absent).

– whitequark – 2012-03-01T09:41:01.733

@m0skit0 I agree that it's not impossible, and realized that I had worded that second sentence a bit too strongly against the idea. What I had implied is that it's impossible to make an operating system that works on so much hardware (like Linux/Windows), since the BIOS is significantly more hardware dependent. That being said, answer updated to reflect this better. – Breakthrough – 2012-03-01T12:08:11.750

@whitequark SMM is implemented in hardware. It just has severe implications for any running OS/software. You can also trigger the interrupt via software, but this is a processor-dependent feature, and not part of the BIOS. All the BIOS does is set-up the interrupt vector, and enable/disable the SMM interrupt based on your saved configuration in the EEPROM.

– Breakthrough – 2012-03-01T12:10:13.617

1@Breakthrough: depends on who manufactures the hardware ;) In case of IBM PCs, logical evolution was independent BIOS and OS manufacturers because of multiplicity of hardware types. This did not happen on old times. This is why the PC was a (fortunate, except for having M$ in it for no reason...) revolution that changed the whole computing market. – m0skit0 – 2012-03-01T12:13:28.263

1@Breakthrough, SMM is implemented in hardware, but the code which implements all of the features is actually the BIOS code: BIOS sets up chipset registers to run a part of its image when a certain event happens. – whitequark – 2012-03-01T12:47:53.930

7

Your operating system is on your hard disk, if you turn on your computer it won't magically start reading from that hard disk. It is the BIOS that loads the boot loader from the hard disk, as well as do some testing and allowing you to configure certain settings of the BIOS.

Your OS can't do that because it is on the hard disk and not in your ROM.

Hence, you need a BIOS or a similar (but different) technology like EFI...

It is possible to put part of the OS on the ROM (responsible for loading the boot loader of the OS) by the manufacturer; however, this is not widely applicable and there is a BIOS or EFI available anyway.

Tamara Wijsman

Posted 2012-02-29T13:06:23.580

Reputation: 54 163

1You're mixing two different concepts. BIOS is independent from OS, that is, BIOS could be part of the OS. For example if it's made by the same manufacturer and only works with that OS, like gaming console's bootstrappers. – m0skit0 – 2012-02-29T13:29:53.737

5"BIOS is independent from OS, that is, BIOS could be part of the OS." Huh? Contradiction is very contradictory, lol. – Breakthrough – 2012-02-29T14:01:37.420

2Gaming consoles are computers, so are Atari, Amiga and old Macs, so it's definitely relevant. @Breakthrough: that's not contradictory. It means BIOS has nothing to do with OS, and thus, can be a part (or not) of it. – m0skit0 – 2012-02-29T14:50:31.873

@TomWijsman You're the only one trolling here. Gaming consoles are a subset of computers. If it's possible for some consoles to do it, then it's possible for some computers. Also, don't use bold just like that. It's inappropriate. – luiscubal – 2012-02-29T18:37:05.413

@luiscubal: We do not support Gaming consoles on Super User. Your comment is off-topic as well...

– Tamara Wijsman – 2012-02-29T18:59:49.050

1@TomWijsman he has a point, if game consoles can do it, then so can computers. Also, so long as it's not a question or answer, I don't see a problem with it being off topic. Comments are comments, after all; nothing more, nothing less. (No comment about the bold issue - to each his own on that, although that deals more with terminology.) – Breakthrough – 2012-02-29T23:35:53.340

Yet, game consoles are different and only a limited amount of different ones exist. For computers, there are a ton of different motherboards. An OS would have to reinvent the BIOS part multiple times to fit all the different motherboards out there, that is what makes it not applicable to the large scale... – Tamara Wijsman – 2012-03-01T01:09:39.353

He's right. Period. – m0skit0 – 2012-03-01T07:31:26.230

@Breakthrough Mind you, I didn't complain about the bold in the answer. I complained about the bold in a comment that has since been deleted. – luiscubal – 2012-03-01T22:51:46.617

The comment is still there, I'm tired of repeating myself here @luiscubal. If your comment is not about my answer, then it is in the wrong place... Stop detrimenting away from the Q&A, thank you! – Tamara Wijsman – 2012-03-01T23:10:03.237

6

No real logical reason. It's more a matter of legacy and history.

  1. There's no requisite that a computer must have a BIOS installed. It's legacy from IBM PC. Although this proved to be a good idea

  2. Having the Operating System doing that wouldn't really change anything because it would still do something like the BIOS does. Of course the OS would need to be in a ROM, not on a I/O device. The problem might arise for monopoly issues when a OS builder decides to make his OS BIOS incompatible with other OSs. Having BIOS manufacturers separate from OSs improves freedom over what software might run.

m0skit0

Posted 2012-02-29T13:06:23.580

Reputation: 1 317

2 is invalid, your OS (or part of it) can't function as a BIOS. – Tamara Wijsman – 2012-02-29T13:20:44.350

1Why it can't function as a BIOS? Give an explanation on why. You only have to put bootstrapper on a ROM and you're done. I do not mean to have it entirely in ROM, and even so it would work if the ROM is big enough (of course to run it you would need to load parts in RAM, but this is done by current BIOS as well). – m0skit0 – 2012-02-29T13:23:08.877

1Thanks for the explanation... The BIOS could be made by the OS manufacturer and put in a ROM. The BIOS would be a part of the ROM. In fact this is what happens on closed devices like gaming consoles (e.g. XBoX, PSP...). Just this simple. – m0skit0 – 2012-02-29T13:26:51.697

However, this is not applicable to PCs on the large scale. Hence, we have a BIOS that fits all purposes... – Tamara Wijsman – 2012-02-29T13:29:38.503

3He said "computer", not PCs. And yes it is applicable. In fact it was this way before the IBM PC (Atari, Amiga... the BIOS is part of the OS). – m0skit0 – 2012-02-29T13:31:41.707

2Silly me, I used to write software for embedded computers that had no BIOS or OS, just application code. Or are we not talking about all computers, just the ones most people think about? – jwernerny – 2012-02-29T17:51:40.213

@m0skit0: That doesn't make it applicable on the large scale... – Tamara Wijsman – 2012-02-29T19:02:29.030

2Not applicable on the large scale? Check out how many Ataris, Amigas and Macs were there before the PC. – m0skit0 – 2012-02-29T22:08:20.533

Yet, they are a small scale compared to PCs. It is currently not applicable on the large scale unless you want to reinvent a ton of BIOSes, which is why you will never see this happen... – Tamara Wijsman – 2012-03-01T01:10:43.910

2The iPhone is a computer and I don't believe it has a BIOS. Even before the digital age... a computer is a programmable machine that performs operations and outputs the same result for a given input, right? A Jacquard loom is a computer, and it certainly doesn't have a BIOS (it even doesn't have an OS). – rds – 2012-03-01T11:32:23.137

1A Jacquard loom is NOT a computer. And iPhone has BIOS (or something similar even if not called so). You always need a bootstrapper. – m0skit0 – 2012-03-01T11:36:11.460

5

Something is required to start the Operating System. If the OS could fit in some non-volatile memory then it could be started directly, but with fully featured OSes such as Windows, OSX or Linux this isn't possible.

What's needed is a small lightweight "OS" that can be loaded on powerup that does the basic things like memory and disk access and then that loads the Operating System. While this could be part of the OS itself and not a separate entity there are other reasons why you might want another process to start first:

  1. Updates - if the OS was fixed like this then it would become difficult to update it if any security patches were needed. It can be done - firmware updates happen all the time to devices to such as routers etc. but these have relatively simple operating systems installed.
  2. Flexibility - a computer is a general purpose machine and the same hardware can run several different operating systems. Having a BIOS which then loads the OS from disk means you can choose which one to run - you can even go as far has having several installed side by side.

The process is known as bootstrapping.

ChrisF

Posted 2012-02-29T13:06:23.580

Reputation: 39 650

1So the answear is because we have a lot of different OSs? I mean, if we have just one OS model for a specific hardware then we would eliminate the need of a BIOS? – Diogo – 2012-02-29T13:12:59.740

@DiogoRocha - not entirely. It's mainly because the OS is too big to fit in non-volatile memory. – ChrisF – 2012-02-29T13:13:37.497

1I don't see why it is not possible that Microsoft makes a BIOS... – m0skit0 – 2012-02-29T13:14:47.400

@ChrisF so are things like SSDs going to change this? – cutrightjm – 2012-02-29T13:15:21.207

1You don't need the whole OS to fit into non-volatile memory (which it can btw, you just need enough ROM :P). You only need the bootstrapper to be there. – m0skit0 – 2012-02-29T13:15:47.277

@ekaj - possibly. – ChrisF – 2012-02-29T13:18:00.270

1@m0skit0 Microsoft can't make a BIOS since it would have to make a different BIOS for every single motherboard it wants it's software to run on. :) – Breakthrough – 2012-02-29T13:53:00.910

1Also, @ChrisF, placing an OS on ROM undermines the whole point of an operating system in the first place. It might make sense to use the ROM to execute some stored programs on the processor directly (which would yield much better performance), but the whole point of an operating system is to explicitly disallow this type of operation, and provide a common software interface to do so. – Breakthrough – 2012-02-29T13:55:16.100

You can direct boot from flash to Linux with the right motherboard and CoreBoot. It is used in some clusters. – Zan Lynx – 2012-03-01T00:22:59.397

1@ZanLynx: CoreBoot is a BIOS :P – m0skit0 – 2012-03-01T11:20:54.880

@m0skit0: Sort of. There are BIOS modules for CoreBoot but you do not need them. Used in the role to start a Linux kernel all it needs to do is some basic motherboard configuration, like RAM initialization. It is (B)asic but has no (I)nput or (O)utput (S)ystem. – Zan Lynx – 2012-03-05T18:37:29.597

I'm not telling the opposite. I'm just telling that there are times where BIOS forms part of the OS. For example a 2 chain secure boot. – m0skit0 – 2012-03-05T21:45:16.477

4

The concept PC BIOS dervies from CP/M, an operating system popular on 8-bit Z-80 "S-100" bus based computers before the IBM PC took over.

CP/M expected hardware-dependent functions to be in a ROM (BIOS). Another part, loaded off disk by the bootloader, was the software that supported the CP/M filesystem (BDOS) and then last the command processor or "shell" (CCP). The hardware that CP/M was expected to support was not very much: a disk drive, a display, a serial port or two (COM or AUX ports) which could have printers or modems attached.

The PC BIOS performed a basic bootstrapping function similar to how CP/M did, and DOS used BIOS functions to perform basic input and output, as intended. Programmers ended up bypassing these functions as they were slow. This led to PC clone makers in the mid 80's recreating the platform as a whole (easy as IBM documented the original PC very well inside and out), instead of just providing a BIOS with compatible interfaces, though they had to do that too.

At this point we can say, for a modern OS, the BIOS isn't really necessary beyond booting the system. However ...

Starting in the early 90's, the notion of power management took hold and the BIOS was tasked with this. APM works well with a single-tasking OS such as DOS, but not with true multitasking OSs such as Windows or Linux. Around this time the 386 was in full force, the Intel CPU that supported real multitasking. DOS and the BIOS were not updated in response to the new capabilites of this CPU, mostly because all Intel CPUs will still run in legacy 16-bit compatibility mode that the original PC-BIOS was designed for. So modern OSes pretty much ignore/bypass all the CP/M-like input/output functionality of the BIOS except possibly during early boot stages.

Eventually ACPI was developed, mostly part of the BIOS, which supported power management and configuration of (often laptop) platform-specific things. ACPI also handles the final power-switching state of hibernation, sleep, or shutdown.

So these days it's ACPI and it's successor, EFI, that keeps something like the BIOS a necessity of PC's The overarching concept is for ACPI to be the interface between things platform or motherboard specific and the OS, so a separate build of OS doesn't have to be made for every different type of motherboard.

Development boards that house ARM CPUs running Linux (as well as cell phone hardware) have this issue. Typically they will come with a bootloader-only firmware such as U-boot, but pretty much the OS must support each board as a separate platform.

LawrenceC

Posted 2012-02-29T13:06:23.580

Reputation: 63 487

3

In a sense, you're right. BIOS and OS partly do the same things. The separation in BIOS and OS is solely for flexibility.

The BIOS is usually created by a hardware manufacturer. The hardware has to ensure, that a basic functionality is present, for example that a disk drive can be read from and that a basic display for diagnostics and errors is shown. Thus the name "Basic Input Output System".

This can be done, to some extent, without further knowledge of the actual components really present on the specific system, since they all have to support a certain small BIOS standard. This enables vendors to custom-build a complete system. The BIOS just has to do enough to start the OS. There are some conventions to where this start-points are, so it just tries one after the other. This also enables the use of different operating systems on the same hardware. (there is flexibility, again)

Once the operation system (or at least it's bootloader) ist found and started by the BIOS, the BIOS itself becomes largely obsolete. Modern OS use very little to nothing of the BIOS functionalitly after loading.

If you wanted to make the OS do all the work you'd have to put the OS in a place where it can be accessed by the hardware without the preliminary help of a software (ROM). This may be possible for some closed systems, where flexibility is no concern. If you think about building hardware support into some other hardware, you're basically building a kind of BIOS again...

Another concern is memory size and cost. Full featured OSs are large and trying to get a multi-gigabyte OS into ROM is expensive, besides the follow-up problems of patching and updating it.

So no, there is no technical reason, but many practical ones, especially for the flexible PC platform.

Oliver

Posted 2012-02-29T13:06:23.580

Reputation: 588

3

In order to run a program on a modern PC, you must already have a program running to begin with that knows how to operate the hardware and load programs into memory. This chicken-and-egg problem is solved by implanting a basic program into the hardware itself.

This basic input/output system (BIOS) is very small and very limited in scope, but provides enough of a foundation that second-stage boot loaders, like GRUB or NTLDR, can be loaded and run. These second-stage loaders are more sophisticated than the BIOS program which enables them to provide a more robust foundation for the operating system proper to load and assume control.

Andrew Lambert

Posted 2012-02-29T13:06:23.580

Reputation: 7 136

Good non-technical explanation. – Mechanical snail – 2012-09-12T05:50:47.403

1

If a CPU had the ability to address a hard drive directly, without relying on BIOS, or EFI or other code in ROM (or NVRAM or what have you), then in theory such a CPU could load an OS from disk into RAM and begin executing it.

Actually, in theory, such a CPU could even execute instructions without loading them to RAM. There is no theoretical reason that a computer couldn't use a hard drive as primary storage. But this would be very, very slow.

This would mean having extra code in the CPU to access the disk, and hard-wiring some concepts about disks, like partition tables and file systems into the CPU. CPUs these days are big enough to do this, but it would not be a very flexible or efficient approach to designing a CPU.

david25272

Posted 2012-02-29T13:06:23.580

Reputation: 377

Used to be computers ran directly off of disk/drum, with no significant amount of RAM. – Daniel R Hicks – 2013-10-08T22:43:07.373

-1

It does not need it!

What is often called the BIOS is a set of 3 things.

  • A boot loader
  • A configuration tool: now mostly obsolete, except boot order, and the clock. Most of the rest should be automatic or set by the manufacturer.
  • The BIOS: a library of input output routines to help the operating system communicate with the hardware. Unfortunately the bios is 16 bit, out of date and can not be used by modern operating systems, so is largely ignored.

ctrl-alt-delor

Posted 2012-02-29T13:06:23.580

Reputation: 1 886

The boot loader is part of the BIOS. – Daniel R Hicks – 2013-10-08T22:42:14.617

@Daniel I have re-written to make in clearer, thanks. – ctrl-alt-delor – 2014-01-17T09:47:56.180