Index: /trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 152)
@@ -43,5 +43,5 @@
 FLG_DPT_SERIAL_DEVICE			EQU	(1<<9)	; Serial Port Device
 FLG_DPT_BLOCK_MODE_SUPPORTED	EQU	(1<<10)	; Use block transfer commands
-
+FLG_DPT_INTERRUPT_IN_SERVICE	EQU	(1<<11)	; Set when waiting for IRQ
 FLG_DPT_RESET_nDRDY				EQU	(1<<12)	; Drive ready to accept commands
 FLG_DPT_RESET_nINITPRMS			EQU	(1<<13)	; Initialize Device Parameters successfull
Index: /trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc	(revision 152)
@@ -6,10 +6,10 @@
 
 ;--------------------------------------------------------------------
-; Emulates INSW for XTIDE dual (8-bit) data port.
+; Emulates INSW for XTIDE.
 ;
-; eDUAL_BYTE_PORT_INSW
+; XTIDE_INSW
 ;	Parameters:
 ;		BX:		Bit mask for toggling XTIDE data low/high reg
-;		DX:		Port address (must be IDE Data Register)
+;		DX:		XTIDE Data Low Register address
 ;		ES:DI:	Ptr to destination buffer
 ;	Returns:
@@ -18,5 +18,5 @@
 ;		AL, FLAGS
 ;--------------------------------------------------------------------
-%macro eDUAL_BYTE_PORT_INSW 0
+%macro XTIDE_INSW 0
 %ifdef USE_186	; INS instruction available
 	insb						; Load low byte from port DX to [ES:DI]
@@ -36,10 +36,10 @@
 
 ;--------------------------------------------------------------------
-; Emulates OUTSW for XTIDE dual (8-bit) data port.
+; Emulates OUTSW for XTIDE.
 ;
-; eDUAL_BYTE_PORT_OUTSW
+; XTIDE_OUTSW
 ;	Parameters:
 ;		BX:		Bit mask for toggling XTIDE data low/high reg
-;		DX:		Port address (must be IDE Data Register)
+;		DX:		XTIDE Data Low Register address
 ;		DS:SI:	Ptr to source buffer
 ;	Returns:
@@ -48,10 +48,10 @@
 ;		AX, FLAGS
 ;--------------------------------------------------------------------
-%macro eDUAL_BYTE_PORT_OUTSW 0
+%macro XTIDE_OUTSW 0
 %ifdef USE_186	; OUTS instruction available
 	lodsb						; Load low byte from [DS:SI] to AL
 	xor		dx, bx				; IDE Data Reg to XTIDE Data High Reg
 	outsb						; Output high byte from [DS:SI]
-	xor		dx, bx				; IDE Data Reg to XTIDE Data Low Reg
+	xor		dx, bx				; XTIDE Data High Reg to Data Low Reg
 	out		dx, al				; Output low byte from AL
 %else	; If 8088/8086
@@ -60,5 +60,36 @@
 	xchg	al, ah				; => AL=high byte, AH=low byte
 	out		dx, al				; Output high byte
-	xor		dx, bx				; XTIDE Data High Reg to IDE Data Reg
+	xor		dx, bx				; XTIDE Data High Reg to Data Low Reg
+	mov		al, ah				; Copy low byte to AL
+	out		dx, al				; Output low byte
+%endif
+%endmacro
+
+
+;--------------------------------------------------------------------
+; Emulates OUTSW for modified XTIDE.
+;
+; XTIDE_MOD_OUTSW
+;	Parameters:
+;		DX:		XTIDE Data Low Register address
+;		DS:SI:	Ptr to source buffer
+;	Returns:
+;		SI:		Incremented/decremented for next word
+;	Corrupts registers:
+;		AX, FLAGS
+;--------------------------------------------------------------------
+%macro XTIDE_MOD_OUTSW 0
+%ifdef USE_186	; OUTS instruction available
+	lodsb						; Load low byte from [DS:SI] to AL
+	inc		dx					; IDE Data Reg to XTIDE MOD Data High Reg
+	outsb						; Output high byte from [DS:SI]
+	dec		dx					; XTIDE Data High Reg to Data Low Reg
+	out		dx, al				; Output low byte from AL
+%else	; If 8088/8086
+	lodsw						; Load word from [DS:SI]
+	inc		dx					; IDE Data Reg to XTIDE MOD Data High Reg
+	xchg	al, ah				; => AL=high byte, AH=low byte
+	out		dx, al				; Output high byte
+	dec		dx					; XTIDE Data High Reg to Data Low Reg
 	mov		al, ah				; Copy low byte to AL
 	out		dx, al				; Output low byte
