1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions for accessing ATA information read with
|
---|
3 | ; IDENTIFY DEVICE command.
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
8 | ;
|
---|
9 | ; This program is free software; you can redistribute it and/or modify
|
---|
10 | ; it under the terms of the GNU General Public License as published by
|
---|
11 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
12 | ; (at your option) any later version.
|
---|
13 | ;
|
---|
14 | ; This program is distributed in the hope that it will be useful,
|
---|
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | ; GNU General Public License for more details.
|
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
19 | ;
|
---|
20 |
|
---|
21 | ; Section containing code
|
---|
22 | SECTION .text
|
---|
23 |
|
---|
24 | %ifdef MODULE_ADVANCED_ATA
|
---|
25 | ;--------------------------------------------------------------------
|
---|
26 | ; AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
|
---|
27 | ; Parameters:
|
---|
28 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
29 | ; Returns:
|
---|
30 | ; AL: Max supported PIO mode
|
---|
31 | ; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise
|
---|
32 | ; CX: Minimum Cycle Time in nanosecs
|
---|
33 | ; Corrupts registers:
|
---|
34 | ; BX
|
---|
35 | ;--------------------------------------------------------------------
|
---|
36 | AtaID_GetMaxPioModeToAXandMinCycleTimeToCX:
|
---|
37 | ; Get PIO mode and cycle time for PIO 0...2
|
---|
38 | mov bx, [es:si+ATA1.bPioMode]
|
---|
39 | mov ax, bx ; AH = 0, AL = PIO mode 0, 1 or 2
|
---|
40 | shl bx, 1 ; Shift for WORD lookup
|
---|
41 | mov cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
|
---|
42 |
|
---|
43 | ; Check if IORDY is supported
|
---|
44 | test BYTE [es:si+ATA2.wCaps+1], A2_wCaps_IORDY >> 8
|
---|
45 | jz SHORT .ReturnPioTimings ; No PIO 3 or higher if no IORDY
|
---|
46 | mov ah, FLGH_DPT_IORDY
|
---|
47 |
|
---|
48 | ; Check if Advanced PIO modes are supported (3 and above)
|
---|
49 | test BYTE [es:si+ATA2.wFields], A2_wFields_64to70
|
---|
50 | jz SHORT .ReturnPioTimings
|
---|
51 |
|
---|
52 | ; Get Advanced PIO mode
|
---|
53 | ; (Hard Disks supports up to 4 but CF cards can support 5 and 6)
|
---|
54 | mov bl, [es:si+ATA2.bPIOSupp]
|
---|
55 | .CheckNextFlag:
|
---|
56 | inc ax
|
---|
57 | shr bl, 1
|
---|
58 | jnz SHORT .CheckNextFlag
|
---|
59 | MIN_U al, 6 ; Make sure not above lookup tables
|
---|
60 | mov cx, [es:si+ATA2.wPIOMinCyF] ; Advanced modes use IORDY
|
---|
61 | .ReturnPioTimings:
|
---|
62 | ret
|
---|
63 |
|
---|
64 | .rgwPio0to2CycleTimeInNanosecs:
|
---|
65 | dw PIO_0_MIN_CYCLE_TIME_NS
|
---|
66 | dw PIO_1_MIN_CYCLE_TIME_NS
|
---|
67 | dw PIO_2_MIN_CYCLE_TIME_NS
|
---|
68 |
|
---|
69 |
|
---|
70 | ;--------------------------------------------------------------------
|
---|
71 | ; AtaID_GetRecoveryTimeToAXfromPioModeInBXandCycleTimeInCX
|
---|
72 | ; Parameters:
|
---|
73 | ; BX: PIO Mode
|
---|
74 | ; CX: PIO Cycle Time in nanosecs
|
---|
75 | ; Returns:
|
---|
76 | ; AX: Active Time in nanosecs
|
---|
77 | ; Corrupts registers:
|
---|
78 | ; BX, CX
|
---|
79 | ;--------------------------------------------------------------------
|
---|
80 | AtaID_GetRecoveryTimeToAXfromPioModeInBXandCycleTimeInCX:
|
---|
81 | call AtaID_GetActiveTimeToAXfromPioModeInBX
|
---|
82 | mov bl, [cs:bx+.rgbPioModeToAddressValidTimeNs]
|
---|
83 | sub cx, bx ; Cycle Time (t0) - Address Valid Time (t1)
|
---|
84 | sub cx, ax ; - Active Time (t2)
|
---|
85 | xchg ax, cx ; AX = Recovery Time (t2i)
|
---|
86 | ret
|
---|
87 |
|
---|
88 | .rgbPioModeToAddressValidTimeNs:
|
---|
89 | db PIO_0_MIN_ADDRESS_VALID_NS
|
---|
90 | db PIO_1_MIN_ADDRESS_VALID_NS
|
---|
91 | db PIO_2_MIN_ADDRESS_VALID_NS
|
---|
92 | db PIO_3_MIN_ADDRESS_VALID_NS
|
---|
93 | db PIO_4_MIN_ADDRESS_VALID_NS
|
---|
94 | db PIO_5_MIN_ADDRESS_VALID_NS
|
---|
95 | db PIO_6_MIN_ADDRESS_VALID_NS
|
---|
96 |
|
---|
97 |
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ; AtaID_GetActiveTimeToAXfromPioModeInBX
|
---|
100 | ; Parameters:
|
---|
101 | ; BX: PIO Mode
|
---|
102 | ; Returns:
|
---|
103 | ; AX: Active Time in nanosecs
|
---|
104 | ; Corrupts registers:
|
---|
105 | ; Nothing
|
---|
106 | ;--------------------------------------------------------------------
|
---|
107 | AtaID_GetActiveTimeToAXfromPioModeInBX:
|
---|
108 | shl bx, 1
|
---|
109 | mov ax, [cs:bx+.rgwPioModeToActiveTimeNs]
|
---|
110 | shr bx, 1
|
---|
111 | ret
|
---|
112 |
|
---|
113 | .rgwPioModeToActiveTimeNs:
|
---|
114 | dw PIO_0_MIN_ACTIVE_TIME_NS
|
---|
115 | dw PIO_1_MIN_ACTIVE_TIME_NS
|
---|
116 | dw PIO_2_MIN_ACTIVE_TIME_NS
|
---|
117 | dw PIO_3_MIN_ACTIVE_TIME_NS
|
---|
118 | dw PIO_4_MIN_ACTIVE_TIME_NS
|
---|
119 | dw PIO_5_MIN_ACTIVE_TIME_NS
|
---|
120 | dw PIO_6_MIN_ACTIVE_TIME_NS
|
---|
121 |
|
---|
122 | %endif ; MODULE_ADVANCED_ATA
|
---|