[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 | ;
|
---|
| 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 |
|
---|
[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
|
---|
| 27 | ; Parameters:
|
---|
| 28 | ; CX: Number of sectors in block
|
---|
| 29 | ; Returns:
|
---|
[442] | 30 | ; CX: Number of DWORDs or QWORDs in block
|
---|
[363] | 31 | ; Corrupts registers:
|
---|
| 32 | ; Nothing
|
---|
| 33 | ;--------------------------------------------------------------------
|
---|
[442] | 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 |
|
---|
[363] | 43 | %macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
|
---|
| 44 | %ifdef USE_186
|
---|
| 45 | shl cx, 6
|
---|
| 46 | %else
|
---|
[442] | 47 | UNROLL_SECTORS_IN_CX_TO_DWORDS
|
---|
[363] | 48 | shr cx, 1
|
---|
| 49 | %endif
|
---|
| 50 | %endmacro
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | ;--------------------------------------------------------------------
|
---|
[152] | 54 | ; Emulates INSW for XTIDE.
|
---|
[3] | 55 | ;
|
---|
[152] | 56 | ; XTIDE_INSW
|
---|
[3] | 57 | ; Parameters:
|
---|
[370] | 58 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
[152] | 59 | ; DX: XTIDE Data Low Register address
|
---|
[3] | 60 | ; ES:DI: Ptr to destination buffer
|
---|
| 61 | ; Returns:
|
---|
| 62 | ; ES:DI: Incremented/decremented for next word
|
---|
| 63 | ; Corrupts registers:
|
---|
| 64 | ; AL, FLAGS
|
---|
| 65 | ;--------------------------------------------------------------------
|
---|
[152] | 66 | %macro XTIDE_INSW 0
|
---|
[3] | 67 | %ifdef USE_186 ; INS instruction available
|
---|
| 68 | insb ; Load low byte from port DX to [ES:DI]
|
---|
[370] | 69 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 70 | insb ; Load high byte from port DX to [ES:DI]
|
---|
[370] | 71 | xor dl, bl ; Restore to IDE Data Register
|
---|
[3] | 72 | %else ; If 8088/8086
|
---|
| 73 | in al, dx ; Load low byte from port
|
---|
[370] | 74 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 75 | stosb ; Store byte to [ES:DI]
|
---|
| 76 | in al, dx ; Load high byte from port
|
---|
[370] | 77 | xor dl, bl ; Restore to IDE Data Register
|
---|
[3] | 78 | stosb ; Store byte to [ES:DI]
|
---|
| 79 | %endif
|
---|
| 80 | %endmacro
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | ;--------------------------------------------------------------------
|
---|
[152] | 84 | ; Emulates OUTSW for XTIDE.
|
---|
[3] | 85 | ;
|
---|
[152] | 86 | ; XTIDE_OUTSW
|
---|
[3] | 87 | ; Parameters:
|
---|
[370] | 88 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
[152] | 89 | ; DX: XTIDE Data Low Register address
|
---|
[3] | 90 | ; DS:SI: Ptr to source buffer
|
---|
| 91 | ; Returns:
|
---|
| 92 | ; SI: Incremented/decremented for next word
|
---|
| 93 | ; Corrupts registers:
|
---|
| 94 | ; AX, FLAGS
|
---|
| 95 | ;--------------------------------------------------------------------
|
---|
[152] | 96 | %macro XTIDE_OUTSW 0
|
---|
[3] | 97 | %ifdef USE_186 ; OUTS instruction available
|
---|
| 98 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
[370] | 99 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 100 | outsb ; Output high byte from [DS:SI]
|
---|
[370] | 101 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
[3] | 102 | out dx, al ; Output low byte from AL
|
---|
| 103 | %else ; If 8088/8086
|
---|
| 104 | lodsw ; Load word from [DS:SI]
|
---|
[370] | 105 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
[3] | 106 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
| 107 | out dx, al ; Output high byte
|
---|
[370] | 108 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
[3] | 109 | mov al, ah ; Copy low byte to AL
|
---|
| 110 | out dx, al ; Output low byte
|
---|
| 111 | %endif
|
---|
| 112 | %endmacro
|
---|
| 113 |
|
---|
| 114 |
|
---|
[152] | 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 |
|
---|
[3] | 146 | %endif ; IDE_8BIT_INC
|
---|