Index: /trunk/XTIDE_Universal_BIOS/Inc/IntController.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/IntController.inc	(revision 152)
+++ /trunk/XTIDE_Universal_BIOS/Inc/IntController.inc	(revision 152)
@@ -0,0 +1,52 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Equates for 8259 Interrupt Controllers.
+%ifndef INT_CONTROLLER_INC
+%define INT_CONTROLLER_INC
+
+; 8259 Master and Slave Interrupt Controller Ports
+MASTER_8259_IRR_AND_ISR_in	EQU		20h		; Interrupt Request Register / Interrupt In-Service Register
+MASTER_8259_COMMAND_out		EQU		20h		; Command output
+MASTER_8259_IMR				EQU		21h		; Interrupt Mask Register
+MASTER_8259_INIT_out		EQU		21h		; Initialization Command Parameters
+SLAVE_8259_IRR_AND_ISR_in	EQU		0A0h	; Interrupt Request Register / Interrupt In-Service Register
+SLAVE_8259_COMMAND_out		EQU		0A0h	; Command output
+SLAVE_8259_IMR				EQU		0A1h	; Interrupt Mask Register
+SLAVE_8259_INIT_out			EQU		0A1h	; Initialization Command Parameters
+
+; 8259 Interrupt Controller Commands
+COMMAND_CLEAR_ROTATE_IN_AUTOMATIC_EOI_MODE	EQU		00h
+COMMAND_READ_INTERRUPT_REQUEST_REGISTER		EQU		0Ah
+COMMAND_READ_INTERRUPT_INSERVICE_REGISTER	EQU		0Bh
+COMMAND_END_OF_INTERRUPT					EQU		20h
+COMMAND_NO_OPERATION						EQU		40h
+COMMAND_CLEAR_SPECIAL_MASK_MODE				EQU		48h
+COMMAND_SPECIFIC_EOI_FOR_IR0				EQU		60h
+COMMAND_SPECIFIC_EOI_FOR_IR1				EQU		61h
+COMMAND_SPECIFIC_EOI_FOR_IR2				EQU		62h
+COMMAND_SPECIFIC_EOI_FOR_IR3				EQU		63h
+COMMAND_SPECIFIC_EOI_FOR_IR4				EQU		64h
+COMMAND_SPECIFIC_EOI_FOR_IR5				EQU		65h
+COMMAND_SPECIFIC_EOI_FOR_IR6				EQU		66h
+COMMAND_SPECIFIC_EOI_FOR_IR7				EQU		67h
+COMMAND_SET_SPECIAL_MASK_MODE				EQU		68h
+COMMAND_SET_ROTATE_IN_AUTOMATIC_EOI_MODE	EQU		80h
+COMMAND_ROTATE_ON_NONSPECIFIC_EOI			EQU		0A0h
+COMMAND_IR0_LOWEST_PRIORITY					EQU		0C0h
+COMMAND_IR1_LOWEST_PRIORITY					EQU		0C1h
+COMMAND_IR2_LOWEST_PRIORITY					EQU		0C2h
+COMMAND_IR3_LOWEST_PRIORITY					EQU		0C3h
+COMMAND_IR4_LOWEST_PRIORITY					EQU		0C4h
+COMMAND_IR5_LOWEST_PRIORITY					EQU		0C5h
+COMMAND_IR6_LOWEST_PRIORITY					EQU		0C6h
+COMMAND_IR7_LOWEST_PRIORITY					EQU		0C7h
+COMMAND_EOI_AND_IR0_LOWEST_PRIORITY			EQU		0E0h
+COMMAND_EOI_AND_IR1_LOWEST_PRIORITY			EQU		0E1h
+COMMAND_EOI_AND_IR2_LOWEST_PRIORITY			EQU		0E2h
+COMMAND_EOI_AND_IR3_LOWEST_PRIORITY			EQU		0E3h
+COMMAND_EOI_AND_IR4_LOWEST_PRIORITY			EQU		0E4h
+COMMAND_EOI_AND_IR5_LOWEST_PRIORITY			EQU		0E5h
+COMMAND_EOI_AND_IR6_LOWEST_PRIORITY			EQU		0E6h
+COMMAND_EOI_AND_IR7_LOWEST_PRIORITY			EQU		0E7h
+
+
+%endif ; INT_CONTROLLER_INC
Index: unk/XTIDE_Universal_BIOS/Inc/Interrupts.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/Interrupts.inc	(revision 151)
+++ 	(revision )
@@ -1,91 +1,0 @@
-; File name		:	Interrupts.inc
-; Project name	:	IDE BIOS
-; Created date	:	29.7.2007
-; Last update	:	6.11.2009
-; Author		:	Tomi Tilli
-; Description	:	Equates for Interrupts.
-%ifndef INTERRUPTS_INC
-%define INTERRUPTS_INC
-
-; 8259 Master and Slave Interrupt Controller Ports
-RPORT_8259MA_IRR_ISR		EQU		20h		; Master 8259 Read IRR / ISR
-WPORT_8259MA_COMMAND		EQU		20h		; Master 8259 Write command
-WPORT_8259MA_INIT			EQU		21h		; Master 8259 Write Init command
-PORT_8259MA_IMR				EQU		21h		; Master 8259 IMR
-RPORT_8259SL_IRR_ISR		EQU		0A0h	; Slave 8259 Read IRR / ISR
-WPORT_8259SL_COMMAND		EQU		0A0h	; Slave 8259 Write command
-WPORT_8259SL_INIT			EQU		0A1h	; Slave 8259 Write Init command
-PORT_8259SL_IMR				EQU		0A1h	; Slave 8259 IMR
-
-; Valid commands to port 20h (master, WPORT_8259MA_COMMAND) 
-; and A0h (slave, WPORT_8259SL_COMMAND)
-CMD_ROT_IN_AUTO_EOI_MODE_CLEAR	EQU		000h
-CMD_READ_IRR					EQU		00Ah
-CMD_READ_ISR					EQU		00Bh
-CMD_END_OF_INTERRUPT			EQU		020h
-CMD_NO_OPERATION				EQU		040h
-CMD_CLEAR_SPECIAL_MASK_MODE		EQU		048h
-CMD_SPEC_EOI_IRQ0				EQU		060h
-CMD_SPEC_EOI_IRQ1				EQU		061h
-CMD_SPEC_EOI_IRQ2				EQU		062h
-CMD_SPEC_EOI_IRQ3				EQU		063h
-CMD_SPEC_EOI_IRQ4				EQU		064h
-CMD_SPEC_EOI_IRQ5				EQU		065h
-CMD_SPEC_EOI_IRQ6				EQU		066h
-CMD_SPEC_EOI_IRQ7				EQU		067h
-CMD_SET_SPECIAL_MASK_MODE		EQU		068h
-CMD_ROT_IN_AUTO_EOI_MODE_SET	EQU		080h
-CMD_ROT_ON_NONSPEC_EOI			EQU		0A0h
-CMD_IRQ0_LOWST_PRIO				EQU		0C0h
-CMD_IRQ1_LOWST_PRIO				EQU		0C1h
-CMD_IRQ2_LOWST_PRIO				EQU		0C2h
-CMD_IRQ3_LOWST_PRIO				EQU		0C3h
-CMD_IRQ4_LOWST_PRIO				EQU		0C4h
-CMD_IRQ5_LOWST_PRIO				EQU		0C5h
-CMD_IRQ6_LOWST_PRIO				EQU		0C6h
-CMD_IRQ7_LOWST_PRIO				EQU		0C7h
-CMD_EOI_AND_IRQ0_LOWST_PRIO		EQU		0E0h
-CMD_EOI_AND_IRQ1_LOWST_PRIO		EQU		0E1h
-CMD_EOI_AND_IRQ2_LOWST_PRIO		EQU		0E2h
-CMD_EOI_AND_IRQ3_LOWST_PRIO		EQU		0E3h
-CMD_EOI_AND_IRQ4_LOWST_PRIO		EQU		0E4h
-CMD_EOI_AND_IRQ5_LOWST_PRIO		EQU		0E5h
-CMD_EOI_AND_IRQ6_LOWST_PRIO		EQU		0E6h
-CMD_EOI_AND_IRQ7_LOWST_PRIO		EQU		0E7h
-
-
-; Interrupt Vector Table
-INTV_IRQ0						EQU		08h		; System timer
-INTV_IRQ1						EQU		09h		; Keyboard
-INTV_IRQ2						EQU		0Ah
-INTV_IRQ3						EQU		0Bh
-INTV_IRQ4						EQU		0Ch
-INTV_IRQ5						EQU		0Dh
-INTV_IRQ6						EQU		0Eh
-INTV_IRQ7						EQU		0Fh
-INTV_EQUIPMENT_CONF				EQU		11h		; Equipment configuration
-INTV_MEMORY_SIZE				EQU		12h		; Base memory size
-INTV_DISK_FUNC					EQU		13h		; Disk functions
-INTV_SYSTEM_SERVICES			EQU		15h		; Different system functions
-INTV_KEYBOARD_FUNC				EQU		16h		; Keyboard functions
-INTV_BOOT_FAILURE				EQU		18h		; Process Boot Failure
-INTV_BOOTSTRAP					EQU		19h		; Boot Strap Loader
-INTV_TIME_OF_DAY				EQU		1Ah		; Time of day functions
-INTV_KEYB_BREAK					EQU		1Bh		; Keyboard break
-INTV_USER_TIMER_TICK			EQU		1Ch		; User timer tick
-INTV_DPT						EQU		1Eh		; Diskette Parameter Table
-INTV_FLOPPY_FUNC				EQU		40h		; Floppy functions
-INTV_HD0DPT						EQU		41h		; Ptr to HD0 Disk Parameter Table
-INTV_HD1DPT						EQU		46h		; Ptr to HD1 Disk Parameter Table
-INTV_USERS_ALARM				EQU		4Ah		; Users alarm
-INTV_IRQ8						EQU		70h
-INTV_IRQ9						EQU		71h
-INTV_IRQ10						EQU		72h
-INTV_IRQ11						EQU		73h
-INTV_IRQ12						EQU		74h
-INTV_IRQ13						EQU		75h
-INTV_IRQ14						EQU		76h
-INTV_IRQ15						EQU		77h
-
-
-%endif ; INTERRUPTS_INC
Index: /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 152)
@@ -22,5 +22,4 @@
 	.fpOldI13h			resb	4	; Far pointer to old INT 13h handler
 	.wTimeoutCounter	resb	2
