Index: trunk/XTIDE_Universal_BIOS/Inc/CompatibleDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CompatibleDPT.inc	(revision 541)
+++ trunk/XTIDE_Universal_BIOS/Inc/CompatibleDPT.inc	(revision 541)
@@ -0,0 +1,97 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Defines for DPT structs to present drive geometry
+;					to ill behaving applications that want
+;					to read DPT from interrupt vectors 41h and 46h.
+
+;
+; XTIDE Universal BIOS and Associated Tools
+; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
+;
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
+
+%ifndef COMPATIBLE_DPT
+%define COMPATIBLE_DPT
+
+; Standard DPT for small drives with 1024 or less cylinders
+struc STANDARD_DPT
+	.wPchsCylinders		resb	2	; 0-1, Physical number of cylinders
+	.bPchsHeads			resb	1	; 2, Physical number of heads
+	.bReserved3to4		resb	2	; 3-4, Reserved
+	.wPrecompCylinder	resb	2	; 5-6, Write Precompensation Cylinder
+	.bReserved7			resb	1	; 7, Reserved
+	.bDrvControlByte	resb	1	; 8, Drive Control Byte
+	.bReserved9to11		resb	3	; 9-11, Reserved
+	.wLandingZone		resb	2	; 12-13, Landing Zone Cylinder
+	.bPchsSectPerTrack	resb	1	; 14, Physical sectors per track
+	.bReserved15		resb	1	; 15, Reserved
+endstruc
+
+
+; Translated DPT for drives with more than 1024 cylinders
+struc TRANSLATED_DPT
+	.wLchsCylinders		resb	2	; 0-1, Logical number of cylinders
+	.bLchsHeads			resb	1	; 2, Logical number of heads
+	.bSignature			resb	1	; 3, Axh signature to indicate Translated DPT
+	.bPchsSectPerTrack	resb	1	; 4, Physical sectors per track
+	.wPrecompCylinder	resb	2	; 5-6, Write Precompensation Cylinder
+	.bReserved7			resb	1	; 7, Reserved
+	.bDrvControlByte	resb	1	; 8, Drive Control Byte
+	.wPchsCylinders		resb	2	; 9-10, Physical number of cylinders
+	.bPchsHeads			resb	1	; 11, Physical number of heads
+	.wLandingZone		resb	2	; 12-13, Landing Zone Cylinder
+	.bLchsSectPerTrack	resb	1	; 14, Logical sectors per track
+	.bChecksum			resb	1	; 15, Checksum: 2's complement of the 8-bit unsigned sum of bytes 0-14
+endstruc
+
+TRANSLATED_DPT_SIGNATURE	EQU		0A0h
+
+
+; Device Parameter Table Extension (returned by AH=48h EBIOS function)
+struc DPTE
+	.wBasePort				resb	2	; 0, Command Block Base Port Address
+	.wControlBlockPort		resb	2	; 2, Control Block Base Port Address
+	.bDrvnhead				resb	1	; 4, Drive and Head Select Register upper nibble
+	.bBiosVendor			resb	1	; 5, BIOS Vendor Specific
+	.bIRQ					resb	1	; 6, IRQ for this device
+	.bBlockSize				resb	1	; 7, Current block size in sectors
+	.bDmaChannelAndType		resb	1	; 8, DMA information
+	.bPioMode				resb	1	; 9, PIO mode
+	.wFlags					resb	2	; 10, BIOS selected hardware specific option flags
+	.wReserved				resb	2	; 12, Reserved. Must be zero.
+	.bRevision				resb	1	; 14, Revision level of this table (11h)
+	.bChecksum				resb	1	; 15, Checksum: 2's complement of the sum of bytes 0-14
+endstruc
+
+; Flags for DPTE.wFlags
+FLG_FAST_PIO_ENABLED		EQU	(1<<0)	; Set if using PIO mode 1 or above (DPTE.bPioMode is valid when set)
+FLG_DMA_ENABLED				EQU	(1<<1)	; Set if DMA enabled (DPTE.bDmaChannelAndType is valid when set)
+FLG_BLOCK_MODE_ENABLED		EQU	(1<<2)	; Set if Block Mode transfers are enabled (DPTE.bBlockSize is valid when set)
+FLG_CHS_TRANSLATION_ENABLED	EQU	(1<<3)	; Set for drives with more than 1024 cylinders
+FLG_LBA_TRANSLATION_ENABLED	EQU	(1<<4)	; Set when LBA addresses from DAP are passed directly to the drive
+FLG_REMOVABLE_MEDIA			EQU	(1<<5)
+FLG_ATAPI_DEVICE			EQU	(1<<6)
+FLG_32BIT_XFER_MODE			EQU	(1<<7)	; Set when using 32-bit data transfers
+FLG_ATAPI_USES_IRQ			EQU	(1<<8)	; ATAPI Device uses IRQ for data transfers
+; L-CHS translation type for old INT 13h (when FLG_CHS_TRANSLATION_ENABLED is set)
+MASK_CHS_TRANSLATION_TYPE	EQU	(3<<TRANSLATION_TYPE_FIELD_POSITION)
+	TRANSLATION_TYPE_FIELD_POSITION	EQU	9
+	BIT_SHIFT_TRANSLATION			EQU	0	; LARGE
+	LBA_ASSISTED_TRANSLATION		EQU	1	; Assisted LBA
+											; 2 = reserved
+	VENDOR_SPECIFIC_TRANSLATION		EQU	3
+
+
+DPTE_REVISION				EQU		11h
+
+
+%endif ; COMPATIBLE_DPT
Index: trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc	(revision 541)
@@ -57,42 +57,4 @@
 
 
-; Device Parameter Table Extension
-struc DPTE
-	.wBasePort				resb	2	; 0, Command Block Base Port Address
-	.wControlBlockPort		resb	2	; 2, Control Block Base Port Address
-	.bDrvnhead				resb	1	; 4, Drive and Head Select Register upper nibble
-	.bBiosVendor			resb	1	; 5, BIOS Vendor Specific
-	.bIRQ					resb	1	; 6, IRQ for this device
-	.bBlockSize				resb	1	; 7, Current block size in sectors
-	.bDmaChannelAndType		resb	1	; 8, DMA information
-	.bPioMode				resb	1	; 9, PIO mode
-	.wFlags					resb	2	; 10, BIOS selected hardware specific option flags
-	.wReserved				resb	2	; 12, Reserved. Must be zero.
-	.bRevision				resb	1	; 14, Revision level of this table (11h)
-	.bChecksum				resb	1	; 15, Checksum, 2's complement of the sum of bytes 0-14
-endstruc
-
-; Flags for DPTE.wFlags
-FLG_FAST_PIO_ENABLED		EQU	(1<<0)	; Set if using PIO mode 1 or above (DPTE.bPioMode is valid when set)
-FLG_DMA_ENABLED				EQU	(1<<1)	; Set if DMA enabled (DPTE.bDmaChannelAndType is valid when set)
-FLG_BLOCK_MODE_ENABLED		EQU	(1<<2)	; Set if Block Mode transfers are enabled (DPTE.bBlockSize is valid when set)
-FLG_CHS_TRANSLATION_ENABLED	EQU	(1<<3)	; Set for drives with more than 1024 cylinders
-FLG_LBA_TRANSLATION_ENABLED	EQU	(1<<4)	; Set when LBA addresses from DAP are passed directly to the drive
-FLG_REMOVABLE_MEDIA			EQU	(1<<5)
-FLG_ATAPI_DEVICE			EQU	(1<<6)
-FLG_32BIT_XFER_MODE			EQU	(1<<7)	; Set when using 32-bit data transfers
-FLG_ATAPI_USES_IRQ			EQU	(1<<8)	; ATAPI Device uses IRQ for data transfers
-; L-CHS translation type for old INT 13h (when FLG_CHS_TRANSLATION_ENABLED is set)
-MASK_CHS_TRANSLATION_TYPE	EQU	(3<<TRANSLATION_TYPE_FIELD_POSITION)
-	TRANSLATION_TYPE_FIELD_POSITION	EQU	9
-	BIT_SHIFT_TRANSLATION			EQU	0	; LARGE
-	LBA_ASSISTED_TRANSLATION		EQU	1	; Assisted LBA
-										; 2 = reserved
-	VENDOR_SPECIFIC_TRANSLATION		EQU	3
-
-
-DPTE_REVISION				EQU		11h
-
-
 ; Disk Address Packet for read, write and verify functions
 struc DAP
