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

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

Changes to XTIDE Universal BIOS:

  • XTIDE rev 2 and modded XTIDE rev 1 work again (fixed A0<->A3 swap when accessing Control Block Registers).
  • System INT 13h handler is no longer copied to INT 40h (testing if something uses INT 40h).
  • Removed controller hardware reset: now AH=0h and AH=Dh will only re-initialize drives (SB16 Tertiary and Quaternary IDE should now be safe to use when using Secondary IDE).
File size: 4.7 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : Command and port direction functions for different device types.
[376]3
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
[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:
[258]49 ; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine
[400]50 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice
[150]51 jmp IdeDPT_Finalize
[294]52.FinalizeDptForSerialPortDevice:
[181]53 jmp SerialDPT_Finalize
[238]54
[400]55%else ; IDE
56 Device_FinalizeDPT EQU IdeDPT_Finalize
[175]57%endif
[150]58
[181]59
[150]60;--------------------------------------------------------------------
61; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
62; Parameters:
63; BH: Drive Select byte for Drive and Head Select Register
[473]64; DX: Autodetected port (for devices that support autodetection)
[150]65; DS: Segment to RAMVARS
[480]66; ES:SI: Ptr to buffer to receive 512-byte IDE Information
[150]67; CS:BP: Ptr to IDEVARS
68; Returns:
69; AH: INT 13h Error Code
70; CF: Cleared if success, Set if error
71; Corrupts registers:
[443]72; AL, BX, CX, DX, SI, DI, ES
[150]73;--------------------------------------------------------------------
[400]74%ifdef MODULE_SERIAL ; IDE + Serial
[150]75Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
[400]76 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
[150]77 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
78.IdentifyDriveFromSerialPort:
79 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[400]80
81%else ; IDE
82 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[175]83%endif
[150]84
[181]85
[150]86;--------------------------------------------------------------------
87; Device_OutputCommandWithParameters
88; Parameters:
89; BH: Default system timer ticks for timeout (can be ignored)
90; BL: IDE Status Register bit to poll after command
[480]91; ES:SI: Ptr to buffer (for data transfer commands)
[150]92; DS:DI: Ptr to DPT (in RAMVARS segment)
93; SS:BP: Ptr to IDEPACK
94; Returns:
95; AH: INT 13h Error Code
[249]96; CX: Number of successfully transferred sectors (for transfer commands)
[150]97; CF: Cleared if success, Set if error
98; Corrupts registers:
[249]99; AL, BX, (CX), DX, (ES:SI for data transfer commands)
[150]100;--------------------------------------------------------------------
[400]101%ifdef MODULE_SERIAL ; IDE + Serial
102ALIGN JUMP_ALIGN
[150]103Device_OutputCommandWithParameters:
[294]104 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
[150]105 jmp IdeCommand_OutputWithParameters
[181]106
[150]107ALIGN JUMP_ALIGN
108.OutputCommandToSerialPort:
109 jmp SerialCommand_OutputWithParameters
[400]110
111%else ; IDE
112 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
[175]113%endif
[150]114
[181]115
[150]116;--------------------------------------------------------------------
117; Device_SelectDrive
118; Parameters:
119; DS:DI: Ptr to DPT (in RAMVARS segment)
120; SS:BP: Ptr to IDEPACK
121; Returns:
122; AH: INT 13h Error Code
123; CF: Cleared if success, Set if error
124; Corrupts registers:
125; AL, BX, CX, DX
126;--------------------------------------------------------------------
[400]127%ifdef MODULE_SERIAL ; IDE + Serial
[150]128Device_SelectDrive:
[400]129 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
[150]130 jmp IdeCommand_SelectDrive
[181]131
[400]132%else ; IDE
133 Device_SelectDrive EQU IdeCommand_SelectDrive
[238]134%endif
135
136
137%ifdef MODULE_SERIAL
138ALIGN JUMP_ALIGN
[150]139ReturnSuccessForSerialPort:
140 xor ax, ax
141 ret
[175]142%endif
Note: See TracBrowser for help on using the repository browser.