-	.pInServiceDPT		resb	2	; Ptr to DPT for drive waiting for interrupt
 	.wSignature			resb	2	; Sign for finding stolen 1 kiB
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 152)
@@ -76,5 +76,4 @@
 ALIGN JUMP_ALIGN
 Device_OutputCommandWithParameters:
-	call	IdeIrq_SetInServiceDPTandClearTaskFlag
 	test	WORD [di+DPT.wFlags], FLG_DPT_SERIAL_DEVICE
 	jnz		SHORT .OutputCommandToSerialPort
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 152)
@@ -114,4 +114,12 @@
 	mov		dl, DEVICE_CONTROL_REGISTER_out
 	mov		al, [bp+IDEPACK.bDeviceControl]
+	test	al, FLG_DEVCONTROL_nIEN
+	jnz		SHORT .DoNotSetInterruptInServiceFlag
+	or		WORD [di+DPT.wFlags], FLG_DPT_INTERRUPT_IN_SERVICE
+	push	ds
+	LOAD_BDA_SEGMENT_TO	ds, cx, !		; Also zero CX
+	mov		[BDA.bHDTaskFlg], al
+	pop		ds
+.DoNotSetInterruptInServiceFlag:
 	call	Device_OutputALtoIdeControlBlockRegisterInDL
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm	(revision 152)
@@ -50,23 +50,4 @@
 
 ;--------------------------------------------------------------------
