Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuInfo.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuInfo.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuInfo.asm	(revision 365)
@@ -65,21 +65,4 @@
 
 ;--------------------------------------------------------------------
-; BootMenuInfo_IsAvailable
-;	Parameters:
-;		Nothing
-;	Returns:
-;		ES:		Segment to BOOTVARS with BOOTMENUINFOs
-;		ZF:		Set if BOOTVARS with BOOTMENUINFOs is available
-;				Cleared if not available (no longer initializing)
-;	Corrupts registers:
-;		BX
-;--------------------------------------------------------------------
-BootMenuInfo_IsAvailable:
-	LOAD_BDA_SEGMENT_TO	es, bx
-	cmp		WORD [es:BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD
-	ret
-
-
-;--------------------------------------------------------------------
 ; Returns offset to BOOTMENUINFO based on DPT pointer.
 ;
@@ -90,8 +73,7 @@
 ;		BX:		Offset to BOOTMENUINFO struct
 ;	Corrupts registers:
-;		Nothing
+;		AX
 ;--------------------------------------------------------------------
 BootMenuInfo_ConvertDPTtoBX:
-	push	ax
 	mov		ax, di
 	sub		ax, BYTE RAMVARS_size					; subtract off base of DPTs
@@ -100,4 +82,3 @@
 	add		ax, BOOTVARS.rgBootNfo					; add base of BOOTMENUINFO
 	xchg	ax, bx
-	pop		ax
 	ret	
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 365)
@@ -65,5 +65,5 @@
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED
 	jz		SHORT .PushBlockSizeFromAX
-	mov		al, [di+DPT_ATA.bSetBlock]
+	mov		al, [di+DPT_ATA.bBlockSize]
 .PushBlockSizeFromAX:
 	push	ax
@@ -114,7 +114,12 @@
 ;--------------------------------------------------------------------
 .PushResetStatus:
-	call	BootMenuInfo_IsAvailable	; Load segment to ES
-	call	BootMenuInfo_ConvertDPTtoBX
-	push	WORD [es:bx+BOOTMENUINFO.wInitErrorFlags]
+	xor		ax, ax
+%ifdef MODULE_SERIAL
+	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
+	jnz		SHORT .AlwaysSuccess
+	mov		al, [di+DPT_ATA.bInitError]
+.AlwaysSuccess:
+%endif
+	push	ax
 
 ;;; fall-out to BootMenuPrint_HardDiskRefreshInformation.
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 365)
@@ -55,5 +55,5 @@
 	mov		[di+DPT.wFlags], ax
 	mov		[di+DPT.bIdevarsOffset], bp
-	mov		BYTE [di+DPT_ATA.bSetBlock], 1	; Block = 1 sector
+	mov		BYTE [di+DPT_ATA.bBlockSize], 1	; Block = 1 sector
 %ifdef MODULE_ADVANCED_ATA
 	call	IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 365)
@@ -30,7 +30,5 @@
 ;--------------------------------------------------------------------
 .StoreBlockMode:
-	mov		al, 1							; Block mode will be enabled on AH=9h
-	mov		ah, [es:si+ATA1.bBlckSize]		; Max block size in sectors
-	mov		[di+DPT_ATA.wSetAndMaxBlock], ax
+	mov		BYTE [di+DPT_ATA.bBlockSize], 1
 
 %ifdef MODULE_ADVANCED_ATA
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 365)
@@ -180,5 +180,5 @@
 	; Store sizes
 	mov		[bp+PIOVARS.bSectorsLeft], ah
-	eMOVZX	ax, BYTE [di+DPT_ATA.bSetBlock]
+	eMOVZX	ax, BYTE [di+DPT_ATA.bBlockSize]
 	mov		[bp+PIOVARS.wSectorsInBlock], ax
 	mov		[bp+PIOVARS.bSectorsDone], ah		; Zero
Index: trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm	(revision 365)
@@ -42,5 +42,5 @@
 	mov		ch, [bp+IDEPACK.bSectorCount]
 	mov		[bp+MEMPIOVARS.wWordsLeft], cx
-	mov		ch, [di+DPT_ATA.bSetBlock]
+	mov		ch, [di+DPT_ATA.bBlockSize]
 	mov		[bp+MEMPIOVARS.wWordsInBlock], cx
 	mov		[bp+MEMPIOVARS.fpDPT], di
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 365)
@@ -40,18 +40,20 @@
 ;		CF:		0 if successful, 1 if error
 ;	Corrupts registers:
-;		AL, BX, CX, DX
+;		AL, CX, DX
 ;--------------------------------------------------------------------
 AH24h_SetBlockSize:
+	push	bx
+
 	push	ax
-	xchg	dx, ax			; DL = Block size (Sector Count Register)
-	or		BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED	; Assume success
+	xchg	dx, ax		; DL = Block size (Sector Count Register)
 	mov		al, COMMAND_SET_MULTIPLE_MODE
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)
 	call	Idepack_StoreNonExtParametersAndIssueCommandFromAL
 	pop		bx
-	jnc		.StoreBlockSize
-	mov		bl, 1	; Disable block mode
-	and		BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_BLOCK_MODE_SUPPORTED
-.StoreBlockSize:	; Store new block size to DPT and return
-	mov		[di+DPT_ATA.bSetBlock], bl
+	jnc		SHORT .StoreBlockSize
+	mov		bl, 1		; Block size 1 will always work
+.StoreBlockSize:		; Store new block size to DPT and return
+	mov		[di+DPT_ATA.bBlockSize], bl
+
+	pop		bx
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 364)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 365)
@@ -43,5 +43,4 @@
 	push	es
 	push	si