Index: trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc	(revision 541)
@@ -76,5 +76,5 @@
 ; Bit 0 must be zero, unlisted bits are reserved.
 ;FLG_DEVCONTROL_HOB		EQU		(1<<7)	; High Order Byte (ATA6+)
-;FLG_DEVCONTROL_O8H		EQU		(1<<3)	; Drive has more than 8 heads (pre-ATA only, 1 on ATA1, reserved on ATA2+)
+FLG_DEVCONTROL_O8H		EQU		(1<<3)	; Drive has more than 8 heads (pre-ATA only, 1 on ATA1, reserved on ATA2+)
 FLG_DEVCONTROL_SRST		EQU		(1<<2)	; Software Reset
 FLG_DEVCONTROL_nIEN		EQU		(1<<1)	; Negated Interrupt Enable (IRQ disabled when set)
Index: trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 541)
@@ -52,4 +52,7 @@
 %ifdef MODULE_EBIOS
 	%include "EBIOS.inc"			; Equates for EBIOS functions
+	%ifdef CREATE_COMPATIBLE_DPT
+		%include "CompatibleDPT.inc"
+	%endif
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 541)
@@ -44,5 +44,5 @@
 	mov		WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h
 
-%ifdef RETURN_DPTE_ON_AH48H
+%ifdef CREATE_COMPATIBLE_DPT
 	call	AH41h_GetSupportBitsToCX
 	mov		[bp+IDEPACK.intpack+INTPACK.cx], cx