-; IdeIrq_SetInServiceDPTandClearTaskFlag
-;	Parameters:
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-IdeIrq_SetInServiceDPTandClearTaskFlag:
-	mov		[RAMVARS.pInServiceDPT], di
-	push	ds
-	LOAD_BDA_SEGMENT_TO	ds, ax, !		; Also zero AX
-	mov		[BDA.bHDTaskFlg], al
-	pop		ds
-	ret
-
-
-;--------------------------------------------------------------------
 ; IDE Interrupt Service Routines.
 ;
@@ -86,5 +67,5 @@
 	call	AcknowledgeIdeInterruptAndSetTaskFlag
 
-	mov		al, CMD_END_OF_INTERRUPT
+	mov		al, COMMAND_END_OF_INTERRUPT
 	jmp		SHORT AcknowledgeMasterInterruptController
 
@@ -96,8 +77,8 @@
 	call	AcknowledgeIdeInterruptAndSetTaskFlag
 
-	mov		al, CMD_END_OF_INTERRUPT	; Load EOI command to AL
-	out		WPORT_8259SL_COMMAND, al	; Acknowledge Slave 8259
+	mov		al, COMMAND_END_OF_INTERRUPT
+	out		SLAVE_8259_COMMAND_out, al	; Acknowledge Slave 8259
 AcknowledgeMasterInterruptController:
-	out		WPORT_8259MA_COMMAND, al	; Acknowledge Master 8259
+	out		MASTER_8259_COMMAND_out, al	; Acknowledge Master 8259
 
 	; Issue Int 15h, function AX=9100h (Interrupt ready)
@@ -122,4 +103,5 @@
 AcknowledgeIdeInterruptAndSetTaskFlag:
 	push	ds
+	push	si
 	push	dx
 	push	bx
@@ -127,7 +109,10 @@
 	; Reading Status Register acknowledges IDE interrupt
 	call	RamVars_GetSegmentToDS
-	mov		di, [RAMVARS.pInServiceDPT]		; DS:DI now points to DPT
+	call	FindDPT_ToDSDIforInterruptInService
 	mov		dl, STATUS_REGISTER_in
 	call	Device_InputToALfromIdeRegisterInDL
+
+	; Clear Interrupt In-Service Flag from DPT
+	and		WORD [di+DPT.wFlags], ~FLG_DPT_INTERRUPT_IN_SERVICE
 
 	; Set Task Flag
@@ -137,4 +122,5 @@
 	pop		bx
 	pop		dx
+	pop		si
 	pop		ds
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 152)
@@ -213,8 +213,9 @@
 
 ;--------------------------------------------------------------------
-; DualByteRead		Dual port 8-bit XTIDE PIO read transfer
-; WordRead			Normal 16-bit IDE PIO read transfer
-; DWordRead			VLB/PCI 32-bit IDE PIO read transfer
-; SingleByteRead	Single port 8-bit PIO read transfer
+; DualByteReadForXtide		Dual port 8-bit XTIDE PIO read transfer
+; SingleByteRead			Single port 8-bit PIO read transfer
+; WordReadForXTIDEmod		8088/8086 compatible 16-bit IDE PIO read transfer
+; WordReadForXTplusAndAT	Normal 16-bit IDE PIO read transfer
+; DWordRead					VLB/PCI 32-bit IDE PIO read transfer
 ;	Parameters:
 ;		CX:		Block size in WORDs
@@ -227,41 +228,28 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-DualByteRead:
-	times 2	shr	cx, 1			; Loop unrolling
-	mov		bx, 8				; Bit mask for toggling data low/high reg
+DualByteReadForXtide:
+	times 2	shr	cx, 1	; Loop unrolling
+	mov		bx, 8		; Bit mask for toggling data low/high reg
 ALIGN JUMP_ALIGN
 .InswLoop:
-	eDUAL_BYTE_PORT_INSW
-	eDUAL_BYTE_PORT_INSW
-	eDUAL_BYTE_PORT_INSW
-	eDUAL_BYTE_PORT_INSW
+	XTIDE_INSW
+	XTIDE_INSW
+	XTIDE_INSW
+	XTIDE_INSW
 	loop	.InswLoop
 	ret
 
-ALIGN JUMP_ALIGN
-WordRead:
-	rep
-	db		6Dh			; INSW
-	ret
-
-ALIGN JUMP_ALIGN
-DWordRead:
-	shr		cx, 1		; WORD count to DWORD count
-	rep
-	db		66h			; Override operand size to 32-bit
-	db		6Dh			; INSW/INSD
-	ret
-
+;----
 ALIGN JUMP_ALIGN
 SingleByteRead:
 %ifdef USE_186	; INS instruction available
-	shl		cx, 1				; WORD count to BYTE count
+	shl		cx, 1		; WORD count to BYTE count
 	rep insb
 %else			; If 8088/8086
