How XNIX and other operating systems startup.txt 1.3 KB

123456789101112131415161718192021222324
  1. How can opereating systems starup? You may ask this when reading source code of linux. Why can hardware execute the linux kernel? How does hardware find it?
  2. We know CPU should execute something when it's starting. The Operating Systems are all in disks (HD or SSD), but CPU can't read from any disks. It reads codes from memory and executes it.
  3. So, hardware engineers write code in ROM (Read-Only Memory) and let the CPU execute it at startup. The name of code in ROM is BIOS (Basic Input & Output System).
  4. BIOS initializes all devices it can find. Then it read from the first sector on disk to 0x0000:0x7c00. It has a special name -- MBR (Master Boot Record).
  5. BIOS checks the end of this disk's MBR. If it's 0xAA55 (10101010 and 01010101 in binary), BIOS will execute the MBR.
  6. Otherwise, it reads the MBR of next disk.
  7. The size of a sector is only 512 bytes, it's too small. So all operating systems will read operating system's kernel from disk, and jump to it.
  8. So when CPU is starting, it will execute BIOS in ROM. BIOS will read MBR from disk and check its tail. MBR always reads kernel from disk.
  9. BIOS: Basic Input & Output System
  10. ROM: Read-Only Memory
  11. MBR: Master Boot Record
  12. Linux: A free i386 UNIX-like operating system kernel.
  13. sector: The smallest unit of disks. (Always 512 Bytes)