@@ -57,5 +57,5 @@
 
 
-%ifdef RETURN_DPTE_ON_AH48H
+%ifdef CREATE_COMPATIBLE_DPT
 ;--------------------------------------------------------------------
 ; AH41h_GetSupportBitsToCX
@@ -87,3 +87,3 @@
 	ret
 
-%endif ; RETURN_DPTE_ON_AH48H
+%endif ; CREATE_COMPATIBLE_DPT
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 541)
@@ -84,9 +84,9 @@
 
 	; Create DPTE (hardware information for device drivers)
-%ifdef RETURN_DPTE_ON_AH48H
+%ifdef CREATE_COMPATIBLE_DPT
 	call	AH41h_GetSupportBitsToCX
 	test	cl, ENHANCED_DISK_DRIVE_SUPPORT
 	jz		SHORT .DoNotCreateDPTE
-	call	CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
+	call	CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
 .DoNotCreateDPTE:
 %endif
@@ -110,5 +110,5 @@
 	; Store DPTE for standard controllers only,
 	; FFFF:FFFF for non standard controllers
-%ifdef RETURN_DPTE_ON_AH48H
+%ifdef CREATE_COMPATIBLE_DPT
 	mov		[di+EDRIVE_INFO.fpDPTE], bx
 	mov		[di+EDRIVE_INFO.fpDPTE+2], es
