Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.

Slides:



Advertisements
Similar presentations
Chapter 2 How Hardware and Software Work Together.
Advertisements

Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Memory Management: Overlays and Virtual Memory
PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Genesis: from raw hardware to processes System booting sequence: how does a machine come into life.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Computer System Overview
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.
Booting the Linux Kernel Dr. Michael L. Collard 1.
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.
Linux+ Guide to Linux Certification, Second Edition
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.
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
CS 630: Advanced Microcomputer Programming Fall 2006 Professor Allan B. Cruse University of San Francisco.
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
Defining protected-mode segment-descriptors An example of a protected-mode bootsector application that draws a message to the video display.
Linux+ Guide to Linux Certification, Second Edition Chapter 3 Linux Installation and Usage.
CS 630: Advanced Microcomputer Programming Fall 2008 Professor Allan B. Cruse University of San Francisco.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
EET 450 Chapter 2 – How hardware and Software Work Together.
CS2422 Assembly Language & System Programming November 2, 2006.
Executing an ELF executable
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
CS 630: Advanced Microcomputer Programming Spring 2004 Professor Allan B. Cruse University of San Francisco.
Executing an ELF executable How to load an executable ELF file for execution in ‘extended’ physical memory.
Understanding POST and ROM-BIOS service functions Numerous low-level services are available to real-mode programs (include boot-loaders)
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
VGA System Services How to use Linux’s ‘vm86()’ system-call to access the video ROM-BIOS functions.
On 64-bit ‘code-relocation’ How we can launch a procedure in 64-bit mode that resides in a page-frame at a high address.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
Introduction Part 1 The Microprocessor Based Systems  Memory and I/O System  Microprocessor.
Tel : 同济大学软件学院 UEFI 与固件程序设计.
Linux+ Guide to Linux Certification Chapter Three Linux Installation and Usage.
Computer Organization
hardware and operating systems basics.
Chapter 5 Basic Input/Output System (BIOS)
Basic Input Output System
Linux Booting Procedure
System Calls 1.
1/2002JNM1 With 20 bits, 1,048,576 different combinations are available. Each memory location is assigned a different combination. Each memory location.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Computer Platforms Week 4: Assembly Language & Operating Systems.
Boot Sequence (DOS) for the IBM PC
From UEFI Shell to Linux - UEFI Linux BootLoader Zhang Rui Software Engineer Sep 28 th 2011.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Hardware Boot Sequence. Vocabulary BIOS = Basic Input Output System UEFI = Unified Extensible Firmware Interface POST= Power On Self Test BR = Boot Record.
Chapter 4 Storage Management (Memory Management).
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
1. Stage-1 Bootloader ENGI 3655 Lab Sessions Richard Khoury.
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)
2003 Dominic Swayne1 Microsoft Disk Operating System and PC DOS CS-550-1: Operating Systems Fall 2003 Dominic Swayne.
SAPC Hardware Pentium CPU (or 486) 4M usable memory no hard disk; boot from floppy no keyboard or monitor or mouse COM2 serial port: used for console i/o.
Computer organization Practical 1. Administrative Issues The course requirements are: –To be nice and open minded –To pass the exam (there is a boolean.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Memory Management: Overlays and Virtual Memory. Agenda Overview of Virtual Memory –Review material based on Computer Architecture and OS concepts Credits.
Genesis: From Raw Hardware to Processes Andy Wang Operating Systems COP 4610 / CGS 5765.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
OS Boot Sequence and File System (implication to “Boot Sector Viruses”) Department of Computer Science Southern Illinois University Edwardsville Spring,
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 1 Looking Inside the Computer System.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Overview A) Power on or reset B) 1st stage boot loader C) 2nd stage boot loader D) Operate system.
Computer Organization & Assembly Language Chapter 3
CS703 - Advanced Operating Systems
Booting Up 15-Nov-18 boot.ppt.
SAPC Hardware Pentium CPU (or 486) 4M usable memory
Genesis: From Raw Hardware to Processes
OS Boot Sequence and File System
OS Boot Sequence and File System
Presentation transcript:

Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware

Our ‘bare machine’ If we want to do a “hands on” study of our CPU, without any operating system getting in our way, we have to begin by exploring ‘Real Mode’ (it’s the CPU’s startup state) We will need to devise a mechanism by which our program-code can get loaded into memory (since we won’t have an OS) This means we must write a ‘boot loader’

Our ‘bare machine’ If we want to do a “hands on” study of our CPU, without any operating system getting in our way, we have to begin by exploring ‘Real Mode’ (it’s the CPU’s startup state) We will need to devise a mechanism by which our program-code can get loaded into memory (since we won’t have an OS) So we utilize the ROM-BIOS ‘boot loader’

