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

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

Changes to XTIDE Universal BIOS:

  • Hopefully this commit is successful. Sorry for the mess.
File size: 4.7 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
22
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;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
40 mov [bp+IDEPACK.bCommand], ah
41 mov ax, [es:si+DAP.wSectorCount]
42 mov [bp+IDEPACK.bSectorCount], al
43 mov [bp+IDEPACK.bSectorCountHighExt], ah ; Always zero
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
61
62;--------------------------------------------------------------------
[150]63; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
64; Parameters:
65; AH: IDE command to issue
66; AL: Number of sectors to transfer (1...255, 0=256)
67; BH: Timeout ticks
68; BL: IDE Status Register flag to wait after command
69; CH: Cylinder number, bits 7...0
70; CL: Bits 7...6: Cylinder number bits 9 and 8
71; Bits 5...0: Starting sector number (1...63)
72; DH: Starting head number (0...255)
73; ES:SI: Ptr to data buffer
74; DS:DI: Ptr to DPT (in RAMVARS segment)
75; SS:BP: Ptr to IDEPACK
76; Returns:
77; AH: INT 13h Error Code
78; CF: Cleared if success, Set if error
79; Corrupts registers:
80; AL, BX, CX, DX
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
84 mov [bp+IDEPACK.bSectorCount], al
85 mov [bp+IDEPACK.bCommand], ah
86 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
87
88 push bx
[155]89 call Address_OldInt13hAddressToIdeAddress
[150]90 call AccessDPT_GetDriveSelectByteToAL
91 or al, bh ; AL now has Drive and Head Select Byte
92 mov [bp+IDEPACK.bDrvAndHead], al
93 mov [bp+IDEPACK.bLbaLow], bl
94 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
95 pop bx
96
[165]97GetDeviceControlByteToIdepackAndStartTransfer:
[150]98 call AccessDPT_GetDeviceControlByteToAL
99 mov [bp+IDEPACK.bDeviceControl], al
[165]100 jmp Device_OutputCommandWithParameters
[150]101
102
103;--------------------------------------------------------------------
104; Idepack_StoreNonExtParametersAndIssueCommandFromAL
105; Parameters:
106; BH: Timeout ticks
107; BL: IDE Status Register flag to wait after command
108; AL: IDE command to issue
109; AH: Parameter to Drive and Head Select Register (Head bits only)
110; DL: Parameter to Sector Count Register
111; DH: Parameter to LBA Low / Sector Number Register
112; CL: Parameter to LBA Middle / Cylinder Low Register
113; CH: Parameter to LBA High / Cylinder High Register
114; SI: Parameter to Features Register
115; DS:DI: Ptr to DPT (in RAMVARS segment)
116; SS:BP: Ptr to IDEPACK
117; Returns:
118; AH: INT 13h Error Code
119; CF: Cleared if success, Set if error
120; Corrupts registers:
121; AL, BX, CX, DX
122;--------------------------------------------------------------------
123ALIGN JUMP_ALIGN
124Idepack_StoreNonExtParametersAndIssueCommandFromAL:
125 mov [bp+IDEPACK.bFeatures], si
126 mov [bp+IDEPACK.bCommand], al
127 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
128 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
129 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
130
131 ; Drive and Head select byte
132 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
133 call AccessDPT_GetDriveSelectByteToAL
134 or al, ah
135 mov [bp+IDEPACK.bDrvAndHead], al
136
137 ; Device Control byte with interrupts disabled
138 call AccessDPT_GetDeviceControlByteToAL
139 or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
140 mov [bp+IDEPACK.bDeviceControl], al
141
142 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.