source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm@ 220

Last change on this file since 220 was 218, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Number of sectors to transfer is now limited to 1-128 for old INT 13h functions.
File size: 4.7 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for managing IDEPACK struct.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Idepack_FakeToSSBP
9; Parameters:
10; Nothing
11; Returns:
12; SS:BP: Ptr to IDEPACK
13; Corrupts registers:
14; AX
15;--------------------------------------------------------------------
16Idepack_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
39ALIGN JUMP_ALIGN
40Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
41 mov [bp+IDEPACK.bCommand], ah
42 mov al, [es:si+DAP.bSectorCount]
43 mov [bp+IDEPACK.bSectorCount], al
44
45 mov al, [es:si+DAP.qwLBA] ; LBA byte 0
46 mov [bp+IDEPACK.bLbaLow], al
47 mov ax, [es:si+DAP.qwLBA+1] ; LBA bytes 1 and 2
48 mov [bp+IDEPACK.wLbaMiddleAndHigh], ax
49 mov ah, [es:si+DAP.qwLBA+3] ; LBA byte 3, LBA28 bits 24...27
50 mov [bp+IDEPACK.bLbaLowExt], ah
51 mov cx, [es:si+DAP.qwLBA+4] ; LBA bytes 4 and 5
52 mov [bp+IDEPACK.wLbaMiddleAndHighExt], cx
53
54 and ah, 0Fh ; Limit bits for LBA28
55 call AccessDPT_GetDriveSelectByteToAL
56 or al, ah
57 mov [bp+IDEPACK.bDrvAndHead], al
58 les si, [es:si+DAP.dwMemoryAddress]
59 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
60%endif
61
62
63;--------------------------------------------------------------------
64; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
65; Parameters:
66; AH: IDE command to issue
67; AL: Number of sectors to transfer
68; BH: Timeout ticks
69; BL: IDE Status Register flag to wait after command
70; CH: Cylinder number, bits 7...0
71; CL: Bits 7...6: Cylinder number bits 9 and 8
72; Bits 5...0: Starting sector number (1...63)
73; DH: Starting head number (0...255)
74; DS:DI: Ptr to DPT (in RAMVARS segment)
75; SS:BP: Ptr to IDEPACK (containing INTPACK)
76; Parameters on INTPACK:
77; ES:BX: Ptr to data buffer
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;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
86 mov [bp+IDEPACK.bSectorCount], al
87 mov [bp+IDEPACK.bCommand], ah
88
89 push bx
90 call PrepareBuffer_ToESSIforOldInt13hTransfer
91 call Address_OldInt13hAddressToIdeAddress
92 call AccessDPT_GetDriveSelectByteToAL
93 or al, bh ; AL now has Drive and Head Select Byte
94 mov [bp+IDEPACK.bDrvAndHead], al
95 mov [bp+IDEPACK.bLbaLow], bl
96 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
97 pop bx
98
99GetDeviceControlByteToIdepackAndStartTransfer:
100 call AccessDPT_GetDeviceControlByteToAL
101 mov [bp+IDEPACK.bDeviceControl], al
102 jmp Device_OutputCommandWithParameters
103
104
105;--------------------------------------------------------------------
106; Idepack_StoreNonExtParametersAndIssueCommandFromAL
107; Parameters:
108; BH: Timeout ticks
109; BL: IDE Status Register flag to wait after command
110; AL: IDE command to issue
111; AH: Parameter to Drive and Head Select Register (Head bits only)
112; DL: Parameter to Sector Count Register
113; DH: Parameter to LBA Low / Sector Number Register
114; CL: Parameter to LBA Middle / Cylinder Low Register
115; CH: Parameter to LBA High / Cylinder High Register
116; SI: Parameter to Features Register
117; DS:DI: Ptr to DPT (in RAMVARS segment)
118; SS:BP: Ptr to IDEPACK
119; Returns:
120; AH: INT 13h Error Code
121; CF: Cleared if success, Set if error
122; Corrupts registers:
123; AL, BX, CX, DX
124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
126Idepack_StoreNonExtParametersAndIssueCommandFromAL:
127 mov [bp+IDEPACK.bFeatures], si
128 mov [bp+IDEPACK.bCommand], al
129 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
130 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
131
132 ; Drive and Head select byte
133 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
134 call AccessDPT_GetDriveSelectByteToAL
135 or al, ah
136 mov [bp+IDEPACK.bDrvAndHead], al
137
138 ; Device Control byte with interrupts disabled
139 call AccessDPT_GetDeviceControlByteToAL
140 or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
141 mov [bp+IDEPACK.bDeviceControl], al
142
143 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.