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

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

Changes to XTIDE Universal BIOS:

  • EBIOS functions now work again (sector count was lost).
File size: 4.9 KB
RevLine 
[150]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
[158]18 sub sp, BYTE EXTRA_BYTES_FOR_INTPACK
[150]19 mov bp, sp
20 jmp ax
21
[181]22
[150]23;--------------------------------------------------------------------
[165]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;--------------------------------------------------------------------
[181]38%ifdef MODULE_EBIOS
[165]39ALIGN JUMP_ALIGN
40Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
[224]41 mov al, [es:si+DAP.wSectorCount]
[221]42 mov [bp+IDEPACK.bSectorCount], al
[165]43 mov [bp+IDEPACK.bCommand], ah
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
[221]58
59 ; Normalize data buffer pointer to ES:SI
[224]60 mov ax, [es:si+DAP.wOffset]
[221]61 mov cx, ax
62 eSHR_IM ax, 4 ; Divide offset by 16
[224]63 add ax, [es:si+DAP.wSegment] ; Add segment
[221]64 mov es, ax ; Segment normalized
65 mov si, cx
66 and si, BYTE 0Fh ; Offset normalized
[165]67 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
[176]68%endif
[165]69
[181]70
[165]71;--------------------------------------------------------------------
[150]72; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
73; Parameters:
74; AH: IDE command to issue
[221]75; AL: Number of sectors to transfer (for xfer commands)
[150]76; BH: Timeout ticks
77; BL: IDE Status Register flag to wait after command
78; CH: Cylinder number, bits 7...0
79; CL: Bits 7...6: Cylinder number bits 9 and 8
80; Bits 5...0: Starting sector number (1...63)
81; DH: Starting head number (0...255)
82; DS:DI: Ptr to DPT (in RAMVARS segment)
[221]83; ES:SI: Ptr to normalized data buffer (for xfer commands)
[218]84; SS:BP: Ptr to IDEPACK (containing INTPACK)
[150]85; Returns:
86; AH: INT 13h Error Code
87; CF: Cleared if success, Set if error
88; Corrupts registers:
89; AL, BX, CX, DX
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
[218]93 mov [bp+IDEPACK.bSectorCount], al
[169]94 mov [bp+IDEPACK.bCommand], ah
[181]95
[150]96 push bx
[155]97 call Address_OldInt13hAddressToIdeAddress
[150]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
[165]105GetDeviceControlByteToIdepackAndStartTransfer:
[150]106 call AccessDPT_GetDeviceControlByteToAL
107 mov [bp+IDEPACK.bDeviceControl], al
[181]108 jmp Device_OutputCommandWithParameters
[150]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;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132Idepack_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
138 ; Drive and Head select byte
139 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
140 call AccessDPT_GetDriveSelectByteToAL
141 or al, ah
142 mov [bp+IDEPACK.bDrvAndHead], al
143
144 ; Device Control byte with interrupts disabled
145 call AccessDPT_GetDeviceControlByteToAL
146 or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
147 mov [bp+IDEPACK.bDeviceControl], al
148
149 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.