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

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

Changes to XTIDE Universal BIOS:

  • Number of successfully transferred sectors is now returned by all transfer functions (instead of requested sector count).
  • Added INT 19h handler for proper reboot.
File size: 5.0 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; CX: Number of successfully transferred sectors (for transfer commands)
35; CF: Cleared if success, Set if error
36; Corrupts registers:
37; AL, BX, (CX), DX, SI, ES
38;--------------------------------------------------------------------
39%ifdef MODULE_EBIOS
40ALIGN JUMP_ALIGN
41Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
42 mov al, [es:si+DAP.wSectorCount]
43 mov [bp+IDEPACK.bSectorCount], al
44 mov [bp+IDEPACK.bCommand], 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
60 ; Normalize data buffer pointer to ES:SI
61 mov ax, [es:si+DAP.wOffset]
62 mov cx, ax
63 eSHR_IM ax, 4 ; Divide offset by 16
64 add ax, [es:si+DAP.wSegment] ; Add segment
65 mov es, ax ; Segment normalized
66 mov si, cx
67 and si, BYTE 0Fh ; Offset normalized
68 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
69%endif
70
71
72;--------------------------------------------------------------------
73; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
74; Parameters:
75; AH: IDE command to issue
76; AL: Number of sectors to transfer (for xfer commands)
77; BH: Timeout ticks
78; BL: IDE Status Register flag to wait after command
79; CH: Cylinder number, bits 7...0
80; CL: Bits 7...6: Cylinder number bits 9 and 8
81; Bits 5...0: Starting sector number (1...63)
82; DH: Starting head number (0...255)
83; DS:DI: Ptr to DPT (in RAMVARS segment)
84; ES:SI: Ptr to normalized data buffer (for xfer commands)
85; SS:BP: Ptr to IDEPACK (containing INTPACK)
86; Returns:
87; AH: INT 13h Error Code
88; CX: Number of successfully transferred sectors (for transfer commands)
89; CF: Cleared if success, Set if error
90; Corrupts registers:
91; AL, BX, (CX), DX
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
95 mov [bp+IDEPACK.bSectorCount], al
96 mov [bp+IDEPACK.bCommand], ah
97
98 push bx
99 call Address_OldInt13hAddressToIdeAddress
100 call AccessDPT_GetDriveSelectByteToAL
101 or al, bh ; AL now has Drive and Head Select Byte
102 mov [bp+IDEPACK.bDrvAndHead], al
103 mov [bp+IDEPACK.bLbaLow], bl
104 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
105 pop bx
106
107GetDeviceControlByteToIdepackAndStartTransfer:
108 call AccessDPT_GetDeviceControlByteToAL
109 mov [bp+IDEPACK.bDeviceControl], al
110 jmp Device_OutputCommandWithParameters
111
112
113;--------------------------------------------------------------------
114; Idepack_StoreNonExtParametersAndIssueCommandFromAL
115; Parameters:
116; BH: Timeout ticks
117; BL: IDE Status Register flag to wait after command
118; AL: IDE command to issue
119; AH: Parameter to Drive and Head Select Register (Head bits only)
120; DL: Parameter to Sector Count Register
121; DH: Parameter to LBA Low / Sector Number Register
122; CL: Parameter to LBA Middle / Cylinder Low Register
123; CH: Parameter to LBA High / Cylinder High Register
124; SI: Parameter to Features Register
125; DS:DI: Ptr to DPT (in RAMVARS segment)
126; SS:BP: Ptr to IDEPACK
127; Returns:
128; AH: INT 13h Error Code
129; CF: Cleared if success, Set if error
130; Corrupts registers:
131; AL, BX, CX, DX
132;--------------------------------------------------------------------
133ALIGN JUMP_ALIGN
134Idepack_StoreNonExtParametersAndIssueCommandFromAL:
135 mov [bp+IDEPACK.bFeatures], si
136 mov [bp+IDEPACK.bCommand], al
137 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
138 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
139
140 ; Drive and Head select byte
141 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
142 call AccessDPT_GetDriveSelectByteToAL
143 or al, ah
144 mov [bp+IDEPACK.bDrvAndHead], al
145
146 ; Device Control byte with interrupts disabled
147 call AccessDPT_GetDeviceControlByteToAL
148 or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
149 mov [bp+IDEPACK.bDeviceControl], al
150
151 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.