@@ -161,107 +161,2 @@
 .ReturnWithError:
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
-
-
-%ifdef RETURN_DPTE_ON_AH48H
-;--------------------------------------------------------------------
-; CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
-;	Parameters:
-;		DS:SI:	Ptr to DPT (in RAMVARS segment)
-;		ES:		RAMVARS segment
-;	Returns:
-;		ES:BX:	Ptr to Device Parameter Table Extension (DPTE)
-;	Corrupts registers:
-;		AX, CX, DX, DI
-;--------------------------------------------------------------------
-CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI:
-	; Point ES:DI to DPTE buffer (valid until next AH=48h call)
-	mov		di, [cs:ROMVARS.bStealSize]
-	eSHL_IM	di, 10							; DI = RAMVARS size in bytes
-	sub		di, BYTE DPTE_size				; DI = Offset to DPTE
-	xor		dx, dx							; Clear for checksum
-
-	; Set 32-bit flag for 32-bit controllers
-	mov		cx, FLG_LBA_TRANSLATION_ENABLED	; DPTE.wFlags
-	cmp		BYTE [si+DPT_ATA.bDevice], DEVICE_32BIT_ATA
-	eCMOVE	cl, FLG_LBA_TRANSLATION_ENABLED | FLG_32BIT_XFER_MODE
-
-	; DPTE.wBasePort
-	mov		ax, [si+DPT.wBasePort]
-	call	StoswThenAddALandAHtoDL			; Bytes 0 and 1
-
-	; DPTE.wControlBlockPort
-	eMOVZX	bx, BYTE [si+DPT.bIdevarsOffset]
-	mov		ax, [cs:bx+IDEVARS.wControlBlockPort]
-	call	StoswThenAddALandAHtoDL			; Bytes 2 and 3
-
-	; DPTE.bDrvnhead and DPTE.bBiosVendor
-	xchg	di, si
-	call	AccessDPT_GetDriveSelectByteForEbiosToAL
-	xchg	si, di
-	call	StoswThenAddALandAHtoDL			; Bytes 4 and 5
-
-	; DPTE.bIRQ and DPTE.bBlockSize
-	mov		al, [cs:bx+IDEVARS.bIRQ]		; No way to define that we might not use IRQ
-	mov		ah, [si+DPT_ATA.bBlockSize]
-	cmp		ah, 1
-	jbe		SHORT .DoNotSetBlockModeFlag
-	or		cl, FLG_BLOCK_MODE_ENABLED
-.DoNotSetBlockModeFlag:
-	call	StoswThenAddALandAHtoDL			; Bytes 6 and 7
-
-	; DPTE.bDmaChannelAndType and DPTE.bPioMode
-	xor		ax, ax
-%ifdef MODULE_ADVANCED_ATA
-	or		ah, [si+DPT_ADVANCED_ATA.bPioMode]
-	jz		SHORT .NoDotSetFastPioFlag
-	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
-	je		SHORT .NoDotSetFastPioFlag
-	inc		cx		; FLG_FAST_PIO_ENABLED
-.NoDotSetFastPioFlag:
-%endif
-	call	StoswThenAddALandAHtoDL			; Bytes 8 and 9
-
-	; Set CHS translation flags and store DPTE.wFlags
-	mov		al, [si+DPT.bFlagsLow]
-	and		al, MASKL_DPT_TRANSLATEMODE
-	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
-	or		cl, FLG_CHS_TRANSLATION_ENABLED
-	test	al, FLGL_DPT_ASSISTED_LBA
-	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
-	or		cx, LBA_ASSISTED_TRANSLATION << TRANSLATION_TYPE_FIELD_POSITION
-.NoChsTranslationOrBitShiftTranslationSet:
-	xchg	ax, cx
-	call	StoswThenAddALandAHtoDL			; Bytes 10 and 11
-
-	; DPTE.wReserved (must be zero)
-	xor		ax, ax
-	call	StoswThenAddALandAHtoDL			; Bytes 12 and 13
-
-	; DPTE.bRevision and DPTE.bChecksum
-	mov		ax, DPTE_REVISION | (DPTE_REVISION<<8)
-	add		ah, dl
-	neg		ah
-	stosw
-	lea		bx, [di-DPTE_size]
-	ret
-
-
-;--------------------------------------------------------------------
-; StoswThenAddALandAHtoDL
-;	Parameters:
-;		AX:		WORD to store
-;		ES:DI:	Ptr to where to store AX
-;		DL:		Checksum byte
-;	Returns:
-;		DL:		Checksum byte
-;		DI:		Incremented by 2
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-StoswThenAddALandAHtoDL:
-	stosw
-	add		dl, al
-	add		dl, ah
-	ret
-
-%endif ; RETURN_DPTE_ON_AH48H
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 541)
@@ -80,5 +80,39 @@
 	call	DetectDrives_FromAllIDEControllers
 	call	Interrupts_InitializeInterruptVectors
