7dd877ac8e80abc927a8818c35f337b8.ppt
- Количество слайдов: 44
DOS- Disk Operating System
Contents Internals of DOS, DOS loading, DOS memory map, Concepts of TSR,
ROM-BIOS POST System configuration analysis Time of the day Print Screen Bootstrap loader I/O support programs
DOS Interface between user and computer Convert command into Computer actions DOS manager, BIOS caretaker
The structure of DOS Three layers are: ◦ The BIOS (Basic Input/Output System) ◦ The DOS kernel ◦ The command processor (shell)
The BIOS Module Specific to the individual computer system and is provided by the manufacturer of the system. It contains the default resident hardware-dependent drivers for the following devices: ◦ Console display and keyboard (CON) ◦ Line printer (PRN) ◦ Auxiliary device (AUX) ◦ Date and time (CLOCK$) ◦ Boot disk device (block device) MS-DOS kernel sends I/O request packets to these device drivers; the drivers translate these requests into the proper commands for the various hardware controllers.
The BIOS Module continued… In many MS-DOS systems, the most primitive parts of the hardware drivers are located in read-only memory (ROM) so that they can be used by stand-alone applications, diagnostics, and the system startup program. The terms resident and installable are used to distinguish between the drivers built into the BIOS and the drivers installed during system initialisation by DEVICE commands in the CONFIG. SYS file. The BIOS is read into random-access memory (RAM) during system initialisation as part of a file named IO. SYS.
MS-DOS Kernel • The kernel provides a collection of hardware-independent services called system functions. - File Management - Memory Management - Device Input and Output - Process control
The DOS Kernel The kernel is a proprietary program and provides a collection of hardware-independent services called system functions. These functions include the following: ◦ ◦ ◦ File and record management Memory management Character-device input/output Spawning of other programs Access to the real-time clock
The DOS Kernel continued… Programs can access system functions by loading registers with function-specific parameters and then transferring to the operating system by means of a software interrupt. The DOS kernel is read into memory during system initialization from the MSDOS. SYS file on the boot disk. (The file is called IBMDOS. COM in PC-DOS. ) This file is marked with the attributes hidden and system.
The Command Processor The command processor, or shell, is the user's interface to the operating system. It is responsible for parsing (describing) and carrying out user commands, including the loading and execution of other programs from a disk or other mass-storage device. The default shell that is provided with MS-DOS is found in a file called COMMAND. COM. It is a special class of program running under the control of MS-DOS.
More about COMMAND. COM Default MS-DOS shell, COMMAND. COM, is divided into three parts: ◦ A resident portion ◦ An initialization section ◦ A transient module The resident portion is loaded in lower memory, above the DOS kernel and its buffers and tables. It contains the routines to process Ctrl-C and Ctrl-Break, critical errors, and the termination (final exit) of other transient programs. This part of COMMAND. COM issues error messages and is responsible for the familiar prompt Abort, Retry, Ignore? The resident portion also contains the code required to reload the transient portion of COMMAND. COM when necessary.
More about COMMAND. COM The continued… initialization section of COMMAND. COM is loaded above the resident portion when the system is started. It processes the AUTOEXEC. BAT batch file (the user's list of commands to execute at system startup), if one is present, and is then discarded.
More about COMMAND. COM continued… The transient portion of COMMAND. COM is loaded at the high end of memory, and its memory can also be used for other purposes by application programs. The transient module issues the user prompt, reads the commands from the keyboard or batch file, and causes them to be executed. When an application program terminates, the resident portion of COMMAND. COM does a checksum of the transient module to determine whether it has been destroyed and fetches a fresh copy from the disk if necessary.
User Commands The user commands that are accepted by COMMAND. COM fall into three categories: Internal commands (carried out by code embedded in COMMAND. COM) External commands (names of programs stored on disk file) Batch files (batch or group of DOS commands)
DOS Loading When system starts/reset program execution begins at an address FFFF 0 H, which lies within ROM area, containing a jump instruction to system test code and the ROM bootstrap routine, ROM bootstrap routine reads the disk bootstrap routine from the boot sector of the system startup disk into memory at some arbitrary address, And then transfers control to it.
DOS Loading Continued…. The disk bootstrap routine checks for MSDOS, by checking first two files from first sector of root directory. If not found user is prompted to change disk, and strike any key to try again. If found, both files will be read into memory by disk bootstrap routine and transfers controls to the initial entry point of IO. SYS.
DOS Loading Continued…. IO. SYS consists of two separate modules ◦ BIOS: containing the linked set of resident device drivers, ◦ SYSINIT: Supplied by Microsoft and linked into the IO. SYS file, along with the BIOS by the computer manufacturer. SYSINIT is called by BIOS initialisation code, Determines the contiguous memory present in the system and then relocates itself to high memory, Then it moves the DOS kernel, MS-DOS. SYS, from its original load location to its final location, overlaying the original SYSINIT code and any other expendable initialisation code of IO. SYS
DOS Loading Continued…. SYSINIT, next calls the initialisation code in MSDOS. SYS, DOS kernel initailises its internal tables and work areas, sets up the interrupt vectors 20 H through 2 FH, and traces through the linked list of resident device drivers, calling the initialisation function for each. These driver functions determine the equipment status, preform any necessary hardware initialisation, and set up the vectors for any external hardware interrupts the driver will service.
Boot Process Step 0: CPU Reset ◦ Blank memory, except ROM ◦ Start running from address FFFF 0 (only 16 bytes left!) Step 1: Power-on self test (POST) Step 2: ROM BIOS startup program searches for and loads an OS Step 3: OS configures the system and completes its own loading Step 4: User executes applications software
Step 1: POST & BIOS Boot A built-in diagnostic program that checks the hardware to ensure that everything is present and functioning properly, before the BIOS begins the actual boot. It then continues with additional tests, e. g. , memory test, as boot process is proceeding. The ROM BIOS startup program surveys hardware resources and needs, and assigns system resources to meet those needs
POST
Step 2: BIOS Finds & Loads OS Most often the OS is loaded from logical drive C on the hard drive Configuration information on CMOS chip tells startup BIOS where to look for the OS BIOS turns to that device, reads the beginning files of the OS, copies them into memory, then turns control over to the OS ◦ Master Boot Record (MBR) loaded.
BIOS Finds & Loads OS 28
Step 3: OS Completes Boot The OS checks some of the same things that startup BIOS checked (e. g. , available memory and whether memory is reliable) The OS loads software to control the mouse, a CD-ROM, a scanner, and other peripheral devices (generally have device drivers) 29
Boot Process 30
Step 4: User Executes Applications Software The OS finds the applications software (on a secondary storage device), copies software into memory, and turns control over to it User commands the applications software, which makes requests to the OS, which uses the system resources, system BIOS, and device drivers to interface with and control the hardware 31
8086 MEMORY MAP 64 K ROM BIOS 384 K ROM 8086 MEMORY MAP F 0000 H - FFFFFH ROM BASIC Present in older computers Reserved ROM Video BIOS ROM A 0000 H Video RAM C 0000 H - C 7 FFFH A 0000 H - BFFFFH User RAM Resident portion of DOS BIOS and DOS data area 00400 H - 005 FFH Interrupt Vector Table 00000 H - 003 FFH 640 K RAM 1 K Varies between 12 K to 40 K
Comparison between DOS and BIOS Parameters DOS BIOS Related to Disk Operations Covers all I/O devices Loaded from Bootable disk(hard/ floppy disk) In ROM Uses function of BIOS Not uses DOS functions Hardware Independent Dependent Command Set Own Not Command Interpreter Yes: Copy, print and delete files No: Ex: MOV AH, 01 H INT 21 H MOV AH, 00 H MOV AL, 03 H INT 10 H
File Management Block Devices are accessed on a sector basis. The MS- DOS kernel through the device driver sees a block as a logical fixed size array of sectors. the device driver in turn translates the logical sector requests from the MS – DOS into physical locations on the block device. MS – DOS file system is divided into four parts - Boot Sector - Always at the beginning of a partition. - Contains OEM identification, a loader routine , and a BIOS parameter block. - File Allocation Tables (FAT) - Provides a map to the storage locations of files on the disk by indicating which clusters are allocated to each file. - Second copy of FAT as back up. - Free cluster is found by scanning the FAT for a zero value. - Root directory entries are 32 bytes long. - Each entry includes a filename and extension, size, starting FAT entry, the time and date the file was created and the files attributes. - Files Area - Contains subdirectories, file data and unallocated clusters. - The area is divided into fixed size clusters and the use for a particular cluster is specified by the corresponding FAT entry
Memory Management Based on a pool of variable sized memory blocks. Two basic functions are to allocate a block from the pool and to return the allocated block to the pool. MS-DOS compatible personal computers can be fitted with three kinds of RAMs ◦ Conventional Memory ◦ Expanded Memory ◦ Extended Memory Conventional Memory - Up to 1 MB of Memory is directly addressable. - Physical addresses for references are generated by a 16 -bit segment register combined with 16 -bit offset. - Out of 1 MB MS-DOS occupies 640 KB of the conventional memory. - This 640 KB is divided into three zones - The interrupt vector table - Occupies lowest 1024 bytes of memory. - Its address and length are hardwired into the processor and cannot be changed. - The operating system area - Begins immediately above the interrupt vector table. - Holds the operating system, its tables and buffers, and device drivers. - Amount of memory occupied varies from version to version of MS-DOS. - The transient program area - Remainder of the 640 KB area. - Organized into a structure called Memory Arena, which is divided into arena entries (memory blocks). - Each arena entry has a arena entry header.
How MS-DOS supports Conventional Memory Management The MS-DOS kernel supports three memory management functions, invoked with interrupt 21 H, which operate on TPA: - Function 48 H (Allocate Memory block) - Function 49 H (Free Memory block) - Function 4 AH (Resize Memory block) The memory manager can use any of three allocation strategies: - First fit – the arena entry at the lowest address that is large enough to satisfy the request. - Best fit – the smallest available arena entry that satisfies the request, regardless of its position. - Last fit – the arena entry at the highest address that is large enough to satisfy the request Default approach used by MS-DOS is First-fit approach. Expanded Memory - To circumvent the 1 MB limit of conventional memory, expanded memory was designed. - As much as 8 MB of expanded memory can be installed in a single machine. - Made available to the application software in 16 KB pages. Expanded Memory Manager - Provides an interface between application programs and expanded memory. - Divided into Driver and Manager. - Manager controls the status, allocation, mapping and deallocation of expanded memory. Extended Memory - Storage at addresses above 1 MB that can be accessed in Protected mode. - Extended memory is linearly addressable, so no manager required.
Device Input and Output MS-DOS recognizes two types of devices: block devices e. g. floppy disk or fixed disk drives; and character devices, e. g keyboard, display, printer, and communication ports. MS-DOS identifies each block device by a drive letter assigned when the devices controlling software, the device driver, is loaded. A character device on the other hand, is identified by a logical name built into the device driver. Distinction between character and block devices is that the MS-DOS always adds new block – device drivers to the tail of the driver chain but adds new character – device drivers to the head of the chain. Techniques to access character devices: - Handle type function calls A handle is a 16 bit number returned by the operating system whenever a device is opened or created. - Character input and output functions: Interrupt 21 H functions 01 H to 0 CH. These functions are designed to communicate directly with the keyboard, display, printer and serial port. Process Control Process, or task, control includes program loading, task execution, task termination, task scheduling and intertask communication. MS-DOS is not a multitasking operating system , it is a single tasking operating system.
Computer Memory and Memory Mapping Use of Hardware mapping registers in protected address space Programs are at same address space and executed simultaneously It maps pages of two sizes(4 KB and 2 MB) Processes of 1 user are protected from other users process Users are not able to use other users data
Hardware Memory Mapping Register CR 3 is the hardware mapping register It points to table available in computer memory CR 3 contains the address of top level table(Page map level 4) Page Map Level: It has 512 entries which points different pages in memory first level of memory translation hierarchy logical to virtual address 0 -11 bit page offset 12 -20 page table index 21 -29 page directory index 30 -38 page directory pointer 39 -47 PML index
Hardware Memory Mapping Register Page Directory Pointer Table second level of memory translation 512 entries, points to Page Directory Table third level of memory translation 512 entries, points to Page Table fourth level of memory translation 512 entries, points to Pages in memory physical address of destination TLB available in cache Recently used pages
BIOS and DOS Interrupts BIOS Calls: INT 10 H Function Description Input Output 00 H Set Video Mode AH=00 h AL= Video Mode Nothing 01 H Set Cursor Type AH=01 h CH= Starting Line of Cursor CL= Ending Line of Cursor Nothing 02 H Set Cursor Position AH=02 h BH= Page DH= row (x co-ordinate) DL= column (y co-ordinate) Nothing 03 H Get Cursor Position AH=03 h BH= Page CH= Starting of Cursor CL= Ending of Cursor DH= row DH= column 08 H Read character and attribute at cursor AH=08 h BH= Page AH=attribute AL= character
BIOS and DOS Interrupts BIOS Calls: INT 10 H Functio n Description Input Output 09 H Write character and attribute at cursor AH=09 h AL= character BH=Page BL= Attribute or color CX= count of characters Nothing 0 AH Write character at cursor AH=0 Ah AL= character BH=Page BL= color (graphics) CX= count of characters Nothing 0 CH Write graphics pixel AH=0 Ch AL= Pixel value BH=Page CX= Column (X) DX=Row(Y) Nothing
BIOS and DOS Interrupts DOS Calls: INT 21 H Function Description Input Output 00 H Terminate Process AH=00 h CS= Seg address of PSP Nothing 01 H Character input with echo AH=01 h AL= 8 bit input data 02 H Character output AH=02 h DL= 8 bit data to output Nothing 08 H Character input without echo AH=08 h AL= 8 bit input data 09 H Display String AH=09 h DS: DX= Segment: offset of string Nothing
BIOS and DOS Interrupts DOS Calls: INT 21 H File Operations Function Description Input Output 3 CH Create File AH=3 Ch CX= File attribute DS: DX= offset of path name Successful: CF=0, AX= Handle unsuccessful: CF=1, AX= Error code 3 DH Open File AH=3 Dh AL= Access Mode DS: DX= offset of path name Successful: CF=0, AX= Handle unsuccessful: CF=1, AX= Error code 3 EH Close File AH=3 Eh BX= Handle Successful: CF=0 unsuccessful: CF=1 AX= Error code 3 FH Read File AH=3 Fh BX= Handle CX= no of bytes to read DS: DX =offset of path name Successful: CF=0, AX= bytes transferred unsuccessful: CF=1, AX= Error code 40 H Write File AH=40 h BX= Handle CX= no of bytes to write DS: DX =offset of buffer Successful: CF=0, AX= bytes transferred unsuccessful: CF=1, AX= Error code