Drive Parameter Block-System Programming-Lecture Notes, Study notes of System Programming

This lecture handout is for System Programming course. It was provided by Prof. Indubhushan Vijayabhas at Ambedkar University, Delhi. It includes: Drive, Parameter, Block, Slide, Exit, Entry, Memory, Information, Contain, Code, Return, Service

Typology: Study notes

2011/2012

Uploaded on 08/07/2012

anishay
anishay 🇮🇳

4.2

(25)

118 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture # 32
Besides the BPB another data structure can be used equivalently called the DPB (Drive
parameter block). The operating system translates the information in BPB on disk into the
DPB which is maintained main memory. This data structure can be accessed using the
undocumented service 21H/32H. Its detail is shown in the slide below.
On Entry:
AH = 32h
DL 0 for current Drive
1 for A: Drive
2 for B: Drive
3 for C: Drive
On Exit:
DS:BX = far address of DPB
Undocumented Services (INT 21H/32H)
The DPB contains the information shown in the table below. This information can be
derived from the BPB but is placed in memory in the form of DPB.
DPB (Drive Parameter Block)
Highest cluster number (number of data
cluster +1)
WORD0Dh
Highest sector number within a clusterBYTE04h
Number of FATsBYTE08h
Number of reserved sectors at beginning
of drive
WORD06h
Number of root directory entriesWORD09h
Number of first sector containing user
data
WORD0Bh
Shift count to convert clusters into sectorsBYTE05h
Bytes per sectorWORD 02h
Unit number within device driverBYTE01h
Drive number (00h = A:, 01h = B:, etc)BYTE 00h
DescriptionSizeOffset
docsity.com
pf3
pf4
pf5
pf8

Partial preview of the text

Download Drive Parameter Block-System Programming-Lecture Notes and more Study notes System Programming in PDF only on Docsity!

Lecture # 32

Besides the BPB another data structure can be used equivalently called the DPB (Drive

parameter block). The operating system translates the information in BPB on disk into the

DPB which is maintained main memory. This data structure can be accessed using the

undocumented service 21H/32H. Its detail is shown in the slide below.

On Entry:

AH = 32h

DL – 0 for current Drive

1 for A: Drive

2 for B: Drive

3 for C: Drive

On Exit:

DS:BX = far address of DPB

Undocumented Services (INT 21H/32H)

The DPB contains the information shown in the table below. This information can be

derived from the BPB but is placed in memory in the form of DPB.

DPB (Drive Parameter Block)

Highest cluster number (number of data

cluster +1)

0Dh WORD

04h BYTE Highest sector number within a cluster

08h BYTE Number of FAT’s

Number of reserved sectors at beginning

of drive

06h WORD

09h WORD Number of root directory entries

Number of first sector containing user

data

0Bh WORD

05h BYTE Shift count to convert clusters into sectors

02h WORD Bytes per sector

01h BYTE Unit number within device driver

00h BYTE Drive number (00h = A:, 01h = B:, etc)

Offset Size Description

DPB (Drive Parameter Block)

17h BYTE Media ID byte

18h BYTE 00h if disk accessed, FFh if not

13h DWORD Address of device driver header

11h WORD Sector number of first directory sector

19h DWORD Pointer to next DPB

0Fh WORD number of sectors per FAT

Cluster at which to start search for free

space when writing, usually the last

cluster allocated

1Dh WORD

Number of free clusters on drive, FFFFh if

not know n

1Fh WORD

Offset Size Description

The following code shows how the service 21H/32H is invoked and the registers in which

it returns a value. It also shows the contents of the DPB by taking the dump at the

location returned by the service for a FAT 12 volume (i.e. Floppy disk).

-a 13A6:0100 mov ah, 13A6:0102 int 21 13A6:

-p AX=3200 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 D I= DS=13A6 ES=13A6 SS=13A6 CS=13A6 IP=0102 NV UP EI PL NZ NA PO NC 13A6:0102 CD21 INT 21

-p AX=3200 BX=13D2 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 D I= DS=00A7 ES=13A6 SS=13A6 CS=13A6 IP=0104 NV UP EI PL NZ NA PO NC 13A6:0104 D3E3 SHL BX,CL

-d a7:13d