What’s a ‘boot loader’ After testing and initializing the machine’s essential hardware devices, the startup program in the ROM-BIOS firmware will execute its ‘boot loader’, to read a small amount of code and data into memory from some type of non-volatile storage medium (e.g, floppy-diskette, hard-disk, magnetic-tape, CD-ROM, etc.) and then ‘jump’ to that location in memory

PC ROM-BIOS BOOT_LOCN BOOT_LOCN 0x00007C00 0x00007E bytes ROM-BIOS VRAM IVT and BDA 8086 memory-map RAM Vendor’s Firmware Video Display Memory No installed memory Volatile Program Memory 1-MB

Some Requirements A ‘boot loader’ has to be 512 bytes in size (because it has to fit within a disk sector) Must begin with executable machine-code Must end with a special ‘boot signature’ Depending on the type of storage medium, it may need to share its limited space with certain other data-structures (such as the ‘partition table’ on a hard disk, or the Bios Parameter Block’ on a MS-DOS diskette)

Writing a ‘boot-sector’ program Not practical to use a high-level language We need to use 8086 assembly language We can use the Linux development tools: –The ‘vi’ editor –The ‘as’ assembler –The ‘ld’ linker –The ‘dd’ copy-and-convert utility

Using ROM-BIOS functions Our system firmware provides many basic service-functions that real mode programs can invoke (this includes ‘boot-loaders’): –Video display functions –Keyboard input functions –Disk access functions –System query functions –A machine ‘re-boot’ function

ROM-BIOS documentation The standard ROM-BIOS service-routines are described in numerous books that deal with assembly language programming for Intel-based Personal Computers They are also documented online (e.g., see the link on our class website to Ralf Brown’s Interrupt List)

A ‘typical’ calling convention A service-function ID-number is placed in the processor’s AH register Other registers are then loaded with the values of any parameters that are needed Then a ‘software interrupt’ instruction is executed which transfers control to the code in the Read-Only Memory (ROM) Often, upon return, the carry-flag is used for indicating that the function succeeded

Example: Write_String function Setup parameters in designated registers –AH = function ID-number (e.g. 0x13) –AL = cursor handling method (e.g. 0x01) –BH = display page-number (e.g., 0x00) –BL = color attributes (e.g., 0x0A) –CX = length of the character-string –DH, DL = row-number, column-number –ES:BP = string’s starting-address (seg:off) Call BIOS via software interrupt (int-0x10)

Real Mode 8086/8088 had only one execution mode It used “segmented” memory-addressing Physical memory on 8086 was subdivided into overlapping “segments” of fixed-size The length of any memory “segment” was fixed at 64KB until the processor has been switched out of its initial ‘real-mode’ and its segment-registers reprogrammed

64KB Memory-Segments Fixed-size segments partially overlap Segments start on paragraph boundaries Segment-registers serve as “selectors” code data stack CS DS SS

Real-Mode Address-Translation 0x12340x6789 Logical address: 16-bit segment-address16-bit offset-address x x18AC9 20-bit bus-address Physical address: 0x x x18AC9

‘Real-Mode’ Memory Map BOOT_LOCN 0x00007C00 0x00007E bytes ROM-BIOS VRAM IVT RAM Vendor’s Firmware Video Display Memory No installed memory Volatile Program Memory 1-MB RBDA 0x x x bytes 256 bytes Extended BIOS Data Top of RAM (= 0x000A0000) Video-ROM 128 kbytes 64+ kbytes

Downloading a class demo You can ‘download’ a program source-file from our CS 630 course-website to your own ‘present working directory’ by using the Linux file-copy command, like this: $ cp /home/web/cruse/cs630/bootdemo.s. (Here the final period-character (‘.’) is the Linux shell’s symbol for your ‘current directory’).

Compiling and Installing Compiling our ‘bootdemo.s’ using ‘as’ is a two- step operation (and requires use of a linker- script, named ‘ldscript’): $ as bootdemo.s –o bootdemo.o $ ld bootdemo.o –T ldscript –o bootdemo.b Installing our bootdemo.b into the starting sector of a hard-disk partition is very simple: $ dd if=bootload.b of=/dev/sda4

Executing our ‘bootdemo’ You’ll need to perform a system ‘reboot’ Our classroom machines will load GRUB (the Linux GRand Unified Boot-loader) GRUB will display a menu of Boot Options You can choose ‘boot from a disk-partition’

In-class exercise Can you modify our ‘bootdemo.s’ program so that it will display some information that is more useful? For example, can you display the Vendor Identification String and the Brand String? (Remember, you code and data must fit within a single 512-byte disk-sector) You can use ‘fileview’ to check on space