Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 270)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 271)
@@ -8,9 +8,12 @@
 ; Int 13h function AH=0h, Disk Controller Reset.
 ;
+; Note: We handle all AH=0h calls, even for drives handled by other
+; BIOSes!
+;
 ; AH0h_HandlerForDiskControllerReset
 ;	Parameters:
 ;		DL:		Translated Drive number (ignored so all drives are reset)
 ;				If bit 7 is set all hard disks and floppy disks reset.
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		DS:DI:	Ptr to DPT (only if DL is our drive)
 ;		SS:BP:	Ptr to IDEPACK
 ;	Returns with INTPACK:
@@ -49,6 +52,7 @@
 
 	; Resetting our hard disks will modify dl and bl such that this call must be the last in the list
-	;
-	call	AH0h_ResetHardDisksHandledByOurBIOS			
+	call	GetDriveNumberForForeignHardDiskHandlerToDL	; Load DPT for our drive
+	jc		SHORT .SkipHardDiskReset					; Our drive not requested so let's not reset them
+	call	ResetHardDisksHandledByOurBIOS			
 
 .SkipHardDiskReset:
@@ -66,7 +70,6 @@
 ;		AX, DL, DI
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 ResetFloppyDrivesWithInt40h:
-	call	GetDriveNumberForForeignBiosesToDL
+	call	GetDriveNumberForForeignHardDiskHandlerToDL
 	and		dl, 7Fh						; Clear hard disk bit
 	xor		ah, ah						; Disk Controller Reset
@@ -85,7 +88,6 @@
 ;		AX, DL, DI
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 ResetForeignHardDisks:
-	call	GetDriveNumberForForeignBiosesToDL
+	call	GetDriveNumberForForeignHardDiskHandlerToDL
 	xor		ah, ah						; Disk Controller Reset
 	call	Int13h_CallPreviousInt13hHandler
@@ -104,37 +106,53 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 BackupErrorCodeFromTheRequestedDriveToBH:
 	cmp		dl, bl				; Requested drive?
 	eCMOVE	bh, ah
 	ret
-		
+
 
 ;--------------------------------------------------------------------
-; GetDriveNumberForForeignBiosesToDL
+; GetDriveNumberForForeignHardDiskHandlerToDL
 ;	Parameters:
 ;		BL:		Requested drive (DL when entering AH=00h)
 ;		DS:		RAMVARS segment
 ;	Returns:
+;		DS:DI:	Ptr to DPT if our drive
 ;		DL:		BL if foreign drive
 ;				80h if our drive
+;		CF:		Set if foreign drive
+;				Cleared if our drive
 ;	Corrupts registers:
-;		DI
+;		(DI)
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-GetDriveNumberForForeignBiosesToDL:
+GetDriveNumberForForeignHardDiskHandlerToDL:
 	mov		dl, bl
-	test	di, di
-	jz		SHORT .Return				; Return what was in BL unmodified
-	mov		dl, 80h
-.Return:
+	call	FindDPT_ForDriveNumberInDL
+	jc		SHORT .ReturnWithForeignDriveInDL
+	mov		dl, 80h				; First possible Hard Disk should be safe value
+.ReturnWithForeignDriveInDL:
 	ret
 
 
 ;--------------------------------------------------------------------
-; AH0h_ResetHardDisksHandledByOurBIOS
+; AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization
+;	Parameters:
+;		DS:		RAMVARS segment
+;		SS:BP:	Ptr to IDEPACK
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization:
+	mov		bl, [RAMVARS.bFirstDrv]
+	call	GetDriveNumberForForeignHardDiskHandlerToDL
+	; Fall to ResetHardDisksHandledByOurBIOS
+
+;--------------------------------------------------------------------
+; ResetHardDisksHandledByOurBIOS
 ;	Parameters:
 ;		BL:		Requested drive (DL when entering AH=00h)
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT for requested drive
 ;		SS:BP:	Ptr to IDEPACK
 ;	Returns:
@@ -143,16 +161,12 @@
 ;		AX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AH0h_ResetHardDisksHandledByOurBIOS:
+ResetHardDisksHandledByOurBIOS:
 	mov		bl, [di+DPT.bIdevarsOffset]					; replace drive number with Idevars pointer for cmp with dl
 	mov		dl, ROMVARS.ideVars0						; starting Idevars offset
 
