Index: trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 507)
@@ -21,5 +21,5 @@
 %define HOTKEYBAR_INC
 
-MIN_TIME_TO_DISPLAY_HOTKEY_BAR			EQU	(3000/55)	; 3000 ms
+MIN_TIME_TO_DISPLAY_HOTKEY_BAR			EQU	(2000/55)	; 2000 ms
 
 ROM_BOOT_HOTKEY_SCANCODE				EQU	42h	; F8
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 507)
@@ -62,4 +62,6 @@
 	%endif
 %endif
+
+NUMBER_OF_IDEVARS					EQU	((ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin) / IDEVARS_size)
 
 ; Bit defines for ROMVARS.wFlags
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 507)
@@ -55,4 +55,24 @@
 %else					; IDE
 	Device_FinalizeDPT		EQU		IdeDPT_Finalize
+%endif
+
+
+;--------------------------------------------------------------------
+; Device_ResetMasterAndSlaveController
+;	Parameters:
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;	Returns:
+;		AH:		INT 13h Error Code
+;		CF:		Cleared if success, Set if error
+;	Corrupts registers:
+;		AL, BX, CX, DX
+;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL	; IDE + Serial
+Device_ResetMasterAndSlaveController:
+	TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE	ReturnSuccessForSerialPort
+	jmp		IdeCommand_ResetMasterAndSlaveController
+
+%else					; IDE
+	Device_ResetMasterAndSlaveController	EQU		IdeCommand_ResetMasterAndSlaveController
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 507)
@@ -20,4 +20,35 @@
 ; Section containing code
 SECTION .text
+
+;--------------------------------------------------------------------
+; IdeCommand_ResetMasterAndSlaveController
+;	Parameters:
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;	Returns:
+;		AH:		INT 13h Error Code
+;		CF:		Cleared if success, Set if error
+;	Corrupts registers:
+;		AL, BX, CX, DX
+;--------------------------------------------------------------------
+IdeCommand_ResetMasterAndSlaveController:
+	; HSR0: Set_SRST
+	call	AccessDPT_GetDeviceControlByteToAL
+	or		al, FLG_DEVCONTROL_SRST | FLG_DEVCONTROL_nIEN	; Set Reset bit
+	OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER		DEVICE_CONTROL_REGISTER_out
+	mov		ax, HSR0_RESET_WAIT_US
+	call	Timer_DelayMicrosecondsFromAX
+
+	; HSR1: Clear_wait
+	call	AccessDPT_GetDeviceControlByteToAL
+	or		al, FLG_DEVCONTROL_nIEN
+	and		al, ~FLG_DEVCONTROL_SRST						; Clear reset bit
+	OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER		DEVICE_CONTROL_REGISTER_out
+	mov		ax, HSR1_RESET_WAIT_US
+	call	Timer_DelayMicrosecondsFromAX
+
+	; HSR2: Check_status
+	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MAXIMUM, FLG_STATUS_BSY)
+	jmp		IdeWait_PollStatusFlagInBLwithTimeoutInBH
+
 
 ;--------------------------------------------------------------------
@@ -49,5 +80,6 @@
 	test	bh, FLG_DRVNHEAD_DRV		; Wait already done for Master
 	jnz		SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster
-	call	AHDh_WaitUntilDriveMotorHasReachedFullSpeed
+	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_DRDY)
+	call	IdeWait_PollStatusFlagInBLwithTimeoutInBH
 .SkipLongWaitSinceDriveIsNotPrimaryMaster:
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 507)
@@ -378,5 +378,5 @@
 	dw	UnsupportedFunction							; 0Bh, Write Disk Sectors with ECC (XT, AT, EISA)
 	dw	AHCh_HandlerForSeek							; 0Ch, Seek (All)
-	dw	AHDh_HandlerForResetHardDisk				; 0Dh, Alternate Disk Reset (All)
+	dw	AH9h_HandlerForInitializeDriveParameters	; 0Dh, Alternate Disk Reset (All)
 	dw	UnsupportedFunction							; 0Eh, Read Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
 	dw	UnsupportedFunction							; 0Fh, Write Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 507)
@@ -119,6 +119,12 @@
 	jz		SHORT .ErrorCodeNotUsed
 	mov		bl, [di+DPT.bIdevarsOffset]					; replace drive number with Idevars pointer for cmp with dl
+.ErrorCodeNotUsed:
 
-.ErrorCodeNotUsed:										; BH will be garbage on exit if this entry point is used,
+	mov		si, ControllerResetForDPTinDSDI
+	call	.CallSIforEveryDrive						; Reset all drives to power on settings
+	mov		si, AH9h_InitializeDriveForUse
+	; Fall to .CallSIforEveryDrive						; Initialize all drives
+
+.CallSIforEveryDrive:									; BH will be garbage on exit if this entry point is used,
 														; but reset of all drives will still happen
 
