[218] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Functions for preparing data buffer for transfer.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[445] | 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 7 | ;
|
---|
| 8 | ; This program is free software; you can redistribute it and/or modify
|
---|
| 9 | ; it under the terms of the GNU General Public License as published by
|
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
| 11 | ; (at your option) any later version.
|
---|
[445] | 12 | ;
|
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful,
|
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | ; GNU General Public License for more details.
|
---|
[445] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
[376] | 19 |
|
---|
[218] | 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
[221] | 23 | ;--------------------------------------------------------------------
|
---|
| 24 | ; Prepare_ByLoadingDapToESSIandVerifyingForTransfer
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; SI: Offset to DAP
|
---|
| 27 | ; DS:DI: Ptr to DPT
|
---|
| 28 | ; SS:BP: Ptr to IDEPACK
|
---|
| 29 | ; Parameters on INTPACK:
|
---|
| 30 | ; DS:SI: Ptr to Disk Address Packet
|
---|
| 31 | ; Returns:
|
---|
| 32 | ; BX: Index to command lookup table
|
---|
| 33 | ; ES:SI: Ptr to Disk Address Packet (DAP)
|
---|
| 34 | ; Exits from INT 13h if invalid DAP
|
---|
| 35 | ; Corrupts registers:
|
---|
| 36 | ; AX, DX
|
---|
| 37 | ;--------------------------------------------------------------------
|
---|
| 38 | %ifdef MODULE_EBIOS
|
---|
| 39 | ALIGN JUMP_ALIGN
|
---|
| 40 | Prepare_ByLoadingDapToESSIandVerifyingForTransfer:
|
---|
| 41 | ; Load pointer to DAP to ES:SI and make sure it is valid
|
---|
| 42 | mov es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet
|
---|
| 43 | cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
|
---|
| 44 | jb SHORT InvalidDAP
|
---|
| 45 |
|
---|
| 46 | ; Make sure that sector count is valid
|
---|
[558] | 47 | %ifdef USE_UNDOC_INTEL
|
---|
[568] | 48 | salc ; Clear AL using CF (CF is cleared since JB above fell through)
|
---|
[558] | 49 | or al, [es:si+DAP.wSectorCount]
|
---|
| 50 | %else
|
---|
[547] | 51 | mov al, [es:si+DAP.wSectorCount]
|
---|
| 52 | test al, al
|
---|
[558] | 53 | %endif
|
---|
[547] | 54 | jz SHORT ZeroSectorsRequestedSoNoErrors
|
---|
| 55 | js SHORT InvalidNumberOfSectorsRequested
|
---|
| 56 |
|
---|
| 57 | %if 0 ; Slow version in the unlikely case that high byte needs to be checked.
|
---|
[221] | 58 | mov ax, [es:si+DAP.wSectorCount]
|
---|
| 59 | test ax, ax
|
---|
| 60 | jz SHORT ZeroSectorsRequestedSoNoErrors
|
---|
| 61 | cmp ax, BYTE 127
|
---|
| 62 | ja SHORT InvalidNumberOfSectorsRequested
|
---|
[547] | 63 | %endif
|
---|
[221] | 64 |
|
---|
[294] | 65 | ; Get EBIOS command index to BX
|
---|
[221] | 66 | ; LBA28 or LBA48 command
|
---|
| 67 | call Prepare_GetOldInt13hCommandIndexToBX
|
---|
[421] | 68 | mov al, [di+DPT.bFlagsLow]
|
---|
[558] | 69 | eSHL_IM al, 1 ; Set CF if LBA48 supported
|
---|
[421] | 70 | adc bl, bh ; LBA48 EXT commands
|
---|
[221] | 71 | ret
|
---|
[421] | 72 | %endif ; MODULE_EBIOS
|
---|
[221] | 73 |
|
---|
| 74 |
|
---|
| 75 | ;--------------------------------------------------------------------
|
---|
| 76 | ; Prepare_GetOldInt13hCommandIndexToBX
|
---|
| 77 | ; Parameters:
|
---|
| 78 | ; DS:DI: Ptr to DPT
|
---|
| 79 | ; Returns:
|
---|
| 80 | ; BX: Index to command lookup table
|
---|
| 81 | ; Corrupts registers:
|
---|
| 82 | ; Nothing
|
---|
| 83 | ;--------------------------------------------------------------------
|
---|
| 84 | ALIGN JUMP_ALIGN
|
---|
| 85 | Prepare_GetOldInt13hCommandIndexToBX:
|
---|
| 86 | ; Block mode or single sector
|
---|
| 87 | mov bl, [di+DPT.bFlagsHigh]
|
---|
[550] | 88 | and bx, BYTE FLGH_DPT_USE_BLOCK_MODE_COMMANDS ; Bit 1
|
---|
[221] | 89 | ret
|
---|
| 90 |
|
---|
| 91 |
|
---|
[218] | 92 | ;---------------------------------------------------------------------
|
---|
[221] | 93 | ; Prepare_BufferToESSIforOldInt13hTransfer
|
---|
[218] | 94 | ; Parameters:
|
---|
| 95 | ; AL: Number of sectors to transfer
|
---|
[474] | 96 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[218] | 97 | ; SS:BP: Ptr to IDEPACK
|
---|
| 98 | ; Parameters on INTPACK:
|
---|
| 99 | ; ES:BX: Ptr to data buffer
|
---|
| 100 | ; Returns:
|
---|
| 101 | ; ES:SI: Ptr to normalized data buffer
|
---|
| 102 | ; Exits INT 13h if error
|
---|
| 103 | ; Corrupts registers:
|
---|
| 104 | ; BX
|
---|
| 105 | ;--------------------------------------------------------------------
|
---|
| 106 | ALIGN JUMP_ALIGN
|
---|
[221] | 107 | Prepare_BufferToESSIforOldInt13hTransfer:
|
---|
[477] | 108 | mov si, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
|
---|
[480] | 109 | mov es, [bp+IDEPACK.intpack+INTPACK.es] ; Load segment
|
---|
[221] | 110 | ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
|
---|
[218] | 111 |
|
---|
[221] | 112 | ;---------------------------------------------------------------------
|
---|
| 113 | ; Prepare_ByValidatingSectorsInALforOldInt13h
|
---|
| 114 | ; Parameters:
|
---|
[567] | 115 | ; AL: Number of sectors to transfer (1...128 is valid)
|
---|
[221] | 116 | ; Returns:
|
---|
| 117 | ; Exits INT 13h if invalid number of sectors in AL
|
---|
| 118 | ; Corrupts registers:
|
---|
| 119 | ; Nothing
|
---|
| 120 | ;--------------------------------------------------------------------
|
---|
| 121 | Prepare_ByValidatingSectorsInALforOldInt13h:
|
---|
[567] | 122 | test al, al ; Check if 0 < AL < 128 (Clears OF)
|
---|
| 123 | jle SHORT .CheckIf128Sectors ; Jump if not
|
---|
[218] | 124 | ret ; Continue with transfer
|
---|
| 125 |
|
---|
| 126 | ALIGN JUMP_ALIGN
|
---|
[567] | 127 | .CheckIf128Sectors:
|
---|
[218] | 128 | cmp al, 128
|
---|
[567] | 129 | jne SHORT InvalidNumberOfSectorsRequested
|
---|
[218] | 130 | test si, si ; Offset must be zero to xfer 128 sectors
|
---|
[221] | 131 | jnz SHORT CannotAlignPointerProperly
|
---|
[218] | 132 | ret ; Continue with transfer
|
---|
| 133 |
|
---|
[596] | 134 | %ifdef MODULE_EBIOS
|
---|
[221] | 135 | InvalidDAP:
|
---|
[596] | 136 | Prepare_ReturnFromInt13hWithInvalidFunctionError:
|
---|
| 137 | %endif
|
---|
[221] | 138 | InvalidNumberOfSectorsRequested:
|
---|
[218] | 139 | mov ah, RET_HD_INVALID
|
---|
[322] | 140 | SKIP2B f
|
---|
| 141 | CannotAlignPointerProperly:
|
---|
| 142 | mov ah, RET_HD_BOUNDARY
|
---|
[596] | 143 | %ifdef MODULE_EBIOS
|
---|
[221] | 144 | ZeroSectorsRequestedSoNoErrors:
|
---|
[596] | 145 | %endif
|
---|
[218] | 146 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
| 147 |
|
---|
[221] | 148 |
|
---|
| 149 |
|
---|
| 150 | ; Command lookup tables
|
---|
| 151 | g_rgbReadCommandLookup:
|
---|
| 152 | db COMMAND_READ_SECTORS ; 00b, CHS or LBA28 single sector
|
---|
| 153 | db COMMAND_READ_SECTORS_EXT ; 01b, LBA48 single sector
|
---|
| 154 | db COMMAND_READ_MULTIPLE ; 10b, CHS or LBA28 block mode
|
---|
[413] | 155 | %ifdef MODULE_EBIOS
|
---|
[221] | 156 | db COMMAND_READ_MULTIPLE_EXT ; 11b, LBA48 block mode
|
---|
[413] | 157 | %endif
|
---|
[221] | 158 |
|
---|
| 159 | g_rgbWriteCommandLookup:
|
---|
| 160 | db COMMAND_WRITE_SECTORS
|
---|
| 161 | db COMMAND_WRITE_SECTORS_EXT
|
---|
| 162 | db COMMAND_WRITE_MULTIPLE
|
---|
[413] | 163 | %ifdef MODULE_EBIOS
|
---|
[221] | 164 | db COMMAND_WRITE_MULTIPLE_EXT
|
---|
[413] | 165 | %endif
|
---|
[221] | 166 |
|
---|
[596] | 167 | %ifdef MODULE_EBIOS
|
---|
[221] | 168 | g_rgbVerifyCommandLookup:
|
---|
| 169 | db COMMAND_VERIFY_SECTORS
|
---|
| 170 | db COMMAND_VERIFY_SECTORS_EXT
|
---|
| 171 | db COMMAND_VERIFY_SECTORS
|
---|
| 172 | db COMMAND_VERIFY_SECTORS_EXT
|
---|
[413] | 173 | %endif
|
---|