What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Computer System Basics 2 Hard Drive Storage & File Partitions Computer Forensics BACS 371.
Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.
Genesis: from raw hardware to processes System booting sequence: how does a machine come into life.
Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
Hard-Disk Partitions Ref: Wikipedia. What and Why Disk partitioning –The creation of logical divisions upon a hard disk that allows one to apply operating.
The power supply performs a self-test. When all voltages and current levels are acceptable, the supply indicates that the power is stable and sends the.
COSC 120 Computer Programming
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
CS2422 Assembly Language & System Programming November 2, 2006.
1 Web Server Administration Chapter 3 Installing the Server.
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
Understanding POST and ROM-BIOS service functions Numerous low-level services are available to real-mode programs (include boot-loaders)
Operating Systems File systems
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
 Contents 1.Introduction about operating system. 2. What is 32 bit and 64 bit operating system. 3. File systems. 4. Minimum requirement for Windows 7.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Files & Partitions BACS 371 Computer Forensics. Data Hierarchy Computer Hard Disk Drive Partition File Physical File Logical File Cluster Sector Word.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
BLOCK DIAGRAM OF COMPUTER
Tel : 同济大学软件学院 UEFI 与固件程序设计.
Computer Systems Week 10: File Organisation Alma Whitfield.
Linux Booting Procedure
Booting. Booting is the process of powering it on and starting the operating system. power on your machine, and in a few minutes your computer will be.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Guide to Linux Installation and Administration, 2e1 Chapter 2 Planning Your System.
Hardware Boot Sequence. Vocabulary BIOS = Basic Input Output System UEFI = Unified Extensible Firmware Interface POST= Power On Self Test BR = Boot Record.
Installation Overview Lab#2 1Hanin Abdulrahman. Installing Ubuntu Linux is the process of copying operating system files from a CD, DVD, or USB flash.
ENGI 3655 Lab Sessions 1Richard Khoury.  Linked Allocation ◦ Section Richard Khoury2.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Chapter 3 Partitioning Drives using NTFS and FAT32 Prepared by: Khurram N. Shamsi.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Week #3 Objectives Partition Disks in Windows® 7 Manage Disk Volumes Maintain Disks in Windows 7 Install and Configure Device Drivers.
Operating System Concepts and Techniques Lecture 18 Information management-2* FFS, UFS2, NTFS M. Naghibzadeh Reference M. Naghibzadeh, Operating System.
GUID Partition Table Unified Extensible Firmware Interface (UEFI)
Memory management.
Genesis: From Raw Hardware to Processes Andy Wang Operating Systems COP 4610 / CGS 5765.
Week1: Introduction to Computer Networks. Copyright © 2012 Cengage Learning. All rights reserved.2 Objectives 2 Describe basic computer components and.
Unit 1: Computing Fundamentals. Computer Tour-There are 7 major components inside a computer  Write down each major component as it is discussed.  Watch.
 Contents 1.Introduction about operating system. 2. Minimum requirement for Windows 7 operating system. 3. Procedure to install Window 7 operating system.
Memory Management Chapter 5 Advanced Operating System.
System initialization Unit objectives A.Outline steps necessary to boot a Linux system, configure LILO and GRUB boot loaders, and dual boot Linux with.
Von Neumann Machines. 3 The Von Neumann Architecture Model for designing and building computers, based on the following three characteristics: 1)The.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
NON STANDARD HARDWARE By the end of this lesson you will be able to: 1. Identify non standard computer hardware 2. Understand ACRONYMS used to describe.
OS Boot Sequence and File System (implication to “Boot Sector Viruses”) Department of Computer Science Southern Illinois University Edwardsville Spring,
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
IT Chapter 2 Part A How Computers Work Input, process, output, and storage The operating system helps the computer perform four basic operations,
Tech Level Cyber Security
Computer Basics.
Chapter Objectives In this chapter, you will learn:
GUID Partition Table Unified Extensible Firmware Interface (UEFI)
Computer Organization & Assembly Language Chapter 3
GUID Partition Table Unified Extensible Firmware Interface (UEFI)
Windows XP File Systems
Computer System Structures
CS-401 Computer Architecture Assembly Language Programming
Booting Up 15-Nov-18 boot.ppt.
Computers: Hardware and Software
Genesis: From Raw Hardware to Processes
Computer-System Architecture
Module 2: Computer-System Structures
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
GUID Partition Table Unified Extensible Firmware Interface (UEFI)
GUID Partition Table Unified Extensible Firmware Interface (UEFI)
Module 2: Computer-System Structures
Course Code 114 Introduction to Computer Science
Introduction to BIOS Prof. Shamim Ahmad Hakim
Presentation transcript:

