[148] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Int 13h function AH=24h, Set Multiple Blocks.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[491] | 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.
|
---|
[491] | 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
|
---|
[491] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[491] | 18 | ;
|
---|
[376] | 19 |
|
---|
[3] | 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
| 24 | ; Int 13h function AH=24h, Set Multiple Blocks.
|
---|
| 25 | ;
|
---|
| 26 | ; AH24h_HandlerForSetMultipleBlocks
|
---|
| 27 | ; Parameters:
|
---|
[148] | 28 | ; AL: Same as in INTPACK
|
---|
| 29 | ; DL: Translated Drive number
|
---|
| 30 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[150] | 31 | ; SS:BP: Ptr to IDEPACK
|
---|
| 32 | ; Parameters on INTPACK:
|
---|
[3] | 33 | ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
|
---|
[150] | 34 | ; Returns with INTPACK:
|
---|
[3] | 35 | ; AH: Int 13h return status
|
---|
[294] | 36 | ; CF: 0 if successful, 1 if error
|
---|
[3] | 37 | ;--------------------------------------------------------------------
|
---|
| 38 | AH24h_HandlerForSetMultipleBlocks:
|
---|
[84] | 39 | %ifndef USE_186
|
---|
[3] | 40 | call AH24h_SetBlockSize
|
---|
[148] | 41 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[84] | 42 | %else
|
---|
[148] | 43 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[162] | 44 | ; Fall to AH24h_SetBlockSize
|
---|
[84] | 45 | %endif
|
---|
[3] | 46 |
|
---|
| 47 |
|
---|
| 48 | ;--------------------------------------------------------------------
|
---|
| 49 | ; AH24h_SetBlockSize
|
---|
| 50 | ; Parameters:
|
---|
| 51 | ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
|
---|
[148] | 52 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[150] | 53 | ; SS:BP: Ptr to IDEPACK
|
---|
[3] | 54 | ; Returns:
|
---|
| 55 | ; AH: Int 13h return status
|
---|
[294] | 56 | ; CF: 0 if successful, 1 if error
|
---|
[3] | 57 | ; Corrupts registers:
|
---|
[365] | 58 | ; AL, CX, DX
|
---|
[3] | 59 | ;--------------------------------------------------------------------
|
---|
| 60 | AH24h_SetBlockSize:
|
---|
[493] | 61 | %ifdef MODULE_8BIT_IDE_ADVANCED
|
---|
[473] | 62 | ; XT-CF does not support largest block size in DMA mode.
|
---|
| 63 | cmp al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
|
---|
[491] | 64 | jbe SHORT .NoNeedToLimitBlockSize
|
---|
[545] | 65 |
|
---|
| 66 | ; Return error if we tried too large block for XT-CF.
|
---|
| 67 | ; Do not limit it to maximum supported since software calling AH=24h
|
---|
| 68 | ; must know what the actual block size is.
|
---|
[491] | 69 | cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
|
---|
[588] | 70 | je SHORT ProcessXTCFsubcommandFromAL.AH1Eh_LoadInvalidCommandToAHandSetCF
|
---|
[473] | 71 | .NoNeedToLimitBlockSize:
|
---|
[493] | 72 | %endif ; MODULE_8BIT_IDE_ADVANCED
|
---|
[473] | 73 |
|
---|
[365] | 74 | push bx
|
---|
| 75 |
|
---|
[550] | 76 | push ax ; Store block size for later use
|
---|
[365] | 77 | xchg dx, ax ; DL = Block size (Sector Count Register)
|
---|
[150] | 78 | mov al, COMMAND_SET_MULTIPLE_MODE
|
---|
| 79 | mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)
|
---|
| 80 | call Idepack_StoreNonExtParametersAndIssueCommandFromAL
|
---|
[545] | 81 |
|
---|
[550] | 82 | ; Disable block mode if failure or if called with block size of 1 sector.
|
---|
| 83 | ; Some drives allow block mode commands for 1 sector blocks and some do not.
|
---|
| 84 | pop bx ; Pop block size to BL
|
---|
| 85 | jc SHORT .DisableBlockMode
|
---|
| 86 |
|
---|
[558] | 87 | ; All valid block sizes are powers of 2 which means BL have just one bit set (parity odd).
|
---|
| 88 | ; Incrementing BX will cause all block sizes except 1 to have two bits set (parity even).
|
---|
| 89 | ; Note that PF reflects only the lowest 8 bits of any register being modified.
|
---|
| 90 | inc bx ; 1 -> 2 ?
|
---|
| 91 | jpo SHORT .DisableBlockMode ; Jump if BL = 2
|
---|
| 92 | dec bx ; Restore block size (was larger than 1)
|
---|
| 93 |
|
---|
[550] | 94 | ; Enable block mode and store block size
|
---|
| 95 | or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_USE_BLOCK_MODE_COMMANDS
|
---|
| 96 | jmp SHORT .StoreBlockSizeFromBLandReturn
|
---|
| 97 |
|
---|
| 98 | .DisableBlockMode:
|
---|
| 99 | and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_USE_BLOCK_MODE_COMMANDS
|
---|
| 100 | mov bl, 1
|
---|
| 101 | stc
|
---|
| 102 | .StoreBlockSizeFromBLandReturn:
|
---|
[365] | 103 | mov [di+DPT_ATA.bBlockSize], bl
|
---|
| 104 | pop bx
|
---|
[3] | 105 | ret
|
---|