-	shr		cx, 1				; WORD count to DWORD count
+	shr		cx, 1		; WORD count to DWORD count
 ALIGN JUMP_ALIGN
 .InsdLoop:
 	in		al, dx
-	stosb						; Store to [ES:DI]
+	stosb				; Store to [ES:DI]
 	in		al, dx
 	stosb
@@ -274,10 +262,46 @@
 	ret
 
-
-;--------------------------------------------------------------------
-; DualByteWrite		Dual port 8-bit XTIDE PIO write transfer
-; WordWrite			Normal 16-bit IDE PIO write transfer
-; DWordWrite		VLB/PCI 32-bit IDE PIO write transfer
-; SingleByteWrite	Single port 8-bit PIO write transfer
+;----
+%ifndef USE_186
+ALIGN JUMP_ALIGN
+WordReadForXTIDEmod:
+	times 2 shr	cx, 1	; WORD count to QWORD count
+ALIGN JUMP_ALIGN
+.ReadNextQword:
+	in		ax, dx		; Read 1st WORD
+	stosw				; Store 1st WORD to [ES:DI]
+	in		ax, dx
+	stosw				; 2nd
+	in		ax, dx
+	stosw				; 3rd
+	in		ax, dx
+	stosw				; 4th
+	loop	.ReadNextQword
+	ret
+%endif
+
+;----
+ALIGN JUMP_ALIGN
+WordReadForXTplusAndAT:
+	rep
+	db		6Dh			; INSW (we want this in XT build)
+	ret
+
+;----
+ALIGN JUMP_ALIGN
+DWordRead:
+	shr		cx, 1		; WORD count to DWORD count
+	rep
+	db		66h			; Override operand size to 32-bit
+	db		6Dh			; INSW/INSD
+	ret
+
+
+;--------------------------------------------------------------------
+; DualByteWriteForXtide		Dual port 8-bit XTIDE PIO write transfer
+; SingleByteWrite			Single port 8-bit PIO write transfer
+; WordWriteForXTIDEmod		8088/8086 compatible 16-bit IDE PIO read transfer
+; WordWrite					Normal 16-bit IDE PIO write transfer
+; DWordWrite				VLB/PCI 32-bit IDE PIO write transfer
 ;	Parameters:
 ;		CX:		Block size in WORDs
@@ -290,17 +314,17 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-DualByteWrite:
+DualByteWriteForXtide:
 	push	ds
 	push	bx
-	times 2	shr	cx, 1			; Loop unrolling
-	mov		bx, 8				; Bit mask for toggling data low/high reg
-	push	es					; Copy ES...
-	pop		ds					; ...to DS
+	times 2	shr	cx, 1	; Loop unrolling
+	mov		bx, 8		; Bit mask for toggling data low/high reg
+	push	es			; Copy ES...
+	pop		ds			; ...to DS
 ALIGN JUMP_ALIGN
 .OutswLoop:
-	eDUAL_BYTE_PORT_OUTSW
-	eDUAL_BYTE_PORT_OUTSW
-	eDUAL_BYTE_PORT_OUTSW
-	eDUAL_BYTE_PORT_OUTSW
+	XTIDE_OUTSW
+	XTIDE_OUTSW
+	XTIDE_OUTSW
+	XTIDE_OUTSW
 	loop	.OutswLoop
 	pop		bx
@@ -308,34 +332,19 @@
 	ret
 
-ALIGN JUMP_ALIGN
-WordWrite:
-	eSEG	es			; Source is ES segment
-	rep
-	db		6Fh			; OUTSW
-	ret
-
-ALIGN JUMP_ALIGN
-DWordWrite:
-	shr		cx, 1		; WORD count to DWORD count
-	eSEG	es			; Source is ES segment
-	rep
-	db		66h			; Override operand size to 32-bit
-	db		6Fh			; OUTSW/OUTSD
-	ret
-
+;----
 ALIGN JUMP_ALIGN
 SingleByteWrite:
 %ifdef USE_186	; OUTS instruction available
-	shl		cx, 1				; WORD count to BYTE count
-	eSEG	es					; Source is ES segment
+	shl		cx, 1		; WORD count to BYTE count
+	eSEG	es			; Source is ES segment
 	rep outsb
 %else			; If 8088/8086
-	shr		cx, 1				; WORD count to DWORD count
-	push	ds					; Store DS
-	push	es					; Copy ES...
-	pop		ds					; ...to DS
+	shr		cx, 1		; WORD count to DWORD count
+	push	ds			; Store DS
+	push	es			; Copy ES...
+	pop		ds			; ...to DS
 ALIGN JUMP_ALIGN
 .OutsdLoop:
-	lodsb						; Load from [DS:SI] to AL
+	lodsb				; Load from [DS:SI] to AL
 	out		dx, al
 	lodsb
@@ -346,7 +355,42 @@
 	out		dx, al
 	loop	.OutsdLoop