What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector

Our own ISR Last time we wrote our own ISR (Interrupt Service Routine) for handling ‘timer-tick’ interrupts while the CPU is in ‘real-mode’ It was short, but it included two essential features of any interrupt service routine: –It preserved all register-values, and –It sent an EOI-command to the PIC

Only six instructions ticks:.word0# stores the number of interrupts # # Our own Interrupt Service Routine for the ‘timer-tick’ interrupt # isr_tick:push%ax# must preserve the AX register incw%cs:ticks# add 1 to our ‘ticks’ counter mov$0x20, %al# send a non-specific EOI out%al, $0x20# to the interrupt controller pop%ax# recover the saved AX value iret# resume the interrupted task

Disassembly You can easily see how much storage is needed for the machine-code in our ISR: $ objdump -d -Mi8086 tickdemo.o This command-line switch asks for a ‘disassembly’ of the object-file This command-line switch tells which kind of Machine that object-code was written for (namely, Intel 8086) so we’ll see 16-bit real-mode assembly mnemonics

ISRs for other devices Our timer’s ISR consumed only 12-bytes (out of 512-bytes in a single disk-sector) But much more code is needed in an ISR for some of the other peripheral devices, such as the computer’s keyboard: –105 keys, with up to 8 interpretations-per-key, so potentially a minimum of 8-hundred bytes It wouldn’t all fit into a single disk-sector!

Serious x86 explorations Experimenting with most x86 features will require us to write larger-size demos than can be fit into one disk-sector (512 bytes) So we need a way to load such programs into memory when no OS is yet running And we need a convenient way to place such programs onto a persistent storage medium so they can easily be accessed

Our classroom setup Our workstations’ hard disks have been ‘partitioned’ in way that provides a large unused storage-area for us to use freely But other portions of these hard disks are dedicated to supporting vital courseware for students who are taking other classes We have to understand how to access our ‘free’ area without disrupting anyone else

Fixed-Size ‘blocks’ All data-transfers to and from the hard disk are comprised of fixed-size blocks called ‘sectors’ (whose size equals 512 bytes) On modern hard disks, these sectors are identified by sector-numbers starting at 0 This scheme for addressing disk sectors is known as Logical Block Addressing (LBA) So the hard disk is just an array of sectors

Visualizing the hard disk ….. A large array of 512-byte disk sectors Disk storage-capacity (in bytes) = (total number of sectors) x (512 bytes/sector) Example: If disk-capacity is 250 GigaBytes, then the total number of disk-sectors can be found by division: ( bytes) / (512 bytes-per-sector) assuming that you have a pocket-calculator capable of displaying enough digits!

Disk Partitions The total storage-area of the hard disk is usually subdivided into non-overlapping regions called ‘disk partitions’ Partition #1Partition #2Partition #3 unused

Master Boot Record A small area at the beginning of the disk is dedicated to ‘managing’ the disk partitions In particular, sector number 0 is known as the Master Boot Record (very important!) MBR … partition #1

Format of the MBR The MBR is subdivided into three areas: –The boot loader program (e.g., GRUB) –The ‘partition table’ data-structure –The MBR signature (i.e., 0x55, 0xAA) signature (2 bytes) Partition Table (64 bytes) Boot Loader (446 bytes) 512 bytes

‘Reading’ the MBR To see the hard disk’s Partition Table, we must ‘read’ the entire Master Boot Record (We ignore the boot-loader and signature) But we will need to understand the format of the data stored in that Partition Table We first need to know how to devise code that can transfer the MBR (sector 0) from the hard-disk into a suitable memory-area

Partition Table Entries The MBR is an array containing four data- structures (called ‘partition-table entries’): Starting sector ID-number Partition length (in sectors) STATUSSTATUS TYPETYPE 16 bytes Some fields contain ‘obsolete’ information

TYPE-ID Each partition-table entry has a TYPE-ID –TYPE-ID is 0x07 for a ‘Windows’ partition –TYPE-ID is 0x83 for our ‘Linux’ partition –TYPE-ID is 0x00 when the entry is ‘unused’ You can find a list of TYPE-ID numbers posted on the internet (see our website) Our disks have an extra ‘Linux’ partition that nobody else is using this semester

BIOS Disk Drive Services An assortment of disk-access functions is available under software Interrupt 0x13 Originally there were just six functions (to support IBM-PC floppy diskette systems) More functions were added when PC/XTs introduced the use of small Hard Disks Now, with huge hard-disk capacities, there is a set of “Enhanced Disk Drive” services

