source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm@ 560

Last change on this file since 560 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 5.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Command and port direction functions for different device types.
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%macro TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE 1
25 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
26 jnz SHORT %1
27%endmacro
28
29%macro CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF 2
30 cmp BYTE [cs:bp+IDEVARS.bDevice], %1
31 je SHORT %2
32%endmacro
33
34
35
36;--------------------------------------------------------------------
37; Device_FinalizeDPT
38; Parameters:
39; DS:DI: Ptr to Disk Parameter Table
40; ES:SI: Ptr to 512-byte ATA information read from the drive
41; CS:BP: Ptr to IDEVARS for the controller
42; Returns:
43; Nothing
44; Corrupts registers:
45; AX, BX, CX, DX
46;--------------------------------------------------------------------
47%ifdef MODULE_SERIAL ; IDE + Serial
48Device_FinalizeDPT:
49 ; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine
50 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice
51 jmp IdeDPT_Finalize
52.FinalizeDptForSerialPortDevice:
53 jmp SerialDPT_Finalize
54
55%else ; IDE
56 Device_FinalizeDPT EQU IdeDPT_Finalize
57%endif
58
59
60;--------------------------------------------------------------------
61; Device_ResetMasterAndSlaveController
62; Parameters:
63; DS:DI: Ptr to DPT (in RAMVARS segment)
64; Returns:
65; AH: INT 13h Error Code
66; CF: Cleared if success, Set if error
67; Corrupts registers:
68; AL, BX, CX, DX
69;--------------------------------------------------------------------
70%ifdef MODULE_SERIAL ; IDE + Serial
71Device_ResetMasterAndSlaveController:
72 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
73 jmp IdeCommand_ResetMasterAndSlaveController
74
75%else ; IDE
76 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
77%endif
78
79
80;--------------------------------------------------------------------
81; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
82; Parameters:
83; BH: Drive Select byte for Drive and Head Select Register
84; DX: Autodetected port (for devices that support autodetection)
85; DS: Segment to RAMVARS
86; ES:SI: Ptr to buffer to receive 512-byte IDE Information
87; CS:BP: Ptr to IDEVARS
88; Returns:
89; AH: INT 13h Error Code
90; CF: Cleared if success, Set if error
91; Corrupts registers:
92; AL, BX, CX, DX, SI, DI, ES
93;--------------------------------------------------------------------
94%ifdef MODULE_SERIAL ; IDE + Serial
95Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
96 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
97 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
98.IdentifyDriveFromSerialPort:
99 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
100
101%else ; IDE
102 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
103%endif
104
105
106;--------------------------------------------------------------------
107; Device_OutputCommandWithParameters
108; Parameters:
109; BH: Default system timer ticks for timeout (can be ignored)
110; BL: IDE Status Register bit to poll after command
111; ES:SI: Ptr to buffer (for data transfer commands)
112; DS:DI: Ptr to DPT (in RAMVARS segment)
113; SS:BP: Ptr to IDEPACK
114; Returns:
115; AH: INT 13h Error Code
116; CX: Number of successfully transferred sectors (for transfer commands)
117; CF: Cleared if success, Set if error
118; Corrupts registers:
119; AL, BX, (CX), DX, (ES:SI for data transfer commands)
120;--------------------------------------------------------------------
121%ifdef MODULE_SERIAL ; IDE + Serial
122ALIGN JUMP_ALIGN
123Device_OutputCommandWithParameters:
124 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
125 jmp IdeCommand_OutputWithParameters
126
127ALIGN JUMP_ALIGN
128.OutputCommandToSerialPort:
129 jmp SerialCommand_OutputWithParameters
130
131%else ; IDE
132 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
133%endif
134
135
136;--------------------------------------------------------------------
137; Device_SelectDrive
138; Parameters:
139; DS:DI: Ptr to DPT (in RAMVARS segment)
140; SS:BP: Ptr to IDEPACK
141; Returns:
142; AH: INT 13h Error Code
143; CF: Cleared if success, Set if error
144; Corrupts registers:
145; AL, BX, CX, DX
146;--------------------------------------------------------------------
147%ifdef MODULE_SERIAL ; IDE + Serial
148Device_SelectDrive:
149 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
150 jmp IdeCommand_SelectDrive
151
152%else ; IDE
153 Device_SelectDrive EQU IdeCommand_SelectDrive
154%endif
155
156
157%ifdef MODULE_SERIAL
158ALIGN JUMP_ALIGN
159ReturnSuccessForSerialPort:
160 xor ax, ax
161 ret
162%endif
Note: See TracBrowser for help on using the repository browser.