1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions for managing IDEPACK struct.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
8 | ; Idepack_FakeToSSBP
|
---|
9 | ; Parameters:
|
---|
10 | ; Nothing
|
---|
11 | ; Returns:
|
---|
12 | ; SS:BP: Ptr to IDEPACK
|
---|
13 | ; Corrupts registers:
|
---|
14 | ; AX
|
---|
15 | ;--------------------------------------------------------------------
|
---|
16 | Idepack_FakeToSSBP:
|
---|
17 | pop ax
|
---|
18 | sub sp, BYTE EXTRA_BYTES_FOR_INTPACK
|
---|
19 | mov bp, sp
|
---|
20 | jmp ax
|
---|
21 |
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; Idepack_ConvertDapToIdepackAndIssueCommandFromAH
|
---|
25 | ; Parameters:
|
---|
26 | ; AH: IDE command to issue
|
---|
27 | ; BH: Timeout ticks
|
---|
28 | ; BL: IDE Status Register flag to wait after command
|
---|
29 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
30 | ; ES:SI: Ptr to DAP (EBIOS Disk Address Packet)
|
---|
31 | ; SS:BP: Ptr to IDEPACK
|
---|
32 | ; Returns:
|
---|
33 | ; AH: INT 13h Error Code
|
---|
34 | ; CF: Cleared if success, Set if error
|
---|
35 | ; Corrupts registers:
|
---|
36 | ; AL, BX, CX, DX, SI, ES
|
---|
37 | ;--------------------------------------------------------------------
|
---|
38 | %ifdef MODULE_EBIOS
|
---|
39 | ALIGN JUMP_ALIGN
|
---|
40 | Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
|
---|
41 | mov [bp+IDEPACK.bCommand], ah
|
---|
42 | mov ax, [es:si+DAP.wSectorCount]
|
---|
43 | mov [bp+IDEPACK.bSectorCount], al
|
---|
44 | mov [bp+IDEPACK.bSectorCountHighExt], ah
|
---|
45 |
|
---|
46 | mov al, [es:si+DAP.qwLBA] ; LBA byte 0
|
---|
47 | mov [bp+IDEPACK.bLbaLow], al
|
---|
48 | mov ax, [es:si+DAP.qwLBA+1] ; LBA bytes 1 and 2
|
---|
49 | mov [bp+IDEPACK.wLbaMiddleAndHigh], ax
|
---|
50 | mov ah, [es:si+DAP.qwLBA+3] ; LBA byte 3, LBA28 bits 24...27
|
---|
51 | mov [bp+IDEPACK.bLbaLowExt], ah
|
---|
52 | mov cx, [es:si+DAP.qwLBA+4] ; LBA bytes 4 and 5
|
---|
53 | mov [bp+IDEPACK.wLbaMiddleAndHighExt], cx
|
---|
54 |
|
---|
55 | and ah, 0Fh ; Limit bits for LBA28
|
---|
56 | call AccessDPT_GetDriveSelectByteToAL
|
---|
57 | or al, ah
|
---|
58 | mov [bp+IDEPACK.bDrvAndHead], al
|
---|
59 | les si, [es:si+DAP.dwMemoryAddress]
|
---|
60 | jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
|
---|
61 | %endif
|
---|
62 |
|
---|
63 |
|
---|
64 | ;--------------------------------------------------------------------
|
---|
65 | ; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
|
---|
66 | ; Parameters:
|
---|
67 | ; AH: IDE command to issue
|
---|
68 | ; AL: Number of sectors to transfer (1...255, 0=256)
|
---|
69 | ; BH: Timeout ticks
|
---|
70 | ; BL: IDE Status Register flag to wait after command
|
---|
71 | ; CH: Cylinder number, bits 7...0
|
---|
72 | ; CL: Bits 7...6: Cylinder number bits 9 and 8
|
---|
73 | ; Bits 5...0: Starting sector number (1...63)
|
---|
74 | ; DH: Starting head number (0...255)
|
---|
75 | ; ES:SI: Ptr to data buffer
|
---|
76 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
77 | ; SS:BP: Ptr to IDEPACK
|
---|
78 | ; Returns:
|
---|
79 | ; AH: INT 13h Error Code
|
---|
80 | ; CF: Cleared if success, Set if error
|
---|
81 | ; Corrupts registers:
|
---|
82 | ; AL, BX, CX, DX
|
---|
83 | ;--------------------------------------------------------------------
|
---|
84 | ALIGN JUMP_ALIGN
|
---|
85 | Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
|
---|
86 | mov [bp+IDEPACK.bCommand], ah
|
---|
87 |
|
---|
88 | xor ah, ah
|
---|
89 | cmp ah, al
|
---|
90 | cmc
|
---|
91 | adc ah, ah
|
---|
92 |
|
---|
93 | mov [bp+IDEPACK.bSectorCount], al
|
---|
94 | mov [bp+IDEPACK.bSectorCountHighExt], ah
|
---|
95 |
|
---|
96 | push bx
|
---|
97 | call Address_OldInt13hAddressToIdeAddress
|
---|
98 | call AccessDPT_GetDriveSelectByteToAL
|
---|
99 | or al, bh ; AL now has Drive and Head Select Byte
|
---|
100 | mov [bp+IDEPACK.bDrvAndHead], al
|
---|
101 | mov [bp+IDEPACK.bLbaLow], bl
|
---|
102 | mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
|
---|
103 | pop bx
|
---|
104 |
|
---|
105 | GetDeviceControlByteToIdepackAndStartTransfer:
|
---|
106 | call AccessDPT_GetDeviceControlByteToAL
|
---|
107 | mov [bp+IDEPACK.bDeviceControl], al
|
---|
108 | jmp Device_OutputCommandWithParameters
|
---|
109 |
|
---|
110 |
|
---|
111 | ;--------------------------------------------------------------------
|
---|
112 | ; Idepack_StoreNonExtParametersAndIssueCommandFromAL
|
---|
113 | ; Parameters:
|
---|
114 | ; BH: Timeout ticks
|
---|
115 | ; BL: IDE Status Register flag to wait after command
|
---|
116 | ; AL: IDE command to issue
|
---|
117 | ; AH: Parameter to Drive and Head Select Register (Head bits only)
|
---|
118 | ; DL: Parameter to Sector Count Register
|
---|
119 | ; DH: Parameter to LBA Low / Sector Number Register
|
---|
120 | ; CL: Parameter to LBA Middle / Cylinder Low Register
|
---|
121 | ; CH: Parameter to LBA High / Cylinder High Register
|
---|
122 | ; SI: Parameter to Features Register
|
---|
123 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
124 | ; SS:BP: Ptr to IDEPACK
|
---|
125 | ; Returns:
|
---|
126 | ; AH: INT 13h Error Code
|
---|
127 | ; CF: Cleared if success, Set if error
|
---|
128 | ; Corrupts registers:
|
---|
129 | ; AL, BX, CX, DX
|
---|
130 | ;--------------------------------------------------------------------
|
---|
131 | ALIGN JUMP_ALIGN
|
---|
132 | Idepack_StoreNonExtParametersAndIssueCommandFromAL:
|
---|
133 | mov [bp+IDEPACK.bFeatures], si
|
---|
134 | mov [bp+IDEPACK.bCommand], al
|
---|
135 | mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
|
---|
136 | mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
|
---|
137 | mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
|
---|
138 |
|
---|
139 | ; Drive and Head select byte
|
---|
140 | and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
|
---|
141 | call AccessDPT_GetDriveSelectByteToAL
|
---|
142 | or al, ah
|
---|
143 | mov [bp+IDEPACK.bDrvAndHead], al
|
---|
144 |
|
---|
145 | ; Device Control byte with interrupts disabled
|
---|
146 | call AccessDPT_GetDeviceControlByteToAL
|
---|
147 | or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
|
---|
148 | mov [bp+IDEPACK.bDeviceControl], al
|
---|
149 |
|
---|
150 | jmp Device_OutputCommandWithParameters
|
---|