source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm@ 389

Last change on this file since 389 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 3.2 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : IDE Register I/O functions.
3
[376]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
23;--------------------------------------------------------------------
[332]24; IdeIO_OutputALtoIdeControlBlockRegisterInDL
[160]25; IdeIO_OutputALtoIdeRegisterInDL
[150]26; Parameters:
27; AL: Byte to output
[332]28; DL: IDE Control Block Register (IdeIO_OutputALtoIdeControlBlockRegisterInDL)
29; IDE Register (IdeIO_OutputALtoIdeRegisterInDL)
[160]30; DS:DI: Ptr to DPT (in RAMVARS segment)
[150]31; Returns:
32; Nothing
33; Corrupts registers:
[160]34; BX, DX
[150]35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
[332]37IdeIO_OutputALtoIdeControlBlockRegisterInDL:
38 mov bl, IDEVARS.wPortCtrl
39 SKIP2B f ; cmp ax, <next instruction>
40 ; Fall to IdeIO_OutputALtoIdeRegisterInDL
41
[160]42IdeIO_OutputALtoIdeRegisterInDL:
[181]43 mov bl, IDEVARS.wPort
[160]44 call GetPortToDXandTranslateA0andA3ifNecessary
[150]45 out dx, al
46 ret
47
48
49;--------------------------------------------------------------------
[160]50; IdeIO_InputToALfromIdeRegisterInDL
[150]51; Parameters:
[160]52; DL: IDE Register
53; DS:DI: Ptr to DPT (in RAMVARS segment)
[150]54; Returns:
55; AL: Inputted byte
56; Corrupts registers:
[160]57; BX, DX
[150]58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
[160]60IdeIO_InputToALfromIdeRegisterInDL:
[181]61 mov bl, IDEVARS.wPort
[160]62 call GetPortToDXandTranslateA0andA3ifNecessary
[150]63 in al, dx
64 ret
[160]65
66
67;--------------------------------------------------------------------
68; GetPortToDXandTranslateA0andA3ifNecessary
69; Parameters:
[181]70; BL: Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl)
[160]71; DL: IDE Register
72; DS:DI: Ptr to DPT (in RAMVARS segment)
73; Returns:
74; DX: Source/Destination Port
75; Corrupts registers:
76; BX
77;--------------------------------------------------------------------
78ALIGN JUMP_ALIGN
79GetPortToDXandTranslateA0andA3ifNecessary:
[181]80 xor bh, bh
[332]81 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address
[160]82 xor dh, dh ; DX now has IDE register offset
83 add dx, [cs:bx]
84 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
85 jz SHORT .ReturnPortInDX
86
87 ; Exchange address lines A0 and A3 from DL
88 mov bl, dl
89 mov bh, MASK_A3_AND_A0_ADDRESS_LINES
90 and bh, bl ; BH = 0, 1, 8 or 9, we can ignore 0 and 9
91 jz SHORT .ReturnPortInDX ; Jump out since DH is 0
92 xor bh, MASK_A3_AND_A0_ADDRESS_LINES
93 jz SHORT .ReturnPortInDX ; Jump out since DH was 9
94 and dl, ~MASK_A3_AND_A0_ADDRESS_LINES
95 or dl, bh ; Address lines now reversed
96.ReturnPortInDX:
97 ret
Note: See TracBrowser for help on using the repository browser.