-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathchap05_read_img.cpp
More file actions
46 lines (36 loc) · 939 Bytes
/
chap05_read_img.cpp
File metadata and controls
46 lines (36 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
void HandleDiskError();
int BIOSReadOneSector(int iSectorNumber, int iHeadNumber, int iTotalSectorCount, int pcTargetAddress);
int main()
{
int iTotalSectorCount = 1024;
int iSectorNumber = 2;
int iHeadNumber = 0;
int iTrackNumber = 0;
//physical address to copy img
char * pcTargetAddress = (char *) 0x10000;
for(iTotalSectorCount = 1024; iTotalSectorCount>0; iTotalSectorCount--)
{
if(BIOSReadOneSector(iSectorNumber, iHeadNumber, iTotalSectorCount, pcTargetAddress))
{
HandleDiskError();
}
//increase address
pcTargetAddress += 0x200;
iSectorNumber++;
if(iSectorNumber < 19) continue;
iHeadNumber = iHeadNumber ^ 0x01;
iSectorNumber = 1;
if(iHeadNumber != 0) continue;
iTrackNumber++;
}
return 0;
}
int BIOSReadOneSector(int iSectorNumber, int iHeadNumber, int iTotalSectorCount, int pcTargetAddress)
{
}
void HandleDiskError()
{
printf("DISK Error~!!");
while(1);
}