Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 197)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 199)
@@ -34,8 +34,11 @@
 
 ; Bit defines for ROMVARS.wFlags
-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
-FLG_ROMVARS_MODULE_SERIAL	EQU (1<<3)
-FLG_ROMVARS_MODULE_EBIOS	EQU (1<<4)
+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
+FLG_ROMVARS_SERIAL_SCANDETECT 		EQU	(1<<3)	; Scan COM ports at the end of drive detection.  Can also be invoked
+												; by holding down the ALT key at the end of drive detection.
+												; (Conveniently, this is 8, a fact we exploit when testing the bit)
+FLG_ROMVARS_MODULE_SERIAL			EQU (1<<6)	; Here in case the configuration needs to know functionality is present
+FLG_ROMVARS_MODULE_EBIOS			EQU (1<<7)	; Here in case the configuration needs to know functionality is present
 
 ; Boot Menu Display Modes (see Assembly Library Display.inc for standard modes)
@@ -58,5 +61,15 @@
 endstruc
 
+; Default values for Port and PortCtrl, shared with the configurator
+;
+DEVICE_XTIDE_DEFAULT_PORT				EQU		300h
+DEVICE_XTIDE_DEFAULT_PORTCTRL			EQU		308h
+DEVICE_ATA_DEFAULT_PORT					EQU		1F0h
+DEVICE_ATA_DEFAULT_PORTCTRL				EQU		3F0h
+DEVICE_SERIAL_DEFAULT_COM				EQU		0		; COM1
+DEVICE_SERIAL_DEFAULT_BAUD				EQU		1		; 9600
+
 ; Device types for IDEVARS.bDevice
+;
 DEVICE_8BIT_DUAL_PORT_XTIDE				EQU	(0<<1)
 DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0	EQU	(1<<1)
@@ -65,4 +78,5 @@
 DEVICE_32BIT_ATA						EQU	(4<<1)
 DEVICE_SERIAL_PORT						EQU	(5<<1)
+
 
 ; Master/Slave drive specific parameters
@@ -80,3 +94,57 @@
 
 
+; Defines for IDEVARS.bSerialPackedPortAndBaud (same format used by DPT.bSerialPortAndBaud)
+;
+; pppp ppbb
+;   i/o port address = p * 2 + 240h
+;   baud rate = b, where 00 = 2400, 01 = 9600, 10 = 38.4K, 11 = 115.2K
+;
+DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK		EQU		0fch
+DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTBITS		EQU		03fh
+DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT	EQU		240h
+DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK		EQU		3h
+DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDBITS		EQU		3h
+
+; Defines for IDEVARS.wSerialPrintBaud
+;
+; pppp ppnn nnnn nnnn
+;   unsigned number to output = n
+;   postfix character = p + '0' (designed for '0' and 'K', although other values are possible)
+;
+; Note that the contents of this word is only used for printing by the BIOS when a drive is detected.  
+; It is not used for any other purpose, and so long as it conforms to the structure, any values can be used.
+;
+DEVICE_SERIAL_PRINTBAUD_NUMBERMASK		EQU		003ffh
+DEVICE_SERIAL_PRINTBAUD_POSTCHARMASK	EQU		0fc00h
+DEVICE_SERIAL_PRINTBAUD_POSTCHARADD		EQU		'0'
+;
+; These are defined here (instead of in the configurator) for consistency since they could also be used 
+; in main.asm as a default for an IDEVARS structure.
+;
+DEVICE_SERIAL_PRINTBAUD_2400  EQU ((('0'-DEVICE_SERIAL_PRINTBAUD_POSTCHARADD)<<10) | 240)		; Prints "2400"
+DEVICE_SERIAL_PRINTBAUD_9600  EQU ((('0'-DEVICE_SERIAL_PRINTBAUD_POSTCHARADD)<<10) | 960)		; Prints "9600"
+DEVICE_SERIAL_PRINTBAUD_38_4  EQU ((('K'-DEVICE_SERIAL_PRINTBAUD_POSTCHARADD)<<10) | 38)		; Prints "38K"
+DEVICE_SERIAL_PRINTBAUD_115_2 EQU ((('K'-DEVICE_SERIAL_PRINTBAUD_POSTCHARADD)<<10) | 115)		; Prints "115K"
+
+;
+; COM Number to I/O Port Address Mapping
+;
+; COM Number:                               1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12		
+; Corresponds to I/O port:                3f8,  2f8,  3e8,  2e8,  2f0,  3e0,  2e0,  260,  368,  268,  360,  270
+; Corresponds to Packed I/O port (hex):    37,   17,   35,   15,   16,   34,   14,    4,   25,    5,   24,    6
+;
+DEVICE_SERIAL_COM1	EQU		3f8h
+DEVICE_SERIAL_COM2	EQU		2f8h
+DEVICE_SERIAL_COM3	EQU		3e8h
+DEVICE_SERIAL_COM4	EQU		2e8h
+DEVICE_SERIAL_COM5	EQU		2f0h
+DEVICE_SERIAL_COM6	EQU		3e0h
+DEVICE_SERIAL_COM7	EQU		2e0h
+DEVICE_SERIAL_COM8	EQU		260h
+DEVICE_SERIAL_COM9	EQU		368h
+DEVICE_SERIAL_COMA	EQU		268h
+DEVICE_SERIAL_COMB	EQU		360h
+DEVICE_SERIAL_COMC	EQU		270h
+
+
 %endif ; ROMVARS_INC
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 197)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 199)
@@ -119,5 +119,5 @@
 		mov		cl, dl
 
