I have tried reading about BIOS on Wikipedia and other websites, but I couldn't understand much. Can anyone please tell me what is BIOS and why do we need it? Also is BIOS present in every electronic device or just computers and smart phones?
PCs are run by complicated programs, called Operating Systems (OSes). They are hosted in RAM memory, which is volatile, i.e., it loses its content when you turn power off.
So the question arises: when the pc power is turned on, since the RAM will be empty, how will the pc start?
The BIOS is what makes this possible. It is a very small program, hosted on Read-Only-Memory (=ROM) which is non-volatile, i.e., it does not vanish when you turn the power off. It is automatically loaded onto the pc from the ROM by special circuitry, so that the pc can start its boot-up process.
Since the amount of ROM memory is small, it is a small program, which can do a limited number of things, basically three:
- It performs a self-test;
- it checks that peripherals (disk, video, keyboard, ...) work correctly, and initializes them;
- determines a list of places where a more advanced stage for the inizialization might reside (your hard drive, a cd-rom disk, a USB stick, the network), and tries to pass control to this new stage. If it succeeds, the start-up process continues, otherwise it halts with some hard-to-fathom error messages.
I was vague about the second stage: basically, the new stage is located in a special location of the hard drive or cd-rom, or USB stick, called a Master Boot Record (MBR). This is a tiny (446 bytes) section of the disk, for instance, which tells the pc how the disk is divided (partitioned is the technical term) in slices, and on which of these slices the next stage of the power-up process can be found. This last stage is the final stage, which will be responsible for loading the true Operating System (Windows, Mac Os, Linux, Unix,...) into the pc's RAM. And, from then on, it is business as usual.
When I took my first programming job back in 1978 we had a room sized mini computer. An HP2100. When it would crash we would need to carefully set 16 switches on the front panel, then toggle a switch to load that memory word in, and repeat this about 20 times. If you made even the smallest mistake you would have to start over.
What had to be programmed in by hand was an extremely simple program called a boot loader. Once it was loaded we would click the run switch to execute this code and a program would start up the paper tape reader and read punch holes in a long paper tape into memory.
On this paper tape was another more complicated program which was a simple BIOS, or Basic Input/Output System. This program knew how to access the hard disks, e.g. it new how to move the read write head back and forth, and how to swoop up a sector of data which contained another program, a bigger one, the operating system. And if something went wrong it had a very simple command line tool to interrogate what was in memory and to hand edit it.
So it's a three step process and that hasn't changed in all of these years.
Now back with these early PCs the BIOS on microcomputers was a little different than it is today.
When you typed a command on the command line, like dir to list the files on a disk, the operating system would compute where to look based on a file system, but then ask BIOS to actually do the work of making the hardware move and spin the disk to get a specific block of data. Similarly the BIOS provided the low level interface to the serial ports used to display information on your screen and get keystrokes, and to send data to the printer, etc. So DOS (the Disk Operating System) would deal with the command line, but once it was figured out that a character needed to be sent to the screen, that job was handed to BIOS which knew how to operate the serial i/o circuit.
Today BIOS is similar but once your operating system is loaded most operating systems replace the BIOS hardware drivers with drivers more tightly integrated into the operating system. This is done to get better performance, i.e. do the same thing faster.
IBM published the source code for it's BIOS for the IBM PC so engineers could study and modify it. One winter I also disassembled MSDos, the whole darn operating system, not something that one is licensed to do today, to see how it worked. It took a couple of months, and some clever basic programs to disassemble it, and a lot of head scratching to try and understand what the code was doing, but in the end it gave me a solid understanding of what exactly an operating system does and how it does it. It's not magic. It's just a bunch of carefully written functions to take high level commands and convert them into hardware actions. And the BIOS is no different. It has a bunch of things you can request it to do, and ways it can be configured for various hardware.
I thought a little history of where all of this stuff came from might help you better understand this modern magic. Today this code is proprietary so most engineer's can't ever know how it works.
So, in a few words.
BIOS mean Basic Input/Output System, it's the most essential program in programable devices, like main boards in computers (PCs, laptops, mainframes and other computers, also in phones and other electronic toys, like tablets) and all another sort of hardware, like DVDs, BDs, etc.
BIOS is stored directly in device and control it behaviour. Main board BIOS has simple interface to configure board.