-	call	ClearErrorFlagFromBootMenuInfo	; Do this for serial devices as well
 
 %ifdef MODULE_SERIAL
@@ -52,6 +51,6 @@
 
 %else
-	; Clear Initialization Error flag from DPT
-	and		BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INITERROR
+	; Clear Initialization Error flags from DPT
+	mov		BYTE [di+DPT_ATA.bInitError], 0
 %endif
 
@@ -60,29 +59,29 @@
 	mov		[bp+IDEPACK.bDrvAndHead], al
 	call	Device_SelectDrive
-	mov		al, FLG_INIT_FAILED_TO_SELECT_DRIVE
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_SELECT_DRIVE
+	call	SetErrorFlagFromALwithErrorCodeInAH
 	jc		SHORT .ReturnWithErrorCodeInAH
 
 	; Initialize CHS parameters if LBA is not used
 	call	InitializeDeviceParameters
-	mov		al, FLG_INIT_FAILED_TO_INITIALIZE_CHS_PARAMETERS
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
+	call	SetErrorFlagFromALwithErrorCodeInAH
 
 	; Enable or Disable Write Cache
 	call	SetWriteCache
-	mov		al, FLG_INIT_FAILED_TO_SET_WRITE_CACHE
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE
+	call	SetErrorFlagFromALwithErrorCodeInAH
 
 	; Recalibrate drive by seeking to cylinder 0
 .RecalibrateDrive:
 	call	AH11h_RecalibrateDrive
-	mov		al, FLG_INIT_FAILED_TO_RECALIBRATE_DRIVE
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE
+	call	SetErrorFlagFromALwithErrorCodeInAH
 
 	; Initialize block mode transfers
 .InitializeBlockMode:
 	call	InitializeBlockMode
-	mov		al, FLG_INIT_FAILED_TO_SET_BLOCK_MODE
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE
+	call	SetErrorFlagFromALwithErrorCodeInAH
 
 %ifdef MODULE_ADVANCED_ATA
@@ -90,12 +89,12 @@
 .InitializePioMode:
 	call	InitializePioMode
-	mov		al, FLG_INIT_FAILED_TO_SET_PIO_MODE
-	call	SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	mov		al, FLG_INITERROR_FAILED_TO_SET_PIO_MODE
+	call	SetErrorFlagFromALwithErrorCodeInAH
 %endif
 
 	; There might have been several errors so just return
 	; one error code for them all
-	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
-	jz		SHORT .ReturnWithErrorCodeInAH
+	cmp		BYTE [di+DPT_ATA.bInitError], 0
+	je		SHORT .ReturnWithErrorCodeInAH
 	mov		ah, RET_HD_RESETFAIL
 	stc
@@ -198,33 +197,26 @@
 InitializeBlockMode:
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED	; Clear CF
-	jz		SHORT ReturnSuccessSinceInitializationNotNeeded
-
+	jz		SHORT .BlockModeNotSupportedOrDisabled
 	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
-	mov		al, 1						; Disable block mode
 	test	BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_BLOCKMODE
-	eCMOVNZ	al, [di+DPT_ATA.bMaxBlock]	; Load max block size
-	jmp		AH24h_SetBlockSize
-
-
-;--------------------------------------------------------------------
-; ClearErrorFlagFromBootMenuInfo
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		BX, ES
-;--------------------------------------------------------------------
-ClearErrorFlagFromBootMenuInfo:
-	call	BootMenuInfo_IsAvailable	; Load BOOTMENUINFO segment to ES
-	jne		SHORT .DoNotStoreErrorFlags
-	call	BootMenuInfo_ConvertDPTtoBX
-	mov		WORD [es:bx+BOOTMENUINFO.wInitErrorFlags], 0	; Must clear whole WORD!
-.DoNotStoreErrorFlags:
-	ret
-
-
-;--------------------------------------------------------------------
-; SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
+	jz		SHORT .BlockModeNotSupportedOrDisabled
+
+	; Try block sizes until we find largest possible supported by drive
+	mov		bl, 128
+.TryNextBlockSize:
+	mov		al, bl
+	call	AH24h_SetBlockSize
+	jnc		SHORT .SupportedBlockSizeFound
+	shr		bl, 1						; Try next size
+	jmp		SHORT .TryNextBlockSize
+.SupportedBlockSizeFound:
+	mov		[di+DPT_ATA.bBlockSize], bl
+.BlockModeNotSupportedOrDisabled:
+ReturnSuccessSinceInitializationNotNeeded:
+	ret
+
+
+;--------------------------------------------------------------------
+; SetErrorFlagFromALwithErrorCodeInAH
 ;	Parameters:
 ;		AH:		BIOS Error Code
@@ -237,21 +229,14 @@
 ;		BX, ES
 ;--------------------------------------------------------------------
-SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo:
-	jnc		SHORT NoErrorFlagToSet
+SetErrorFlagFromALwithErrorCodeInAH:
+	jnc		SHORT .NoErrorFlagToSet
 	cmp		ah, RET_HD_INVALID
 	jbe		SHORT .IgnoreInvalidCommandError
 
-	call	BootMenuInfo_IsAvailable
-	jne		SHORT .BootvarsNotAvailableSoDoNotSetErrorFlag
-
-	call	BootMenuInfo_ConvertDPTtoBX
-	or		[es:bx+BOOTMENUINFO.wInitErrorFlags], al
-.BootvarsNotAvailableSoDoNotSetErrorFlag:
-	or		BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
+	or		[di+DPT_ATA.bInitError], al
 	stc
 	ret
 .IgnoreInvalidCommandError:
-ReturnSuccessSinceInitializationNotNeeded:
 	xor		ah, ah
-NoErrorFlagToSet:
-	ret
+.NoErrorFlagToSet:
+	ret
