Changeset 218 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS
- Timestamp:
- Jan 23, 2012, 9:10:05 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc
r170 r218 41 41 .bSize resb 1 ; 0, Size of this packet in bytes 42 42 .bReservedAt1 resb 1 ; 1, Currently unused, must be zero 43 .wSectorCount resb 2 ; 2, Number of sectors to process (1...127) 43 .bSectorCount resb 1 ; 2, Number of sectors to process (0...127) 44 .bReservedAt3 resb 1 ; 3, Currently unused, must be zero 44 45 .dwMemoryAddress: 45 46 .wOffset resb 2 ; 4, Memory offset for transfer -
trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc
r150 r218 45 45 46 46 47 MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS EQU 6448 49 47 %define TIMEOUT_AND_STATUS_TO_WAIT(timeout, status) (((timeout)<<8) | (status)) 50 48 -
trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
r203 r218 61 61 .bCommand resb 1 62 62 .bDeviceControl resb 1 ; Offset 7 shared with PIOVARS 63 resb 1 63 64 64 65 ; Parameters for 48-bit LBA 65 .wSectorCountHighAndLbaLowExt:66 .bSectorCountHighExt resb 167 66 .bLbaLowExt resb 1 ; LBA48 31...24 68 69 67 .wLbaMiddleAndHighExt: 70 68 .bLbaMiddleExt resb 1 ; LBA48 39...32 -
trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
r181 r218 54 54 ; BH: Drive Select byte for Drive and Head Select Register 55 55 ; DS: Segment to RAMVARS 56 ; ES:SI: Ptr to buffer to receive 512-byte IDE Information56 ; ES:SI: Ptr to normalized buffer to receive 512-byte IDE Information 57 57 ; CS:BP: Ptr to IDEVARS 58 58 ; Returns: … … 80 80 ; BH: Default system timer ticks for timeout (can be ignored) 81 81 ; BL: IDE Status Register bit to poll after command 82 ; ES:SI: Ptr to buffer (for data transfer commands)82 ; ES:SI: Ptr to normalized buffer (for data transfer commands) 83 83 ; DS:DI: Ptr to DPT (in RAMVARS segment) 84 84 ; SS:BP: Ptr to IDEPACK -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r169 r218 128 128 129 129 ; Output Sector Address High (only used by LBA48) 130 mov ax, [bp+IDEPACK.wSectorCountHighAndLbaLowExt]130 eMOVZX ax, BYTE [bp+IDEPACK.bLbaLowExt] 131 131 mov cx, [bp+IDEPACK.wLbaMiddleAndHighExt] 132 132 call OutputSectorCountAndAddress -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r181 r218 5 5 ; This struct must not be larger than IDEPACK without INTPACK. 6 6 struc PIOVARS 7 .wBlocksLeft resb 2 8 .wBlockSize resb 2 ; Block size in WORDs (256...32768) 9 .wDataPort resb 2 10 .bSectorsInLastBlock: resb 1 11 resb 1 ; Offset 7 = IDEPACK.bDeviceControl 12 .fnXfer resb 2 ; Offset to transfer function 7 .wWordsInBlock resb 2 ; 0, Block size in WORDs 8 .wWordsLeft resb 2 ; 2, WORDs left to transfer 9 .wWordsDone resb 2 ; 4, Number of sectors xferred 10 resb 1 ; 6, 11 resb 1 ; 7, IDEPACK.bDeviceControl 12 .wDataPort resb 2 ; 8, IDE Data Port 13 .fnXfer resb 2 ; 10, Offset to transfer function 13 14 endstruc 14 15 … … 22 23 ; AL: IDE command that was used to start the transfer 23 24 ; (all PIO read and write commands including Identify Device) 24 ; ES:SI: Ptr to destination buffer or source data25 ; ES:SI: Ptr to normalized data buffer 25 26 ; DS:DI: Ptr to DPT (in RAMVARS segment) 26 27 ; SS:BP: Ptr to IDEPACK 27 28 ; Returns: 28 29 ; AH: INT 13h Error Code 30 ; CX: Number of successfully transferred sectors 29 31 ; CF: Cleared if success, Set if error 30 32 ; Corrupts registers: 31 ; AL, BX, CX,DX, SI, ES33 ; AL, BX, DX, SI, ES 32 34 ;-------------------------------------------------------------------- 33 35 ALIGN JUMP_ALIGN 34 36 IdeTransfer_StartWithCommandInAL: 35 mov ah, [bp+IDEPACK.bSectorCount HighExt]37 mov ah, [bp+IDEPACK.bSectorCount] 36 38 37 39 ; Are we reading or writing? … … 43 45 ; Prepare to read data to ESSI 44 46 mov bx, g_rgfnPioRead 45 mov al, [bp+IDEPACK.bSectorCount] 46 call InitializePiovarsInSSBPwithSectorCountInAX 47 call InitializePiovarsInSSBPwithSectorCountInAH 47 48 xchg si, di 48 call Registers_NormalizeESDI49 49 jmp SHORT ReadFromDrive 50 50 … … 52 52 .PrepareToWriteDataFromESSI: 53 53 mov bx, g_rgfnPioWrite 54 mov al, [bp+IDEPACK.bSectorCount] 55 call InitializePiovarsInSSBPwithSectorCountInAX 56 call Registers_NormalizeESSI 54 call InitializePiovarsInSSBPwithSectorCountInAH 57 55 ; Fall to WriteToDrive 58 56 … … 66 64 ; Returns: 67 65 ; AH: BIOS Error code 66 ; CX: Number of successfully transferred sectors 68 67 ; CF: 0 if transfer succesfull 69 68 ; 1 if any error 70 69 ; Corrupts registers: 71 ; AL, BX, CX,DX, SI, ES70 ; AL, BX, DX, SI, ES 72 71 ;-------------------------------------------------------------------- 73 72 WriteToDrive: … … 75 74 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 76 75 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 77 jc SHORT .ReturnWithTransferErrorInAH 78 ALIGN JUMP_ALIGN 79 .WriteNextBlock: 76 jc SHORT ReturnWithTransferErrorInAH 77 78 ALIGN JUMP_ALIGN 79 .WriteNextBlockToDrive: 80 mov cx, [bp+PIOVARS.wWordsInBlock] 80 81 mov dx, [bp+PIOVARS.wDataPort] 81 dec WORD [bp+PIOVARS.wBlocksLeft] ; Transferring last (possibly partial) block? 82 jz SHORT .XferLastBlock ; If so, jump to transfer 83 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 84 call [bp+PIOVARS.fnXfer] ; Transfer full block 85 86 ; Normalize pointer when necessary 87 mov ax, si 88 shr ax, 1 ; WORD offset 89 add ax, [bp+PIOVARS.wBlockSize] 90 jns SHORT .WaitUntilReadyToTransferNextBlock 91 call Registers_NormalizeESSI 92 93 ALIGN JUMP_ALIGN 94 .WaitUntilReadyToTransferNextBlock: 95 %ifdef USE_186 96 push .WriteNextBlock 97 jmp IdeWait_IRQorDRQ 98 %else 99 call IdeWait_IRQorDRQ 100 jnc SHORT .WriteNextBlock 101 %endif 102 .ReturnWithTransferErrorInAH: 103 ret 104 105 ALIGN JUMP_ALIGN 106 .XferLastBlock: 107 xor cx, cx 82 cmp [bp+PIOVARS.wWordsLeft], cx 83 jbe SHORT .WriteLastBlockToDrive 84 call [bp+PIOVARS.fnXfer] 85 86 ; Wait until ready for next block and check for errors 87 call IdeWait_IRQorDRQ ; Wait until ready to transfer 88 jc SHORT ReturnWithTransferErrorInAH 89 90 ; Increment number of successfully written WORDs 91 mov ax, [bp+PIOVARS.wWordsInBlock] 92 sub [bp+PIOVARS.wWordsLeft], ax 93 add [bp+PIOVARS.wWordsDone], ax 94 jmp SHORT .WriteNextBlockToDrive 95 96 ALIGN JUMP_ALIGN 97 .WriteLastBlockToDrive: 98 mov cx, [bp+PIOVARS.wWordsLeft] 99 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 100 101 ; Check for errors in last block 108 102 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 109 mov ch, [bp+PIOVARS.bSectorsInLastBlock]; CX = Partial block size in WORDs 110 %ifdef USE_186 111 push IdeWait_IRQorStatusFlagInBLwithTimeoutInBH 112 jmp [bp+PIOVARS.fnXfer] 113 %else 114 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 115 jmp IdeWait_IRQorStatusFlagInBLwithTimeoutInBH ; Check for errors 116 %endif 103 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 104 jmp SHORT ReturnWithTransferErrorInAH 117 105 118 106 … … 126 114 ; DS:DI: Ptr to DPT (in RAMVARS segment) 127 115 ; AH: BIOS Error code 116 ; CX: Number of successfully transferred sectors 128 117 ; CF: 0 if transfer succesfull 129 118 ; 1 if any error 130 119 ; Corrupts registers: 131 ; AL, BX, CX,DX, SI, ES120 ; AL, BX, DX, SI, ES 132 121 ;-------------------------------------------------------------------- 133 122 ALIGN JUMP_ALIGN … … 136 125 xchg di, si ; DS:DI now points DPT 137 126 call IdeWait_IRQorDRQ ; Wait until ready to transfer 138 jc SHORT WriteToDrive.ReturnWithTransferErrorInAH127 jc SHORT ReturnWithTransferErrorInAH 139 128 xchg si, di ; ES:DI now points buffer 140 129 141 ; Transfer full or last (possible partial) block 130 ALIGN JUMP_ALIGN 131 .ReadNextBlockFromDrive: 132 mov cx, [bp+PIOVARS.wWordsInBlock] 142 133 mov dx, [bp+PIOVARS.wDataPort] 143 dec WORD [bp+PIOVARS.wBlocksLeft] 144 jz SHORT .XferLastBlock 145 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 146 call [bp+PIOVARS.fnXfer] ; Transfer full block 147 148 ; Normalize pointer when necessary 149 mov ax, di 150 shr ax, 1 ; WORD offset 151 add ax, [bp+PIOVARS.wBlockSize] 152 jns SHORT ReadFromDrive 153 %ifdef USE_186 154 push ReadFromDrive 155 jmp Registers_NormalizeESDI 156 %else 157 call Registers_NormalizeESDI 158 jmp SHORT ReadFromDrive ; Loop while blocks left 159 %endif 160 161 162 ALIGN JUMP_ALIGN 163 .XferLastBlock: 164 xor cx, cx 165 mov ch, [bp+PIOVARS.bSectorsInLastBlock]; CX = Partial block size in WORDs 134 cmp [bp+PIOVARS.wWordsLeft], cx 135 jbe SHORT .ReadLastBlockFromDrive 136 call [bp+PIOVARS.fnXfer] 137 138 ; Wait until ready for next block and check for errors 139 xchg di, si ; DS:DI now points DPT 140 call IdeWait_IRQorDRQ ; Wait until ready to transfer 141 jc SHORT ReturnWithTransferErrorInAH 142 xchg si, di ; ES:DI now points buffer 143 144 ; Increment number of successfully read WORDs 145 mov ax, [bp+PIOVARS.wWordsInBlock] 146 sub [bp+PIOVARS.wWordsLeft], ax 147 add [bp+PIOVARS.wWordsDone], ax 148 jmp SHORT .ReadNextBlockFromDrive 149 150 ALIGN JUMP_ALIGN 151 .ReadLastBlockFromDrive: 152 mov cx, [bp+PIOVARS.wWordsLeft] 166 153 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 154 155 ; Check for errors in last block 167 156 mov di, si ; DS:DI now points DPT 168 157 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 169 jmp IdeWait_PollStatusFlagInBLwithTimeoutInBH 170 171 172 ;-------------------------------------------------------------------- 173 ; InitializePiovarsInSSBPwithSectorCountInAX 174 ; Parameters: 175 ; AX: Number of sectors to transfer (1...65535) 158 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 159 160 ; Return number of successfully read sectors 161 ReturnWithTransferErrorInAH: 162 mov cx, [bp+PIOVARS.wWordsDone] 163 jc SHORT .ConvertTransferredWordsInCXtoSectors 164 add cx, [bp+PIOVARS.wWordsLeft] ; Never sets CF 165 .ConvertTransferredWordsInCXtoSectors: 166 xchg cl, ch 167 ret 168 169 170 ;-------------------------------------------------------------------- 171 ; InitializePiovarsInSSBPwithSectorCountInAH 172 ; Parameters: 173 ; AH: Number of sectors to transfer (1...128) 176 174 ; BX: Offset to transfer function lookup table 177 175 ; DS:DI: Ptr to DPT (in RAMVARS segment) … … 183 181 ;-------------------------------------------------------------------- 184 182 ALIGN JUMP_ALIGN 185 InitializePiovarsInSSBPwithSectorCountInAX: 186 ; Store number of blocks to transfer 187 eMOVZX cx, BYTE [di+DPT_ATA.bSetBlock] ; Block size in sectors 188 xor dx, dx ; DX:AX = Sectors to transfer (1...65535) 189 div cx ; AX = Full blocks to transfer 190 test dx, dx 191 mov dh, cl ; DH = Full block size if no partial blocks to transfer 192 jz SHORT .NoPartialBlocksToTransfer 193 inc ax ; Partial block 194 mov dh, dl ; DH = Size of partial block in sectors 195 .NoPartialBlocksToTransfer: 196 mov [bp+PIOVARS.wBlocksLeft], ax 197 mov [bp+PIOVARS.bSectorsInLastBlock], dh 198 199 ; Store block size in WORDs 200 xchg ch, cl ; CX = Block size in WORDs 201 mov [bp+PIOVARS.wBlockSize], cx 183 InitializePiovarsInSSBPwithSectorCountInAH: 184 ; Store sizes 185 xor al, al 186 mov [bp+PIOVARS.wWordsLeft], ax 187 cbw 188 mov [bp+PIOVARS.wWordsDone], ax ; Zero 189 mov ah, [di+DPT_ATA.bSetBlock] 190 mov [bp+PIOVARS.wWordsInBlock], ax 202 191 203 192 ; Get transfer function based on bus type -
trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm
r181 r218 40 40 Idepack_ConvertDapToIdepackAndIssueCommandFromAH: 41 41 mov [bp+IDEPACK.bCommand], ah 42 mov a x, [es:si+DAP.wSectorCount]42 mov al, [es:si+DAP.bSectorCount] 43 43 mov [bp+IDEPACK.bSectorCount], al 44 mov [bp+IDEPACK.bSectorCountHighExt], ah45 44 46 45 mov al, [es:si+DAP.qwLBA] ; LBA byte 0 … … 66 65 ; Parameters: 67 66 ; AH: IDE command to issue 68 ; AL: Number of sectors to transfer (1...255, 0=256)67 ; AL: Number of sectors to transfer 69 68 ; BH: Timeout ticks 70 69 ; BL: IDE Status Register flag to wait after command … … 73 72 ; Bits 5...0: Starting sector number (1...63) 74 73 ; DH: Starting head number (0...255) 75 ; ES:SI: Ptr to data buffer76 74 ; DS:DI: Ptr to DPT (in RAMVARS segment) 77 ; SS:BP: Ptr to IDEPACK 75 ; SS:BP: Ptr to IDEPACK (containing INTPACK) 76 ; Parameters on INTPACK: 77 ; ES:BX: Ptr to data buffer 78 78 ; Returns: 79 79 ; AH: INT 13h Error Code … … 84 84 ALIGN JUMP_ALIGN 85 85 Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH: 86 mov [bp+IDEPACK.bSectorCount], al 86 87 mov [bp+IDEPACK.bCommand], ah 87 88 88 xor ah, ah89 cmp ah, al90 cmc91 adc ah, ah92 93 mov [bp+IDEPACK.bSectorCount], al94 mov [bp+IDEPACK.bSectorCountHighExt], ah95 96 89 push bx 90 call PrepareBuffer_ToESSIforOldInt13hTransfer 97 91 call Address_OldInt13hAddressToIdeAddress 98 92 call AccessDPT_GetDriveSelectByteToAL … … 135 129 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx 136 130 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx 137 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0138 131 139 132 ; Drive and Head select byte -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
r181 r218 53 53 ;ALIGN JUMP_ALIGN 54 54 AH24h_SetBlockSize: 55 MIN_U al, MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS56 55 push ax 57 56 xchg dx, ax ; DL = Block size (Sector Count Register) -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r169 r218 31 31 mov ah, [cs:bx+g_rgbReadCommandLookup] 32 32 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 33 mov si, [bp+IDEPACK.intpack+INTPACK.bx]34 33 %ifdef USE_186 35 34 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm
r169 r218 55 55 cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE 56 56 jb SHORT AH42h_ReturnWithInvalidFunctionError 57 cmp WORD [es:si+DAP. wSectorCount], BYTE 057 cmp WORD [es:si+DAP.bSectorCount], BYTE 0 58 58 je SHORT AH42h_ReturnWithInvalidFunctionError 59 59 ret -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r199 r218 210 210 %include "Address.asm" ; For sector address translations 211 211 %include "CommandLookup.asm" ; For getting correct transfer command 212 %include "PrepareBuffer.asm" ; For buffer pointer normalization 212 213 %include "Int13h.asm" ; For Int 13h, Disk functions 213 214 %include "AH0h_HReset.asm" ; Required by Int13h_Jump.asm
Note:
See TracChangeset
for help on using the changeset viewer.