Summer 2003 Lecture 26 07/24/03

Similar documents
Ρουτίνες Λειτουργίας (DOS function calls)

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

DOS INT 21h - DOS Function Codes

Lecture 13: I/O I/O. Interrupts. How?

Microprocessors (A) DOS Services

Time Left. sec(s) Quiz Start Time: 12:13 AM. Question # 5 of 10 ( Start time: 12:18:29 AM ) Total Marks: 1

DOS. 5/1/2006 Computer System Software CS 012 BE 7th Semester 2

Code segment Stack segment

Programming in Module. Near Call

EC-333 Microprocessor and Interfacing Techniques

Come and join us at WebLyceum

CP/M-86 Compatibility Guide For CP/M-80 Users

AT DISK DRIVE INTERFACE MODULE

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Hong Kong Polytechnic University Department of Electronic and Information Engineering. Experiment On DOS File system

Chapter 2 COMPUTER SYSTEM HARDWARE

Interrupt Services. Which Way is Best? Characteristics. Direct in, out. BIOS Average Average DOS Most Least

x86 Assembly Tutorial COS 318: Fall 2017

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

CS609 Final Term Solved MCQs with References Without Repetitions 14/02/2013

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Signed number Arithmetic. Negative number is represented as

File Management. Ezio Bartocci.

Intel 8086 MICROPROCESSOR ARCHITECTURE

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

16.317: Microprocessor Systems Design I Fall 2013

makes floppy bootable o next comes root directory file information ATTRIB command used to modify name

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Troubleshooting & Repair

Assembler Programming. Lecture 2

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Proposed Common Configuration Method

Experiment 3 3 Basic Input Output

UNIT 2 PROCESSORS ORGANIZATION CONT.

8086 INTERNAL ARCHITECTURE

Programming in Assembler. Laboratory manual. Exercise 3

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Logic Instructions. Basic Logic Instructions (AND, OR, XOR, TEST, NOT, NEG) Shift and Rotate instructions (SHL, SAL, SHR, SAR) Segment 4A

The x86 Architecture

6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Chapter 2: The Microprocessor and its Architecture

IA32 Intel 32-bit Architecture

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

DVD :50 PM Page 1 BIOS

Assembly Language Programming Introduction

Error num: 1 Meaning: Not owner Error num: 2 Meaning: No such file or directory Error num: 3 Meaning: No such process Error num: 4 Meaning:

Arithmetic Instructions

Typical File Extensions File Structure

Computer Systems. Assembly Language for x86 Processors 6th Edition, Kip Irvine

Intel 8086 MICROPROCESSOR. By Y V S Murthy

Glossary. The target of keyboard input in a

Assembly Language Each statement in an assembly language program consists of four parts or fields.

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

The x86 Architecture. ICS312 - Spring 2018 Machine-Level and Systems Programming. Henri Casanova

The Microprocessor and its Architecture

COMMON-ISDN-API. Version 2.0. Part II. 4 th Edition. Operating Systems

EEM336 Microprocessors I. Data Movement Instructions

Tutorial Letter 103/3/2012 Computer Organization COS2621 Semesters 1 & 2

16.317: Microprocessor Systems Design I Spring 2014

Addressing Modes on the x86

Hardware and Software Architecture. Chapter 2

ECE 598 Advanced Operating Systems Lecture 14

Proposal of an Improved Description of Read Native Max and Set Max Commands including rules for C/H/S and LBA calculation

Lf1w1'eLC bliotfitl ~NS C.. /00/CAL VSTEMS. Maintenance Utility

11/3/71 SYS MOUNT (II) sys mount; special; name / mount = 21.; not in assembler

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Lesson 1. Fundamentals of assembly language

EXPERIMENT TWELVE: USING DISK FILES

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

EC 333 Microprocessor and Interfacing Techniques (3+1)

Older Operating Systems

icroprocessor istory of Microprocessor ntel 8086:

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS3600 SYSTEMS AND NETWORKS

Chapter Two File Systems. CIS 4000 Intro. to Forensic Computing David McDonald, Ph.D.

Computer Architecture 1 ح 303

Operating Systems. Project #2: System Calls

LABORATORY 1: EXPLORING THE SOFTWARE ARCHITECTURE OF THE MICROPROCESSOR

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

EC-333 Microprocessor and Interfacing Techniques

CS609 Final Term Subjective Paper Solved with references March (2014)

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

Instruction Set Architecture (ISA) Data Types

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

CS370 Operating Systems

Intel 8086: Instruction Set

