Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 532)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 533)
@@ -251,5 +251,4 @@
 ;	Parameters:
 ;		AH:		BIOS Error code
-;		DS:		RAMVARS segment
 ;		SS:BP:	Ptr to IDEPACK
 ;	Returns:
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 532)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 533)
@@ -23,4 +23,44 @@
 ;--------------------------------------------------------------------
 ; Int 13h function AH=48h, Get Extended Drive Parameters.
+;
+; It is not completely clear what this function should return as total sector count in some cases.
+; What is certain is that:
+; A) Phoenix Enhanced Disk Drive Specification v3.0 says that P-CHS values
+;    are never returned for drives with more than 15,482,880 sectors (16384*15*63).
+;    For those drives we can simply return total sector count from
+;    ATA ID WORDs 60 and 61 (LBA28) or WORDs 100-103 (LBA48).
+; B) IBM PC DOS 7.1 fdisk32 displays warning message if P-CHS values multiplied
+;    together are different than total sector count. Therefore for drives with less
+;    than or equal 15,482,880 sectors we MUST NOT return total sector count from
+;    ATA ID WORDs 60 and 61.
+;
+;    Lets take an example. 6 GB Hitachi microdrive reports following values in ATA ID:
+;    Sector count from WORDs 60 and 61	: 12,000,556
+;    Cylinders							: 11905
+;    Heads								:    16
+;    Sectors per track					:    63
+;
+;    When multiplying C*H*S we get		: 12,000,240
+;    So the CHS size is a little bit less than LBA size. But we must use
+;    the smaller value since C*H*S must equal total sector count!
+;
+; Now we get to the uncertain area where I could not find any information.
+; Award BIOS from 1997 Pentium motherboard returns following values:
+;    AH=08h L-CHS:   745, 255, 63 (exactly the same as what we return)
+;    => Total Sector Count:		  745*255*63 = 11,968,425
+;    AH=48h P-CHS: 11873,  16, 63
+;    AH=48h Total Sector Count: 11873* 16*63 = 11,967,984
+;
+; Notice how AH=48h returns lesser total sector count than AH=8h! The only
+; way I could think of to get 11873 cylinders is to divide AH=08h sector
+; count with P-CHS heads and sectors: (745*255*63) / (16*63) = 11873
+;
+; I have no idea what is the reasoning behind it but at least there is one
+; BIOS that does just that.
+;
+; Since I don't have any better knowledge, I decided that when RESERVE_DIAGNOSTIC_CYLINDER
+; is defined, we do what the Award BIOS does. When it is not defined, we multiply
+; P-CHS values together and use that as total sector count.
+;
 ;
 ; AH48h_GetExtendedDriveParameters
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 532)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 533)
@@ -118,6 +118,18 @@
 	mov		[di+DPT.bPchsHeads], bl
 %ifdef MODULE_EBIOS
+	mov		[di+DPT.bPchsSectorsPerTrack], bh
+
+%ifdef RESERVE_DIAGNOSTIC_CYLINDER
+	; Do not store P-Cylinders, instead calculate it from L-CHS total sector count.
+	; Read AH=48h_GetExtendedDriveParameters.asm for more info.
+	xchg	ax, bx
+	mul		ah
+	push	ax							; P-Heads * P-Sectors per track
+	call	AH15h_GetSectorCountToBXDXAX
+	pop		bx
+	div		bx							; AX = Calculated cylinders
+%endif ; RESERVE_DIAGNOSTIC_CYLINDER
+
 	mov		[di+DPT.wPchsCylinders], ax
-	mov		[di+DPT.bPchsSectorsPerTrack], bh
 	; Fall to .StoreNumberOfLbaSectors
 
@@ -141,5 +153,20 @@
 	call	StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
 
+	; If we have 15,482,880 or less sectors, we multiply P-CHS values
+	; and use that as total sector count.
+	; Read AH=48h_GetExtendedDriveParameters.asm for more info.
+	sub		ax, 4001h
+	sbb		dx, 0ECh
+	sbb		bx, BYTE 0
+	jnc		SHORT .NoNeedToUseCHSsectorCount	; More than EC4000h
+
+	mov		al, [di+DPT.bPchsHeads]
+	mul		BYTE [di+DPT.bPchsSectorsPerTrack]
+	mul		WORD [di+DPT.wPchsCylinders]
+	xor		bx, bx
+	call	StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
+
 	; Load user defined LBA
+.NoNeedToUseCHSsectorCount:
 	call	GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
 	test	cl, FLG_DRVPARAMS_USERLBA
