[150] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Macros for accessing data port(s) on 8-bit
|
---|
| 3 | ; IDE controllers.
|
---|
[376] | 4 |
|
---|
| 5 | ;
|
---|
[445] | 6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[376] | 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.
|
---|
[445] | 13 | ;
|
---|
[376] | 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
|
---|
[445] | 17 | ; GNU General Public License for more details.
|
---|
[376] | 18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 19 | ;
|
---|
| 20 |
|
---|
[3] | 21 | %ifndef IDE_8BIT_INC
|
---|
| 22 | %define IDE_8BIT_INC
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
[442] | 25 | ; UNROLL_SECTORS_IN_CX_TO_DWORDS
|
---|
[363] | 26 | ; UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
[445] | 27 | ; UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
[363] | 28 | ; Parameters:
|
---|
| 29 | ; CX: Number of sectors in block
|
---|
| 30 | ; Returns:
|
---|
[445] | 31 | ; CX: Number of DWORDs, QWORDs or OWORDs in block
|
---|
[363] | 32 | ; Corrupts registers:
|
---|
| 33 | ; Nothing
|
---|
| 34 | ;--------------------------------------------------------------------
|
---|
[442] | 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 |
|
---|
[363] | 44 | %macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
|
---|
| 45 | %ifdef USE_186
|
---|
| 46 | shl cx, 6
|
---|
| 47 | %else
|
---|
[442] | 48 | UNROLL_SECTORS_IN_CX_TO_DWORDS
|
---|
[363] | 49 | shr cx, 1
|
---|
| 50 | %endif
|
---|
| 51 | %endmacro
|
---|
| 52 |
|
---|
[445] | 53 | %macro UNROLL_SECTORS_IN_CX_TO_OWORDS 0
|
---|
| 54 | %ifdef USE_186
|
---|
| 55 | shl cx, 5
|
---|
| 56 | %else
|
---|
[491] | 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
|
---|
[445] | 62 | %endif
|
---|
| 63 | %endmacro
|
---|
[363] | 64 |
|
---|
[445] | 65 |
|
---|
[363] | 66 | ;--------------------------------------------------------------------
|
---|
[152] | 67 | ; Emulates INSW for XTIDE.
|
---|
[3] | 68 | ;
|
---|
[152] | 69 | ; XTIDE_INSW
|
---|
[3] | 70 | ; Parameters:
|
---|
[370] | 71 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
[152] | 72 | ; DX: XTIDE Data Low Register address
|
---|
[3] | 73 | ; ES:DI: Ptr to destination buffer
|
---|
| 74 | ; Returns:
|
---|
| 75 | ; ES:DI: Incremented/decremented for next word
|
---|
| 76 | ; Corrupts registers:
|
---|
| 77 | ; AL, FLAGS
|
---|
| 78 | ;--------------------------------------------------------------------
|
---|
[152] | 79 | %macro XTIDE_INSW 0
|
---|
[3] | 80 | %ifdef USE_186 ; INS instruction available
|
---|
| 81 | insb ; Load low byte from port DX to [ES:DI]
|
---|
[370] | 82 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 83 | insb ; Load high byte from port DX to [ES:DI]
|
---|
[370] | 84 | xor dl, bl ; Restore to IDE Data Register
|
---|
[3] | 85 | %else ; If 8088/8086
|
---|
| 86 | in al, dx ; Load low byte from port
|
---|
[370] | 87 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 88 | stosb ; Store byte to [ES:DI]
|
---|
| 89 | in al, dx ; Load high byte from port
|
---|
[370] | 90 | xor dl, bl ; Restore to IDE Data Register
|
---|
[3] | 91 | stosb ; Store byte to [ES:DI]
|
---|
| 92 | %endif
|
---|
| 93 | %endmacro
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | ;--------------------------------------------------------------------
|
---|
[152] | 97 | ; Emulates OUTSW for XTIDE.
|
---|
[3] | 98 | ;
|
---|
[152] | 99 | ; XTIDE_OUTSW
|
---|
[3] | 100 | ; Parameters:
|
---|
[370] | 101 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
[152] | 102 | ; DX: XTIDE Data Low Register address
|
---|
[3] | 103 | ; DS:SI: Ptr to source buffer
|
---|
| 104 | ; Returns:
|
---|
| 105 | ; SI: Incremented/decremented for next word
|
---|
| 106 | ; Corrupts registers:
|
---|
| 107 | ; AX, FLAGS
|
---|
| 108 | ;--------------------------------------------------------------------
|
---|
[152] | 109 | %macro XTIDE_OUTSW 0
|
---|
[3] | 110 | %ifdef USE_186 ; OUTS instruction available
|
---|
| 111 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
[370] | 112 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 113 | outsb ; Output high byte from [DS:SI]
|
---|
[370] | 114 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
[3] | 115 | out dx, al ; Output low byte from AL
|
---|
| 116 | %else ; If 8088/8086
|
---|
| 117 | lodsw ; Load word from [DS:SI]
|
---|
[370] | 118 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 119 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
| 120 | out dx, al ; Output high byte
|
---|
[370] | 121 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
[3] | 122 | mov al, ah ; Copy low byte to AL
|
---|
| 123 | out dx, al ; Output low byte
|
---|
| 124 | %endif
|
---|
| 125 | %endmacro
|
---|
| 126 |
|
---|
| 127 |
|
---|
[152] | 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 |
|
---|
[3] | 159 | %endif ; IDE_8BIT_INC
|
---|