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

Last change on this file since 607 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
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : Command and port direction functions for different device types.
[526]3
[376]4;
[526]5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[526]12;
[376]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.
[526]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[376]18;
[526]19
[150]20; Section containing code
21SECTION .text
22
[238]23
[294]24%macro TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE 1
[238]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
[150]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
[160]41; CS:BP: Ptr to IDEVARS for the controller
[150]42; Returns:
43; Nothing
44; Corrupts registers:
45; AX, BX, CX, DX
46;--------------------------------------------------------------------
[400]47%ifdef MODULE_SERIAL ; IDE + Serial
[150]48Device_FinalizeDPT:
[568]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
[150]56 jmp IdeDPT_Finalize
[294]57.FinalizeDptForSerialPortDevice:
[181]58 jmp SerialDPT_Finalize
[568]59%endif
[238]60
[400]61%else ; IDE
62 Device_FinalizeDPT EQU IdeDPT_Finalize
[175]63%endif
[150]64
[181]65
[150]66;--------------------------------------------------------------------
[507]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;--------------------------------------------------------------------
[150]87; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
88; Parameters:
89; BH: Drive Select byte for Drive and Head Select Register
[473]90; DX: Autodetected port (for devices that support autodetection)
[150]91; DS: Segment to RAMVARS
[480]92; ES:SI: Ptr to buffer to receive 512-byte IDE Information
[150]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:
[443]98; AL, BX, CX, DX, SI, DI, ES
[150]99;--------------------------------------------------------------------
[400]100%ifdef MODULE_SERIAL ; IDE + Serial
[150]101Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
[568]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
[150]108 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
109.IdentifyDriveFromSerialPort:
110 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[568]111%endif
[400]112
113%else ; IDE
114 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[175]115%endif
[150]116
[181]117
[150]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
[480]123; ES:SI: Ptr to buffer (for data transfer commands)
[150]124; DS:DI: Ptr to DPT (in RAMVARS segment)
125; SS:BP: Ptr to IDEPACK
126; Returns:
127; AH: INT 13h Error Code
[249]128; CX: Number of successfully transferred sectors (for transfer commands)
[150]129; CF: Cleared if success, Set if error
130; Corrupts registers:
[249]131; AL, BX, (CX), DX, (ES:SI for data transfer commands)
[150]132;--------------------------------------------------------------------
[400]133%ifdef MODULE_SERIAL ; IDE + Serial
134ALIGN JUMP_ALIGN
[150]135Device_OutputCommandWithParameters:
[568]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
[150]142 jmp IdeCommand_OutputWithParameters
[181]143
[150]144ALIGN JUMP_ALIGN
145.OutputCommandToSerialPort:
146 jmp SerialCommand_OutputWithParameters
[568]147%endif
[400]148
149%else ; IDE
150 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
[175]151%endif
[150]152
[181]153
[150]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;--------------------------------------------------------------------
[400]165%ifdef MODULE_SERIAL ; IDE + Serial
[150]166Device_SelectDrive:
[568]167 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
168%ifndef USE_386
169 jnz SHORT ReturnSuccessForSerialPort
[150]170 jmp IdeCommand_SelectDrive
[568]171%else
172 jz IdeCommand_SelectDrive
173 ; Fall to ReturnSuccessForSerialPort
174%endif
[181]175
[400]176%else ; IDE
177 Device_SelectDrive EQU IdeCommand_SelectDrive
[238]178%endif
179
180
181%ifdef MODULE_SERIAL
182ALIGN JUMP_ALIGN
[150]183ReturnSuccessForSerialPort:
184 xor ax, ax
185 ret
[175]186%endif
Note: See TracBrowser for help on using the repository browser.