-	call	RamVars_GetIdeControllerCountToCX
+	call	RamVars_GetIdeControllerCountToCX			; get count of ide controllers
 	jcxz	.done										; just in case bIdeCnt is zero (shouldn't be)
-
-	mov		si, IterateFindFirstDPTforIdevars			; iteration routine (see below)
-
 .loop:
-	call	IterateAllDPTs								; look for the first drive on this controller, if any
+	call	FindDPT_ForIdevarsOffsetInDL				; look for the first drive on this controller, if any
 	jc		.notFound
 
@@ -166,15 +180,2 @@
 .done:
 	ret
-
-;--------------------------------------------------------------------
-; Iteration routine for AH0h_ResetHardDisksHandledByOurBIOS, 
-; for use with IterateAllDPTs
-; 
-; Returns when DPT is found on the controller with Idevars offset in DL
-;--------------------------------------------------------------------
-IterateFindFirstDPTforIdevars:		
-	cmp		dl, [di+DPT.bIdevarsOffset]			; Clears CF if matched
-	jz		.done
-	stc											; Set CF for not found
-.done:	
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 270)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 271)
@@ -33,6 +33,5 @@
 ; AHDh_ResetDrive
 ;	Parameters:
-;		DL:		Drive number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT
 ;		SS:BP:	Ptr to IDEPACK
 ;	Returns:
@@ -40,9 +39,9 @@
 ;		CF:		0 if succesfull, 1 if error
 ;	Corrupts registers:
-;		AL, CX, SI
+;		AL, SI
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
 AHDh_ResetDrive:
 	push	dx
+	push	cx
 	push	bx
 	push	di
@@ -58,5 +57,5 @@
 		
 	mov		si, IterateAndResetDrives
-	call	IterateAllDPTs
+	call	FindDPT_IterateAllDPTs
 
 	shr		ah, 1								; Move error code and CF into proper position
@@ -64,4 +63,5 @@
 	pop		di
 	pop		bx
+	pop		cx
 	pop		dx
 	ret
@@ -76,5 +76,5 @@
 IterateAndResetDrives:
 	cmp		al, [di+DPT.bIdevarsOffset]			; The right controller?
-	jnz		.done
+	jne		.done
 	push	ax
 	call	AH9h_InitializeDriveForUse			; Reset Master and Slave (Master will come first in DPT list)
@@ -83,5 +83,4 @@
 	or		ah, (RET_HD_RESETFAIL << 1) | 1		; OR in Reset Failed error code and CF, will SHR into position later
 .done:
-	stc											; From IterateAllDPTs perspective, the DPT is never found
+	stc											; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
 	ret
-		
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 270)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 271)
@@ -96,5 +96,5 @@
 .ResetDetectedDrives:
 	call	Idepack_FakeToSSBP
-	call	AH0h_ResetHardDisksHandledByOurBIOS
+	call	AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization
 	add		sp, BYTE EXTRA_BYTES_FOR_INTPACK
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 270)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 271)
@@ -116,4 +116,42 @@
 	ret
 
+
+;--------------------------------------------------------------------
+; FindDPT_ForIdevarsOffsetInDL
+;	Parameters:
+;		DL:		Offset to IDEVARS to search for
+;		DS:		RAMVARS segment
+;	Returns:
+;		DS:DI:		Ptr to first DPT with same IDEVARS as in DL
+;		CF:			Clear if wanted DPT found
+;					Set if DPT not found, or no DPTs present
+;	Corrupts registers:
+;		SI
+;--------------------------------------------------------------------
+FindDPT_ForIdevarsOffsetInDL:
+	mov		si, IterateFindFirstDPTforIdevars			; iteration routine (see below)
+	jmp		SHORT FindDPT_IterateAllDPTs				; look for the first drive on this controller, if any
+
+;--------------------------------------------------------------------
+; Iteration routine for FindDPT_ForIdevarsOffsetInDL, 
+; for use with IterateAllDPTs
+; 
+; Returns when DPT is found on the controller with Idevars offset in DL
+;
+; IterateFindFirstDPTforIdevars
+;       DL:		Offset to IDEVARS to search from DPTs
+;		DS:DI:	Ptr to DPT to examine
+;	Returns:
+;		CF:		Clear if wanted DPT found
+;				Set if wrong DPT
+;--------------------------------------------------------------------
+IterateFindFirstDPTforIdevars:		
+	cmp		dl, [di+DPT.bIdevarsOffset]			; Clears CF if matched
+	je		.done
+	stc											; Set CF for not found
+.done:	
+	ret
+
+
 ;--------------------------------------------------------------------
 ; Finds pointer to first unused Disk Parameter Table.
@@ -198,5 +236,5 @@
 ; Iterates all Disk Parameter Tables.
 ;
-; IterateAllDPTs
+; FindDPT_IterateAllDPTs
 ;	Parameters:
 ;		AX,BX,DX:	Parameters to callback function
@@ -213,5 +251,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-IterateAllDPTs:
+FindDPT_IterateAllDPTs:
 	push	cx
 
