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

Last change on this file since 510 was 491, checked in by krille_n_@…, 12 years ago

Changes:

  • Added a new define (USE_UNDOC_INTEL) that enables optimizations possible by using undocumented instructions available on all Intel processors and truly compatible clones. AFAIK the only exceptions are the NEC V-series and the Sony CXQ70108 processors so this option should be safe for use on the AT builds.
  • Building BIOSDRVS or the BIOS without MODULE_STRINGS_COMPRESSED would fail due to the recent code exclusions so I changed them a bit. Also fixed the mistaken change to Main.asm
  • Changed the Tandy specific info in Configuration_FullMode.txt so it matches the info in the Wiki.
  • Optimizations and fixes in general.
File size: 4.9 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; UNROLL_SECTORS_IN_CX_TO_OWORDS
28; Parameters:
29; CX: Number of sectors in block
30; Returns:
31; CX: Number of DWORDs, QWORDs or OWORDs in block
32; Corrupts registers:
33; Nothing
34;--------------------------------------------------------------------
35%macro UNROLL_SECTORS_IN_CX_TO_DWORDS 0
36%ifdef USE_186
37 shl cx, 7
38%else
39 xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
40 shr cx, 1
41%endif
42%endmacro
43
44%macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
45%ifdef USE_186
46 shl cx, 6
47%else
48 UNROLL_SECTORS_IN_CX_TO_DWORDS
49 shr cx, 1
50%endif
51%endmacro
52
53%macro UNROLL_SECTORS_IN_CX_TO_OWORDS 0
54%ifdef USE_186
55 shl cx, 5
56%else
57; UNROLL_SECTORS_IN_CX_TO_QWORDS
58; shr cx, 1
59 mov ch, cl ; 2 bytes shorter but possibly slower
60 mov cl, 3
61 shr cx, cl
62%endif
63%endmacro
64
65
66;--------------------------------------------------------------------
67; Emulates INSW for XTIDE.
68;
69; XTIDE_INSW
70; Parameters:
71; BL: Bit mask for toggling XTIDE data low/high reg
72; DX: XTIDE Data Low Register address
73; ES:DI: Ptr to destination buffer
74; Returns:
75; ES:DI: Incremented/decremented for next word
76; Corrupts registers:
77; AL, FLAGS
78;--------------------------------------------------------------------
79%macro XTIDE_INSW 0
80%ifdef USE_186 ; INS instruction available
81 insb ; Load low byte from port DX to [ES:DI]
82 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
83 insb ; Load high byte from port DX to [ES:DI]
84 xor dl, bl ; Restore to IDE Data Register
85%else ; If 8088/8086
86 in al, dx ; Load low byte from port
87 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
88 stosb ; Store byte to [ES:DI]
89 in al, dx ; Load high byte from port
90 xor dl, bl ; Restore to IDE Data Register
91 stosb ; Store byte to [ES:DI]
92%endif
93%endmacro
94
95
96;--------------------------------------------------------------------
97; Emulates OUTSW for XTIDE.
98;
99; XTIDE_OUTSW
100; Parameters:
101; BL: Bit mask for toggling XTIDE data low/high reg
102; DX: XTIDE Data Low Register address
103; DS:SI: Ptr to source buffer
104; Returns:
105; SI: Incremented/decremented for next word
106; Corrupts registers:
107; AX, FLAGS
108;--------------------------------------------------------------------
109%macro XTIDE_OUTSW 0
110%ifdef USE_186 ; OUTS instruction available
111 lodsb ; Load low byte from [DS:SI] to AL
112 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
113 outsb ; Output high byte from [DS:SI]
114 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
115 out dx, al ; Output low byte from AL
116%else ; If 8088/8086
117 lodsw ; Load word from [DS:SI]
118 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
119 xchg al, ah ; => AL=high byte, AH=low byte
120 out dx, al ; Output high byte
121 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
122 mov al, ah ; Copy low byte to AL
123 out dx, al ; Output low byte
124%endif
125%endmacro
126
127
128;--------------------------------------------------------------------
129; Emulates OUTSW for modified XTIDE.
130;
131; XTIDE_MOD_OUTSW
132; Parameters:
133; DX: XTIDE Data Low Register address
134; DS:SI: Ptr to source buffer
135; Returns:
136; SI: Incremented/decremented for next word
137; Corrupts registers:
138; AX, FLAGS
139;--------------------------------------------------------------------
140%macro XTIDE_MOD_OUTSW 0
141%ifdef USE_186 ; OUTS instruction available
142 lodsb ; Load low byte from [DS:SI] to AL
143 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
144 outsb ; Output high byte from [DS:SI]
145 dec dx ; XTIDE Data High Reg to Data Low Reg
146 out dx, al ; Output low byte from AL
147%else ; If 8088/8086
148 lodsw ; Load word from [DS:SI]
149 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
150 xchg al, ah ; => AL=high byte, AH=low byte
151 out dx, al ; Output high byte
152 dec dx ; XTIDE Data High Reg to Data Low Reg
153 mov al, ah ; Copy low byte to AL
154 out dx, al ; Output low byte
155%endif
156%endmacro
157
158
159%endif ; IDE_8BIT_INC
Note: See TracBrowser for help on using the repository browser.