@@ -130,11 +136,19 @@
 	; will point to them.  Performance isn't an issue, as this is a reset operation.
     ;
-	mov		cx, (ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin) / IDEVARS_size
+	mov		cx, NUMBER_OF_IDEVARS
 
 .loop:
+	push	si
 	call	FindDPT_ForIdevarsOffsetInDL				; look for the first drive on this controller, if any
+	pop		si
 	jc		SHORT .notFound
 
-	call	AHDh_ResetDrive								; reset master and slave on that controller
+	push	bx
+	push	cx
+	push	dx
+	call	si											; Reset Master AND Slave or initialize Master OR Slave drive
+	pop		dx
+	pop		cx
+	pop		bx
 	call	BackupErrorCodeFromTheRequestedDriveToBH	; save error code if same controller as drive from entry
 
@@ -142,5 +156,26 @@
 	add		dl, IDEVARS_size							; move Idevars pointer forward
 	loop	.loop
+	ret
 
-.done:
-	ret
+
+;--------------------------------------------------------------------
+; ControllerResetForDPTinDSDI
+;	Parameters:
+;		DS:DI:	Ptr to DPT for drive to reset (resets both Master and Slave drive)
+;		SS:BP:	Ptr to IDEPACK
+;	Returns:
+;		AH:		Int 13h return status
+;		CF:		0 if successful, 1 if error
+;	Corrupts registers:
+;		AL, BX, CX, DX
+;--------------------------------------------------------------------
+ControllerResetForDPTinDSDI:
+%ifdef MODULE_IRQ
+	call	Interrupts_UnmaskInterruptControllerForDriveInDSDI
+%endif
+%ifdef MODULE_ADVANCED_ATA
+	call	Device_ResetMasterAndSlaveController
+	jmp		AdvAtaInit_InitializeControllerForDPTinDSDI
+%else
+	jmp		Device_ResetMasterAndSlaveController
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 506)
+++ 	(revision )
@@ -1,150 +1,0 @@
-; Project name	:	XTIDE Universal BIOS
-; Description	:	Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
-
-;
-; XTIDE Universal BIOS and Associated Tools
-; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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
-
-;--------------------------------------------------------------------
-; Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
-;
-; AHDh_HandlerForResetHardDisk
-;	Parameters:
-;		DL:		Translated Drive number
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;		SS:BP:	Ptr to IDEPACK
-;	Returns with INTPACK:
-;		AH:		Int 13h return status
-;		CF:		0 if successful, 1 if error
-;--------------------------------------------------------------------
-AHDh_HandlerForResetHardDisk:
-%ifndef USE_186
-	call	AHDh_ResetDrive
-	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
-%else
-	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
-	; Fall to AHDh_ResetDrive
-%endif
-
-
-;--------------------------------------------------------------------
-; Resets hard disk.
-;
-; AHDh_ResetDrive
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;		SS:BP:	Ptr to IDEPACK
-;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if successful, 1 if error
-;	Corrupts registers:
-;		AL, SI
-;--------------------------------------------------------------------
-AHDh_ResetDrive:
-	push	dx
-	push	cx
-	push	bx
-	push	di
-
-%ifdef MODULE_IRQ
-	call	Interrupts_UnmaskInterruptControllerForDriveInDSDI
-%endif
-	; Initialize Master and Slave drives
-	call	AccessDPT_GetIdevarsToCSBX
-	xchg	ax, bx								; (AL) pointer to controller we are looking to reset
-												; (AH) initialize error code, assume success
-
-	mov		si, IterateAndResetDrives			; Callback function for FindDPT_IterateAllDPTs
-	call	FindDPT_IterateAllDPTs
-
-	shr		ah, 1								; Move error code and CF into proper position
-
-	pop		di
-	pop		bx
-	pop		cx
-	pop		dx
-	ret
-
-;--------------------------------------------------------------------
-; IterateAndResetDrives: Iteration routine for use with IterateAllDPTs.
-;
-; When a drive on the controller is found, it is reset, and the error code
-; merged into overall error code for this controller.  Master will be reset
-; first.  Note that the iteration will go until the end of the DPT list.
-;
-;	Parameters:
-;		AL:		Offset to IDEVARS for drives to initialize
-;		AH:		Error status from previous initialization
-;		DS:DI:	Ptr to DPT to examine
-;	Returns:
-;		AH:		Error status from initialization
-;		CF:		Set to iterate all DPTs
-;	Corrupts registers:
-;		AL, BX, DX
-;--------------------------------------------------------------------
-IterateAndResetDrives:
-	cmp		al, [di+DPT.bIdevarsOffset]			; The right controller?
-	jne		.Done
-	push	cx
-	push	ax
-	call	AHDh_WaitUntilDriveMotorHasReachedFullSpeed
-	call	AH9h_InitializeDriveForUse			; Initialize Master or Slave (Master will come first in DPT list)
-
-%ifdef MODULE_ADVANCED_ATA
-	jc		SHORT .SkipControllerInitSinceError
-	; Here we initialize the more advanced controllers (VLB and PCI) to get better performance for systems with 32-bit bus.
-	; This step is optional since the controllers use slowest possible settings by default if they are not initialized.
-
-	pop		ax
-	push	ax
-	cmp		al, [di+LARGEST_DPT_SIZE+DPT.bIdevarsOffset]	; We check if next DPT is for the same IDE controller.
-	je		SHORT .SkipInitializationUntilNextDrive			; If it is, we skip the initialization.
-	call	AdvAtaInit_InitializeControllerForDPTinDSDI		; Done after drive init so drives are first set to advanced PIO mode, then the controller
-.SkipInitializationUntilNextDrive:
-.SkipControllerInitSinceError:
-%endif	; MODULE_ADVANCED_ATA
-
-	pop		ax
-	pop		cx
-	jnc		.Done
-	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 (continue iteration)
-	ret
-
-
-;--------------------------------------------------------------------
-; AHDh_WaitUntilDriveMotorHasReachedFullSpeed
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		AH:		Int 13h return status
-;		CF:		0 if successful, 1 if error
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-AHDh_WaitUntilDriveMotorHasReachedFullSpeed:
-%ifdef MODULE_SERIAL
-	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
-	jz		SHORT .WaitSinceRealHardDisk
-	ret
-.WaitSinceRealHardDisk:
-%endif
-
-	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_DRDY)
-	jmp		IdeWait_PollStatusFlagInBLwithTimeoutInBH
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 507)
@@ -69,8 +69,9 @@
 ;		DS:DI:	Ptr to DPT for Single or Slave Drive
 ;	Returns:
