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

Last change on this file since 600 was 568, checked in by krille_n_@…, 10 years ago

Changes:

  • SerDrive: Using named pipe mode (serdrive -p) now works under Windows XP/2000/Server 2003.
  • checksum.pl: Added a compatibility fix for 3Com 3C503 cards.
  • XTIDECFG will now scan every possible segment address to find and load the BIOS and/or its settings from EEPROM. This should simplify things for people using combined option ROMs.
  • Fixed a bug from r521 in BootSector.asm where the BIOS would not display a timeout error if it failed to load the boot sector from harddrive.
  • Fixed a bug from r541 in CompatibleDPT.asm where CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI would generate an invalid checksum in the DPTE.
  • Optimizations and other fixes.
File size: 5.9 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 BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
51%ifdef USE_386
52 jne IdeDPT_Finalize
53 jmp SerialDPT_Finalize
54%else
55 je SHORT .FinalizeDptForSerialPortDevice
56 jmp IdeDPT_Finalize
57.FinalizeDptForSerialPortDevice:
58 jmp SerialDPT_Finalize
59%endif
60
61%else ; IDE
62 Device_FinalizeDPT EQU IdeDPT_Finalize
63%endif
64
65
66;--------------------------------------------------------------------
67; Device_ResetMasterAndSlaveController
68; Parameters:
69; DS:DI: Ptr to DPT (in RAMVARS segment)
70; Returns:
71; AH: INT 13h Error Code
72; CF: Cleared if success, Set if error
73; Corrupts registers:
74; AL, BX, CX, DX
75;--------------------------------------------------------------------
76%ifdef MODULE_SERIAL ; IDE + Serial
77Device_ResetMasterAndSlaveController:
78 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
79 jmp IdeCommand_ResetMasterAndSlaveController
80
81%else ; IDE
82 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
83%endif
84
85
86;--------------------------------------------------------------------
87; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
88; Parameters:
89; BH: Drive Select byte for Drive and Head Select Register
90; DX: Autodetected port (for devices that support autodetection)
91; DS: Segment to RAMVARS
92; ES:SI: Ptr to buffer to receive 512-byte IDE Information
93; CS:BP: Ptr to IDEVARS
94; Returns:
95; AH: INT 13h Error Code
96; CF: Cleared if success, Set if error
97; Corrupts registers:
98; AL, BX, CX, DX, SI, DI, ES
99;--------------------------------------------------------------------
100%ifdef MODULE_SERIAL ; IDE + Serial
101Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
102 cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
103%ifdef USE_386
104 jne IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
105 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
106%else
107 je SHORT .IdentifyDriveFromSerialPort
108 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
109.IdentifyDriveFromSerialPort:
110 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
111%endif
112
113%else ; IDE
114 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
115%endif
116
117
118;--------------------------------------------------------------------
119; Device_OutputCommandWithParameters
120; Parameters:
121; BH: Default system timer ticks for timeout (can be ignored)
122; BL: IDE Status Register bit to poll after command
123; ES:SI: Ptr to buffer (for data transfer commands)
124; DS:DI: Ptr to DPT (in RAMVARS segment)
125; SS:BP: Ptr to IDEPACK
126; Returns:
127; AH: INT 13h Error Code
128; CX: Number of successfully transferred sectors (for transfer commands)
129; CF: Cleared if success, Set if error
130; Corrupts registers:
131; AL, BX, (CX), DX, (ES:SI for data transfer commands)
132;--------------------------------------------------------------------
133%ifdef MODULE_SERIAL ; IDE + Serial
134ALIGN JUMP_ALIGN
135Device_OutputCommandWithParameters:
136 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
137%ifdef USE_386
138 jz IdeCommand_OutputWithParameters
139 jmp SerialCommand_OutputWithParameters
140%else
141 jnz SHORT .OutputCommandToSerialPort
142 jmp IdeCommand_OutputWithParameters
143
144ALIGN JUMP_ALIGN
145.OutputCommandToSerialPort:
146 jmp SerialCommand_OutputWithParameters
147%endif
148
149%else ; IDE
150 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
151%endif
152
153
154;--------------------------------------------------------------------
155; Device_SelectDrive
156; Parameters:
157; DS:DI: Ptr to DPT (in RAMVARS segment)
158; SS:BP: Ptr to IDEPACK
159; Returns:
160; AH: INT 13h Error Code
161; CF: Cleared if success, Set if error
162; Corrupts registers:
163; AL, BX, CX, DX
164;--------------------------------------------------------------------
165%ifdef MODULE_SERIAL ; IDE + Serial
166Device_SelectDrive:
167 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
168%ifndef USE_386
169 jnz SHORT ReturnSuccessForSerialPort
170 jmp IdeCommand_SelectDrive
171%else
172 jz IdeCommand_SelectDrive
173 ; Fall to ReturnSuccessForSerialPort
174%endif
175
176%else ; IDE
177 Device_SelectDrive EQU IdeCommand_SelectDrive
178%endif
179
180
181%ifdef MODULE_SERIAL
182ALIGN JUMP_ALIGN
183ReturnSuccessForSerialPort:
184 xor ax, ax
185 ret
186%endif
Note: See TracBrowser for help on using the repository browser.