+	; Fall to .StoreDptPointersToIntVectors
+
+
+%ifdef CREATE_COMPATIBLE_DPT
+;--------------------------------------------------------------------
+; .StoreDptPointersToIntVectors
+;	Parameters:
+;		DS:		RAMVARS segment
+;		ES:		BDA and interrupt vector segment (zero)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+.StoreDptPointersToIntVectors:
+	mov		dl, 80h
+	call	FindDPT_ForDriveNumberInDL	; DPT to DS:DI
+	jc		SHORT .FindForDrive81h		; Store nothing if not our drive
+
+	call	CompatibleDPT_CreateToAXSIforDriveDL
+	mov		[es:HD0_DPT_POINTER_41h*4], si
+	mov		[es:HD0_DPT_POINTER_41h*4+2], ax
+
+.FindForDrive81h:
+	mov		dl, 81h
+	call	FindDPT_ForDriveNumberInDL
+	jc		SHORT .CompatibleDPTsCreated
+
+	call	CompatibleDPT_CreateToAXSIforDriveDL
+	mov		[es:HD1_DPT_POINTER_46h*4], si
+	mov		[es:HD1_DPT_POINTER_46h*4+2], ax
+.CompatibleDPTsCreated:
 	; Fall to .ResetDetectedDrives
+%endif ; CREATE_COMPATIBLE_DPT
+
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 541)
@@ -282,3 +282,6 @@
 	%include "AH48h_GetExtendedDriveParameters.asm"
 	%include "AH41h_CheckIfExtensionsPresent.asm"
