Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 175)
@@ -12,5 +12,9 @@
 	.bFlagsHigh					resb	1
 	.bIdevarsOffset				resb	1	; Offset to IDEVARS for this drive
-								resb	1
+%ifdef MODULE_SERIAL
+	.bSerialPortAndBaud			resb	1	; Packed I/O port and baud rate for serial drives
+%else
+								resb	1	; without serial port support, alignment byte
+%endif
 
 	; IDE Drive related
@@ -44,5 +48,7 @@
 FLGH_DPT_REVERSED_A0_AND_A3		EQU	(1<<0)	; XTIDE mod, Address lines 0 and 3 reversed
 FLGH_DPT_BLOCK_MODE_SUPPORTED	EQU	(1<<1)	; Use block transfer commands (must be bit 1!)
+%ifdef MODULE_SERIAL
 FLGH_DPT_SERIAL_DEVICE			EQU	(1<<2)	; Serial Port Device
+%endif
 FLGH_DPT_INTERRUPT_IN_SERVICE	EQU	(1<<3)	; Set when waiting for IRQ
 FLGH_DPT_RESET_nDRDY			EQU	(1<<4)	; Drive ready to accept commands
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 175)
@@ -27,4 +27,6 @@
 	.ideVars2		resb	IDEVARS_size
 	.ideVars3		resb	IDEVARS_size
+
+	.ideVarsSerialAuto	resb	IDEVARS_size
 endstruc
 
@@ -32,4 +34,9 @@
 FLG_ROMVARS_FULLMODE	EQU	(1<<0)	; Full operating mode (steals base RAM, supports EBIOS etc.)
 FLG_ROMVARS_DRVXLAT		EQU	(1<<2)	; Enable drive number translation
+%ifdef MODULE_SERIAL
+FLG_ROMVARS_MODULE_SERIAL	EQU (1<<3)
+%else
+FLG_ROMVARS_MODULE_SERIAL   EQU 0
+%endif
 
 ; Boot Menu Display Modes (see Assembly Library Display.inc for standard modes)
@@ -47,5 +54,5 @@
 endstruc
 
-; Device types for IDEVARS.bDeviceType
+; Device types for IDEVARS.bDevice
 DEVICE_8BIT_DUAL_PORT_XTIDE				EQU	(0<<1)
 DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0	EQU	(1<<1)
@@ -53,6 +60,7 @@
 DEVICE_16BIT_ATA						EQU	(3<<1)
 DEVICE_32BIT_ATA						EQU	(4<<1)
+%ifdef MODULE_SERIAL
 DEVICE_SERIAL_PORT						EQU	(5<<1)
-
+%endif
 
 ; Master/Slave drive specific parameters
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 175)
@@ -17,10 +17,13 @@
 ;--------------------------------------------------------------------
 Device_FinalizeDPT:
+%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
-	jnz		SHORT ReturnSuccessForSerialPort
+	jnz		SHORT .FinalizeDptForSerialPortDevice
+%endif
 	jmp		IdeDPT_Finalize
-;.FinalizeDptForSerialPortDevice:	; Dead label
-;	jmp		SerialDPT_Finalize		; and code
-
+%ifdef MODULE_SERIAL
+.FinalizeDptForSerialPortDevice:
+	jmp		SerialDPT_Finalize		
+%endif
 
 ;--------------------------------------------------------------------
@@ -35,6 +38,8 @@
 ;--------------------------------------------------------------------
 Device_ResetMasterAndSlaveController:
+%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT ReturnSuccessForSerialPort
+%endif
 	jmp		IdeCommand_ResetMasterAndSlaveController
 
@@ -54,10 +59,13 @@
 ;--------------------------------------------------------------------
 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
+%ifdef MODULE_SERIAL
 	cmp		BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
 	je		SHORT .IdentifyDriveFromSerialPort
+%endif
 	jmp		IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
+%ifdef MODULE_SERIAL
 .IdentifyDriveFromSerialPort:
 	jmp		SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
-
+%endif
 
 ;--------------------------------------------------------------------