Phoenix Technologies Ltd You can find online documentation for the BIOS EDD specification 3.0 (see website) We’ll use function 0x42 to read the MBR It requires initializing some fields in a small data-structure (the “Disk-Address Packet”) Then we load parameters in four registers (DS:SI = address of the DAP, DL = disk-ID and AH = 0x42) and execute ‘int $0x13’

EDD Disk-Address Packet reserved (=0x00) sector count reserved (=0x00) packet length segment-address of transfer-area offset-address of transfer area Logical Block Address of disk-sector (64-bits) Physical-address of memory transfer-area (64-bits) (in case segment:offset above is 0xFFFF:FFFF) NOTE: The final 8-byte field (shown in gray) is not needed when we’re transferring disk-sectors into memory-regions that are addressable in ‘real-mode’ (i.e., address can be expressed in ‘segment:offset’ format)

The MBR parameters # packet:.byte16, 0# packet-size = 16 bytes.byte1, 0# sector-count = 1 sector.word0x0200, 0x07C0# transfer-area’s address.quad0# MBR’s Logical Block Address # Here are assembly language statements that you could use to create a Disk Address Packet for reading the hard-disk’s Master Boot Record into the memory-area immediately following the 512-byte BOOT_LOCN area Our demo-program (named ‘cs630ipl.s’) uses statements similar to these.

‘Extended’ partitions The hard-disk’s Master Boot Record only has room for four Partition-Table Entries But some systems need to use more than four disk-partitions, so a way was devised to allow one of the MBR’s partition-table entries to describe an ‘extended’ partition This scheme does not seem to have been ‘standardized’ yet -- hence, confusion!

The Linux scheme Partition #1 Partition #2 Partition #3 Extended Partition (partition #4) Partition #5 Partition #6 Partition #7

Our ‘cs630ipl.s’ boot-loader We created a ‘boot-loader’ that will work with Linux systems that have ‘extended’ disk-partitions (“Initial Program Loader”) It uses the EDD Read_Sectors function, and it will read 127 consecutive sectors from the disk’s final Linux-type partition It transfers these disk-sectors into the memory-arena at address 0x

The ‘ourfirst.s’ demo-program To demonstrate our boot-loader, we wrote a short program that can be ‘loaded’ into memory at 0x10000 and then executed It will just show a message (but thereby will verify that our boot-loader worked!) Our boot-loader requires that a special ‘program signature’ (i.e., 0xABCD) must occupy the first word of any program it attempts to execute (as a ‘sanity’ check)

A depiction of ‘boot-strapping’ system ram ‘cs630ipl.b’ any demo program 0x x00007C00 0x Step 1: The ROM-BIOS firmware loads GRUB Step 2: The user selects a disk-partition from the GRUB program’s menu’s options Step 3: GRUB loads our ‘cs630ipl.b’ loader Step 4: ‘cs630ipl.b’ loads our program demo We install our ‘cs630ipl.b’ loader into the boot-sector of disk-partition number 4: $ dd if=cs630ipl.b of=/dev/sda4 We install the ‘ourfirst.b’ demo-program into the subsequent disk-sectors: $ dd if=ourfirst.b of=/dev/sda4 seek=1 Then we ‘reboot’ our machine to begin the bootstrapping process…

In-class exercise #1 Use ‘dd’ to install the ‘cs630ipl.b’ boot-loader on your classroom machine’s CS630 Partition: $ dd if=cs630ipl.b of=/dev/sda4 Also install the ‘ourfirst.b’ demo-program on your classroom machine’s disk, following sector 0: $ dd if=ourfirst.b of=/dev/sda4 seek=1 Then use the ‘fileview’ utility-program (from our class website, under ‘System Software’) to view the first few disk-sectors in partition number 4: $ fileview /dev/sda4

In-class exercise #2 Try ‘rebooting’ your classroom machine, to see the message shown by ‘ourfirst.b’ –Use ‘reboot’ to restart your machine –Watch for the GRUB menu-selection that will launch the ‘boot-strapping’ process (i.e., the ‘CS 630 Partition’ GRUB-menu selection) –Confirm that our ‘boot-loader’ works (i.e., by watching for the message that the ‘ourfirst.s’ demo-program is supposed to display

In-class exercise #3 Can you apply what you’ve learned in our previous lessons to enhance the message that the ‘ourfirst.s’ demo-program prints, so that it would include some truly useful item of information about your machine’s state at boot-time?