Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 3)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	AtaID.asm
-; Project name	:	IDE BIOS
-; Created date	:	6.4.2010
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for accessing ATA information read with
 ;					IDENTIFY DEVICE command.
@@ -11,6 +7,4 @@
 
 ;--------------------------------------------------------------------
-; Returns P-CHS values from ATA information.
-;
 ; AtaID_GetPCHS
 ;	Parameters:
@@ -18,20 +12,17 @@
 ;	Returns:
 ;		AX:		Number of user specified P-CHS cylinders
-;		BL:		Number of user specified P-CHS sectors per track
-;		BH:		Number of user specified P-CHS heads
+;		BH:		Number of user specified P-CHS sectors per track
+;		BL:		Number of user specified P-CHS heads
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AtaID_GetPCHS:
 	mov		ax, [es:si+ATA1.wCylCnt]	; Cylinders (1...16383)
-	mov		bh, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
-	mov		bl, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
+	mov		bl, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
+	mov		bh, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
 	ret
 
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors from ATA information.
-;
 ; AtaID_GetTotalSectorCount
 ;	Parameters:
@@ -42,18 +33,19 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AtaID_GetTotalSectorCount:
+	push	ds
+
+	push	es
+	pop		ds
 	xor		bx, bx
-	test	WORD [es:si+ATA1.wCaps], A1_wCaps_LBA
-	jz		SHORT AtaID_GetChsSectorCount
-	; Fall to AtaID_GetLbaSectorCount
+	test	WORD [si+ATA1.wCaps], A1_wCaps_LBA
+	jz		SHORT .GetChsSectorCount
+	; Fall to .GetLbaSectorCount
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors for LBA addressing.
-;
-; AtaID_GetLbaSectorCount
+; .GetLbaSectorCount
 ;	Parameters:
 ;		BX:		Zero
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		DS:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
 ;		BX:DX:AX:	48-bit sector count
@@ -61,24 +53,22 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-AtaID_GetLbaSectorCount:
-	test	WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
+.GetLbaSectorCount:
+	test	WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48
 	jz		SHORT .GetLba28SectorCount
-	mov		ax, [es:si+ATA6.qwLBACnt]
-	mov		dx, [es:si+ATA6.qwLBACnt+2]
-	mov		bx, [es:si+ATA6.qwLBACnt+4]
+	mov		ax, [si+ATA6.qwLBACnt]
+	mov		dx, [si+ATA6.qwLBACnt+2]
+	mov		bx, [si+ATA6.qwLBACnt+4]
+	pop		ds
 	ret
-ALIGN JUMP_ALIGN
 .GetLba28SectorCount:
-	mov		ax, [es:si+ATA1.dwLBACnt]
-	mov		dx, [es:si+ATA1.dwLBACnt+2]
+	mov		ax, [si+ATA1.dwLBACnt]
+	mov		dx, [si+ATA1.dwLBACnt+2]
+	pop		ds
 	ret
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors for P-CHS addressing.
-;
-; AtaID_GetChsSectorCount
+; .GetChsSectorCount
 ;	Parameters:
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		DS:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
 ;		DX:AX:	24-bit sector count
@@ -86,8 +76,8 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AtaID_GetChsSectorCount:
-	mov		al, [es:si+ATA1.wSPT]		; AL=Sectors per track
-	mul		BYTE [es:si+ATA1.wHeadCnt]	; AX=Sectors per track * number of heads
-	mul		WORD [es:si+ATA1.wCylCnt]	; DX:AX=Sectors per track * number of heads * number of cylinders
+.GetChsSectorCount:
+	mov		al, [si+ATA1.wSPT]		; AL=Sectors per track
+	mul		BYTE [si+ATA1.wHeadCnt]	; AX=Sectors per track * number of heads
+	mul		WORD [si+ATA1.wCylCnt]	; DX:AX=Sectors per track * number of heads * number of cylinders
+	pop		ds
 	ret
