Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
34
CH = low eight bits of cylinder number
CL = sector number 1-63 (bits 0-5)
high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer
The values are loaded by the section of coe shown below:
On studying the above code, it is clear that the ax, cx and dx registers are
loaded with the values listed above. To calculate thae value to load into the cx
register, two bitmasks are used, 768 which corresponds to binary 1100000000
and 255 which corresponds to binary 0011111111. These are used to mask off
the appropriate bits of the cylinder number in order to calculate the value that
corresponds to the low 8 bits of the cylinder number for the high byte of cx, and
the combination of the sector number and hi 2 bits of the cylinder number for the
low byte of cx. The bx and es registers are loaded with the segment and offset
of the pointer to the data buffer. Note that this pointer has to be a real-mode
pointer for use by the BIOS, rather than the protected-mode pointer used by the
library code.
The remainder of the function simply calls SimulateRMInt to issue the
interrupt.
5.7 Layer 0: The GetDiskParams Function
The GetDiskParams function calls the BIOS disk function to retrieve the
physical disk geometry for each drive connected to the PC. The values recorded
are the maximum cylinder, head and sector numbers. These are read into a
global array of data structures called DISKINFO, the definition of this type is
shown below:
callStruct.eax = 0x0201;
// BIOS read, 1 sector
//ch = low 8 bits of cyl # cl = hi 2 bits ohf cyl # and sect num
callStruct.ecx = MAKEWORD((((wCyl & 768) >> 2) | wSec), (wCyl & 255));
callStruct.edx = MAKEWORD(bDrive, wHead);
// Head #, Drive #
callStruct.ebx = LOWORD(RMlpBuffer);
// Offset of sector buffer
callStruct.es = HIWORD(RMlpBuffer);
// Segment of sector buffer
typedef struct diskinfo
{
DWORD rgDskParams[4];
struct firstsector FirstSec;
} DISKINFO;