SlideServe
Menu
Préférences
© SlideServe · v2026

Lecture 26

pippa avatar
17 diapositives · 394 Views · Sep 12, 2014

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.

Lecture 26 - slide 1
01 / 17Lecture 26
1 / 17

Télécharger la présentation

Lecture 26
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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