00A7:13D0 00 00 00 02 00 00-01 00 02 E0 00 21 00 20 ...........!. 00A7:13E0 0B 09 00 13 00 56 34 12-00 F0 0A FF FF FF FF 00 .....V4......... 00A7:13F0 00 C9 06 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1400 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1410 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1420 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00A7:1430 00 00 00 00 00 00 00 0C-00 00 80 00 B0 13 10 00 ................ 00A7:1440 D8 12 4D 5A 9A 00 29 00-00 00 20 00 C5 00 FF FF ..MZ..)... ..... 00A7:1450 A7 05 ..

The details of the information read from the dump of the DPB are shown below.

drive no = 05 = F drive

unit no = 05

bytes per sector = 200H = 512

Highest sector number within a cluster = 7

Hence Sec. per cluster = highest sec. within a

cluster + 1 = 7 + 1 = 8

shift count = 3

reserved sectors = 0008

Number of Fats = 2

Root Dir Entries = 0200H = 512

First sector containing user data = 01C0 = 448

Highest cluster number = cbb4H = 52148

No of sectors per FAT = CC = 204

Sector number of First directory = 01A0 = 416

#include <bios.h>

#include <dos.h>

struct BPB

{

unsigned int bytespersec;

unsigned char secperclust;

unsigned int reservedsecs;

unsigned char fats;

unsigned int rootdirents;

unsigned int smallsecs;

unsigned char media;

unsigned int fatsecs;

unsigned int secspertrack;

unsigned int heads;

unsigned long int hiddensecs;

unsigned long int hugesecs;

unsigned char driveno;

unsigned char reserved;

unsigned char bootsignature;

unsigned long int volumeid;

unsigned char volumelabel[11];

unsigned char filesystem[8];

};

struct bootblock

{

unsigned char jumpinstruction[3];

unsigned char osname[8];

struct BPB bpb;

unsigned char code[448];

};

*void nputs( char p, int n)

{

int i ;

for (i =0;i<n;i++)

putch(p[i]);

}

void main( void)

{

struct bootblock bb;

clrscr();

absread(0,1,0,&bb);

printf("jump instruction = % x\n" ,

bb.jumpinstruction);

printf("OS = ");

nputs (bb.osname,8);

puts("\n");

#include <dos.h>

#include <bios.h>

struct DPB {

unsigned char driveno;

unsigned char unitno;

unsigned int bytespersec;

unsigned char highestsecinclust;

unsigned char shiftcount;

unsigned int reservedsecs; unsigned char fats;

unsigned int rootentries; unsigned int firstuserdatasec;

unsigned int highestclustnumber; //only for 16 and 12

bit FATs

unsigned int secsperfat;

unsigned int firstdirsec;

unsigned int ddheaderoff;

unsigned int ddheaderseg;

unsigned char media;

unsigned char accessed;

unsigned int nextdpboff;

unsigned int nextdpbseg; unsigned int searchstart;

unsigned int freeclust;

};

void main (void)

{

*struct DPB far ptr;

struct DPB dpb;

clrscr();

_asm push DS;

_asm push BX; _AH=0x32;

_DL=1;

geninterrupt (0x21);

*ptr = (struct DPB far )MK_FP(_DS,_BX);

dpb=ptr; _asm pop BX;*

_asm pop DS;

printf("Drive No = %x\n",dpb.driveno);

printf("Unit No = %x\n",dpb.unitno);

printf("Bytes per sector = %d\n",dpb.bytespersec);

printf("Highest sector number within a cluster =

%d\n",dpb.highestsecinclust); printf("Shift Count = %d\n",dpb.shiftcount);

printf("Reserved sectors = %d\n",dpb.reservedsecs); printf("number of FATs = %d\n",dpb.fats);

printf("Root enteries = %d\n",dpb.rootentries);

printf("First User data sec = %d\n",dpb.firstuserdatasec);

printf("Highest Cluster number =

%d\n",dpb.highestclustnumber);

printf("No of Sectors per FAT = %d\n",dpb.secsperfat);

printf("First directory Sector = %d\n",dpb.firstdirsec);

printf("DD header offset = %x\n",dpb.ddheaderoff);

printf("DD header segment = %x\n",dpb.ddheaderseg); printf("Media ID= %d\n",dpb.media);

printf("Disk accessed recently= %d\n",dpb.accessed);

printf("Next DPB offset address = %d\n",dpb.nextdpboff);

printf("Next DPB segment address =

%d\n",dpb.nextdpbseg);

printf("Point where to start the search for next cluster=

%d\n",dpb.searchstart); printf("Free cluster= %d\n",dpb.freeclust);

getch(); }

The above program is doing is the same using the DPB rather than BPB.