-	pop		ds					; Restore DS
-%endif
-	ret
+	pop		ds			; Restore DS
+%endif
+	ret
+
+;---
+ALIGN JUMP_ALIGN
+WordWriteForXTIDEmod:
+	push	ds
+	times 2	shr	cx, 1	; Loop unrolling
+	push	es			; Copy ES...
+	pop		ds			; ...to DS
+ALIGN JUMP_ALIGN
+.WriteNextQword:
+	XTIDE_MOD_OUTSW
+	XTIDE_MOD_OUTSW
+	XTIDE_MOD_OUTSW
+	XTIDE_MOD_OUTSW
+	loop	.WriteNextQword
+	pop		ds
+	ret
+
+;----
+ALIGN JUMP_ALIGN
+WordWrite:
+	eSEG	es			; Source is ES segment
+	rep
+	db		6Fh			; OUTSW
+	ret
+
+ALIGN JUMP_ALIGN
+DWordWrite:
+	shr		cx, 1		; WORD count to DWORD count
+	eSEG	es			; Source is ES segment
+	rep
+	db		66h			; Override operand size to 32-bit
+	db		6Fh			; OUTSW/OUTSD
+	ret
+
 
 
@@ -354,13 +398,18 @@
 ALIGN WORD_ALIGN
 g_rgfnPioRead:
-	dw		DualByteRead		; DEVICE_8BIT_DUAL_PORT_XTIDE
-	dw		NULL				; DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
-	dw		SingleByteRead		; DEVICE_8BIT_SINGLE_PORT
-	dw		WordRead			; DEVICE_16BIT_ATA
-	dw		DWordRead			; DEVICE_32BIT_ATA
+	dw		DualByteReadForXtide	; DEVICE_8BIT_DUAL_PORT_XTIDE
+%ifdef USE_186
+	dw		WordReadForXTplusAndAT	; DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
+%else
+	dw		WordReadForXTIDEmod
+%endif
+	dw		SingleByteRead			; DEVICE_8BIT_SINGLE_PORT
+	dw		WordReadForXTplusAndAT	; DEVICE_16BIT_ATA
+	dw		DWordRead				; DEVICE_32BIT_ATA
+
 g_rgfnPioWrite:
-	dw		DualByteWrite		; DEVICE_8BIT_DUAL_PORT_XTIDE
-	dw		NULL				; DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
-	dw		SingleByteWrite		; DEVICE_8BIT_SINGLE_PORT
-	dw		WordWrite			; DEVICE_16BIT_ATA
-	dw		DWordWrite			; DEVICE_32BIT_ATA
+	dw		DualByteWriteForXtide	; DEVICE_8BIT_DUAL_PORT_XTIDE
+	dw		WordWriteForXTIDEmod	; DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
+	dw		SingleByteWrite			; DEVICE_8BIT_SINGLE_PORT
+	dw		WordWrite				; DEVICE_16BIT_ATA
+	dw		DWordWrite				; DEVICE_32BIT_ATA
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 152)
@@ -161,8 +161,6 @@
 	xor		bx, bx
 	call	FindDPT_ForDriveNumber
-	jnc		SHORT .DptNotFound
 	mov		bl, [di+DPT.bIdevarsOffset]
 	mov		bx, [cs:bx+IDEVARS.wPort]
-.DptNotFound:
 	xchg	bx, cx
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hLate.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hLate.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hLate.asm	(revision 152)
@@ -16,5 +16,5 @@
 ALIGN JUMP_ALIGN
 Int19hLate_InitializeInt19h:
-	mov		bx, INTV_BOOTSTRAP
+	mov		bx, BIOS_BOOT_LOADER_INTERRUPT_19h
 	mov		si, HandlerForLateInitialization
 	jmp		Interrupts_InstallHandlerToVectorInBXFromCSSI
@@ -31,9 +31,9 @@
 HandlerForLateInitialization:
 	LOAD_BDA_SEGMENT_TO	es, ax
-	call	Initialize_ShouldSkip		; Skip initialization?
+	call	Initialize_ShouldSkip			; Skip initialization?
 	jnz		SHORT .SkipInitialization
-	call	Initialize_AndDetectDrives	; Installs boot menu loader
-	int		INTV_BOOTSTRAP
+	call	Initialize_AndDetectDrives		; Installs boot menu loader
+	int		BIOS_BOOT_LOADER_INTERRUPT_19h
 .SkipInitialization:
-	call	RamVars_Initialize			; RAMVARS must be initialized even for simple boot loader
-	int		INTV_BOOTSTRAP				; Call default system boot loader
+	call	RamVars_Initialize				; RAMVARS must be initialized even for simple boot loader
+	int		BIOS_BOOT_LOADER_INTERRUPT_19h	; Call default system boot loader
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hMenu.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hMenu.asm	(revision 152)
@@ -85,5 +85,5 @@
 	SWITCH_BACK_TO_POST_STACK
 	call	ClearSegmentsForBoot
-	int		INTV_BOOT_FAILURE		; Never returns
+	int		BIOS_BOOT_FAILURE_INTERRUPT_18h	; Never returns
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 152)
@@ -19,5 +19,5 @@
 ;--------------------------------------------------------------------
 FloppyDrive_IsInt40hInstalled:
-	cmp		WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h	; Any ROM segment?
+	cmp		WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h	; Any ROM segment?
 %ifdef USE_AT	; No need to verify on XT systems.
 	jb		SHORT .Int40hHandlerIsNotInstalled
@@ -45,5 +45,5 @@
 
 	call	.LoadInt40hVerifyParameters
-	int		INTV_DISK_FUNC
+	int		BIOS_DISK_INTERRUPT_13h
 	jc		SHORT .Int40hIsInstalled	; Maybe there are not any floppy drives at all
 	push	es
