BootUp Process of Computer

Once video has been enabled,

http://www.dewassoc.com/kbase/hard_drives/master_boot_record.htm

https://www.engineersgarage.com/tutorials/how-computer-pc-boots-up

https://manybutfinite.com/post/how-computers-boot-up/

https://opensource.com/article/17/2/linux-boot-and-startup

https://www.thegeekstuff.com/2011/02/linux-boot-process/

http://www.dewassoc.com/support/msdos/dos_commands.htm

http://flint.cs.yale.edu/feng/cos/resources/BIOS/

http://flint.cs.yale.edu/feng/cos/resources/BIOS/biosextension.htm

Windows Boot Troubleshooting (great resource on boot process) - https://docs.microsoft.com/en-us/windows/client-management/advanced-troubleshooting-boot-problems

https://www.howtogeek.com/398493/what-exactly-happens-when-you-turn-on-your-computer/

https://www.howtogeek.com/124711/what-does-my-bios-do-after-booting/

https://www.lifewire.com/what-is-cmos-2625826

https://www.quora.com/Why-are-CMOS-and-BIOS-needed-in-a-computer

https://www.computerhope.com/issues/ch001360.htm

https://www.tldp.org/HOWTO/Unix-and-Internet-Fundamentals-HOWTO/

===========
https://developer.ibm.com/articles/l-linuxboot/
===========

 In early days of modern PCs the BIOS was stored in a volatile, low power consumption CMOS SRAM (Static RAM). If it's volatile, then when the power is off, the contents of BIOS should be lost. To overcome this issue, manufacturers added a battery for CMOS to the motherboard, as seen below (the huge metallic circle to the right and center).
enter image description here
Modern motherboards have the BIOS installed in non-volatile EEPROMs (Electrically EPROM) and still keep the battery. If the memory is non-volatile, why keep the battery? The answer is to keep track of peripherals and date-time, to power RTC (Real-Time Clock).

