Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm	(revision 33)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm	(revision 34)
@@ -8,22 +8,4 @@
 ; Section containing code
 SECTION .text
-
-;--------------------------------------------------------------------
-; HError_ProcessErrorsAfterPollingTaskFlag
-;	Parameters:
-;		DS:		RAMVARS segment
-;		CF:		Set if timeout
-;				Cleared if task flag was properly set
-;	Returns:
-;		AH:		BIOS error code
-;		CF:		Set if error
-;				Cleared if no error
-;	Corrupts registers:
-;		AL
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HError_ProcessErrorsAfterPollingTaskFlag:
-	jnc		SHORT HError_ProcessErrorsAfterPollingBSY
-	; Fall to HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 33)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 34)
@@ -10,38 +10,7 @@
 
 ;--------------------------------------------------------------------
-; Wait for IRQ.
-;
-; HIRQ_WaitIRQ
+; HIRQ_WaitForIRQ
 ;	Parameters:
 ;		DS:		RAMVARS segment
-;	Returns:
-;		AH:		BIOS Error code
-;		CF:		Cleared if wait succesfull
-;				Set if any error
-;	Corrupts registers:
-;		AL
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HIRQ_WaitIRQ:
-	push	es
-
-	LOAD_BDA_SEGMENT_TO	es, ax
-%ifdef USE_AT	; OS hook only available on AT+ machines
-	call	.NotifyOperatingSystemAboutWaitingForIRQ
-	cmc
-	jnc		SHORT .TaskFlagPollingComplete
-%endif
-	call	.WaitUntilTaskFlagIsSet		; Process errors
-
-ALIGN JUMP_ALIGN
-.TaskFlagPollingComplete:
-	pop		es
-	jmp		HError_ProcessErrorsAfterPollingTaskFlag
-
-
-;--------------------------------------------------------------------
-; .NotifyOperatingSystemAboutWaitingForIRQ
-;	Parameters:
-;		ES:		BDA segment (zero)
 ;	Returns:
 ;		CF:		Set if wait done by operating system
@@ -50,10 +19,27 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifdef USE_AT
+ALIGN JUMP_ALIGN
+HIRQ_WaitForIRQ:
+	test	BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN	; Clears CF
+	jz		SHORT .NotifyOperatingSystemAboutWaitingForIRQ
+	ret		; Go to poll status register
+
+;--------------------------------------------------------------------
+; .NotifyOperatingSystemAboutWaitingForIRQ
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set if wait done by operating system
+;				Cleared if BIOS must perform task flag polling
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 .NotifyOperatingSystemAboutWaitingForIRQ:
+	push	ds
+
+	LOAD_BDA_SEGMENT_TO	ds, ax			; Zero AX
 	cli									; Disable interrupts
-	xor		ax, ax
-	cmp		al, [es:BDA.bHDTaskFlg]		; Task flag already set?
+	cmp		al, [ds:BDA.bHDTaskFlg]		; Task flag already set?
 	jc		SHORT .ReturnFromWaitNotify	;  If so, skip OS notification
 
@@ -67,42 +53,6 @@
 	stc									; Set CF since wait done by OS
 .ReturnFromWaitNotify:
+	pop		ds
 	sti									; Enable interrupts
-	ret
-%endif
-
-;--------------------------------------------------------------------
-; Polls IRQ Task Flag until it has been set or timeout.
-;
-; .WaitUntilTaskFlagIsSet
-;	Parameters:
-;		DS:		RAMVARS segment
-;		ES:		BDA segment
-;	Returns:
-;		CF:		Set if timeout
-;				Cleared if Task Flag set
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.WaitUntilTaskFlagIsSet:
-	push	cx
-
-	mov		cl, B_TIMEOUT_DRQ		; Load timeout ticks
-	call	SoftDelay_InitTimeout	; Initialize timeout counter
-	xor		ax, ax					; Zero AX
-ALIGN JUMP_ALIGN
-.PollIrqFlag:
-	cli								; Disable interrupt until next HLT
-	cmp		[es:BDA.bHDTaskFlg], al	; Task flag set? (clears CF)
-	jne		SHORT .Return
-	call	SoftDelay_UpdTimeout	; Update timeout
-	jc		SHORT .Return			; Return if timeout
-	sti								; Enable interrupts (STI has delay so HLT will catch all interrupts)
-	hlt								; Sleep until any interrupt
-	jmp		SHORT .PollIrqFlag		; Jump to check if IDE interrupt
-ALIGN JUMP_ALIGN
-.Return:
-	pop		cx
-	sti
 	ret
 
@@ -158,9 +108,7 @@
 	out		WPORT_8259MA_COMMAND, al	; Acknowledge Master 8259
 
-%ifdef USE_AT	; OS hook only available on AT+ machines
 	; Issue Int 15h, function AX=9100h (Interrupt ready)
 	mov		ax, 9100h					; Interrupt ready, device 0 (HD)
 	int		INTV_SYSTEM_SERVICES
-%endif
 
 	pop		ax							; Restore AX
@@ -187,7 +135,6 @@
 
 	; Reading Status Register acknowledges IDE interrupt
-	;call	RamVars_GetSegmentToDS
-	;call	HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
-	LOAD_BDA_SEGMENT_TO	ds, ax
+	call	RamVars_GetSegmentToDS
+	call	HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
 	mov		BYTE [BDA.bHDTaskFlg], 0FFh		; Set task flag
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 33)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 34)
@@ -2,5 +2,5 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	15.12.2009
-; Last update	:	1.8.2010
+; Last update	:	23.8.2010
 ; Author		:	Tomi Tilli
 ; Description	:	IDE Status Register polling functions.
@@ -25,10 +25,10 @@
 ALIGN JUMP_ALIGN
 HStatus_WaitIrqOrRdy:
-	test	BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
-	jnz		SHORT .PollRdySinceInterruptsAreDisabled
-	jmp		HIRQ_WaitIRQ
-
-ALIGN JUMP_ALIGN
-.PollRdySinceInterruptsAreDisabled:
+	call	HIRQ_WaitForIRQ
+	jnc		SHORT .PollRdySinceNoWaitingOnOsHook
+	jmp		HError_ProcessErrorsAfterPollingBSY
+
+ALIGN JUMP_ALIGN
+.PollRdySinceNoWaitingOnOsHook:
 	mov		cl, B_TIMEOUT_DRQ				; Load DRQ (not RDY) timeout
 	jmp		SHORT HStatus_WaitRdy			; Jump to poll RDY
@@ -50,10 +50,10 @@
 ALIGN JUMP_ALIGN
 HStatus_WaitIrqOrDrq:
-	test	BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
-	jnz		SHORT .PollDrqSinceInterruptsAreDisabled
-	jmp		HIRQ_WaitIRQ
-
-ALIGN JUMP_ALIGN
-.PollDrqSinceInterruptsAreDisabled:
+	call	HIRQ_WaitForIRQ
+	jnc		SHORT .PollDrqSinceNoWaitingOnOsHook
+	jmp		HError_ProcessErrorsAfterPollingBSY
+
+ALIGN JUMP_ALIGN
+.PollDrqSinceNoWaitingOnOsHook:
 	push	dx
 	push	cx