-		and		cl, SerialCommand_PackedPortAndBaud_BaudMask
+		and		cl, DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK
 		shl		cl, 1
 		mov		ch, SerialCommand_UART_divisorLow_startingBaud
@@ -125,8 +125,8 @@
 		adc		ch, 0
 
-		and		dl, SerialCommand_PackedPortAndBaud_PortMask
+		and		dl, DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK
 		mov		dh, 0
 		shl		dx, 1			; port offset already x4, needs one more shift to be x8
-		add		dx, SerialCommand_PackedPortAndBaud_StartingPort
+		add		dx, DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT
 
 ;
@@ -501,8 +501,11 @@
 SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
 
-		mov		dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud]
+		mov		dx,[cs:bp+IDEVARS.bSerialCOMDigit]
 		test	dl,dl
 		jz		SerialCommand_AutoSerial
 
+		xchg	dh,dl			; dh (the COM character to print) will be transmitted to the server,
+								; so we know this is not an auto detect
+		
 ; fall-through
 SerialCommand_IdentifyDeviceInDL_DriveInBH:
@@ -543,8 +546,12 @@
 ;
 
-SerialCommand_ScanPortAddresses:     db  0b8h, 0f8h, 0bch, 0bah, 0fah, 0beh, 0feh, 0
-; Corresponds to I/O port:                3f8,  2f8,  3e8,  2e8,  2f0,  3e0,  2e0,  260,  368,  268,  360,  270
-; COM Assignments:                          1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12
-; Corresponds to Packed I/O port (hex):    37,   17,   35,   15,   16,   34,   14,    4,   25,    5,   24,    6		
+SerialCommand_ScanPortAddresses:    db	DEVICE_SERIAL_COM7 >> 2
+									db	DEVICE_SERIAL_COM6 >> 2
+									db	DEVICE_SERIAL_COM5 >> 2
+									db	DEVICE_SERIAL_COM4 >> 2
+									db	DEVICE_SERIAL_COM3 >> 2
+									db	DEVICE_SERIAL_COM2 >> 2
+									db	DEVICE_SERIAL_COM1 >> 2
+									db	0
 
 ALIGN JUMP_ALIGN
@@ -581,6 +588,7 @@
 ; Pack into dl, baud rate starts at 0
 ;
-		add		dx,-(SerialCommand_PackedPortAndBaud_StartingPort)
-		shr		dx,1
+		add		dx,-(DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT)
+		shr		dx,1			; dh is zero at this point, and will be sent to the server,
+								; so we know this is an auto detect
 
 		jmp		.testFirstBaud
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 197)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 199)
@@ -31,13 +31,18 @@
 	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
 	loop	.DriveDetectLoop
-
 %ifdef MODULE_SERIAL
-	test	BYTE [es:BDA.bKBFlgs1], 8       ; alt key depressed
- 	jz		.done
+	mov		al,[cs:ROMVARS.wFlags]
+	or		al,[es:BDA.bKBFlgs1]
+	and		al,8		; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
+	jz		.done
 	mov		bp, ROMVARS.ideVarsSerialAuto
 	mov		si, g_szDetectCOMAuto