Certified Ethical Hacker. Module 25 Writing Virus Codes

CC411: Introduction To Microprocessors

Northern India Engineering College, Delhi (GGSIP University) PAPER I

Introduction to IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung

BOOTSTRAP, PC BIOS, AND IA32 MEMORY MODES. CS124 Operating Systems Winter , Lecture 5

Transcription:

Summer 2003 Lecture 26 07/24/03 Organization of Data on the Disk The logical organization of the FAT file system on a disk is made up of the following elements. BOOT Sector Root Directory Structure File Allocation Tables (FAT) Data Clusters The BOOT sector is described in Section 9.2 of the text. It contains a data structure that describes the format of the disk, followed by the boot loader. The boot loader is a short program that loads the operating system from the disk into memory and starts it executing. In the case of DOS, the boot loader actually loads the operating system. In the case of many other operating systems, such as Windows or Windows NT, the boot loader in the boot sector only loads a more sophisticated loader, which then loads the actual operating system. The Root directory structure contains the top level directory structure of the hierarchical file system. The root directory is special, in that the information in it is stored in a hard coded location on the disk, and a fixed amount of space is allocated for it when the disk format is defined. If a disk has hard sector errors in the region where the root directory is stored, the disk is unusable. Subdirectories of the root directory are stored in special files A directory is a table of fixed sized directory entries. Each directory entry is 32 bytes long and contains the file name, creation and access dates and times for the file, file attributes, and all other information that DOS knows about the file. For the root directory, this table is stored at a fixed location on the disk. Subdirectories are special files that contain directory entries. Windows NT and versions of Windows beginning with Window 95, long file names are supported. Files with a long file name (or a name containing embedded spaces) will have multiple directory entries. There will be a directory entry containing a short file name (confirming to the 8.3 character file naming convention of DOS).

There will also be multiple additional directory entries containing the complete file name. The number of directory entries will vary depending on the length of the file name. These directory entries immediately precede the short file name entry in the directory, and contain reserved fields with special values that cause earlier versions of DOS to ignore them and to indicate that they are all bound together to make up a complete file name. One of the key pieces of information that is stored in the root directory is the head of the FAT chain. This is the information that allows the DOS file manager to find the data associated with the directory entry (i.e. the actual file data for the file). Space on a disk is allocated in units called a cluster. A cluster is some number of sectors that are treated by DOS as an atomic unit. When space is allocated for a file, it is always allocated a cluster at a time. On small disks, such as floppy disks, a cluster is 1 sector. On large hard disks, a cluster may be as large as 16 or 32 sectors. Each cluster on a disk is assigned an index number, starting at 0. The file allocation table (FAT) is an array of entries indexed by the cluster number. If the cluster is free, the FAT entry for cluster will have a special value in it indicating that it is free. If the cluster contains a bad sector, there will be another special value that marks the cluster as bad, and not to be used. Clusters that are part of a file, will be linked together into a linked list of all of the clusters that make up the file. So, for clusters that are part of a file, the FAT entry for a cluster will contain the index of the next cluster in the file. The last cluster assigned to a file will have a special value indicating that it is the end of the chain for that file. The directory entry for a file has a field that indicates the cluster number of the first cluster assigned to the file (this is the head of the linked list). DOS Functions for Accessing Files The common way of accessing files is the use the HANDLE based functions. This method of accessing files was introduced in DOS version 2.0 along with the hierarchical file system. In these functions, when a file is opened or created, DOS returns a 16 bit integer value called a file handle.

For future operations involving that file (e.g. reading, writing), the file handle is one of the parameters to the DOS call, and it specified which file the operation is to be performed on. With this set of functions, file names are represented as ASCII strings. The following are the file handle based functions used for accessing files under DOS:

Function 3Ch (60) Create a File (CREAT) Create a new file or open and truncate an existing file to zero length. On entry: AH 3Ch CX File attribute DS:DX Pointer to filename (Zeroterminated ASCII string) Returns: AX File handle, if CF is not set, or Error code, if CF is set Error codes: 3 Path not found 4 No handle available 5 Access denied (file is readonly, or root directory is full) Notes: The CX register specifies the attribute of the file you're creating, as follows: CX 00h 01h 02h 04h Attribute specified Normal Read-only Hidden System Sum the values to combine attributes. Fcn 3Dh Open File

