source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc@ 442

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

Changes to XTIDE Universal BIOS:

  • ATA ID validation now compares heads to correct maximum number of heads.
  • Added XTCF 8-bit mode transfer functions.
File size: 4.6 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Macros for accessing data port(s) on 8-bit
3; IDE controllers.
4
5;
6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
13;
14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17; GNU General Public License for more details.
18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
21%ifndef IDE_8BIT_INC
22%define IDE_8BIT_INC
23
24;--------------------------------------------------------------------
25; UNROLL_SECTORS_IN_CX_TO_DWORDS
26; UNROLL_SECTORS_IN_CX_TO_QWORDS
27; Parameters:
28; CX: Number of sectors in block
29; Returns:
30; CX: Number of DWORDs or QWORDs in block
31; Corrupts registers:
32; Nothing
33;--------------------------------------------------------------------
34%macro UNROLL_SECTORS_IN_CX_TO_DWORDS 0
35%ifdef USE_186
36 shl cx, 7
37%else
38 xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
39 shr cx, 1
40%endif
41%endmacro
42
43%macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
44%ifdef USE_186
45 shl cx, 6
46%else
47 UNROLL_SECTORS_IN_CX_TO_DWORDS
48 shr cx, 1
49%endif
50%endmacro
51
52
53;--------------------------------------------------------------------
54; Emulates INSW for XTIDE.
55;
56; XTIDE_INSW
57; Parameters:
58; BL: Bit mask for toggling XTIDE data low/high reg
59; DX: XTIDE Data Low Register address
60; ES:DI: Ptr to destination buffer
61; Returns:
62; ES:DI: Incremented/decremented for next word
63; Corrupts registers:
64; AL, FLAGS
65;--------------------------------------------------------------------
66%macro XTIDE_INSW 0
67%ifdef USE_186 ; INS instruction available
68 insb ; Load low byte from port DX to [ES:DI]
69 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
70 insb ; Load high byte from port DX to [ES:DI]
71 xor dl, bl ; Restore to IDE Data Register
72%else ; If 8088/8086
73 in al, dx ; Load low byte from port
74 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
75 stosb ; Store byte to [ES:DI]
76 in al, dx ; Load high byte from port
77 xor dl, bl ; Restore to IDE Data Register
78 stosb ; Store byte to [ES:DI]
79%endif
80%endmacro
81
82
83;--------------------------------------------------------------------
84; Emulates OUTSW for XTIDE.
85;
86; XTIDE_OUTSW
87; Parameters:
88; BL: Bit mask for toggling XTIDE data low/high reg
89; DX: XTIDE Data Low Register address
90; DS:SI: Ptr to source buffer
91; Returns:
92; SI: Incremented/decremented for next word
93; Corrupts registers:
94; AX, FLAGS
95;--------------------------------------------------------------------
96%macro XTIDE_OUTSW 0
97%ifdef USE_186 ; OUTS instruction available
98 lodsb ; Load low byte from [DS:SI] to AL
99 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
100 outsb ; Output high byte from [DS:SI]
101 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
102 out dx, al ; Output low byte from AL
103%else ; If 8088/8086
104 lodsw ; Load word from [DS:SI]
105 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
106 xchg al, ah ; => AL=high byte, AH=low byte
107 out dx, al ; Output high byte
108 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
109 mov al, ah ; Copy low byte to AL
110 out dx, al ; Output low byte
111%endif
112%endmacro
113
114
115;--------------------------------------------------------------------
116; Emulates OUTSW for modified XTIDE.
117;
118; XTIDE_MOD_OUTSW
119; Parameters:
120; DX: XTIDE Data Low Register address
121; DS:SI: Ptr to source buffer
122; Returns:
123; SI: Incremented/decremented for next word
124; Corrupts registers:
125; AX, FLAGS
126;--------------------------------------------------------------------
127%macro XTIDE_MOD_OUTSW 0
128%ifdef USE_186 ; OUTS instruction available
129 lodsb ; Load low byte from [DS:SI] to AL
130 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
131 outsb ; Output high byte from [DS:SI]
132 dec dx ; XTIDE Data High Reg to Data Low Reg
133 out dx, al ; Output low byte from AL
134%else ; If 8088/8086
135 lodsw ; Load word from [DS:SI]
136 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
137 xchg al, ah ; => AL=high byte, AH=low byte
138 out dx, al ; Output high byte
139 dec dx ; XTIDE Data High Reg to Data Low Reg
140 mov al, ah ; Copy low byte to AL
141 out dx, al ; Output low byte
142%endif
143%endmacro
144
145
146%endif ; IDE_8BIT_INC
Note: See TracBrowser for help on using the repository browser.