Industrial Training




Reading Boot Parameters



The Boot sector on the floppy disk contains two things, namely, boot parameters and the disk bootstrap program. The purpose of the disk bootstrap program is to load DOS files from the disk into memory. Whether the disk bootstrap program would be used or not depends on whether the disk is being used for booting the computer or not. The boot parameters are used by DOS at the time a read or write operation is performed on the disk. This is because the boot parameters contain the vital information about how the disk has been formatted. From format to format the values of the boot parameters may change, but their order remains same. The following program display boot parameters of floppy.

/* Display boot parameters of floppy */

# include "dos.h"

# include "stdio.h"

main( )

{

struct boot

{

unsigned char code[3] ;

unsigned char system_id[8] ;

int bytes_per_sec ;

char sec_per_clus ;

int res_sec ;

char fat_copies ;

int root_dir_entry ;

unsigned int no_sects ;

unsigned char format_id ;

int sec_per_fat ;

int sec_per_trk ;

int no_sides ;

int no_sp_res_sect ;

unsigned char rest_code[482] ;

} ;

struct boot b ;

char temp[4] ;

int val, drive ;

val = absread ( 0, 1, 0, &b ) ;

if ( val == -1 )

{

printf ( "Disk read Error...bad sector\n" ) ;

exit ( 1 ) ;

}

clrscr ( ) ;

printf ( "System id %s\n", b.system_id ) ;

printf ( "Bytes per sector %d\n", b.bytes_per_sec ) ;

printf ( "Sectors per cluster %d\n", b.sec_per_clus ) ;

printf ( "Reserved sectors %d\n", b.res_sec ) ;

printf ( "FAT copies %d\n", b.fat_copies ) ;

printf ( "Root directory entries %d\n", b.root_dir_entry ) ;

printf ( "No. of sectors on disk %u\n", b.no_sects ) ;

printf ( "Format id %X\n", b.format_id ) ;

printf ( "Sectors per FAT %d\n", b.sec_per_fat ) ;

printf ( "Sectors per track %d\n", b.sec_per_trk ) ;

printf ( "No. of sides %d\n", b.no_sides ) ;

printf ( "No. of reserved sectors %d\n", b.no_sp_res_sect ) ;

}

The typical values obtained are tabulated as follows :

Description Length in bytes Typical D9 disk values
Jump Instruction 3 EB 34 90
System ID 8 IBM 3.0
No.of bytes per sector 2 512
No. of sectors per cluster 1 2
No. of sectors in reserved area 2 1
No. of copies of FAT 1 2
Max. no. of root directory entry 2 112
Total no. of sectors 2 720
Media descriptor 1 FD
No of sectors per FAT 2 2
No of sectors per track 2 9
No. of sides 2 2
No. of hidden sectors 2 0


Hi I am Pluto.