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

Last change on this file since 478 was 477, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Added non-working DMA transfer code.
File size: 6.1 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : Functions for managing IDEPACK struct.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[150]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Idepack_FakeToSSBP
25; Parameters:
26; Nothing
27; Returns:
28; SS:BP: Ptr to IDEPACK
29; Corrupts registers:
30; AX
31;--------------------------------------------------------------------
32Idepack_FakeToSSBP:
33 pop ax
[443]34 sub sp, BYTE SIZE_OF_IDEPACK_WITHOUT_INTPACK
[150]35 mov bp, sp
36 jmp ax
37
[181]38
[150]39;--------------------------------------------------------------------
[165]40; Idepack_ConvertDapToIdepackAndIssueCommandFromAH
41; Parameters:
42; AH: IDE command to issue
43; BH: Timeout ticks
44; BL: IDE Status Register flag to wait after command
45; DS:DI: Ptr to DPT (in RAMVARS segment)
46; ES:SI: Ptr to DAP (EBIOS Disk Address Packet)
47; SS:BP: Ptr to IDEPACK
48; Returns:
49; AH: INT 13h Error Code
[249]50; CX: Number of successfully transferred sectors (for transfer commands)
[165]51; CF: Cleared if success, Set if error
52; Corrupts registers:
[249]53; AL, BX, (CX), DX, SI, ES
[165]54;--------------------------------------------------------------------
[181]55%ifdef MODULE_EBIOS
[165]56ALIGN JUMP_ALIGN
57Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
[224]58 mov al, [es:si+DAP.wSectorCount]
[221]59 mov [bp+IDEPACK.bSectorCount], al
[165]60 mov [bp+IDEPACK.bCommand], ah
61
62 mov al, [es:si+DAP.qwLBA] ; LBA byte 0
63 mov [bp+IDEPACK.bLbaLow], al
64 mov ax, [es:si+DAP.qwLBA+1] ; LBA bytes 1 and 2
65 mov [bp+IDEPACK.wLbaMiddleAndHigh], ax
66 mov ah, [es:si+DAP.qwLBA+3] ; LBA byte 3, LBA28 bits 24...27
67 mov [bp+IDEPACK.bLbaLowExt], ah
68 mov cx, [es:si+DAP.qwLBA+4] ; LBA bytes 4 and 5
69 mov [bp+IDEPACK.wLbaMiddleAndHighExt], cx
70
71 and ah, 0Fh ; Limit bits for LBA28
[421]72 call AccessDPT_GetDriveSelectByteForEbiosToAL
[165]73 or al, ah
74 mov [bp+IDEPACK.bDrvAndHead], al
[221]75
76 ; Normalize data buffer pointer to ES:SI
[477]77%ifdef MODULE_8BIT_IDE
78 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
79 jne SHORT .NormalizeForSmallestPossibleOffset
80
81 ; DMA transfers do not need to normalize pointer
82 ; (it will be converted to physical address in IdeDmaTransfer.asm)
83 les si, [es:si+DAP.dwMemoryAddress]
84 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
85%endif ; MODULE_8BIT_IDE
86
87.NormalizeForSmallestPossibleOffset:
[224]88 mov ax, [es:si+DAP.wOffset]
[221]89 mov cx, ax
90 eSHR_IM ax, 4 ; Divide offset by 16
[224]91 add ax, [es:si+DAP.wSegment] ; Add segment
[221]92 mov es, ax ; Segment normalized
93 mov si, cx
94 and si, BYTE 0Fh ; Offset normalized
[165]95 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
[421]96%endif ; MODULE_EBIOS
[165]97
[181]98
[165]99;--------------------------------------------------------------------
[150]100; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
101; Parameters:
102; AH: IDE command to issue
[221]103; AL: Number of sectors to transfer (for xfer commands)
[150]104; BH: Timeout ticks
105; BL: IDE Status Register flag to wait after command
106; CH: Cylinder number, bits 7...0
107; CL: Bits 7...6: Cylinder number bits 9 and 8
108; Bits 5...0: Starting sector number (1...63)
109; DH: Starting head number (0...255)
110; DS:DI: Ptr to DPT (in RAMVARS segment)
[221]111; ES:SI: Ptr to normalized data buffer (for xfer commands)
[218]112; SS:BP: Ptr to IDEPACK (containing INTPACK)
[150]113; Returns:
114; AH: INT 13h Error Code
[249]115; CX: Number of successfully transferred sectors (for transfer commands)
[150]116; CF: Cleared if success, Set if error
117; Corrupts registers:
[249]118; AL, BX, (CX), DX
[150]119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
[218]122 mov [bp+IDEPACK.bSectorCount], al
[169]123 mov [bp+IDEPACK.bCommand], ah
[181]124
[150]125 push bx
[155]126 call Address_OldInt13hAddressToIdeAddress
[421]127 call AccessDPT_GetDriveSelectByteForOldInt13hToAL
[150]128 or al, bh ; AL now has Drive and Head Select Byte
129 mov [bp+IDEPACK.bDrvAndHead], al
130 mov [bp+IDEPACK.bLbaLow], bl
131 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
132 pop bx
133
[165]134GetDeviceControlByteToIdepackAndStartTransfer:
[150]135 call AccessDPT_GetDeviceControlByteToAL
136 mov [bp+IDEPACK.bDeviceControl], al
[181]137 jmp Device_OutputCommandWithParameters
[150]138
139
140;--------------------------------------------------------------------
141; Idepack_StoreNonExtParametersAndIssueCommandFromAL
142; Parameters:
143; BH: Timeout ticks
144; BL: IDE Status Register flag to wait after command
145; AL: IDE command to issue
146; AH: Parameter to Drive and Head Select Register (Head bits only)
147; DL: Parameter to Sector Count Register
148; DH: Parameter to LBA Low / Sector Number Register
149; CL: Parameter to LBA Middle / Cylinder Low Register
150; CH: Parameter to LBA High / Cylinder High Register
151; SI: Parameter to Features Register
152; DS:DI: Ptr to DPT (in RAMVARS segment)
153; SS:BP: Ptr to IDEPACK
154; Returns:
155; AH: INT 13h Error Code
156; CF: Cleared if success, Set if error
157; Corrupts registers:
158; AL, BX, CX, DX
159;--------------------------------------------------------------------
160ALIGN JUMP_ALIGN
161Idepack_StoreNonExtParametersAndIssueCommandFromAL:
162 mov [bp+IDEPACK.bFeatures], si
163 mov [bp+IDEPACK.bCommand], al
164 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
165 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
166
167 ; Drive and Head select byte
168 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
[421]169 call AccessDPT_GetDriveSelectByteForOldInt13hToAL
[150]170 or al, ah
171 mov [bp+IDEPACK.bDrvAndHead], al
172
173 ; Device Control byte with interrupts disabled
[443]174 mov BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
[150]175
176 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.