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

Last change on this file since 367 was 363, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Added Advanced ATA Module (MODULE_ADVANCED_ATA) with native support for QDI Vision QD6500 and QD6580 VLB IDE Controllers.
  • Hopefully optimized IDE transfer functions for 8088 (replaced some memory accesses from WORD to BYTE).
  • XT build does not fit in 8k at the moment!!!
File size: 3.7 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
[3]2; Description : Macros for accessing data port(s) on 8-bit
3; IDE controllers.
4%ifndef IDE_8BIT_INC
5%define IDE_8BIT_INC
6
7;--------------------------------------------------------------------
[363]8; UNROLL_SECTORS_IN_CX_TO_QWORDS
9; Parameters:
10; CX: Number of sectors in block
11; Returns:
12; CX: Number of QWORDs in block
13; Corrupts registers:
14; Nothing
15;--------------------------------------------------------------------
16%macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
17%ifdef USE_186
18 shl cx, 6
19%else
20 xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
21 shr cx, 1
22 shr cx, 1
23%endif
24%endmacro
25
26
27;--------------------------------------------------------------------
[152]28; Emulates INSW for XTIDE.
[3]29;
[152]30; XTIDE_INSW
[3]31; Parameters:
32; BX: Bit mask for toggling XTIDE data low/high reg
[152]33; DX: XTIDE Data Low Register address
[3]34; ES:DI: Ptr to destination buffer
35; Returns:
36; ES:DI: Incremented/decremented for next word
37; Corrupts registers:
38; AL, FLAGS
39;--------------------------------------------------------------------
[152]40%macro XTIDE_INSW 0
[3]41%ifdef USE_186 ; INS instruction available
42 insb ; Load low byte from port DX to [ES:DI]
43 xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
44 insb ; Load high byte from port DX to [ES:DI]
45 xor dx, bx ; Restore to IDE Data Register
46%else ; If 8088/8086
47 in al, dx ; Load low byte from port
48 xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
49 stosb ; Store byte to [ES:DI]
50 in al, dx ; Load high byte from port
51 xor dx, bx ; Restore to IDE Data Register
52 stosb ; Store byte to [ES:DI]
53%endif
54%endmacro
55
56
57;--------------------------------------------------------------------
[152]58; Emulates OUTSW for XTIDE.
[3]59;
[152]60; XTIDE_OUTSW
[3]61; Parameters:
62; BX: Bit mask for toggling XTIDE data low/high reg
[152]63; DX: XTIDE Data Low Register address
[3]64; DS:SI: Ptr to source buffer
65; Returns:
66; SI: Incremented/decremented for next word
67; Corrupts registers:
68; AX, FLAGS
69;--------------------------------------------------------------------
[152]70%macro XTIDE_OUTSW 0
[3]71%ifdef USE_186 ; OUTS instruction available
72 lodsb ; Load low byte from [DS:SI] to AL
73 xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
74 outsb ; Output high byte from [DS:SI]
[152]75 xor dx, bx ; XTIDE Data High Reg to Data Low Reg
[3]76 out dx, al ; Output low byte from AL
77%else ; If 8088/8086
78 lodsw ; Load word from [DS:SI]
79 xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
80 xchg al, ah ; => AL=high byte, AH=low byte
81 out dx, al ; Output high byte
[152]82 xor dx, bx ; XTIDE Data High Reg to Data Low Reg
[3]83 mov al, ah ; Copy low byte to AL
84 out dx, al ; Output low byte
85%endif
86%endmacro
87
88
[152]89;--------------------------------------------------------------------
90; Emulates OUTSW for modified XTIDE.
91;
92; XTIDE_MOD_OUTSW
93; Parameters:
94; DX: XTIDE Data Low Register address
95; DS:SI: Ptr to source buffer
96; Returns:
97; SI: Incremented/decremented for next word
98; Corrupts registers:
99; AX, FLAGS
100;--------------------------------------------------------------------
101%macro XTIDE_MOD_OUTSW 0
102%ifdef USE_186 ; OUTS instruction available
103 lodsb ; Load low byte from [DS:SI] to AL
104 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
105 outsb ; Output high byte from [DS:SI]
106 dec dx ; XTIDE Data High Reg to Data Low Reg
107 out dx, al ; Output low byte from AL
108%else ; If 8088/8086
109 lodsw ; Load word from [DS:SI]
110 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
111 xchg al, ah ; => AL=high byte, AH=low byte
112 out dx, al ; Output high byte
113 dec dx ; XTIDE Data High Reg to Data Low Reg
114 mov al, ah ; Copy low byte to AL
115 out dx, al ; Output low byte
116%endif
117%endmacro
118
119
[3]120%endif ; IDE_8BIT_INC
Note: See TracBrowser for help on using the repository browser.