Fcn 3Eh Close File Function 3Eh (62) Close a File Handle Flush the file's buffers, close the file, and release the file handle. On Entry: AH 3Eh BX File handle Returns: AX Error code, if CF is set Error codes: 6 Invalid handle ------------------------------------------------ This function flushes the file's buffers, closes the file, releases the handle, and updates the directory. Fcn 3Fh Read File Function 3Fh (63) Handle Read from File or Device, Using a Read bytes from a file or device into a buffer. On entry: AH 3Fh BX File handle CX Number of bytes to read DS:DX Address of buffer Returns: AX Number of bytes read, or Error code, if CF is set Error codes: 5 Access denied 6 Invalid handle Fcn 40h Write File Function 40h (64) Handle Write to File or Device, Using a Write bytes from a buffer to a file or device.

On entry: AH 40h BX File handle CX Number of bytes to write DS:DX Address of buffer Returns: AX Number of bytes written, or Error code, if CF is set Error codes: 5 Access denied 6 Invalid handle Fcn 41h Delete File (doesn t use a handle, uses ASCII string) Function 41h (65) Delete File (UNLINK) Delete the named file. On entry: AH 41h DS:DX Pointer to filespec (Zeroterminated ASCII string) Returns: AX Error code, if CF is set Error codes: 2 File not found 3 Path not found 5 Access denied Fcn 42h Fcn 45h Fcn 46h Fcn 4Eh Fcn 4Fh Fcn 57h Fcn 5Bh Seek File Pointer Duplicate File Handle Force Duplicate File Handle Find First Matching File Entry (uses ASCIIZ file name) Find Next Matching File Entry Read File Date and Time Force Create a New File (deletes existing file) Function 59h (89). DOS 3.0 Get Extended Error Information Returns diagnostic information following an unsuccessful DOS function call or Interrupt 24h.

On entry: AH 59h BX 0000h for DOS 3.0 and above Returns: AX Extended error code BH Error class BL Suggested action CH Locus (Source of error) Destroys: changed CL, DX, SI, DI, ES, and DS are all Values returned in AX (extended error code): AX Extended error code AX Extended error code 01h Invalid function number 14h Unknown unit 02h File not found 15h Drive not ready 03h Path not found 16h Unknown command 04h Too many open files 17h Data error (CRC) 05h Access denied 18h Bad request structure 06h Invalid handle length 07h Memory control blocks 19h Seek error destroyed 1Ah Unknown medium type 08h Insufficient memory 1Bh Sector not found 09h Invalid memory block address 1Ch Printer out of paper 0Ah Invalid environment 1Dh Write fault 0Bh Invalid format 1Eh Read fault 0Ch Invalid access code 1Fh General failure 0Dh Invalid data 20h Sharing violation 0Fh Invalid disk drive 21h Lock violation

10h Attempt to remove current disk change directory unavailable 11h Not the same device already exists 12h No more files make directory 13h Disk is write-protected error 22h Invalid 23h FCB 50h File 52h Cannot 53h Critical Values returned in BH (error class): BX Error class 01h Out of resource 02h Temporary problem that can be expected to go away 03h Authorization (permission) problem 04h Internal error (i.e., a system software bug) 05h Hardware problem (not the fault of your program) 06h System software failure (e.g. bad or missing CONFIG.SYS) 07h Application program error 08h File or other item not found 09h File or other item of invalid or unsuitable format or type 0Ah File or other item interlocked 0Bh Media problem (e.g. CRC error, wrong disk in drive) 0Ch Collision with existing item 0Dh Other (unclassified) Values returned in BL (suggested action): BL Suggested action 01h Retry a few times 02h Pause, then retry 03h Ask user to resupply input 04h Abort with cleanup (orderly shutdown) 05h Immediate abort (do not pass GO) 06h Ignore 07h Ask user for remedial action (e.g. insertion of diskette), then retry

Values returned in CH (source of error): CH Source of error 01h Unknown 02h Block device (disk) 03h Network 04h Serial device 05h Memory

File Operations Using File Handles The file handle based file operations in DOS were patterned after the low level file operations in the C runtime (e.g. open, read, write, etc), so file operations in DOS are very similar to those written in C using these low lever functions. Before a file can be accessed, it must be opened. The open function takes a pointer to a zero terminated string giving the file name (DS:DX), and an access type byte indicating if the file is being opened for read, write, or both (AL). If the file open is successful, the file handle is returned in AX. If not, an error code is returned in AX and the carry flag is set. Once the file is opened, the file can be read or written by passing the file handle (BX), a byte count (CX), and a pointer to the data buffer (DS:DX). If the operation is successful, the count of bytes read or written is returned in AX. If not, an error code is returned in AX and the carry flag is set. When access to the file is no longer needed, it should be closed.