+;		AH:		Int 13h return status
 ;		CF:		Cleared if success or no controller to initialize
 ;				Set if error
 ;	Corrupts registers:
-;		AX, BX, CX, DX
+;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
 AdvAtaInit_InitializeControllerForDPTinDSDI:
@@ -91,4 +92,5 @@
 
 .NoAdvancedController:
+	xor		ax, ax						; Success
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 507)
@@ -80,28 +80,4 @@
 	call	DetectDrives_FromAllIDEControllers
 	call	Interrupts_InitializeInterruptVectors
-	; Fall to .StoreDptPointersToIntVectors
-
-;--------------------------------------------------------------------
-; .StoreDptPointersToIntVectors
-;	Parameters:
-;		DS:		RAMVARS segment
-;		ES:		BDA and interrupt vector segment (zero)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		DX, DI
-;--------------------------------------------------------------------
-.StoreDptPointersToIntVectors:
-	mov		dl, 80h
-	call	FindDPT_ForDriveNumberInDL   ; DPT to DS:DI
-	jc		SHORT .FindForDrive81h	; Store nothing if not our drive
-	mov		[es:HD0_DPT_POINTER_41h*4], di
-	mov		[es:HD0_DPT_POINTER_41h*4+2], ds
-.FindForDrive81h:
-	inc		dx
-	call	FindDPT_ForDriveNumberInDL
-	jc		SHORT .ResetDetectedDrives
-	mov		[es:HD1_DPT_POINTER_46h*4], di
-	mov		[es:HD1_DPT_POINTER_46h*4+2], ds
 	; Fall to .ResetDetectedDrives
 
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 507)
@@ -266,5 +266,4 @@
 	%include "AH9h_HInit.asm"		; Required by Int13h_Jump.asm
 	%include "AHCh_HSeek.asm"		; Required by Int13h_Jump.asm
-	%include "AHDh_HReset.asm"		; Required by Int13h_Jump.asm
 	%include "AH10h_HReady.asm"		; Required by Int13h_Jump.asm
 	%include "AH11h_HRecal.asm"		; Required by Int13h_Jump.asm
Index: trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS/makefile	(revision 506)
+++ trunk/XTIDE_Universal_BIOS/makefile	(revision 507)
@@ -9,4 +9,5 @@
 # checksum* Builds all and then generates checksum byte to all binary files                        #
 # strings*  Compress src\Strings.asm to src\StringsCompressed.asm                                  #
+# unused*	Checks if there are any unused functions that can be removed to save space             #
 #                                                                                                  #
 # * at the end of target name means that Perl is required for the job.                             #