@@ -51,5 +51,5 @@
 
 	call	.LoadInt40hVerifyParameters
-	int		INTV_FLOPPY_FUNC
+	int		BIOS_DISKETTE_INTERRUPT_40h
 
 	pop		dx
@@ -113,5 +113,5 @@
 	mov		ah, 08h			; Get Drive Parameters
 	xor		bx, bx			; FLOPPY_TYPE_525_OR_35_DD when function not supported
-	int		INTV_FLOPPY_FUNC
+	int		BIOS_DISKETTE_INTERRUPT_40h
 	ret
 
@@ -167,5 +167,5 @@
 	mov		ah, 08h					; Get Drive Parameters
 	cwd								; Floppy Drive 00h
-	int		INTV_FLOPPY_FUNC
+	int		BIOS_DISKETTE_INTERRUPT_40h
 	mov		cl, dl					; Number of Floppy Drives to CL
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 152)
@@ -89,14 +89,16 @@
 .StoreDptPointersToIntVectors:
 	mov		dl, 80h
+	call	RamVars_IsDriveHandledByThisBIOS
+	jnc		SHORT .FindForDrive81h	; Store nothing if not our drive
 	call	FindDPT_ForDriveNumber	; DPT to DS:DI
-	jnc		SHORT .FindForDrive81h	; Store nothing if not our drive
-	mov		[es:INTV_HD0DPT*4], di
-	mov		[es:INTV_HD0DPT*4+2], ds
+	mov		[es:HD0_DPT_POINTER_41h*4], di
+	mov		[es:HD0_DPT_POINTER_41h*4+2], ds
 .FindForDrive81h:
 	inc		dx
+	call	RamVars_IsDriveHandledByThisBIOS
+	jnc		SHORT .ResetDetectedDrives
 	call	FindDPT_ForDriveNumber
-	jnc		SHORT .ResetDetectedDrives
-	mov		[es:INTV_HD1DPT*4], di
-	mov		[es:INTV_HD1DPT*4+2], ds
+	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/Initialization/Interrupts.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 152)
@@ -29,9 +29,9 @@
 ;--------------------------------------------------------------------
 .InitializeInt13hAnd40h:
-	mov		ax, [es:INTV_DISK_FUNC*4]			; Load old INT 13h offset
-	mov		dx, [es:INTV_DISK_FUNC*4+2]			; Load old INT 13h segment
+	mov		ax, [es:BIOS_DISK_INTERRUPT_13h*4]	; Load old INT 13h offset
+	mov		dx, [es:BIOS_DISK_INTERRUPT_13h*4+2]; Load old INT 13h segment
 	mov		[RAMVARS.fpOldI13h], ax				; Store old INT 13h offset
 	mov		[RAMVARS.fpOldI13h+2], dx			; Store old INT 13h segment
-	mov		bx, INTV_DISK_FUNC					; INT 13h interrupt vector offset
+	mov		bx, BIOS_DISK_INTERRUPT_13h			; INT 13h interrupt vector offset
 	mov		si, Int13h_DiskFunctionsHandler		; Interrupt handler offset
 	call	Interrupts_InstallHandlerToVectorInBXFromCSSI
@@ -42,6 +42,6 @@
 	call	FloppyDrive_IsInt40hInstalled
 	jc		SHORT .InitializeInt19h
-	mov		[es:INTV_FLOPPY_FUNC*4], ax		; Store old INT 13h offset
-	mov		[es:INTV_FLOPPY_FUNC*4+2], dx	; Store old INT 13h segment
+	mov		[es:BIOS_DISKETTE_INTERRUPT_40h*4], ax		; Store old INT 13h offset
+	mov		[es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx	; Store old INT 13h segment
 	; Fall to .InitializeInt19h
 
@@ -57,5 +57,5 @@
 ;--------------------------------------------------------------------
 .InitializeInt19h:
-	mov		bx, INTV_BOOTSTRAP
+	mov		bx, BIOS_BOOT_LOADER_INTERRUPT_19h
 	mov		si, Int19hMenu_BootLoader
 	call	Interrupts_InstallHandlerToVectorInBXFromCSSI
@@ -110,5 +110,5 @@
 ;--------------------------------------------------------------------
 .InstallHighIrqHandler:
-	add		bx, BYTE INTV_IRQ8 - 8			; Interrupt vector number
+	add		bx, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8	; Interrupt vector number
 	mov		si, IdeIrq_InterruptServiceRoutineForIrqs8to15
 	jmp		SHORT Interrupts_InstallHandlerToVectorInBXFromCSSI
@@ -125,5 +125,5 @@
 ;--------------------------------------------------------------------
 .InstallLowIrqHandler:
-	add		bx, BYTE INTV_IRQ0				; Interrupt vector number
+	add		bx, BYTE HARDWARE_IRQ_0_INTERRUPT_08h		; Interrupt vector number
 	mov		si, IdeIrq_InterruptServiceRoutineForIrqs2to7
 	; Fall to Interrupts_InstallHandlerToVectorInBXFromCSSI
@@ -177,5 +177,5 @@
 .UnmaskHighIrqController:
 	sub		al, 8				; Slave interrupt number
-	mov		dx, PORT_8259SL_IMR	; Load Slave Mask Register address
+	mov		dx, SLAVE_8259_IMR
 	call	.ClearBitFrom8259MaskRegister
 	mov		al, 2				; Master IRQ 2 to allow slave IRQs
@@ -192,5 +192,5 @@
 ;--------------------------------------------------------------------
 .UnmaskLowIrqController:
-	mov		dx, PORT_8259MA_IMR	; Load Mask Register address
+	mov		dx, MASTER_8259_IMR
 	; Fall to .ClearBitFrom8259MaskRegister
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 152)
@@ -15,5 +15,5 @@
 ; Included .inc files
 %include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