-%endif
+%ifdef CREATE_COMPATIBLE_DPT
+	%include "CompatibleDPT.asm"
+%endif
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 541)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 541)
@@ -0,0 +1,287 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Functions to handle DPT structs to present drive geometry
+;					to ill behaving applications that want
+;					to read DPT from interrupt vectors 41h and 46h.
+
+;
+; XTIDE Universal BIOS and Associated Tools
+; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
+;
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; CompatibleDPT_CreateToAXSIforDriveDL
+;	Parameters:
+;		DL:		Drive number (80h or 81h)
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		AX:SI	Ptr to destination buffer
+;	Corrupts registers:
+;		CX, DX
+;--------------------------------------------------------------------
+CompatibleDPT_CreateToAXSIforDriveDL:
+	push	es
+
+	call	AccessDPT_GetDeviceControlByteToAL
+	xchg	cx, ax							; Device control byte to CL
+	mov		si, di							; DPT now in DS:SI
+	call	GetBufferForDrive80hToESDI
+	shr		dx, 1
+	jnc		SHORT .BufferLoadedToESDI
+	add		di, BYTE TRANSLATED_DPT_size	; For drive 81h
+.BufferLoadedToESDI:
+
+	call	FillToESDIusingDPTfromDSSI
+	xchg	di, si
+	mov		ax, es
+
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; GetTemporaryBufferForDPTEtoESDI
+; GetBufferForDrive80hToESDI
+;	Parameters:
+;		DS:		RAMVARS segment
+;	Returns:
+;		ES:DI:	Ptr to buffer (in RAMVARS segment)
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+GetTemporaryBufferForDPTEtoESDI:
+	call	GetBufferForDrive80hToESDI
+	add		di, BYTE TRANSLATED_DPT_size * 2
+	ret
+
+GetBufferForDrive80hToESDI:
+	push	ds
+	pop		es
+	mov		di, [cs:ROMVARS.bStealSize]	; No harm to read WORD
+	eSHL_IM	di, 10						; DI = RAMVARS size in bytes
+	sub		di, BYTE (TRANSLATED_DPT_size * 2) + DPTE_size
+	ret
+
+
+;--------------------------------------------------------------------
+; FillToESDIusingDPTfromDSSI
+;	Parameters:
+;		CL:		Device Control Byte
+;		DS:SI:	Ptr to DPT
+;		ES:DI	Ptr to destination buffer
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DX
+;--------------------------------------------------------------------
+FillToESDIusingDPTfromDSSI:
+	test	BYTE [si+DPT.bFlagsLow], MASKL_DPT_TRANSLATEMODE
+	jz		SHORT FillStandardDPTtoESDIfromDPTinDSSI
+	; Fall to FillTranslatedDPTtoESDIfromDPTinDSSI
+
+;--------------------------------------------------------------------
+; FillTranslatedDPTtoESDIfromDPTinDSSI
+;	Parameters:
+;		CL:		Device Control Byte
+;		DS:SI:	Ptr to DPT
+;		ES:DI:	Ptr to destination buffer
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DX
+;--------------------------------------------------------------------
+FillTranslatedDPTtoESDIfromDPTinDSSI:
+	xor		dx, dx						; Clear for checksum
+	mov		ax, [si+DPT.wLchsCylinders]
+	MIN_U	ax, MAX_LCHS_CYLINDERS		; Our DPT can have up to 1027
+	call	StoswThenAddALandAHtoDL		; Bytes 0 and 1 (Logical number of cylinders)
+
+	mov		al, BYTE [si+DPT.bLchsHeads]
+	mov		ah, TRANSLATED_DPT_SIGNATURE
+	call	StoswThenAddALandAHtoDL		; Bytes 2 (Logical number of heads) and 3 (Axh signature to indicate Translated DPT)
+
+	eMOVZX	ax, BYTE [si+DPT.bPchsSectorsPerTrack]
+	call	StoswThenAddALandAHtoDL		; Bytes 4 (Physical sectors per track) and 5 (Write Precompensation Cylinder low)
+
+	mov		al, ah
+	call	StoswThenAddALandAHtoDL		; Bytes 6 (Write Precompensation Cylinder high) and 7
+
+	xchg	ax, cx						; Device Control byte to AL
+	mov		ah, [si+DPT.wPchsCylinders]
+	call	StoswThenAddALandAHtoDL		; Bytes 8 (Drive Control Byte) and 9 (Physical number of cylinders low)
+
+	mov		al, [si+DPT.wPchsCylinders+1]
+	mov		ah, [si+DPT.bPchsHeads]
+	call	StoswThenAddALandAHtoDL		; Bytes 10 (Physical number of cylinders high) and 11 (Physical number of heads)
+
+	xor		ax, ax
+	call	StoswThenAddALandAHtoDL		; Bytes 12 and 13 (Landing Zone Cylinder)
+
+	mov		al, [si+DPT.bLchsSectorsPerTrack]
+%ifdef USE_186
+	push	FillStandardDPTtoESDIfromDPTinDSSI.RestoreOffsetsAndReturn
+	jmp		StoswALandChecksumFromDL	; Bytes 14 (Logical sectors per track) and 15 (Checksum)
+%else
+	call	StoswALandChecksumFromDL
+	jmp		SHORT FillStandardDPTtoESDIfromDPTinDSSI.RestoreOffsetsAndReturn
+%endif
+
+
+;--------------------------------------------------------------------
+; FillStandardDPTtoESDIfromDPTinDSSI
+;	Parameters:
+;		CL:		Device Control Byte
+;		DS:SI:	Ptr to DPT
+;		ES:DI:	Ptr to destination buffer
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+FillStandardDPTtoESDIfromDPTinDSSI:
+	mov		ax, [si+DPT.wLchsCylinders]
+	stosw				; Bytes 0 and 1 (Physical number of cylinders)
+	eMOVZX	ax, BYTE [si+DPT.bLchsHeads]
+	stosw				; Bytes 2 (Physical number of heads) and 3
+	mov		al, ah		; Zero AX
+	stosw				; Bytes 4 and 5 (Write Precompensation Cylinder low)
+	stosw				; Bytes 6 (Write Precompensation Cylinder high) and 7
+	mov		al, cl		; Device control byte to AL
+	stosw				; Bytes 8 (Drive Control Byte) and 9
+	mov		al, ah		; Zero AX
+	stosw				; Bytes 10 and 11
+	stosw				; Bytes 12 and 13 (Landing Zone Cylinder)
+	mov		al, [si+DPT.bLchsSectorsPerTrack]
+	stosw				; Bytes 14 (Physical sectors per track) and 15
+
+.RestoreOffsetsAndReturn:
+	sub		di, BYTE STANDARD_DPT_size
+	ret
+
+
+;--------------------------------------------------------------------
+; CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
+;	Parameters:
+;		DS:SI:	Ptr to DPT (in RAMVARS segment)
+;	Returns:
+;		ES:BX:	Ptr to Device Parameter Table Extension (DPTE)
+;	Corrupts registers:
+;		AX, CX, DX, DI
+;--------------------------------------------------------------------
+CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI:
+	call	GetTemporaryBufferForDPTEtoESDI	; valid until next AH=48h call
+
+	; Set 32-bit flag for 32-bit controllers
+	mov		cx, FLG_LBA_TRANSLATION_ENABLED	; DPTE.wFlags
+	cmp		BYTE [si+DPT_ATA.bDevice], DEVICE_32BIT_ATA
+	eCMOVE	cl, FLG_LBA_TRANSLATION_ENABLED | FLG_32BIT_XFER_MODE
+
+	; DPTE.wBasePort
+	mov		ax, [si+DPT.wBasePort]
+	call	StoswThenAddALandAHtoDL			; Bytes 0 and 1
+
+	; DPTE.wControlBlockPort
+	eMOVZX	bx, BYTE [si+DPT.bIdevarsOffset]
+	mov		ax, [cs:bx+IDEVARS.wControlBlockPort]
+	call	StoswThenAddALandAHtoDL			; Bytes 2 and 3
+
+	; DPTE.bDrvnhead and DPTE.bBiosVendor
+	xchg	di, si
+	call	AccessDPT_GetDriveSelectByteForEbiosToAL
+	xchg	si, di
+	call	StoswThenAddALandAHtoDL			; Bytes 4 and 5
+
+	; DPTE.bIRQ and DPTE.bBlockSize
+	mov		al, [cs:bx+IDEVARS.bIRQ]		; No way to define that we might not use IRQ
+	mov		ah, [si+DPT_ATA.bBlockSize]
+	cmp		ah, 1
+	jbe		SHORT .DoNotSetBlockModeFlag
+	or		cl, FLG_BLOCK_MODE_ENABLED
+.DoNotSetBlockModeFlag:
+	call	StoswThenAddALandAHtoDL			; Bytes 6 and 7
+
+	; DPTE.bDmaChannelAndType and DPTE.bPioMode
+	xor		ax, ax
+%ifdef MODULE_ADVANCED_ATA
+	or		ah, [si+DPT_ADVANCED_ATA.bPioMode]
+	jz		SHORT .NoDotSetFastPioFlag
+	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
+	je		SHORT .NoDotSetFastPioFlag
+	inc		cx		; FLG_FAST_PIO_ENABLED
+.NoDotSetFastPioFlag:
+%endif
+	call	StoswThenAddALandAHtoDL			; Bytes 8 and 9
+
+	; Set CHS translation flags and store DPTE.wFlags
+	mov		al, [si+DPT.bFlagsLow]
+	and		al, MASKL_DPT_TRANSLATEMODE
+	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
+	or		cl, FLG_CHS_TRANSLATION_ENABLED
+	test	al, FLGL_DPT_ASSISTED_LBA
+	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
+	or		cx, LBA_ASSISTED_TRANSLATION << TRANSLATION_TYPE_FIELD_POSITION
+.NoChsTranslationOrBitShiftTranslationSet:
+	xchg	ax, cx
+	call	StoswThenAddALandAHtoDL			; Bytes 10 and 11
+
+	; DPTE.wReserved (must be zero)
+	xor		ax, ax
+	call	StoswThenAddALandAHtoDL			; Bytes 12 and 13
+
+	; DPTE.bRevision and DPTE.bChecksum
+	mov		al, DPTE_REVISION
+	call	StoswALandChecksumFromDL		; Bytes 14 and 15
+	lea		bx, [di-DPTE_size]
+	ret
+
+
+;--------------------------------------------------------------------
+; StoswThenAddALandAHtoDL
+;	Parameters:
+;		AX:		WORD to store
+;		DL:		Sum of bytes so far
+;		ES:DI:	Ptr to where to store AX
+;	Returns:
+;		DL:		Sum of bytes so far
+;		DI:		Incremented by 2
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+StoswThenAddALandAHtoDL:
+	stosw
+	add		dl, al
+	add		dl, ah
+	ret
+
+
+;--------------------------------------------------------------------
+; StoswALandChecksumFromDL
+;	Parameters:
+;		AL:		Last byte to store before checksum byte
+;		DL:		Sum of bytes so far
+;		ES:DI:	Ptr to where to store AL and Checksum byte
+;	Returns:
+;		DL:		Sum of bytes so far
+;		DI:		Incremented by 2
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+StoswALandChecksumFromDL:
+	mov		ah, al
+	add		ah, dl
+	neg		ah
+	stosw
+	ret
Index: trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS/makefile	(revision 540)
+++ trunk/XTIDE_Universal_BIOS/makefile	(revision 541)
@@ -32,5 +32,5 @@
 # RELOCATE_INT13H_STACK **    Relocates INT 13h stack to beginning of stolen conventional memory   #
 # RESERVE_DIAGNOSTIC_CYLINDER Reserve one L-CHS cylinder for compatibility with old BIOSes         #