BIOS chip is EEPROM storing the BIOS that uses the settings present in another memory which is a RAM chip (which lose the settings it's storing when the computer is shut down , just like how the contents of RAM are not maintained each time you restart your computer). However, the CMOS battery is used to provide constant power to the chip and hence this RAM chip memory is wrongly termed as CMOS memory. now why a separate memory is required because BIOS is nonvolatile and we may want to change some of the BIOS settings like the order in which the memory disk are searched for the MBR and the system time , since the nonvolatile nature of BIOS memory doesnt' allow such changes frequently a separate reconfigurable chip was required and this facility was provided by the RAM Chip aka CMOS chip.


  • The BIOS is the program that starts a computer up, and the CMOS is where the BIOS stores the date, time, and system configuration details it needs to start the computer. 
  •  The BIOS is a small program that controls the computer from the time it powers on until the time the operating system takes over. The BIOS is firmware, which means it cannot store variable data. 
  •  CMOS is a type of memory technology, but most people use the term to refer to the chip that stores variable data for startup. A computer's BIOS will initialize and control components like the floppy and hard drive controllers and the computer's hardware clock, but the specific parameters for startup and initializing components are stored in the CMOS.

What is BIOS

BIOS is only appropriate for referring to the start up Firmware of the PC motherboard itself.
Every computer with a motherboard includes a special chip referred to as the BIOS or ROM BIOS (Read Only Memory Basic Input/Output System). The BIOS includes instructions on how to load basic computer hardware. The BIOS also includes a test referred to as a POST (Power On Self Test) which will ensure that the computer meets requirements to boot up properly. If the computer does not pass the POST you will receive a combination of beeps indicating what is malfunctioning within the computer.
The BIOS has 4 main functions:
POST - Test computer hardware insuring hardware is properly functioning before starting process of loading Operating System.
Bootstrap Loader - Process of locating the operating system. If capable Operating system located BIOS will pass the control to it.
BIOS - Software / Drivers which interfaces between the operating system and your hardware. When running DOS or Windows you are using complete BIOS support.
CMOS Setup - Configuration program. Which allows you to configure hardware settings including system settings such as computer passwords, time, and date.


What role does the BIOS play with during the system boot up?

How does system bootstrap

The system BIOS is what starts the computer running when you turn it on. The following are the steps that a typical boot sequence involves.
  1. The internal power supply turns on and initializes. The power supply takes some time until it can generate reliable power for the rest of the computer, and having it turn on prematurely could potentially lead to damage. Therefore, the chipset will generate a reset signal to the processor (the same as if you held the reset button down for a while on your case) until it receives the Power Good signal from the power supply.
  2. When the reset button is released, the processor will be ready to start executing. When the processor first starts up, it is suffering from amnesia; there is nothing at all in the memory to execute. Of course processor makers know this will happen, so they pre-program the processor to always look at the same place in the system BIOS ROM for the start of the BIOS boot program. This is normally location FFFF0h, right at the end of the system memory. They put it there so that the size of the ROM can be changed without creating compatibility problems. Since there are only 16 bytes left from there to the end of conventional memory, this location just contains a "jump" instruction telling the processor where to go to find the real BIOS startup program.
  3. The BIOS performs the power-on self test (POST). which tests and initializes your system’s hardware—including the CPU itself. For example, if your computer doesn’t have any RAM, it will beep and show you an error, stopping the boot process. If there are any fatal errors, the boot process stops. POST beep codes can be found in this area of the Troubleshooting Expert.
  4. The BIOS looks for the video card. In particular, it looks for the video card's built in BIOS program and runs it. This BIOS is normally found at location C000h in memory. The system BIOS executes the video card BIOS, which initializes the video card. Most modern cards will display information on the screen about the video card. (This is why on a modern PC you usually see something on the screen about the video card before you see the messages from the system BIOS itself).
  5. Once video has been enabled,the BIOS begins searching for other devices that may have their own ROM and whether that ROM has its own BIOS code (The BIOS then looks for other devices' ROMs to see if any of them have BIOSes as some peripherals like external HDD , Video Card , Wi-Fi Card can have there own BIOS to initialize there operation ).Normally, the floppy drive is located at 0000:7C00 and the IDE/ATA hard disk BIOS will be found at C8000h and executed. If any other device BIOSes are found, they are executed as well.
  6. The BIOS displays its startup screen.
  7. The BIOS does more tests on the system, including the memory count-up test which you see on the screen. The BIOS will generally display a text error message on the screen if it encounters an error at this point; these error messages and their explanations can be found in this part of the Troubleshooting Expert.
  8. The BIOS performs a "system inventory" of sorts, doing more tests to determine what sort of hardware is in the system. Modern BIOSes have many automatic settings and will determine memory timing (for example) based on what kind of memory it finds. Many BIOSes can also dynamically set hard drive parameters and access modes, and will determine these at roughly this time. Some will display a message on the screen for each drive they detect and configure this way. The BIOS will also now search for and label logical devices (COM and LPT ports).
  9. If the BIOS supports the Plug and Play standard, it will detect and configure Plug and Play devices at this time and display a message on the screen for each one it finds. See here for more details on how PnP detects devices and assigns resources.
  10. The BIOS will display a summary screen about your system's configuration. Checking this page of data can be helpful in diagnosing setup problems, although it can be hard to see because sometimes it flashes on the screen very quickly before scrolling off the top.
  11. The BIOS begins the search for a drive to boot from (depending on the order provided in the BIOS setting stored in the BIOS memory (in old pc it was a separate memory powered by CMOS battery and hence called as CMOS memory , the CMOS battery also powers the system clock i.e. RTC (Real Time Clock , which is a quartz watch ) which stores date and time of the system - On older systems the CMOS battery provided the small amount of charge required to maintain the non-volatile BIOS memory (often called as CMOS memory (mistakenly)as it was powered by CMOS battery), which remembered BIOS settings between reboots. On modern systems this information is typically stored in flash memory and does not require a charge to be maintained.). Most modern BIOSes contain a setting that controls if the system should first try to boot from the floppy disk (A:) or first try the hard disk (C:). Some BIOSes will even let you boot from your CD-ROM drive or other devices, depending on the boot sequence BIOS setting. In modern PC since the settings are stored in flash drive , a BIOS can still work with RTC/CMOS
  12. Having identified its target boot drive, the BIOS looks for boot information to start the operating system boot process. If it is searching a hard disk, it looks for a master boot record at cylinder 0, head 0, sector 1 (the first sector on the disk); if it is searching a floppy disk, it looks at the same address on the floppy disk for a volume boot sector.Traditionally, a BIOS looked at the MBR (master boot record)The MBR is on the first 512-byte sector, a special boot sector at the beginning of a disk. The MBR contains code that loads the rest of the operating system, known as a “bootloader.” MBR normally contains two vital components: a tiny bootstrapping program at the start of the MBR followed by a partition table for the disk. The BIOS however does not care about any of this: it simply loads the contents of the MBR into memory and starts executing whatever code is in the MBR.

    Traditionally Microsoft MBR code takes a look at the partition table, finds the (only) partition marked as active, loads the boot sector for that partition, and runs that code. The boot sector is the first sector of a designated ‘partition’, as opposed to the first sector for the whole disk. The BIOS executes the bootloader, which takes it from there and begins booting the actual operating system—Windows or Linux, for example.
    Computers with UEFI can still use this old-style MBR boot method to boot an operating system, but they normally use something called an EFI executable instead. These don’t have to be stored at the beginning of a disk. Instead, they’re stored on something called an “EFI system partition.”
  13. Either way, the principle is the same—the BIOS or UEFI examines a storage device on your system to look for a small program, either in the MBR or on an EFI system partition, and runs it. If there’s no bootable boot device, the bootup process fails, and you’ll see an error message saying so on your display.
  14. If it finds what it is looking for, the BIOS starts the process of booting the operating system, using the information in the boot sector. At this point, the code in the boot sector takes over from the BIOS. The DOS boot process is described in detail here. If the first device that the system tries (floppy, hard disk, etc.) is not found, the BIOS will then try the next device in the boot sequence, and continue until it finds a bootable device.
  15. If no boot device at all can be found, the system will normally display an error message and then freeze up the system. What the error message is depends entirely on the BIOS, and can be anything from the rather clear "No boot device available" to the very cryptic "NO ROM BASIC - SYSTEM HALTED". This will also happen if you have a bootable hard disk partition but forget to set it active.

The bootloader is a small program that has the large task of booting the rest of the operating system. Windows uses a bootloader named Windows Boot Manager (Bootmgr.exe), most Linux systems use GRUB, and Macs use something called boot.efi.
The bootloader is just one small program, and it doesn’t handle the boot process on its own. On Windows, the Windows Boot Manager finds and starts the Windows OS Loader. The OS loader loads essential hardware drivers that are required to run the kernel—the core part of the Windows operating system—and then launches the kernel. The kernel then loads the system Registry into memory and also loads any additional hardware drivers that are marked with “BOOT_START,” which means they should be loaded at boot. The Windows kernel then launches the session manager process (Smss.exe), which starts the system session and loads additional drivers. This process continues, and Windows loads background services as well as the welcome screen, which lets you sign in.
On Linux, the GRUB boot loader loads the Linux kernel. The kernel also starts the init system—that’s systemd on most modern Linux distributions. The init system handles starting services and other user processes that lead all the way to a login prompt.
This involved process is just a way of making everything load correctly by doing things in the correct order.
By the way, so-called “startup programs” actually load when you sign into your user account, not when the system boots. But some background services (on Windows) or daemons (on Linux and macOS) are started in the background when your system boots.

BIOS is a piece of program. When the system starts, the register EIP is initialized to FFFF0 to execute the JMP instruction there, which leads to the execution of the system BIOS code.
BIOS will initialize other devices; initialize the interrupt vector; find other BIOS programs and run them.


BIOS Extension  -- This is a Hyperlink


  • BIOS runs it's processes (detect CPU, count RAM, scan for hard drives, scan for CD-ROMS, etc).
  • It reads the data from CMOS related to boot priority (i.e. where it should start searching for the MBR i.e. in HDD , Floppy or CD/DVD)
  • BIOS reads from HDD boot sector and finds the target (starting) address on a bootable partition.
  • BIOS starts reading from the hard drive at the address specified in the boot sector.
  • The program/commands that reside at that starting address are the first instructions that the CPU begins to process. Those initial commands load more and more stuff, eventually culminating in your operating system being loaded into memory and listening for user inputs.

The CMOS battery, or RTC battery, provides power for the real-time clock so that your computer can continue to keep time when it is unplugged.

  • The name "CMOS battery" is a misnomer on modern computers. Older computers used the battery to maintain BIOS settings, which were stored in a CMOS SRAM chip that would lose its contents if disconnected from power. This setup does have the advantage of making it easy to clear the BIOS settings, either by removing the battery or by inserting or removing a jumper. Newer systems store firmware (BIOS or UEFI) settings in flash memory or EEPROM, which does not require power to maintain data. See: Wikipedia article on nonvolatile BIOS memory and How can a CMOS battery store data?
  • This battery was, and still is, used to maintain the real-time clock. As this is the sole purpose of the battery today, it is sometimes called the RTC battery. This ensures that your computer can continue to keep time even when unplugged. The battery is usually a readily-available CR2032 button cell, and is typically usable for 2 to 10 years. If your computer loses track of time when unplugged for more than a few hours, it is time to replace the battery. See: How long does CMOS battery (3V) on a motherboard last?


An overview of the boot process

sequence

The BIOS chip tells it to look in a fixed place, usually on the lowest-numbered hard disk (the boot disk) for a special program called a boot loader (under Linux the boot loader is called Grub or LILO). The boot loader is pulled into memory and started. The boot loader’s job is to start the real operating system.
POST (Power On Self Test) The Power On Self Test happens each time you turn your computer on.
The POST first checks the bios and then tests the CMOS RAM. If there is no problem with this then POST continues to check the CPU, hardware devices such as the Video Card, the secondary storage devices such as the Hard Drive, Floppy Drives, Zip Drive or CD/DVD Drives. If some errors found then an error message is displayed on the screen or a number of beeps are heard. These beeps are known as POST beep codes.

Master Boot Record

The Master Boot Record (MBR) is a small program that starts when the computer is booting, in order to find the operating system (eg. Windows XP). This complicated process (called the Boot Process) starts with the POST (Power On Self Test) and ends when the Bios searches for the MBR on the Hard Drive, which is generally located in the first sector, first head, first cylinder (cylinder 0, head 0, sector 1).
A typical structure looks like:
mbr

Alternatively referred to as bootstrappingbootloader, or boot program, a bootstrap loader is a program that resides in the computer's EPROMROM, or another non-volatile memory. It is automatically executed by the processor when turning on the computer. The bootstrap loader reads the hard drives boot sector to continue the process of loading the computer's operating system. The term bootstrap comes from the old phrase "Pull yourself up by your bootstraps."

The bootstrap loader is stored in the master boot record (MBR) on the computer’s hard drive. When the computer is turned on or restarted, it first performs the power-on-self-test, also known as POST. If the POST is successful and no issues are found, the bootstrap loader will load the operating system for the computer into memory. The computer will then be able to quickly access, load, and run the operating system.

Upon starting, an IBM-compatible personal computer's x86 CPU executes, in real mode, the instruction located at reset vector (the physical memory address FFFF0h on 16-bit x86 processorsand FFFFFFF0h on 32-bit and 64-bit x86 processors), usually pointing to the firmware (UEFI or BIOS) entry point inside the ROM. This memory location typically contains a jump instruction that transfers execution to the location of the firmware (UEFI or BIOS) start-up program. This program runs a power-on self-test (POST) to check and initialize required devices such as DRAM and the PCI bus (including running embedded ROMs). The most complicated step is setting up DRAM over SPI, made more difficult by the fact that at this point memory is very limited.
After initializing required hardware, the firmware (UEFI or BIOS) goes through a pre-configured list of non-volatile storage devices ("boot device sequence") until it finds one that is bootable. A bootable MBR device is defined as one that can be read from, and where the last two bytes of the first sector contain the little-endian wordAA55h found as byte sequence 55hAAh on disk (also known as the MBR boot signature), or where it is otherwise established that the code inside the sector is executable on x86 PCs.
Once the BIOS has found a bootable device it loads the boot sector to linear address 7C00h (usually segment:offset 0000h:7C00h,but some BIOSes erroneously use 07C0h:0000h) and transfers execution to the boot code. In the case of a hard disk, this is referred to as the Master Boot Record (MBR) and is by definition not operating-system specific. The conventional MBR code checks the MBR's partition table for a partition set as bootable (the one with active flag set). If an active partition is found, the MBR code loads the boot sector code from that partition, known as Volume Boot Record (VBR), and executes it.
The VBR is often operating-system specific; however, in most operating systems its main function is to load and execute the operating system kernel, which continues startup.
If there is no active partition, or the active partition's boot sector is invalid, the MBR may load a secondary boot loader which will select a partition (often via user input) and load its boot sector, which usually loads the corresponding operating system kernel. In some cases, the MBR may also attempt to load secondary boot loaders before trying to boot the active partition. If all else fails, it should issue an INT 18h[29][27] BIOS interrupt call (followed by an INT 19h just in case INT 18h would return) in order to give back control to the BIOS, which would then attempt to boot off other devices, attempt a remote boot via network or invoke ROM BASIC.[27]
Some systems (particularly newer Macintoshes and new editions of Microsoft Windows) use Intel's EFI. Also coreboot allows a computer to boot without having the firmware/BIOS constantly running in system management mode. 16-bit BIOS interfaces are required by certain x86 operating systems, such as DOS and Windows 3.1/95/98 (and all when not booted via UEFI). However, most boot loaders retain 16-bit BIOS call support.

Reset Vector

The reset vector is the default location a central processing unit will go to find the first instruction it will execute after a reset. The reset vector is a pointer or address, where the CPU should always begin as soon as it is able to execute instructions. The address is in a section of non-volatile memory initialized to contain instructions to start the operation of the CPU, as the first step in the process of booting the system containing the CPU.
  • The reset vector for the 8086 processor is at physical address FFFF0h (16 bytes below 1 MB). The value of the CS register at reset is FFFFh and the value of the IP register at reset is 0000h to form the segmented address FFFFh:0000h, which maps to physical address FFFF0h.

Shadowing

A technique used to increase a computer's speed by using high-speed RAM memory in place of slower ROM memory (RAM is about three times as fast as ROM). On PCs, for example, all code to control hardware devices, such as keyboards, is normally executed in a special ROM chip called the BIOS ROM. However, this chip is slower than the general-purpose RAM that comprises main memory. Many PC manufacturers, therefore, configure their PCs to copy the BIOS code into RAM when the computer boots. The RAM used to hold the BIOS code is called shadow RAM.



  • GNU Grand Unified Bootloader (GRUB): A multiboot specification that allows the user to choose one of several OSs
  • NT Loader (NTLDR): A bootloader for Microsoft’s Windows NT OS that usually runs from the hard drive
  • Linux Loader (LILO): A bootloader for Linux that generally runs from a hard drive or floppy disc
  • Network Interface Controller (NIC): Uses a bootloader that supports booting from a network interface such as Etherboot or pre-boot execution environment (PXE)

Comments

Popular posts from this blog

What is .TLC (Target Language Compiler) and MEX file in Matlab Simulink

Simulink & Matlab Interview Question and Answers For Automotive , Aerospace etc.

Real World Value Vs Stored Integer In Simulink ( Fixed Point Number Debunked )