@@ -77,11 +85,14 @@
 ALIGN JUMP_ALIGN
 Device_OutputCommandWithParameters:
+%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT .OutputCommandToSerialPort
+%endif
 	jmp		IdeCommand_OutputWithParameters
+%ifdef MODULE_SERIAL
 ALIGN JUMP_ALIGN
 .OutputCommandToSerialPort:
 	jmp		SerialCommand_OutputWithParameters
-
+%endif
 
 ;--------------------------------------------------------------------
@@ -98,8 +109,12 @@
 ALIGN JUMP_ALIGN
 Device_SelectDrive:
+%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT ReturnSuccessForSerialPort
+%endif
 	jmp		IdeCommand_SelectDrive
+%ifdef MODULE_SERIAL
 ReturnSuccessForSerialPort:
 	xor		ax, ax
 	ret
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 175)
@@ -21,9 +21,16 @@
 	mov		bp, ROMVARS.ideVars0			; CS:BP now points to first IDEVARS
 .DriveDetectLoop:
-	call	DetectDrives_WithIDEVARS		; Detect Master and Slave
+	call	.DetectDrives_WithIDEVARS		; Detect Master and Slave
 	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
 	loop	.DriveDetectLoop
+
+%ifdef MODULE_SERIAL
+	test	BYTE [es:BDA.bKBFlgs1], (1<<2)
+;; 	jz		.done
+	mov		bp, ROMVARS.ideVarsAutoSerial
+;;; fall-through		
+%else
 	ret
-
+%endif
 
 ;--------------------------------------------------------------------
@@ -40,5 +47,5 @@
 ;		AX, BX, DX, SI, DI
 ;--------------------------------------------------------------------
-DetectDrives_WithIDEVARS:
+.DetectDrives_WithIDEVARS:
 	push	cx
 	mov		ax, g_szMaster
@@ -50,7 +57,8 @@
 	call	StartDetectionWithDriveSelectByteInBHandStringInAX
 	pop		cx
+.done:	
 	ret
 
-
+		
 ;--------------------------------------------------------------------
 ; StartDetectionWithDriveSelectByteInBHandStringInAX
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 175)
@@ -54,5 +54,5 @@
 ;---------------------------;
 %ifdef USE_AT
-	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT
+	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_MODULE_SERIAL
 	at	ROMVARS.wDisplayMode,	dw	DEFAULT_TEXT_MODE
 	at	ROMVARS.wBootTimeout,	dw	30 * TICKS_PER_SECOND	; Boot Menu selection timeout
@@ -89,9 +89,15 @@
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+
+%ifdef MODULE_SERIAL
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice,		db	DEVICE_SERIAL_PORT
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE		
+%endif			
 %else
 ;-----------------------------------;
 ; XT and XT+ Build default settings ;
 ;-----------------------------------;
-	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_DRVXLAT
+	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_DRVXLAT | FLG_ROMVARS_MODULE_SERIAL
 	at	ROMVARS.wDisplayMode,	dw	DEFAULT_TEXT_MODE
 	at	ROMVARS.wBootTimeout,	dw	30 * TICKS_PER_SECOND	; Boot Menu selection timeout
@@ -116,4 +122,10 @@
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+
+%ifdef MODULE_SERIAL
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice,		db	DEVICE_SERIAL_PORT
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE		
+%endif	
 %endif
 iend
@@ -165,7 +177,9 @@
 %include "IdeError.asm"			; Must be included after IdeWait.asm
 
+%ifdef MODULE_SERIAL		
 ; Serial Port Device support
 %include "SerialCommand.asm"
 %include "SerialDPT.asm"
+%endif
 
 ; INT 13h Hard Disk BIOS functions
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 174)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 175)
@@ -63,4 +63,12 @@
 .StoreFlags:
 	mov		[di+DPT.wFlags], ax
+
+%ifdef MODULE_SERIAL
+	cmp		byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
+	jnz		.around
+	or		byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
+.around:				
+%endif		
+
 	; Fall to .StoreAddressing
 
