- Timestamp:
- Aug 21, 2011, 4:39:58 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc
r167 r169 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: 44 .bSectorCount resb 1 ; 2, Number of sectors to process (1...127) 45 .bReservedAt3 resb 1 ; 3, Currently unused, must be zero 43 .wSectorCount resb 2 ; 2, Number of sectors to process (1...127) 46 44 .dwMemoryAddress: 47 45 .wOffset resb 2 ; 4, Memory offset for transfer -
trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
r167 r169 54 54 55 55 ; Parameters for 48-bit LBA 56 resb 1 56 .wSectorCountHighAndLbaLowExt: 57 .bSectorCountHighExt resb 1 57 58 .bLbaLowExt resb 1 ; LBA48 31...24 58 59 -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r167 r169 128 128 129 129 ; Output Sector Address High (only used by LBA48) 130 xor ax, ax ; Sector Count High always zero since 127 sector limit 131 mov ah, BYTE [bp+IDEPACK.bLbaLowExt] 130 mov ax, [bp+IDEPACK.wSectorCountHighAndLbaLowExt] 132 131 mov cx, [bp+IDEPACK.wLbaMiddleAndHighExt] 133 132 call OutputSectorCountAndAddress -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r167 r169 5 5 ; This struct must not be larger than IDEPACK without INTPACK. 6 6 struc PIOVARS 7 .wBlockLeftAndSectorsInLastBlock: 8 .bBlocksLeft resb 1 9 .bSectorsInLastBlock: resb 1 7 .wBlocksLeft resb 2 10 8 .wBlockSize resb 2 ; Block size in WORDs (256...32768) 11 9 .wDataPort resb 2 12 10 .bSectorsInLastBlock: resb 1 13 11 resb 1 ; Offset 7 = IDEPACK.bDeviceControl 14 12 .fnXfer resb 2 ; Offset to transfer function … … 34 32 ALIGN JUMP_ALIGN 35 33 IdeTransfer_StartWithCommandInAL: 34 mov ah, [bp+IDEPACK.bSectorCountHighExt] 35 36 36 ; Are we reading or writing? 37 37 test al, 16 ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands … … 42 42 ; Prepare to read data to ESSI 43 43 mov bx, g_rgfnPioRead 44 call InitializePiovarsToSSBPfromIdepackInSSBP 44 mov al, [bp+IDEPACK.bSectorCount] 45 call InitializePiovarsInSSBPwithSectorCountInAX 45 46 xchg si, di 46 %ifdef USE_18647 push ReadFromDriveToESDI48 jmp Registers_NormalizeESDI49 %else50 47 call Registers_NormalizeESDI 51 jmp SHORT ReadFromDriveToESDI 52 %endif 48 jmp SHORT ReadFromDrive 53 49 54 50 ALIGN JUMP_ALIGN 55 51 .PrepareToWriteDataFromESSI: 56 52 mov bx, g_rgfnPioWrite 57 call InitializePiovarsToSSBPfromIdepackInSSBP 53 mov al, [bp+IDEPACK.bSectorCount] 54 call InitializePiovarsInSSBPwithSectorCountInAX 58 55 call Registers_NormalizeESSI 59 ; Fall to WriteToDrive FromESSI60 61 62 ;-------------------------------------------------------------------- 63 ; WriteToDrive FromESSI56 ; Fall to WriteToDrive 57 58 59 ;-------------------------------------------------------------------- 60 ; WriteToDrive 64 61 ; Parameters: 65 62 ; DS:DI: Ptr to DPT (in RAMVARS segment) … … 73 70 ; AL, BX, CX, DX, SI, ES 74 71 ;-------------------------------------------------------------------- 75 WriteToDrive FromESSI:72 WriteToDrive: 76 73 ; Always poll when writing first block (IRQs are generated for following blocks) 77 74 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) … … 81 78 .WriteNextBlock: 82 79 mov dx, [bp+PIOVARS.wDataPort] 83 dec BYTE [bp+PIOVARS.bBlocksLeft] ; Transferring last (possibly partial) block?80 dec WORD [bp+PIOVARS.wBlocksLeft] ; Transferring last (possibly partial) block? 84 81 jz SHORT .XferLastBlock ; If so, jump to transfer 85 82 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 86 83 call [bp+PIOVARS.fnXfer] ; Transfer full block 84 85 ; Normalize pointer when necessary 86 mov ax, si 87 shr ax, 1 ; WORD offset 88 add ax, [bp+PIOVARS.wBlockSize] 89 jns SHORT .WaitUntilReadyToTransferNextBlock 90 call Registers_NormalizeESSI 91 92 ALIGN JUMP_ALIGN 93 .WaitUntilReadyToTransferNextBlock: 87 94 %ifdef USE_186 88 95 push .WriteNextBlock … … 110 117 111 118 ;-------------------------------------------------------------------- 112 ; ReadFromDrive ToESDI119 ; ReadFromDrive 113 120 ; Parameters: 114 121 ; ES:DI: Normalized ptr to buffer to recieve data … … 124 131 ;-------------------------------------------------------------------- 125 132 ALIGN JUMP_ALIGN 126 ReadFromDrive ToESDI:133 ReadFromDrive: 127 134 ; Wait until drive is ready to transfer 128 135 xchg di, si ; DS:DI now points DPT 129 136 call IdeWait_IRQorDRQ ; Wait until ready to transfer 130 jc SHORT WriteToDrive FromESSI.ReturnWithTransferErrorInAH137 jc SHORT WriteToDrive.ReturnWithTransferErrorInAH 131 138 xchg si, di ; ES:DI now points buffer 132 139 133 140 ; Transfer full or last (possible partial) block 134 141 mov dx, [bp+PIOVARS.wDataPort] 135 dec BYTE [bp+PIOVARS.bBlocksLeft]142 dec WORD [bp+PIOVARS.wBlocksLeft] 136 143 jz SHORT .XferLastBlock 137 144 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 138 %ifdef USE_186139 push ReadFromDriveToESDI140 jmp [bp+PIOVARS.fnXfer]141 %else142 145 call [bp+PIOVARS.fnXfer] ; Transfer full block 143 jmp SHORT ReadFromDriveToESDI ; Loop while blocks left 144 %endif 146 147 ; Normalize pointer when necessary 148 mov ax, di 149 shr ax, 1 ; WORD offset 150 add ax, [bp+PIOVARS.wBlockSize] 151 jns SHORT ReadFromDrive 152 %ifdef USE_186 153 push ReadFromDrive 154 jmp Registers_NormalizeESDI 155 %else 156 call Registers_NormalizeESDI 157 jmp SHORT ReadFromDrive ; Loop while blocks left 158 %endif 159 145 160 146 161 ALIGN JUMP_ALIGN … … 155 170 156 171 ;-------------------------------------------------------------------- 157 ; InitializePiovarsToSSBPfromIdepackInSSBP 158 ; Parameters: 172 ; InitializePiovarsInSSBPwithSectorCountInAX 173 ; Parameters: 174 ; AX: Number of sectors to transfer (1...65535) 159 175 ; BX: Offset to transfer function lookup table 160 176 ; DS:DI: Ptr to DPT (in RAMVARS segment) 161 ; SS:BP: Ptr to IDEPACK162 ; Returns:163 177 ; SS:BP: Ptr to PIOVARS 178 ; Returns: 179 ; Nothing 164 180 ; Corrupts registers: 165 181 ; AX, BX, CX, DX 166 182 ;-------------------------------------------------------------------- 167 183 ALIGN JUMP_ALIGN 168 InitializePiovars ToSSBPfromIdepackInSSBP:184 InitializePiovarsInSSBPwithSectorCountInAX: 169 185 ; Store number of blocks to transfer 170 eMOVZX cx, BYTE [di+DPT_ATA.bSetBlock] ; Block size in sectors, zero CH 171 eMOVZX ax, BYTE [bp+IDEPACK.bSectorCount] ; AX = sectors to transfer (1...128) 172 div cl ; AL = Full blocks to transfer 173 test ah, ah ; AH = Sectors in partial block 186 eMOVZX cx, BYTE [di+DPT_ATA.bSetBlock] ; Block size in sectors 187 xor dx, dx ; DX:AX = Sectors to transfer (1...65535) 188 div cx ; AX = Full blocks to transfer 189 test dx, dx 190 mov dh, cl ; DH = Full block size if no partial blocks to transfer 174 191 jz SHORT .NoPartialBlocksToTransfer 175 inc ax ; Add partial block to total block count176 SKIP2B dx ; Skip mov ah, cl192 inc ax ; Partial block 193 mov dh, dl ; DH = Size of partial block in sectors 177 194 .NoPartialBlocksToTransfer: 178 mov ah, cl ; Full block size if no partial blocks to transfer179 mov [bp+PIOVARS. wBlockLeftAndSectorsInLastBlock], ax195 mov [bp+PIOVARS.wBlocksLeft], ax 196 mov [bp+PIOVARS.bSectorsInLastBlock], dh 180 197 181 198 ; Store block size in WORDs -
trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm
r167 r169 39 39 Idepack_ConvertDapToIdepackAndIssueCommandFromAH: 40 40 mov [bp+IDEPACK.bCommand], ah 41 mov a l, [es:si+DAP.wSectorCount]41 mov ax, [es:si+DAP.wSectorCount] 42 42 mov [bp+IDEPACK.bSectorCount], al 43 mov [bp+IDEPACK.bSectorCountHighExt], ah 43 44 44 45 mov al, [es:si+DAP.qwLBA] ; LBA byte 0 … … 81 82 ALIGN JUMP_ALIGN 82 83 Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH: 84 mov [bp+IDEPACK.bCommand], ah 85 test al, al 86 eCSETZ ah 83 87 mov [bp+IDEPACK.bSectorCount], al 84 mov [bp+IDEPACK.b Command], ah88 mov [bp+IDEPACK.bSectorCountHighExt], ah 85 89 86 90 push bx … … 125 129 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx 126 130 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx 131 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0 127 132 128 133 ; Drive and Head select byte -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r167 r169 15 15 ; SS:BP: Ptr to IDEPACK 16 16 ; Parameters on INTPACK: 17 ; AL: Number of sectors to read (1... 127)17 ; AL: Number of sectors to read (1...255, 0=256) 18 18 ; CH: Cylinder number, bits 7...0 19 19 ; CL: Bits 7...6: Cylinder number bits 9 and 8 … … 28 28 ALIGN JUMP_ALIGN 29 29 AH2h_HandlerForReadDiskSectors: 30 cmp al, 031 jle SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero32 33 30 call CommandLookup_GetOldInt13hIndexToBX 34 31 mov ah, [cs:bx+g_rgbReadCommandLookup] … … 42 39 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 43 40 %endif 44 45 46 ;--------------------------------------------------------------------47 ; AH2h_ExitInt13hSinceSectorCountInIntpackIsZero48 ; Parameters:49 ; Nothing50 ; Returns:51 ; Jumps to Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH52 ;--------------------------------------------------------------------53 AH2h_ExitInt13hSinceSectorCountInIntpackIsZero:54 mov ah, RET_HD_INVALID55 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm
r167 r169 15 15 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 16 16 ; Parameters on INTPACK: 17 ; AL: Number of sectors to write (1... 127)17 ; AL: Number of sectors to write (1...255, 0=256) 18 18 ; CH: Cylinder number, bits 7...0 19 19 ; CL: Bits 7...6: Cylinder number bits 9 and 8 … … 27 27 ALIGN JUMP_ALIGN 28 28 AH3h_HandlerForWriteDiskSectors: 29 cmp al, 030 jle SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero31 32 29 call CommandLookup_GetOldInt13hIndexToBX 33 30 mov ah, [cs:bx+g_rgbWriteCommandLookup] -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
r167 r169 15 15 ; SS:BP: Ptr to INTPACK 16 16 ; Parameters on INTPACK in SS:BP: 17 ; AL: Number of sectors to verify (1... 127)17 ; AL: Number of sectors to verify (1...255, 0=256) 18 18 ; CH: Cylinder number, bits 7...0 19 19 ; CL: Bits 7...6: Cylinder number bits 9 and 8 … … 26 26 ALIGN JUMP_ALIGN 27 27 AH4h_HandlerForVerifyDiskSectors: 28 cmp al, 029 jle SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero30 31 28 mov ah, COMMAND_VERIFY_SECTORS 32 29 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm
r167 r169 54 54 mov es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet 55 55 cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE 56 jb SHORT .DapContentsNotValid56 jb SHORT AH42h_ReturnWithInvalidFunctionError 57 57 cmp WORD [es:si+DAP.wSectorCount], BYTE 0 58 j le SHORT .DapContentsNotValid ; Must be 1...12758 je SHORT AH42h_ReturnWithInvalidFunctionError 59 59 ret 60 .DapContentsNotValid: 61 jmp AH2h_ExitInt13hSinceSectorCountInIntpackIsZero 60 AH42h_ReturnWithInvalidFunctionError: 61 mov ah, RET_HD_INVALID 62 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm
r165 r169 27 27 AH43h_HandlerForExtendedWriteSectors: 28 28 cmp BYTE [bp+IDEPACK.intpack+INTPACK.al], 2 ; Verify requested? 29 jae SHORT .WriteWithVerifyNotSupported29 jae SHORT AH42h_ReturnWithInvalidFunctionError 30 30 31 31 call AH42h_LoadDapToESSIandVerifyForTransfer … … 40 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 41 41 %endif 42 43 .WriteWithVerifyNotSupported:44 jmp AH2h_ExitInt13hSinceSectorCountInIntpackIsZero -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH47h_ExtendedSeek.asm
r165 r169 25 25 mov es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet 26 26 cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE 27 jb SHORT .DapContentsNotValid27 jb SHORT AH42h_ReturnWithInvalidFunctionError 28 28 29 29 mov ah, COMMAND_SEEK … … 36 36 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 37 37 %endif 38 39 .DapContentsNotValid:40 jmp AH2h_ExitInt13hSinceSectorCountInIntpackIsZero -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
r167 r169 34 34 call AH25h_GetDriveInformationToBufferInESSI 35 35 jc SHORT .ReturnWithError 36 call AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI37 xchg cx, ax ; Sector count now in BX:DX:CX38 36 39 ; Point ES:DI to Destination buffer37 ; Point DS:DI to Destination buffer 40 38 mov di, [bp+IDEPACK.intpack+INTPACK.si] 41 mov es, [bp+IDEPACK.intpack+INTPACK.ds]39 mov ds, [bp+IDEPACK.intpack+INTPACK.ds] 42 40 mov ax, MINIMUM_EDRIVEINFO_SIZE 43 cmp WORD [ es:di+EDRIVE_INFO.wSize], ax44 jb SHORT .BufferTooSmall41 cmp WORD [di+EDRIVE_INFO.wSize], ax 42 jb SHORT AH42h_ReturnWithInvalidFunctionError 45 43 je SHORT .SkipEddConfigurationParameters 46 44 … … 48 46 xor ax, ax 49 47 dec ax ; AX = FFFFh 50 mov [ es:di+EDRIVE_INFO.fpEDDparams], ax51 mov [ es:di+EDRIVE_INFO.fpEDDparams+2], ax48 mov [di+EDRIVE_INFO.fpEDDparams], ax 49 mov [di+EDRIVE_INFO.fpEDDparams+2], ax 52 50 mov ax, EDRIVE_INFO_size 53 51 54 ; Fill Extended Drive Information Table in ES:DI52 ; Fill Extended Drive Information Table in DS:DI 55 53 .SkipEddConfigurationParameters: 56 stosw ; Store Extended Drive Information Table size 57 mov al, FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS 58 stosw 59 add di, BYTE 12 ; Skip CHS parameters 60 xchg ax, cx 61 stosw ; LBA WORD 0 62 xchg ax, dx 63 stosw ; LBA WORD 1 64 xchg ax, bx 65 stosw ; LBA WORD 2 66 xor ax, ax 67 stosw ; LBA WORD 3 always zero since 48-bit address 68 mov ah, 512>>8 69 stosw ; Always 512-byte sectors 54 mov [di+EDRIVE_INFO.wSize], ax 55 mov WORD [di+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS | FLG_CHS_INFORMATION_IS_VALID 56 57 call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI 58 xor cx, cx 59 mov [di+EDRIVE_INFO.dwCylinders], ax 60 mov [di+EDRIVE_INFO.dwCylinders+2], cx 61 eMOVZX ax, bl 62 mov [di+EDRIVE_INFO.dwHeads], ax 63 mov [di+EDRIVE_INFO.dwHeads+2], cx 64 mov al, bh 65 mov [di+EDRIVE_INFO.dwSectorsPerTrack], ax 66 mov [di+EDRIVE_INFO.dwSectorsPerTrack+2], cx 67 68 call AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI 69 mov [di+EDRIVE_INFO.qwTotalSectors], ax 70 mov [di+EDRIVE_INFO.qwTotalSectors+2], dx 71 mov [di+EDRIVE_INFO.qwTotalSectors+4], bx 72 mov [di+EDRIVE_INFO.qwTotalSectors+6], cx 73 74 mov WORD [di+EDRIVE_INFO.wSectorSize], 512 70 75 71 76 ; Return with success 72 77 xor ah, ah 73 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH74 75 .BufferTooSmall:76 mov ah, RET_HD_INVALID77 78 .ReturnWithError: 78 79 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r165 r169 7 7 8 8 ;-------------------------------------------------------------------- 9 ; AtaID_GetPCHS 9 ; AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI 10 10 ; Parameters: 11 11 ; ES:SI: Ptr to 512-byte ATA information read from the drive … … 17 17 ; Nothing 18 18 ;-------------------------------------------------------------------- 19 AtaID_GetPCHS :19 AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI: 20 20 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383) 21 21 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16) -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r162 r169 83 83 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 84 84 jnz SHORT .GetUserSpecifiedPCHS 85 call AtaID_GetPCHS ; Get from ATA information85 call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI 86 86 jmp SHORT .StorePCHStoDPT 87 87
Note:
See TracChangeset
for help on using the changeset viewer.