Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 22)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 23)
@@ -2,5 +2,5 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	27.9.2007
-; Last update	:	2.5.2010
+; Last update	:	1.7.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Int 13h function AH=0h, Disk Controller Reset.
@@ -23,5 +23,5 @@
 ;		DS:		RAMVARS segment
 ;	Returns:
-;		AH:		Int 13h return status
+;		AH:		Int 13h return status (from drive requested in DL)
 ;		CF:		0 if succesfull, 1 if error
 ;		IF:		1
@@ -36,118 +36,161 @@
 	push	ax
 
-	test	dl, 80h						; Reset floppy drives only?
-	jz		SHORT .ResetForeignControllers
-	call	AH0h_ResetOurControllers
-.ResetForeignControllers:
-	call	AH0h_ResetFloppyAndForeignHardDiskControllers
-	jmp		Int13h_PopXRegsAndReturn	; Return since error
+	eMOVZX	bx, dl						; Copy requested drive to BL, zero BH to assume no errors
+	call	AH0h_ResetFloppyDrivesWithInt40h
+	test	bl, 80h						; Reset hard disks too?
+	jz		SHORT .Return
+	call	AH0h_ResetForeignHardDisks
+	call	AH0h_ResetAllOurControllers
+ALIGN JUMP_ALIGN
+.Return:
+	mov		ah, bh						; Copy error code to AH
+	xor		al, al						; Zero AL...
+	sub		al, ah						; ...and set CF if error
+	jmp		Int13h_PopXRegsAndReturn
 
 
 ;--------------------------------------------------------------------
-; Resets all IDE controllers handled by this BIOS.
-;
-; AH0h_ResetOurControllers
+; AH0h_ResetFloppyDrivesWithInt40h
 ;	Parameters:
+;		BL:		Requested drive (DL when entering AH=00h)
+;		DL:		Drive number
+;	Returns:
+;		BH:		Error code from requested drive (if available)
+;	Corrupts registers:
+;		AX, DL
+;--------------------------------------------------------------------	
+ALIGN JUMP_ALIGN
+AH0h_ResetFloppyDrivesWithInt40h:
+	xor		ax, ax						; Disk Controller Reset
+	and		dl, 7Fh						; Clear bit 7
+	int		INTV_FLOPPY_FUNC
+	jmp		SHORT AH0h_BackupErrorCodeFromTheRequestedDriveToBH
+
+
+;--------------------------------------------------------------------
+; AH0h_ResetForeignHardDisks
+;	Parameters:
+;		BL:		Requested drive (DL when entering AH=00h)
 ;		DS:		RAMVARS segment
 ;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if succesfull, 1 if error
+;		BH:		Error code from requested drive (if available)
 ;	Corrupts registers:
-;		AL, BX, CX, DI
-;--------------------------------------------------------------------
+;		AX, DL
+;--------------------------------------------------------------------	
 ALIGN JUMP_ALIGN
-AH0h_ResetOurControllers:
-	push	dx
-	mov		bx, ROMVARS.ideVars0			; Load offset to first IDEVARS
-	call	Initialize_GetIdeControllerCountToCX
+AH0h_ResetForeignHardDisks:
+	mov		cl, [RAMVARS.bFirstDrv]		; Load number of first our drive
+	and		cx, BYTE 7Fh				; CX = number of drives to reset
+	jz		SHORT .Return
+	mov		dl, 80h						; Start resetting from drive 80h
 ALIGN JUMP_ALIGN
-.ResetLoop:
-	call	AH0h_ResetIdevarsController
-	jc		SHORT .Return
-	add		bx, BYTE IDEVARS_size
-	loop	.ResetLoop
-	xor		ax, ax							; Clear AH and CF since no errors
+.DriveResetLoop:
+	mov		ah, 0Dh						; Reset Hard Disk (Alternate reset)
+	pushf								; Push flags to simulate INT
+	cli									; Disable interrupts since INT does that
+	call	FAR [RAMVARS.fpOldI13h]
+	sti									; Make sure interrupts are enabled again (some BIOSes fails to enable it)
+	call	AH0h_BackupErrorCodeFromTheRequestedDriveToBH
+	inc		dx							; Next drive to reset
+	loop	.DriveResetLoop
+ALIGN JUMP_ALIGN
 .Return:
-	pop		dx
 	ret
 
 
 ;--------------------------------------------------------------------
-; Resets master and slave drive based on either drive number.
-;
-; AH0h_ResetIdevarsController
+; AH0h_ResetAllOurControllers
 ;	Parameters:
-;		CS:BX:	Ptr to IDEVARS
+;		BL:		Requested drive (DL when entering AH=00h)
 ;		DS:		RAMVARS segment
 ;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if succesfull, 1 if error
+;		BH:		Error code from requested drive (if available)
 ;	Corrupts registers:
-;		AL, DX, DI
+;		AX, CX, DX, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-AH0h_ResetIdevarsController:
-	mov		dx, [cs:bx+IDEVARS.wPort]
+AH0h_ResetAllOurControllers:
+	push	si
+	mov		si, ROMVARS.ideVars0			; Load offset to first IDEVARS
+	call	Initialize_GetIdeControllerCountToCX
+ALIGN JUMP_ALIGN
+.ResetLoop:
+	call	AH0h_ResetIdevarsControllerMasterAndSlaveDrives
+	add		si, BYTE IDEVARS_size
+	loop	.ResetLoop
+.Return:
+	pop		si
+	ret
+
+
+;--------------------------------------------------------------------
+; AH0h_ResetIdevarsControllerMasterAndSlaveDrives
+;	Parameters:
+;		BL:		Requested drive (DL when entering AH=00h)
+;		CS:SI:	Ptr to IDEVARS
+;		DS:		RAMVARS segment
+;	Returns:
+;		BH:		Error code from requested drive (if available)
+;	Corrupts registers:
+;		AX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+AH0h_ResetIdevarsControllerMasterAndSlaveDrives:
+	mov		dx, [cs:si+IDEVARS.wPort]
 	call	FindDPT_ForIdeMasterAtPort		; Find master drive to DL
 	jc		SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
 	call	FindDPT_ForIdeSlaveAtPort		; Find slave if master not present
 	jc		SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