-# RETURN_DPTE_ON_AH48H        Returns extra hardware related information on AH=48h for OS drivers  #
+# CREATE_COMPATIBLE_DPT       Presents compatible DPTs for ill behaving applications               #
 # USE_186                     Use instructions supported by 80188/80186 and V20/V30 and later      #
 # USE_286                     Use instructions supported by 286 and later (defines USE_UNDOC_INTEL)#
@@ -100,5 +100,5 @@
 #################################################################
 DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_8BIT_IDE MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_EBIOS MODULE_FEATURE_SETS RESERVE_DIAGNOSTIC_CYLINDER
-DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_8BIT_IDE_ADVANCED
+DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_8BIT_IDE_ADVANCED CREATE_COMPATIBLE_DPT
 
 DEFINES_XT = $(DEFINES_COMMON) ELIMINATE_CGA_SNOW MODULE_8BIT_IDE_ADVANCED
@@ -111,5 +111,5 @@
 
 DEFINES_XT_TINY = MODULE_STRINGS_COMPRESSED MODULE_8BIT_IDE
-DEFINES_386_8K = $(DEFINES_AT) USE_386 RETURN_DPTE_ON_AH48H
+DEFINES_386_8K = $(DEFINES_AT) USE_386 CREATE_COMPATIBLE_DPT
 
 DEFINES_ALL_FEATURES = MODULE_8BIT_IDE MODULE_8BIT_IDE_ADVANCED MODULE_ADVANCED_ATA MODULE_EBIOS MODULE_BOOT_MENU MODULE_HOTKEYS MODULE_IRQ MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_STRINGS_COMPRESSED MODULE_FEATURE_SETS
