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

Last change on this file since 615 was 596, checked in by Krister Nordvall, 6 years ago

Changes:

  • Made changes to HotkeyBar.asm to give the Boot Menu and Hotkey Bar a more consistent look. It will probably seem a bit strange at first to people used to the classic theme.
  • Added the missing parts of USE_NEC_V that should have been committed with the rest in r593.
  • Removed DEFINES_ALL_FEATURES from the BIOS makefile. It didn't work anymore and never really made sense anyway. Added all the official builds to 'make unused' instead which actually uncovered some unused code in the Tiny build.
  • XTIDECFG will no longer load color themes from unrecognized versions of the BIOS.
  • Other fixes in comments and some minor optimizations.
File size: 5.5 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for managing IDEPACK struct.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
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
34 sub sp, BYTE SIZE_OF_IDEPACK_WITHOUT_INTPACK
35 mov bp, sp
36 jmp ax
37
38
39;--------------------------------------------------------------------
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
50; CX: Number of successfully transferred sectors (for transfer commands)
51; CF: Cleared if success, Set if error
52; Corrupts registers:
53; AL, BX, (CX), DX, SI, ES
54;--------------------------------------------------------------------
55%ifdef MODULE_EBIOS
56ALIGN JUMP_ALIGN
57Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
58 mov al, [es:si+DAP.wSectorCount]
59 mov [bp+IDEPACK.bSectorCount], al
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
72 call AccessDPT_GetDriveSelectByteToAL
73 or al, ah
74 mov [bp+IDEPACK.bDrvAndHead], al
75
76 ; Load data buffer pointer to ES:SI
77 les si, [es:si+DAP.dwMemoryAddress]
78 jmp SHORT GetDeviceControlByteToIdepackAndStartTransfer
79%endif ; MODULE_EBIOS
80
81
82;--------------------------------------------------------------------
83; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
84; Parameters:
85; AH: IDE command to issue
86; AL: Number of sectors to transfer (for xfer commands)
87; BH: Timeout ticks
88; BL: IDE Status Register flag to wait after command
89; CH: Cylinder number, bits 7...0
90; CL: Bits 7...6: Cylinder number bits 9 and 8
91; Bits 5...0: Starting sector number (1...63)
92; DH: Starting head number (0...255)
93; DS:DI: Ptr to DPT (in RAMVARS segment)
94; ES:SI: Ptr to normalized data buffer (for xfer commands)
95; SS:BP: Ptr to IDEPACK (containing INTPACK)
96; Returns:
97; AH: INT 13h Error Code
98; CX: Number of successfully transferred sectors (for transfer commands)
99; CF: Cleared if success, Set if error
100; Corrupts registers:
101; AL, BX, (CX), DX
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
105 mov [bp+IDEPACK.bSectorCount], al
106 mov [bp+IDEPACK.bCommand], ah
107
108 push bx
109 call Address_OldInt13hAddressToIdeAddress
110 call AccessDPT_GetDriveSelectByteToAL
111 or al, bh ; AL now has Drive and Head Select Byte
112 mov [bp+IDEPACK.bDrvAndHead], al
113 mov [bp+IDEPACK.bLbaLow], bl
114 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
115 pop bx
116 ; Fall to GetDeviceControlByteToIdepackAndStartTransfer
117
118GetDeviceControlByteToIdepackAndStartTransfer:
119 call AccessDPT_GetDeviceControlByteToAL
120 mov [bp+IDEPACK.bDeviceControl], al
121 jmp Device_OutputCommandWithParameters
122
123
124;--------------------------------------------------------------------
125; Idepack_StoreNonExtParametersAndIssueCommandFromAL
126; Parameters:
127; BH: Timeout ticks
128; BL: IDE Status Register flag to wait after command
129; AL: IDE command to issue
130; AH: Parameter to Drive and Head Select Register (Head bits only)
131; DL: Parameter to Sector Count Register
132; DH: Parameter to LBA Low / Sector Number Register
133; CL: Parameter to LBA Middle / Cylinder Low Register
134; CH: Parameter to LBA High / Cylinder High Register
135; SI: Parameter to Features Register
136; DS:DI: Ptr to DPT (in RAMVARS segment)
137; SS:BP: Ptr to IDEPACK
138; Returns:
139; AH: INT 13h Error Code
140; CF: Cleared if success, Set if error
141; Corrupts registers:
142; AL, BX, CX, DX
143;--------------------------------------------------------------------
144ALIGN JUMP_ALIGN
145Idepack_StoreNonExtParametersAndIssueCommandFromAL:
146 mov [bp+IDEPACK.bFeatures], si
147 mov [bp+IDEPACK.bCommand], al
148 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
149 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
150
151 ; Drive and Head select byte
152 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
153 call AccessDPT_GetDriveSelectByteToAL
154 or al, ah
155 mov [bp+IDEPACK.bDrvAndHead], al
156
157 ; Device Control byte with interrupts disabled
158 mov BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
159
160 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.