-%include "Interrupts.inc"		; For interrupt equates
+%include "IntController.inc"	; For Interrupt Controller equates
 %include "ATA_ID.inc"			; For ATA Drive Information structs
 %include "IdeRegisters.inc"		; For ATA Registers, flags and commands
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 151)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 152)
@@ -71,10 +71,10 @@
 ALIGN JUMP_ALIGN
 FindDPT_ToDSDIForIdeMasterAtPortDX:
-	mov		si, FindDPT_IterateToMasterAtPortCallback
+	mov		si, IterateToMasterAtPortCallback
 	jmp		SHORT IterateAllDPTs
 
 ALIGN JUMP_ALIGN
 FindDPT_ToDSDIForIdeSlaveAtPortDX:
-	mov		si, FindDPT_IterateToSlaveAtPortCallback
+	mov		si, IterateToSlaveAtPortCallback
 	jmp		SHORT IterateAllDPTs
 
@@ -83,6 +83,6 @@
 ; IDE base port for Master or Slave drive.
 ;
-; FindDPT_IterateToSlaveAtPortCallback
-; FindDPT_IterateToMasterAtPortCallback
+; IterateToSlaveAtPortCallback
+; IterateToMasterAtPortCallback
 ;	Parameters:
 ;		CH:		Drive number
@@ -97,5 +97,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-FindDPT_IterateToSlaveAtPortCallback:
+IterateToSlaveAtPortCallback:
 	test	BYTE [di+DPT.wFlags], FLG_DPT_SLAVE	; Clears CF
 	jnz		SHORT CompareBasePortAddress
@@ -103,5 +103,5 @@
 
 ALIGN JUMP_ALIGN
-FindDPT_IterateToMasterAtPortCallback:
+IterateToMasterAtPortCallback:
 	test	BYTE [di+DPT.wFlags], FLG_DPT_SLAVE
 	jnz		SHORT ReturnWrongDPT				; Return if slave drive
@@ -116,6 +116,40 @@
 	stc											; Set CF since wanted DPT
 	ret
+
+
+;--------------------------------------------------------------------
+; FindDPT_ToDSDIforInterruptInService
+;	Parameters:
+;		DS:		RAMVARS segment
+;	Returns:
+;		DS:DI:	Ptr to DPT
+;		CF:		Set if wanted DPT found
+;				Cleared if DPT not found
+;	Corrupts registers:
+;		SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FindDPT_ToDSDIforInterruptInService:
+	mov		si, IterateToDptWithInterruptInServiceFlagSet
+	jmp		SHORT IterateAllDPTs
+
+;--------------------------------------------------------------------
+; IterateToDptWithInterruptInServiceFlagSet
+;	Parameters:
+;		DS:DI:	Ptr to DPT to examine
+;	Returns:
+;		CF:		Set if wanted DPT found
+;				Cleared if wrong DPT
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+IterateToDptWithInterruptInServiceFlagSet:
+	test	WORD [di+DPT.wFlags], FLG_DPT_INTERRUPT_IN_SERVICE
+	jz		SHORT ReturnWrongDPT
+	stc										; Set CF since wanted DPT
+	ret
 ReturnWrongDPT:
-	clc											; Clear CF since wrong DPT
+	clc										; Clear CF since wrong DPT
 	ret
 
@@ -126,11 +160,11 @@
 ; IterateAllDPTs
 ;	Parameters:
-;		BX,DX:	Parameters to callback function
-;		CS:SI:	Ptr to callback function
-;		DS:		RAMVARS segment
+;		AX,BX,DX:	Parameters to callback function
+;		CS:SI:		Ptr to callback function
+;		DS:			RAMVARS segment
 ;	Returns:
-;		DS:DI:	Ptr to wanted DPT (if found)
-;		CF:		Set if wanted DPT found
-;				Cleared if DPT not found
+;		DS:DI:		Ptr to wanted DPT (if found)
+;		CF:			Set if wanted DPT found
+;					Cleared if DPT not found
 ;	Corrupts registers:
 ;		Nothing unless corrupted by callback function
@@ -141,5 +175,5 @@
 	mov		cx, [RAMVARS.wDrvCntAndFirst]
 	jcxz	.AllDptsIterated			; Return if no drives
-	call	FindDPT_PointToFirstDPT		; Point DS:DI to first DPT
+	mov		di, RAMVARS_size			; Point DS:DI to first DPT
 ALIGN JUMP_ALIGN
 .LoopWhileDPTsLeft:
@@ -155,19 +189,2 @@
 	pop		cx
 	ret
-
-
-;--------------------------------------------------------------------
-; Sets DI to point to first Disk Parameter Table.
-;
-; FindDPT_PointToFirstDPT
-;	Parameters:
-;		Nothing
-;	Returns:
-;		DI:		Offset to first DPT (even if unused)
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FindDPT_PointToFirstDPT:
-	mov		di, RAMVARS_size
-	ret
