1 / 17

Lecture 26

Lecture 26. Reading/Writing a physical Block. BiosDisk(int cmd, int drive, int head, int track, int sector, int nsects, void * buffer); Cmd 0 = disk reset 1 = disk status (status of last disk operation) 2 = disk read 3 = disk write 4 = disk verify 5 = disk format.

pippa
Download Presentation

Lecture 26

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 26

  2. Reading/Writing a physical Block • BiosDisk(int cmd, int drive, int head, int track, int sector, int nsects, void * buffer); • Cmd 0 = disk reset • 1 = disk status (status of last disk operation) • 2 = disk read • 3 = disk write • 4 = disk verify • 5 = disk format

  3. Reading Writing a physical Block • Drive 0x80 = first fixed disk (physcial drive) • 0x81 = second fixed disk • 0x82 = third fixed disks • …. …. • 0x00 = first removable disk • 0x01 = second removable disk • …. ….

  4. Reading Writing a physical Block #include <bios.h> #include <dos.h> FILE *fp; unsigned char buf[512]; unsigned char st[60]; unsigned char headno[10]; unsigned char secno[10]; unsigned char trackno[10]; void main (void) { int i ; for (i=0;i<512;i++) buf[i]=0;

  5. Cont… gets(st); fp=fopen(st,"wb"); printf("Head "); gets(headno); puts (headno); printf("\nsector "); gets(secno); puts(secno); printf("\ntrack "); gets(trackno); puts(trackno);

  6. Cont… i = biosdisk(2,0x80,atoi(headno), atoi(trackno),atoi(secno),1,buf) ; if (*(((char *)(&i))+1)==0) { fwrite(buf,1,512,fp); fclose(fp); } else printf("Cannot Read Error# = %x",i); }

  7. Limitation of biosdisk • Biosdisk() calls int 13H/0/1/2/3/4/5 • Details of 13H services used by Biosdisk() • On Entry • AH = service # • AL=No. of sectors • BX = offset address of data buffer • CH = track # • CL = sector # • DH = head/side # • DL = Drive # • ES = Segment Address of buffer.

  8. Limitation of biosdisk() • Large sized disk are available now with thousands of tracks • But this BIOS routine only is capable of accessing a max. of 1024 tracks. • Hence if a large disk is being used not whole of the disk can be accessed using this routine.

  9. Extended BIOS functions • Extended BIOS functions of int 13h can be used for operations on higher tracks • As discussed later usual BIOS functions can access a maximum of 504MB of disk approx.

  10. Extended BIOS functions

  11. Highest biosdisk() capacity • Hence the highest capacity of disk can be accessed using bios functions is • 63x16x1024x512= 504 MB approx.

  12. Highest IDE capacity • Hence highest physical capacity of the disk according to the IDE interface is • 255x16x65536x512 = 127GB • Extended BIOS functions allow to access disk with sizes greater than 504 MB through LBA translation.

  13. LBA Translation Method • Each unique combination of three parameters is assigned a unique index as shown below • Firstly all the sectors of a cylinder are indexed for head=0, then when whole track has been indexed the sector in the track of same cylinder with head =1 are indexed and so on up till the end of all heads • When done with one cylinder the same is repeated for the next cylinder till the end of cylinders

  14. LBA Translation method • Cylinder head sec • 0 0 1 = 0 • 0 0 2 = 1 • 0 0 3 = 2 • …. …. … …. • 0 0 63 = 62 • 0 1 1 = 63 • 0 1 2 = 64 • …. …. … …. • 0 2 1 = 126

  15. Mathematical Notation for LBA translation • LBA address = (C * H’ +H)* S’ + S – 1 • Where • C = Selected cylinder number • H’ = No. of heads • H = Selected head number • S’=Maximum Sector number • S= Selected Sector number

  16. LBA to CHS translation • Conversely LBA address can be translated into CHS address • cylinder = LBA / (heads_per_cylinder * sectors_per_track) • temp = LBA % (heads_per_cylinder * sectors_per_track) • head = temp / sectors_per_track • sector = temp % sectors_per_track + 1

  17. Disk Address Packet

More Related