-;;; fall-through		
+;;; fall-through					
 %else
 	ret
+%endif
+
+%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
+%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_ALWAYSDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 197)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 199)
@@ -53,19 +53,13 @@
 %ifdef MODULE_SERIAL
 ;
-; Baud rate is packed into one word:
-;    High order 6 bits: number to add to '0' to get postfix character ('0' or 'K')
-;    Low order 10 bits:	binary number to display (960, 240, 38, or 115)
-;          To get 9600:	'0'<<10 + 960
-;          To get 2400:	'0'<<10 + 240
-;          To get 38K:	('K'-'0')<<10 + 38
-;          To get 115K:	('K'-'0')<<10 + 115
-;
+; Print baud rate from .wSerialPackedPrintBaud, in two parts - %u and then %c
+; 
 	mov		ax,cx						; Unpack baud rate number
-	and		ax,03ffh
+	and		ax,DEVICE_SERIAL_PRINTBAUD_NUMBERMASK
 	push	ax
 
 	mov		al,ch						; Unpack baud rate postfix ('0' or 'K')
-	eSHR_IM	al,2
-	add		al,'0'
+	eSHR_IM	al,2				        ; also effectively masks off the postfix
+	add		al,DEVICE_SERIAL_PRINTBAUD_POSTCHARADD
 	push	ax
 %endif
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 197)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 199)
@@ -82,6 +82,6 @@
 	at	ROMVARS.bStealSize,		db	1						; Steal 1kB from base memory
 
-	at	ROMVARS.ideVars0+IDEVARS.wPort,			dw	1F0h			; Controller Command Block base port
-	at	ROMVARS.ideVars0+IDEVARS.wPortCtrl,		dw	3F0h			; Controller Control Block base port
+	at	ROMVARS.ideVars0+IDEVARS.wPort,			dw	DEVICE_ATA_DEFAULT_PORT 		; Controller Command Block base port
+	at	ROMVARS.ideVars0+IDEVARS.wPortCtrl,		dw	DEVICE_ATA_DEFAULT_PORTCTRL 	; Controller Control Block base port
 	at	ROMVARS.ideVars0+IDEVARS.bDevice,		db	DEVICE_16BIT_ATA
 	at	ROMVARS.ideVars0+IDEVARS.bIRQ,			db	0
@@ -96,6 +96,6 @@
 	at	ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
 
-	at	ROMVARS.ideVars2+IDEVARS.wPort,			dw	300h			; Controller Command Block base port
-	at	ROMVARS.ideVars2+IDEVARS.wPortCtrl,		dw	308h			; Controller Control Block base port
+	at	ROMVARS.ideVars2+IDEVARS.wPort,			dw	DEVICE_XTIDE_DEFAULT_PORT			; Controller Command Block base port
+	at	ROMVARS.ideVars2+IDEVARS.wPortCtrl,		dw	DEVICE_XTIDE_DEFAULT_PORTCTRL		; Controller Control Block base port
 	at	ROMVARS.ideVars2+IDEVARS.bDevice,		db	DEVICE_8BIT_DUAL_PORT_XTIDE
 	at	ROMVARS.ideVars2+IDEVARS.bIRQ,			db	0
@@ -127,6 +127,6 @@
 	at	ROMVARS.bStealSize,		db	1						; Steal 1kB from base memory in full mode
 
-	at	ROMVARS.ideVars0+IDEVARS.wPort,			dw	300h			; Controller Command Block base port
-	at	ROMVARS.ideVars0+IDEVARS.wPortCtrl,		dw	308h			; Controller Control Block base port
+	at	ROMVARS.ideVars0+IDEVARS.wPort,			dw	DEVICE_XTIDE_DEFAULT_PORT			; Controller Command Block base port
+	at	ROMVARS.ideVars0+IDEVARS.wPortCtrl,		dw	DEVICE_XTIDE_DEFAULT_PORTCTRL		; Controller Control Block base port
 	at	ROMVARS.ideVars0+IDEVARS.bDevice,		db	DEVICE_8BIT_DUAL_PORT_XTIDE
 	at	ROMVARS.ideVars0+IDEVARS.bIRQ,			db	0				; IRQ