-	clc
 	ret
 
-
 ;--------------------------------------------------------------------
-; Resets master and slave drive based on either drive number.
-;
 ; AH0h_ResetMasterAndSlaveDriveWithRetries
 ;	Parameters:
+;		BL:		Requested drive (DL when entering AH=00h)
 ;		DL:		Drive number for master or slave drive
+;		DS:		RAMVARS segment
 ;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if succesfull, 1 if error
+;		BH:		Error code from requested drive (if available)
 ;	Corrupts registers:
-;		AL, DX, DI
+;		AX, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH0h_ResetMasterAndSlaveDriveWithRetries:
+	push	dx
 	push	cx
 	push	bx
-	mov		cx, RETRIES_IF_RESET_FAILS
+	mov		di, RETRIES_IF_RESET_FAILS
 ALIGN JUMP_ALIGN
 .RetryLoop:
-	mov		di, cx						; Backup counter
 	call	AHDh_ResetDrive
-	jnc		SHORT .Return
+	jnc		SHORT .Return				; Jump if successful
 	mov		cx, TIMEOUT_BEFORE_RESET_RETRY
 	call	SoftDelay_TimerTicks
-	mov		cx, di
-	loop	.RetryLoop
-	mov		ah, RET_HD_RESETFAIL
-	stc
+	dec		di
+	jnz		SHORT .RetryLoop
 ALIGN JUMP_ALIGN
 .Return:
 	pop		bx
 	pop		cx
-	ret
-
+	pop		dx
+	; Fall to AH0h_BackupErrorCodeFromTheRequestedDriveToBH
 
 ;--------------------------------------------------------------------
-; Resets floppy drives and foreign hard disks.
-;
-; AH0h_ResetFloppyAndForeignHardDiskControllers
+; AH0h_BackupErrorCodeFromTheRequestedDriveToBH
 ;	Parameters:
-;		DL:		Drive number (ignored so all drives are reset)
-;				If bit 7 is set all hard disks and floppy disks reset.
+;		AH:		Error code from the last resetted drive
+;		DL:		Drive last resetted
+;		BL:		Requested drive (DL when entering AH=00h)
 ;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if succesfull, 1 if error
+;		BH:		Backuped error code
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-AH0h_ResetFloppyAndForeignHardDiskControllers:
-	xor		ah, ah						; AH=0h, Disk Controller Reset
-	pushf								; Push flags to simulate INT
-	cli									; Disable interrupts
-	call	FAR [RAMVARS.fpOldI13h]
+AH0h_BackupErrorCodeFromTheRequestedDriveToBH:
+	cmp		dl, bl						; Requested drive?
+	jne		SHORT .Return
+	mov		bh, ah
+ALIGN JUMP_ALIGN
+.Return:
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 22)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 23)
@@ -2,5 +2,5 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	23.3.2010
-; Last update	:	2.5.2010
+; Last update	:	1.7.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for initializing the BIOS.
@@ -418,13 +418,6 @@
 ALIGN JUMP_ALIGN
 Initialize_ResetDetectedDrives:
-	; Initialize to speed up POST. DOS will reset drives anyway.
-	eMOVZX	cx, BYTE [RAMVARS.bDrvCnt]
-	jcxz	.Return
-	mov		dl, [RAMVARS.bFirstDrv]
-ALIGN JUMP_ALIGN
-.InitLoop:
-	call	AH9h_InitializeDriveForUse
-	inc		dx					; Next drive
-	loop	.InitLoop
-.Return:
-	ret
+	xor		ah, ah				; Disk Controller Reset
+	mov		dl, 80h				; Reset all floppy drives and hard disks
+	int		INTV_DISK_FUNC
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 22)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 23)
@@ -2,5 +2,5 @@
 ; Project name	:	XTIDE Universal BIOS
 ; Created date	:	28.7.2007
-; Last update	:	2.5.2010
+; Last update	:	1.7.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Main file for BIOS. This is the only file that needs
@@ -38,5 +38,5 @@
 	at	ROMVARS.bRomSize,	db	CNT_ROM_BLOCKS	; ROM size in 512B blocks
 	at	ROMVARS.rgbJump, 	jmp	Initialize_FromMainBiosRomSearch
-	at	ROMVARS.rgbDate,	db	"05/02/10"		; Build data (mm/dd/yy)
+	at	ROMVARS.rgbDate,	db	"07/01/10"		; Build data (mm/dd/yy)
 	at	ROMVARS.rgbSign,	db	"XTIDE110"		; Signature for flash program
 	at	ROMVARS.szTitle
@@ -49,5 +49,5 @@
 		db	" (XT)=-",STOP
 %endif
-	at	ROMVARS.szVersion,	db	"v1.1.0 (05/02/10)",STOP
+	at	ROMVARS.szVersion,	db	"v1.1.1 (07/01/10)",STOP
 
 ;---------------------------;
