Changeset 150 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers
- Timestamp:
- Apr 29, 2011, 7:04:13 PM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Handlers
- Files:
-
- 7 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
r148 r150 22 22 Int13h_DiskFunctionsHandler: 23 23 sti ; Enable interrupts 24 SAVE_AND_GET_INTPACK_TO_SSBP 24 cld ; String instructions to increment pointers 25 SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK 25 26 26 27 call RamVars_GetSegmentToDS … … 46 47 ; DL: Translated drive number 47 48 ; DS: RAMVARS segment 48 ; SS:BP: Ptr to I NTPACK49 ; SS:BP: Ptr to IDEPACK 49 50 ; BX, DI: Corrupted on Int13h_DiskFunctionsHandler 50 51 ; Other: Function specific INT 13h parameters … … 58 59 Int13h_DirectCallToAnotherBios: 59 60 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler 60 mov bx, [bp+I NTPACK.bx]61 mov di, [bp+I NTPACK.di]62 mov ds, [bp+I NTPACK.ds]63 push WORD [bp+I NTPACK.flags]61 mov bx, [bp+IDEPACK.intpack+INTPACK.bx] 62 mov di, [bp+IDEPACK.intpack+INTPACK.di] 63 mov ds, [bp+IDEPACK.intpack+INTPACK.ds] 64 push WORD [bp+IDEPACK.intpack+INTPACK.flags] 64 65 popf 65 66 push bp 66 mov bp, [bp+I NTPACK.bp]67 mov bp, [bp+IDEPACK.intpack+INTPACK.bp] 67 68 int BIOS_DISK_INTERRUPT_13h ; Can safely do as much recursion as it wants 68 69 … … 70 71 pop bp ; Standard INT 13h functions never uses BP as return register 71 72 %ifdef USE_386 72 mov [bp+I NTPACK.gs], gs73 mov [bp+I NTPACK.fs], fs73 mov [bp+IDEPACK.intpack+INTPACK.gs], gs 74 mov [bp+IDEPACK.intpack+INTPACK.fs], fs 74 75 %endif 75 mov [bp+I NTPACK.es], es76 mov [bp+I NTPACK.ds], ds77 mov [bp+I NTPACK.di], di78 mov [bp+I NTPACK.si], si79 mov [bp+I NTPACK.bx], bx80 mov [bp+I NTPACK.dh], dh81 mov [bp+I NTPACK.cx], cx82 mov [bp+I NTPACK.ax], ax76 mov [bp+IDEPACK.intpack+INTPACK.es], es 77 mov [bp+IDEPACK.intpack+INTPACK.ds], ds 78 mov [bp+IDEPACK.intpack+INTPACK.di], di 79 mov [bp+IDEPACK.intpack+INTPACK.si], si 80 mov [bp+IDEPACK.intpack+INTPACK.bx], bx 81 mov [bp+IDEPACK.intpack+INTPACK.dh], dh 82 mov [bp+IDEPACK.intpack+INTPACK.cx], cx 83 mov [bp+IDEPACK.intpack+INTPACK.ax], ax 83 84 pushf 84 pop WORD [bp+I NTPACK.flags]85 pop WORD [bp+IDEPACK.intpack+INTPACK.flags] 85 86 call RamVars_GetSegmentToDS 86 87 cmp dl, [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv] 87 88 je SHORT .ExchangeInt13hHandlers 88 mov [bp+I NTPACK.dl], dl ; Something is returned in DL89 mov [bp+IDEPACK.intpack+INTPACK.dl], dl ; Something is returned in DL 89 90 ALIGN JUMP_ALIGN 90 91 .ExchangeInt13hHandlers: … … 98 99 ; Parameters: 99 100 ; AH: BIOS Error code 100 ; SS:BP: Ptr to I NTPACK101 ; SS:BP: Ptr to IDEPACK 101 102 ; Returns: 102 103 ; All registers are loaded from INTPACK … … 104 105 ALIGN JUMP_ALIGN 105 106 Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH: 106 call HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH107 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH 107 108 Int13h_ReturnFromHandlerWithoutStoringErrorCode: 108 or WORD [bp+I NTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled109 or WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled 109 110 mov sp, bp ; Now we can exit anytime 110 RESTORE_INTPACK_ FROM_SSBP111 RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK 111 112 112 113 … … 146 147 LOAD_BDA_SEGMENT_TO es, di 147 148 mov di, [RAMVARS.fpOldI13h] 149 cli 148 150 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4] 149 151 mov [RAMVARS.fpOldI13h], di … … 152 154 mov [RAMVARS.fpOldI13h+2], di 153 155 pop es 156 sti 157 ret 158 159 160 ;-------------------------------------------------------------------- 161 ; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH 162 ; Int13h_SetErrorCodeToIntpackInSSBPfromAH 163 ; Parameters: 164 ; AH: BIOS error code (00h = no error) 165 ; SS:BP: Ptr to IDEPACK 166 ; Returns: 167 ; SS:BP: Ptr to IDEPACK with error condition set 168 ; Corrupts registers: 169 ; DS, DI 170 ;-------------------------------------------------------------------- 171 ALIGN JUMP_ALIGN 172 Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH: 173 ; Store error code to BDA 174 LOAD_BDA_SEGMENT_TO ds, di 175 mov [BDA.bHDLastSt], ah 176 177 ; Store error code to INTPACK 178 Int13h_SetErrorCodeToIntpackInSSBPfromAH: 179 mov [bp+IDEPACK.intpack+INTPACK.ah], ah 180 test ah, ah 181 jnz SHORT .SetCFtoIntpack 182 and BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF 183 ret 184 .SetCFtoIntpack: 185 or BYTE [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_CF 154 186 ret 155 187 … … 224 256 ; dw Int13h_UnsupportedFunction ; 3Fh, 225 257 ; dw Int13h_UnsupportedFunction ; 40h, 226 ; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS) 227 ; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS) 228 ; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS) 229 ; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS) 230 ; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS) 231 ; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS) 232 ; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS) 233 ; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS) 234 ; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS) 258 ; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)* 259 ; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)* 260 ; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)* 261 ; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)* 262 ; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)*** 263 ; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)*** 264 ; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)* 265 ; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)* 266 ; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)*** 235 267 ; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM) 236 268 ; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM) 237 269 ; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM) 238 270 ; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM) 239 ; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS) 271 ; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)** 272 ; 273 ; * = Enhanced Drive Access Support (minimum required EBIOS functions) 274 ; ** = Enhanced Disk Drive (EDD) Support 275 ; *** = Drive Locking and Ejecting Support -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r148 r150 13 13 ; If bit 7 is set all hard disks and floppy disks reset. 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Returns with INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Returns with INTPACK: 17 17 ; AH: Int 13h return status (from drive requested in DL) 18 18 ; CF: 0 if succesfull, 1 if error … … 89 89 90 90 ;-------------------------------------------------------------------- 91 ; ResetHardDisksHandledByOurBIOS91 ; AH0h_ResetHardDisksHandledByOurBIOS 92 92 ; Parameters: 93 93 ; BL: Requested drive (DL when entering AH=00h) 94 94 ; DS: RAMVARS segment 95 ; SS:BP: Ptr to IDEPACK 95 96 ; Returns: 96 97 ; BH: Error code from requested drive (if available) 97 98 ; Corrupts registers: 98 ; AX, CX, DX, DI99 ; AX, CX, DX, SI, DI 99 100 ;-------------------------------------------------------------------- 100 101 ALIGN JUMP_ALIGN … … 103 104 test dh, dh 104 105 jz SHORT .AllDrivesReset ; Return if no drives 105 mov dl, [RAMVARS.bFirstDrv] ; Load number of first ourdrive106 mov dl, [RAMVARS.bFirstDrv] ; Load number of our first drive 106 107 add dh, dl ; DH = one past last drive to reset 107 108 ALIGN JUMP_ALIGN … … 132 133 .BackupErrorCodeFromMasterOrSlaveToBH: 133 134 call BackupErrorCodeFromTheRequestedDriveToBH 134 mov cx, [RAMVARS.wIdeBase]; Load base port for resetted drive135 135 call GetBasePortToCX ; Load base port for resetted drive 136 push cx 136 137 inc dx ; DL to next drive 137 call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS138 jnc SHORT .NoMoreDrivesOrNoSlaveDrive139 cmp cx, [RAMVARS.wIdeBase]; Next drive is from same controller?138 call GetBasePortToCX 139 pop di 140 cmp cx, di ; Next drive is from same controller? 140 141 je SHORT BackupErrorCodeFromTheRequestedDriveToBH 141 142 .NoMoreDrivesOrNoSlaveDrive: 142 143 dec dx 144 ret 145 146 ;-------------------------------------------------------------------- 147 ; GetBasePortToCX 148 ; Parameters: 149 ; DL: Drive number 150 ; DS: RAMVARS segment 151 ; Returns: 152 ; CX: Base port address 153 ; CF: Set if valid drive number 154 ; Cleared if invalid drive number 155 ; Corrupts registers: 156 ; DI 157 ;-------------------------------------------------------------------- 158 ALIGN JUMP_ALIGN 159 GetBasePortToCX: 160 xchg cx, bx 161 xor bx, bx 162 call FindDPT_ForDriveNumber 163 jnc SHORT .DptNotFound 164 mov bl, [di+DPT.bIdevarsOffset] 165 mov bx, [cs:bx+IDEVARS.wPort] 166 .DptNotFound: 167 xchg bx, cx 143 168 ret 144 169 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 19 19 ALIGN JUMP_ALIGN 20 20 AH10h_HandlerForCheckDriveReady: 21 call HStatus_WaitRdyDefTime 22 xor ah, ah 21 %ifdef USE_186 22 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 23 jmp Device_SelectDrive 24 %else 25 call Device_SelectDrive 23 26 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 27 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: BIOS Error code 17 17 ; CF: 0 if succesfull, 1 if error … … 32 32 ; Parameters: 33 33 ; DS:DI: Ptr to DPT (in RAMVARS segment) 34 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 34 35 ; Returns: 35 36 ; AH: BIOS Error code -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; If succesfull: 17 17 ; AH: 3 (Hard disk accessible) … … 25 25 ALIGN JUMP_ALIGN 26 26 AH15h_HandlerForReadDiskDriveSize: 27 call HCapacity_GetSectorCountFromOurAH08h ; Sector count to DX:AX28 mov [bp+I NTPACK.cx], dx; HIWORD to CX29 mov [bp+I NTPACK.dx], ax; LOWORD to DX27 call AH15h_GetSectorCountToDXAX 28 mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX 29 mov [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX 30 30 31 31 xor ah, ah 32 call HError_SetErrorCodeToIntpackInSSBPfromAH ; Store success to BDA and CF33 mov BYTE [bp+I NTPACK.ah], 3; Type code = Hard disk32 call Int13h_SetErrorCodeToIntpackInSSBPfromAH ; Store success to BDA and CF 33 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 ; Type code = Hard disk 34 34 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode 35 36 37 ;-------------------------------------------------------------------- 38 ; AH15h_GetSectorCountFromForeignDriveToDXAX: 39 ; AH15h_GetSectorCountToDXAX: 40 ; Parameters: 41 ; DL: Drive number 42 ; DS: RAMVARS segment 43 ; DS:DI: Ptr to DPT (AH15h_GetSectorCount only) 44 ; Returns: 45 ; DX:AX: Total sector count 46 ; BX: Zero 47 ; Corrupts registers: 48 ; CX 49 ;-------------------------------------------------------------------- 50 AH15h_GetSectorCountFromForeignDriveToDXAX: 51 mov ah, GET_DRIVE_PARAMETERS 52 call Int13h_CallPreviousInt13hHandler 53 jmp SHORT ConvertAH08hReturnValuesToSectorCount 54 55 ALIGN JUMP_ALIGN 56 AH15h_GetSectorCountToDXAX: 57 call AH8h_GetDriveParameters 58 ; Fall to ConvertAH08hReturnValuesToSectorCount 59 60 ConvertAH08hReturnValuesToSectorCount: 61 call HAddress_ExtractLCHSparametersFromOldInt13hAddress 62 xor ax, ax ; Zero AX 63 inc cx ; Max cylinder number to cylinder count 64 xchg al, bh ; AX=Max head number, BX=Sectors per track 65 inc ax ; AX=Head count 66 mul bx ; AX=Head count * Sectors per track 67 mul cx ; DX:AX = Total sector count 68 xor bx, bx ; Zero BX for 48-bit sector count (and clear CF) 69 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h floppy return status 17 17 ; CF: 0 if AH = RET_HD_SUCCESS, 1 otherwise (error) … … 21 21 LOAD_BDA_SEGMENT_TO ds, ax, ! 22 22 xchg ah, [BDA.bHDLastSt] ; Load and clear last error 23 call HError_SetErrorCodeToIntpackInSSBPfromAH23 call Int13h_SetErrorCodeToIntpackInSSBPfromAH 24 24 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm
r148 r150 14 14 ; DL: Translated Drive number 15 15 ; DS:DI: Ptr to DPT (in RAMVARS segment) 16 ; SS:BP: Ptr to I NTPACK17 ; Parameters on INTPACK in SS:BP:16 ; SS:BP: Ptr to IDEPACK 17 ; Parameters on INTPACK: 18 18 ; AL: Feature Number (parameter to Features Register = subcommand) 19 ; (Parameter registers are undocumented, the re are specific for this BIOS):20 ; B H: Parameter to Sector Count Register (subcommand specific)21 ; B L: Parameter toSector Number Register (subcommand specific)22 ; CL: Parameter to L ow CylinderRegister (subcommand specific)23 ; CH: Parameter to High CylinderRegister (subcommand specific)24 ; Returns with INTPACK in SS:BP:19 ; (Parameter registers are undocumented, these are specific for this BIOS): 20 ; BL: Parameter to Sector Count Register (subcommand specific) 21 ; BH: Parameter to LBA Low / Sector Number Register (subcommand specific) 22 ; CL: Parameter to LBA Middle / Cylinder Low Register (subcommand specific) 23 ; CH: Parameter to LBA High / Cylinder High Register (subcommand specific) 24 ; Returns with INTPACK: 25 25 ; AH: Int 13h return status 26 26 ; CF: 0 if succesfull, 1 if error … … 28 28 ALIGN JUMP_ALIGN 29 29 AH23h_HandlerForSetControllerFeatures: 30 xchg si, ax ; SI = Feature Number 31 mov dx, [bp+IDEPACK.intpack+INTPACK.bx] 30 32 %ifndef USE_186 31 33 call AH23h_SetControllerFeatures … … 40 42 ; AH23h_SetControllerFeatures 41 43 ; Parameters: 42 ; AL: Feature Number (parameter to Features Register = subcommand)43 ; BH: Parameter to Sector CountRegister (subcommand specific)44 ; BL: Parameter to Sector NumberRegister (subcommand specific)45 ; C L: Parameter to Low CylinderRegister (subcommand specific)46 ; CH: Parameter to High Cylinder Register (subcommand specific)44 ; DL: Parameter to Sector Count Register (subcommand specific) 45 ; DH: Parameter to LBA Low / Sector Number Register (subcommand specific) 46 ; CL: Parameter to LBA Middle / Cylinder Low Register (subcommand specific) 47 ; CH: Parameter to LBA High / Cylinder High Register (subcommand specific) 48 ; SI: Feature Number (parameter to Features Register = subcommand) 47 49 ; DS:DI: Ptr to DPT (in RAMVARS segment) 50 ; SS:BP: Ptr to IDEPACK 48 51 ; Returns: 49 52 ; AH: Int 13h return status 50 53 ; CF: 0 if succesfull, 1 if error 51 54 ; Corrupts registers: 52 ; A X, BX, CX, DX, SI55 ; AL, BX, CX, DX 53 56 ;-------------------------------------------------------------------- 54 57 ALIGN JUMP_ALIGN 55 58 AH23h_SetControllerFeatures: 56 ; Backup AL and BH to SI 57 mov ah, bh 58 xchg si, ax 59 60 ; Select Master or Slave and wait until ready 61 call HDrvSel_SelectDriveAndDisableIRQ 62 jc SHORT .ReturnWithErrorCodeInAH 63 64 ; Output Feature Number 65 mov ax, si ; Feature number to AL 66 mov dx, [RAMVARS.wIdeBase] ; Load base port address 67 inc dx ; REGW_IDE_FEAT 68 out dx, al 69 70 ; Output parameters to Sector Number Register and Cylinder Registers 71 xor bh, bh ; Zero head number 72 dec dx ; Back to base port address 73 call HCommand_OutputTranslatedLCHSaddress 74 75 ; Output parameter to Sector Count Register and command 76 xchg ax, si ; Sector Count Reg param to AH 77 mov al, ah ; Sector Count Reg param to AL 78 mov ah, HCMD_SET_FEAT ; Load Set Features command to AH 79 call HCommand_OutputSectorCountAndCommand 80 81 jmp HStatus_WaitBsyDefTime ; Wait until drive ready 82 .ReturnWithErrorCodeInAH: 83 ret 59 mov al, COMMAND_SET_FEATURES 60 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 61 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 17 17 ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128) 18 ; Returns with INTPACK in SS:BP:18 ; Returns with INTPACK: 19 19 ; AH: Int 13h return status 20 20 ; CF: 0 if succesfull, 1 if error … … 22 22 ALIGN JUMP_ALIGN 23 23 AH24h_HandlerForSetMultipleBlocks: 24 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 25 jnz SHORT .TryToSetBlockMode 26 stc 27 mov ah, RET_HD_INVALID 28 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 29 30 ALIGN JUMP_ALIGN 31 .TryToSetBlockMode: 24 32 %ifndef USE_186 25 33 call AH24h_SetBlockSize … … 32 40 33 41 ;-------------------------------------------------------------------- 34 ; Sets block size for block mode transfers.35 ;36 42 ; AH24h_SetBlockSize 37 43 ; Parameters: 38 44 ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128) 39 45 ; DS:DI: Ptr to DPT (in RAMVARS segment) 46 ; SS:BP: Ptr to IDEPACK 40 47 ; Returns: 41 48 ; AH: Int 13h return status … … 46 53 ALIGN JUMP_ALIGN 47 54 AH24h_SetBlockSize: 48 ; Select Master or Slave and wait until ready 49 mov bl, al ; Backup block size 50 call HDrvSel_SelectDriveAndDisableIRQ ; Select drive and wait until ready 51 jc SHORT .ReturnWithErrorCodeInAH ; Return if error 52 53 ; Output block size and command 54 mov al, bl ; Restore block size to AL 55 mov ah, HCMD_SET_MUL ; Load command to AH 56 mov dx, [RAMVARS.wIdeBase] ; Load base port address 57 add dx, BYTE REG_IDE_CNT 58 call HCommand_OutputSectorCountAndCommand 59 call HStatus_WaitBsyDefTime ; Wait until drive not busy 55 MIN_U al, MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS 56 push ax 57 xchg dx, ax ; DL = Block size (Sector Count Register) 58 mov al, COMMAND_SET_MULTIPLE_MODE 59 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY) 60 call Idepack_StoreNonExtParametersAndIssueCommandFromAL 61 pop bx 60 62 jc SHORT .DisableBlockMode 61 63 62 64 ; Store new block size to DPT and return 63 mov [di+DPT.bSetBlock], bl ; Store new block size 64 xor ah, ah ; Zero AH and CF since success 65 mov [di+DPT_ATA.bSetBlock], bl ; Store new block size 65 66 ret 66 67 .DisableBlockMode: 67 mov BYTE [di+DPT.bSetBlock], 1 ; Disable block mode 68 .ReturnWithErrorCodeInAH: 68 mov BYTE [di+DPT_ATA.bSetBlock], 1 ; Disable block mode 69 69 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 17 17 ; ES:BX: Ptr to buffer to receive 512-byte drive information 18 ; Returns with INTPACK in SS:BP:18 ; Returns with INTPACK: 19 19 ; AH: Int 13h return status 20 20 ; CF: 0 if succesfull, 1 if error … … 22 22 ALIGN JUMP_ALIGN 23 23 AH25h_HandlerForGetDriveInformation: 24 ; Wait until previously selected drive is ready 25 call HDrvSel_SelectDriveAndDisableIRQ 26 jc SHORT .ReturnWithErrorCodeInAH ; Return if error 24 push bp 27 25 28 ; Get drive information 29 mov bx, [bp+INTPACK.bx] 30 call HPIO_NormalizeDataPointer 31 push bx 32 mov dx, [RAMVARS.wIdeBase] ; Load base port address 33 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; Load offset to IDEVARS 34 mov bl, [cs:bx+IDEVARS.bBusType]; Load bus type to BL 35 mov bh, [di+DPT.bDrvSel] ; Load drive sel byte to BH 36 pop di ; Pop buffer offset to DI 37 call AH25h_GetDriveInfo ; Get drive information 38 .ReturnWithErrorCodeInAH: 26 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 27 call AccessDPT_GetDriveSelectByteToAL 28 mov bh, al 29 eMOVZX ax, BYTE [di+DPT.bIdevarsOffset] 30 xchg bp, ax 31 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH 32 33 pop bp 39 34 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 40 41 42 ;--------------------------------------------------------------------43 ; Gets drive information using Identify Device command.44 ;45 ; AH25h_GetDriveInfo46 ; Parameters:47 ; BH: Drive Select byte for Drive and Head Select Register48 ; BL: Bus type49 ; DX: IDE Controller base port address50 ; DS: Segment to RAMVARS51 ; ES:DI: Ptr to buffer to receive 512 byte drive information52 ; Returns:53 ; AH: Int 13h return status (will be stored to BDA)54 ; CF: 0 if succesfull, 1 if error55 ; Corrupts registers:56 ; AL, CX57 ;--------------------------------------------------------------------58 ALIGN JUMP_ALIGN59 AH25h_GetDriveInfo:60 push di61 push dx62 push bx63 64 ; Select Master or Slave drive.65 ; DO NOT WAIT UNTIL CURRENTLY SELECTED IS READY!66 ; It makes slave drive detection impossible if master is not present.67 mov [RAMVARS.wIdeBase], dx ; Store IDE Base port to RAMVARS68 add dx, BYTE REG_IDE_DRVHD ; DX to Drive and Head Sel Register69 mov al, bh ; Drive Select byte to AL70 out dx, al ; Select Master or Slave drive71 sub dx, BYTE REG_IDE_DRVHD ; Back to IDE Base port72 73 ; Wait until ready to accept commands74 xor bh, bh ; BX now contains bus type75 mov cl, B_TIMEOUT_DRVINFO ; Load short timeout76 cmp [RAMVARS.bDrvCnt], bh ; Detecting first drive?77 eCMOVE cl, B_TIMEOUT_RESET ; If so, load long timeout78 call HStatus_WaitRdy ; Wait until ready to accept commands79 jc SHORT .ReturnWithErrorCodeInAH80 81 ; Output command82 mov al, HCMD_ID_DEV ; Load Identify Device command to AL83 out dx, al ; Output command84 call HStatus_WaitDrqDefTime ; Wait until ready to transfer (no IRQ!)85 jc SHORT .ReturnWithErrorCodeInAH86 87 ; Transfer data88 sub dx, BYTE REGR_IDE_ST ; DX to IDE Data Reg89 mov cx, 256 ; Transfer 256 words (single sector)90 cld ; INSW to increment DI91 call [cs:bx+g_rgfnPioRead] ; Read ID sector92 call HStatus_WaitRdyDefTime ; Wait until drive ready93 94 .ReturnWithErrorCodeInAH:95 pop bx96 pop dx97 pop di98 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:17 ; AL: Number of sectors to read (1...255 )15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 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 … … 21 21 ; DH: Starting head number (0...255) 22 22 ; ES:BX: Pointer to buffer recieving data 23 ; Returns with INTPACK in SS:BP:23 ; Returns with INTPACK: 24 24 ; AH: Int 13h/40h floppy return status 25 25 ; AL: Burst error length if AH returns 11h, undefined otherwise … … 28 28 ALIGN JUMP_ALIGN 29 29 AH2h_HandlerForReadDiskSectors: 30 test al, al ; Invalid sector count? 31 jz SHORT AH2h_ZeroCntErr ; If so, return with error 32 33 ; Select sector or block mode command 34 mov ah, HCMD_READ_SECT ; Load sector mode command 35 cmp BYTE [di+DPT.bSetBlock], 1 ; Block mode enabled? 36 eCMOVA ah, HCMD_READ_MUL ; Load block mode command 37 38 ; Transfer data 39 call HCommand_OutputCountAndLCHSandCommand 40 jc SHORT .ReturnWithErrorCodeInAH 41 mov bx, [bp+INTPACK.bx] 42 call HPIO_ReadBlock ; Read data from IDE-controller 43 .ReturnWithErrorCodeInAH: 30 mov ah, COMMAND_READ_SECTORS ; Load sector mode command 31 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 32 eCMOVNZ ah, COMMAND_READ_MULTIPLE ; Load block mode command 33 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 34 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 35 %ifdef USE_186 36 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 37 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 38 %else 39 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 44 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 45 46 ; Invalid sector count (also for AH=3h and AH=4h) 47 AH2h_ZeroCntErr: 48 mov ah, RET_HD_INVALID ; Invalid value passed 49 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 41 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 16 ; Parameters on INTPACK: 17 17 ; AL: Number of sectors to write 18 18 ; CH: Cylinder number, bits 7...0 … … 21 21 ; DH: Starting head number (0...255) 22 22 ; ES:BX: Pointer to source data 23 ; Returns with INTPACK in SS:BP:23 ; Returns with INTPACK: 24 24 ; AH: Int 13h/40h floppy return status 25 25 ; CF: 0 if successfull, 1 if error … … 27 27 ALIGN JUMP_ALIGN 28 28 AH3h_HandlerForWriteDiskSectors: 29 test al, al ; Invalid sector count? 30 jz SHORT AH2h_ZeroCntErr ; If so, return with error 31 32 ; Select sector or block mode command 33 mov ah, HCMD_WRITE_SECT ; Load sector mode command 34 cmp BYTE [di+DPT.bSetBlock], 1 ; Block mode enabled? 35 eCMOVA ah, HCMD_WRITE_MUL ; Load block mode command 36 37 ; Transfer data 38 call HCommand_OutputCountAndLCHSandCommand 39 jc SHORT .ReturnWithErrorCodeInAH 40 mov bx, [bp+INTPACK.bx] 41 call HPIO_WriteBlock ; Write data to IDE-controller 42 .ReturnWithErrorCodeInAH: 29 ; Prepare parameters 30 mov ah, COMMAND_WRITE_SECTORS ; Load sector mode command 31 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 32 eCMOVNZ ah, COMMAND_WRITE_MULTIPLE ; Load block mode command 33 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 34 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 35 %ifdef USE_186 36 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 37 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 38 %else 39 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 43 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 41 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
r148 r150 26 26 ALIGN JUMP_ALIGN 27 27 AH4h_HandlerForVerifyDiskSectors: 28 test al, al ; Invalid sector count? 29 jz SHORT AH2h_ZeroCntErr ; If so, return with error 30 31 mov ah, HCMD_VERIFY_SECT ; Load command to AH 32 call HCommand_OutputCountAndLCHSandCommand 33 jc SHORT .ReturnWithErrorCodeInAH 34 mov bx, di ; DS:BX now points to DPT 35 call HStatus_WaitIrqOrRdy ; Wait for IRQ or RDY 36 .ReturnWithErrorCodeInAH: 28 mov ah, COMMAND_WRITE_SECTORS 29 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 30 %ifdef USE_186 31 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 32 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 33 %else 34 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 37 35 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 36 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; CH: Maximum cylinder number, bits 7...0 17 17 ; CL: Bits 7...6: Cylinder number bits 9...8 … … 34 34 call RamVars_GetCountOfKnownDrivesToDL 35 35 .ReturnAfterStoringValuesToIntpack: 36 mov [bp+I NTPACK.cx], cx37 mov [bp+I NTPACK.dx], dx36 mov [bp+IDEPACK.intpack+INTPACK.cx], cx 37 mov [bp+IDEPACK.intpack+INTPACK.dx], dx 38 38 xor ah, ah 39 39 .ReturnErrorFromPreviousInt13hHandler: -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 34 34 ; Parameters: 35 35 ; DS:DI: Ptr to DPT (in RAMVARS segment) 36 ; SS:BP: Ptr to IDEPACK 36 37 ; Returns: 37 38 ; AH: Int 13h return status … … 45 46 46 47 ; Try to select drive and wait until ready 47 or BYTE [di+DPT.bReset], MASK_RESET_ALL ; Everything uninitialized 48 call HDrvSel_SelectDriveAndDisableIRQ 48 or WORD [di+DPT.wFlags], MASK_DPT_RESET ; Everything uninitialized 49 call AccessDPT_GetDriveSelectByteToAL 50 mov [bp+IDEPACK.bDrvAndHead], al 51 call Device_SelectDrive 49 52 jc SHORT .ReturnNotSuccessfull 50 and BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY; Clear since success53 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nDRDY ; Clear since success 51 54 52 55 ; Initialize CHS parameters if LBA is not used 53 call AH9h_InitializeDeviceParameters56 call InitializeDeviceParameters 54 57 jc SHORT .RecalibrateDrive 55 and BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS58 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nINITPRMS 56 59 57 60 ; Recalibrate drive by seeking to cylinder 0 58 ALIGN JUMP_ALIGN59 61 .RecalibrateDrive: 60 62 call AH11h_RecalibrateDrive 61 63 jc SHORT .InitializeBlockMode 62 and BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE64 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nRECALIBRATE 63 65 64 66 ; Initialize block mode transfers 65 67 .InitializeBlockMode: 66 call AH9h_InitializeBlockMode68 call InitializeBlockMode 67 69 jc SHORT .ReturnNotSuccessfull 68 and BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK ; Keeps CF clear70 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nSETBLOCK ; Keeps CF clear 69 71 70 72 .ReturnNotSuccessfull: … … 74 76 75 77 ;-------------------------------------------------------------------- 76 ; Sends Initialize Device Parameters command to IDE Hard Disk. 77 ; Initialization is used to initialize logical CHS parameters. Drives 78 ; may not support all CHS values. 79 ; This command is only supported by drives that supports CHS addressing. 80 ; 81 ; AH9h_InitializeDeviceParameters 78 ; InitializeDeviceParameters 82 79 ; Parameters: 83 ; DS:DI: Ptr to DPT 84 ; Returns: 85 ; AH: BIOS Error code 86 ; CF: Cleared if succesfull 87 ; Set if any error 88 ; Corrupts registers: 89 ; AL, BX, CX 90 ;-------------------------------------------------------------------- 91 ALIGN JUMP_ALIGN 92 AH9h_InitializeDeviceParameters: 93 ; No need to initialize CHS parameters if LBA mode enabled 94 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA ; Clears CF 95 jnz SHORT .Return 96 97 push dx 98 mov bh, [di+DPT.bPHeads] 99 dec bh ; Max head number 100 mov dx, [RAMVARS.wIdeBase] 101 call HCommand_OutputTranslatedLCHSaddress 102 mov ah, HCMD_INIT_DEV 103 mov al, [di+DPT.bPSect] ; Sectors per track 104 call HCommand_OutputSectorCountAndCommand 105 call HStatus_WaitBsyDefTime ; Wait until drive ready (DRDY won't be set!) 106 pop dx 107 .Return: 108 ret 109 110 111 ;-------------------------------------------------------------------- 112 ; Initializes block mode transfers. 113 ; 114 ; AH9h_InitializeBlockMode 115 ; Parameters: 116 ; DS:DI: Ptr to DPT 80 ; DS:DI: Ptr to DPT (in RAMVARS segment) 81 ; SS:BP: Ptr to IDEPACK 117 82 ; Returns: 118 83 ; AH: BIOS Error code … … 123 88 ;-------------------------------------------------------------------- 124 89 ALIGN JUMP_ALIGN 125 AH9h_InitializeBlockMode: 126 mov ax, FLG_DRVPARAMS_BLOCKMODE 127 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 128 jz SHORT .Return ; Block mode disabled (CF cleared) 129 eMOVZX ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH 130 test al, al ; Block mode supported? (clears CF) 131 jz SHORT .Return ; If not, return 90 InitializeDeviceParameters: 91 ; No need to initialize CHS parameters if LBA mode enabled 92 test BYTE [di+DPT.wFlags], FLG_DRVNHEAD_LBA ; Clear CF 93 jnz SHORT ReturnSuccessSinceInitializationNotNeeded 94 95 ; Initialize Locigal Sectors per Track and Max Head number 96 mov ah, [di+DPT.bPchsHeads] 97 dec ah ; Max Head number 98 mov dl, [di+DPT.bPchsSectors] ; Sectors per Track 99 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS 100 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 101 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL 102 103 104 ;-------------------------------------------------------------------- 105 ; InitializeBlockMode 106 ; Parameters: 107 ; DS:DI: Ptr to DPT (in RAMVARS segment) 108 ; Returns: 109 ; AH: BIOS Error code 110 ; CF: Cleared if succesfull 111 ; Set if any error 112 ; Corrupts registers: 113 ; AL, BX, CX, DX 114 ;-------------------------------------------------------------------- 115 ALIGN JUMP_ALIGN 116 InitializeBlockMode: 117 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED ; Clear CF 118 jz SHORT ReturnSuccessSinceInitializationNotNeeded 119 120 mov al, [di+DPT_ATA.bMaxBlock] ; Load max block size, zero AH 132 121 jmp AH24h_SetBlockSize 133 .Return:122 ReturnSuccessSinceInitializationNotNeeded: 134 123 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 16 ; Parameters on INTPACK: 17 17 ; CH: Cylinder number, bits 7...0 18 18 ; CL: Bits 7...6: Cylinder number bits 9 and 8 19 19 ; Bits 5...0: Starting sector number (1...63) 20 20 ; DH: Starting head number (0...255) 21 ; Returns with INTPACK in SS:BP:21 ; Returns with INTPACK: 22 22 ; AH: BIOS Error code 23 23 ; CF: 0 if succesfull, 1 if error … … 33 33 %endif 34 34 35 36 35 ;-------------------------------------------------------------------- 37 36 ; AHCh_SeekToCylinder … … 42 41 ; DH: Starting head number (0...255) 43 42 ; DS:DI: Ptr to DPT (in RAMVARS segment) 43 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 44 44 ; Returns: 45 45 ; AH: BIOS Error code … … 49 49 ;-------------------------------------------------------------------- 50 50 AHCh_SeekToCylinder: 51 mov ax, HCMD_SEEK<<8 ; Load cmd to AH, AL=zero sector cnt 52 call HCommand_OutputCountAndLCHSandCommand 53 jc SHORT .ReturnWithErrorCodeInAH 54 mov bx, di ; DS:BX now points to DPT 55 jmp HStatus_WaitIrqOrRdy ; Wait for IRQ or RDY 56 .ReturnWithErrorCodeInAH: 57 ret 51 mov ah, COMMAND_SEEK 52 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 53 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 35 35 ; DL: Drive number 36 36 ; DS: RAMVARS segment 37 ; SS:BP: Ptr to IDEPACK 37 38 ; Returns: 38 39 ; AH: Int 13h return status 39 40 ; CF: 0 if succesfull, 1 if error 40 41 ; Corrupts registers: 41 ; AL, CX, DI42 ; AL, CX, SI, DI 42 43 ;-------------------------------------------------------------------- 43 44 ALIGN JUMP_ALIGN … … 48 49 call FindDPT_ForDriveNumber ; DS:DI now points to DPT 49 50 call Interrupts_UnmaskInterruptControllerForDriveInDSDI 50 call AHDh_ResetMasterAndSlave51 call Device_ResetMasterAndSlaveController 51 52 ;jc SHORT .ReturnError ; CF would be set if slave drive present without master 52 53 ; (error register has special values after reset) 53 54 54 55 ; Initialize Master and Slave drives 55 mov dx, [RAMVARS.wIdeBase] ; Load base port address 56 call AHDh_InitializeMasterAndSlave 56 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] 57 mov dx, [cs:bx+IDEVARS.wPort] 58 call InitializeMasterAndSlaveDriveFromPortInDX 57 59 58 60 pop bx … … 62 64 63 65 ;-------------------------------------------------------------------- 64 ; Resets Master and Slave drives at wanted port. 65 ; Both IDE drives will be reset. It is not possible to reset 66 ; Master or Slave only. 67 ; 68 ; AHDh_ResetMasterAndSlave 69 ; Parameters: 70 ; DS:DI: Ptr to DPT for Master or Slave drive 71 ; Returns: 72 ; CF: 0 if reset succesfull 73 ; 1 if any error 74 ; Corrupts registers: 75 ; AX, BX, CX, DX 76 ;-------------------------------------------------------------------- 77 ALIGN JUMP_ALIGN 78 AHDh_ResetMasterAndSlave: 79 ; Reset controller 80 ; HSR0: Set_SRST 81 mov al, [di+DPT.bDrvCtrl] ; Load value for ACR 82 or al, FLG_IDE_CTRL_SRST ; Set Reset bit 83 call HDrvSel_OutputDeviceControlByte 84 mov ax, 5 ; Delay at least 5us 85 call HTimer_DelayMicrosecondsFromAX 86 87 ; HSR1: Clear_wait 88 mov al, [di+DPT.bDrvCtrl] ; Load value for ACR 89 out dx, al ; End Reset 90 mov ax, 2000 ; Delay at least 2ms 91 call HTimer_DelayMicrosecondsFromAX 92 93 ; HSR2: Check_status 94 mov cl, B_TIMEOUT_RESET ; Reset timeout delay 95 jmp HStatus_WaitBsy 96 97 98 ;-------------------------------------------------------------------- 99 ; Initializes Master and Slave drive. 100 ; 101 ; AHDh_InitializeMasterAndSlave 66 ; InitializeMasterAndSlaveDriveFromPortInDX 102 67 ; Parameters: 103 68 ; DX: IDE Base Port address 69 ; SS:BP: Ptr to IDEPACK 104 70 ; Returns: 105 71 ; AH: Error code … … 107 73 ; 1 if any error 108 74 ; Corrupts registers: 109 ; AL, BX, CX, DX, DI75 ; AL, BX, CX, DX, SI, DI 110 76 ;-------------------------------------------------------------------- 111 77 ALIGN JUMP_ALIGN 112 AHDh_InitializeMasterAndSlave:78 InitializeMasterAndSlaveDriveFromPortInDX: 113 79 push dx ; Store base port address 114 80 xor cx, cx ; Assume no errors 115 call FindDPT_ ForIdeMasterAtPort81 call FindDPT_ToDSDIForIdeMasterAtPortDX 116 82 jnc SHORT .InitializeSlave ; Master drive not present 117 83 call AH9h_InitializeDriveForUse … … 119 85 .InitializeSlave: 120 86 pop dx ; Restore base port address 121 call FindDPT_ ForIdeSlaveAtPort87 call FindDPT_ToDSDIForIdeSlaveAtPortDX 122 88 jnc SHORT .CombineErrors ; Slave drive not present 123 89 call AH9h_InitializeDriveForUse -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HAddress.asm
r3 r150 1 ; File name : HAddress.asm 2 ; Project name : IDE BIOS 3 ; Created date : 11.3.2010 4 ; Last update : 4.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for address translations. 7 3 … … 9 5 SECTION .text 10 6 7 ; Jump table for conversion functions 8 ALIGN WORD_ALIGN 9 g_rgfnAddressTranslation: 10 dw DoNotConvertLCHS ; 0, ADDR_DPT_LCHS 11 dw ConvertLCHStoPCHS ; 1, ADDR_DPT_PCHS 12 dw ConvertLCHStoLBARegisterValues ; 2, ADDR_DPT_LBA28 13 dw ConvertLCHStoLBARegisterValues ; 3, ADDR_DPT_LBA48 14 15 11 16 ;-------------------------------------------------------------------- 12 ; Outputs sector count, L-CHS address and command to IDE registers. 13 ; This function does not wait until command has been completed. 14 ; 15 ; HAddress_ConvertParamsFromBiosLCHStoIDE 17 ; HAddress_OldInt13hAddressToIdeAddress 16 18 ; Parameters: 17 19 ; CH: Cylinder number, bits 7...0 … … 28 30 ; AX, DX 29 31 ;-------------------------------------------------------------------- 30 ALIGN WORD_ALIGN31 g_rgfnAddressTranslation:32 dw HAddress_DoNotConvertLCHS ; 0, ADDR_DPT_LCHS33 dw HAddress_ConvertLCHStoPCHS ; 1, ADDR_DPT_PCHS34 dw HAddress_ConvertLCHStoLBARegisterValues ; 2, ADDR_DPT_LBA2835 dw HAddress_ConvertLCHStoLBARegisterValues ; 3, ADDR_DPT_LBA4836 37 32 ALIGN JUMP_ALIGN 38 HAddress_ConvertParamsFromBiosLCHStoIDE: 39 mov bl, [di+DPT.bFlags] 40 and bx, BYTE MASK_DPT_ADDR ; Addressing mode to BX 33 HAddress_OldInt13hAddressToIdeAddress: 34 call AccessDPT_GetAddressingModeForWordLookToBX 41 35 push WORD [cs:bx+g_rgfnAddressTranslation] ; Push return address 42 ; Fall to HAddress_ExtractLCHS FromBiosParams36 ; Fall to HAddress_ExtractLCHSparametersFromOldInt13hAddress 43 37 44 38 ;--------------------------------------------------------------------- 45 ; Extracts L-CHS parameters from BIOS function parameters. 46 ; 47 ; HAddress_ExtractLCHSFromBiosParams: 39 ; HAddress_ExtractLCHSparametersFromOldInt13hAddress 48 40 ; Parameters: 49 41 ; CH: Cylinder number, bits 7...0 … … 58 50 ; Nothing 59 51 ;-------------------------------------------------------------------- 60 ALIGN JUMP_ALIGN 61 HAddress_ExtractLCHSFromBiosParams: 52 HAddress_ExtractLCHSparametersFromOldInt13hAddress: 62 53 mov bl, cl ; Copy sector number... 63 54 and bl, 3Fh ; ...and limit to 1...63 … … 70 61 71 62 ;--------------------------------------------------------------------- 72 ; Converts BIOSLCHS parameters to IDE P-CHS parameters.63 ; Converts LCHS parameters to IDE P-CHS parameters. 73 64 ; PCylinder = (LCylinder << n) + (LHead / PHeadCount) 74 65 ; PHead = LHead % PHeadCount … … 89 80 ;-------------------------------------------------------------------- 90 81 ALIGN JUMP_ALIGN 91 HAddress_ConvertLCHStoPCHS:82 ConvertLCHStoPCHS: 92 83 ; LHead / PHeadCount and LHead % PHeadCount 93 84 eMOVZX ax, bh ; Copy L-CHS Head number to AX 94 div BYTE [di+DPT.bP Heads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount85 div BYTE [di+DPT.bPchsHeads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount 95 86 mov bh, ah ; Copy P-CHS Head number to BH 96 87 xor ah, ah ; AX = LHead / PHeadCount … … 98 89 ; (LCylinder << n) + (LHead / PHeadCount) 99 90 mov dx, cx ; Copy L-CHS Cylinder number to DX 100 mov cl, [di+DPT.bShLtoP] ; Load shift count 91 mov cl, [di+DPT.wFlags] ; Load shift count 92 and cl, MASK_DPT_CHS_SHIFT_COUNT 101 93 shl dx, cl ; DX = LCylinder << n 102 94 add ax, dx ; AX = P-CHS Cylinder number 103 95 mov cx, ax ; Copy P-CHS Cylinder number to CX 104 ALIGN JUMP_ALIGN 105 HAddress_DoNotConvertLCHS: 96 DoNotConvertLCHS: 106 97 ret 107 98 … … 109 100 ;--------------------------------------------------------------------- 110 101 ; Converts LCHS parameters to 28-bit LBA address. 102 ; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit. 103 ; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1 104 ; 111 105 ; Returned address is in same registers that 112 106 ; HAddress_DoNotConvertLCHS and HAddress_ConvertLCHStoPCHS returns. 113 107 ; 114 ; HAddress_ConvertLCHStoLBARegisterValues:108 ; ConvertLCHStoLBARegisterValues: 115 109 ; Parameters: 116 110 ; BL: Sector number (1...63) … … 127 121 ;-------------------------------------------------------------------- 128 122 ALIGN JUMP_ALIGN 129 HAddress_ConvertLCHStoLBARegisterValues: 130 call HAddress_ConvertLCHStoLBA28 131 mov bl, al ; Sector Number Register (LBA 7...0) 132 mov cl, ah ; Low Cylinder Register (LBA 15...8) 133 mov ch, dl ; High Cylinder Register (LBA 23...16) 134 mov bh, dh ; Drive and Head Register (LBA 27...24) 135 ret 136 137 ;--------------------------------------------------------------------- 138 ; Converts LCHS parameters to 28-bit LBA address. 139 ; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit. 140 ; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1 141 ; 142 ; HAddress_ConvertLCHStoLBA28: 143 ; Parameters: 144 ; BL: Sector number (1...63) 145 ; BH: Head number (0...255) 146 ; CX: Cylinder number (0...1023) 147 ; DS:DI: Ptr to Disk Parameter Table 148 ; Returns: 149 ; DX:AX: 28-bit LBA address (DH is always zero) 150 ; Corrupts registers: 151 ; BX, CX 152 ;-------------------------------------------------------------------- 153 ALIGN JUMP_ALIGN 154 HAddress_ConvertLCHStoLBA28: 123 ConvertLCHStoLBARegisterValues: 155 124 ; cylToSeek*headsPerCyl (18-bit result) 156 125 mov ax, cx ; Copy Cylinder number to AX 157 mul WORD [di+DPT.wLHeads] ; DX:AX = cylToSeek*headsPerCyl 126 eMOVZX dx, BYTE [di+DPT.bLchsHeads] 127 mul dx ; DX:AX = cylToSeek*headsPerCyl 158 128 159 129 ; +=headToSeek (18-bit result) … … 163 133 164 134 ; *=sectPerTrack (18-bit by 6-bit multiplication with 24-bit result) 165 eMOVZX cx, BYTE [di+DPT.bP Sect]; Load Sectors per Track135 eMOVZX cx, BYTE [di+DPT.bPchsSectors] ; Load Sectors per Track 166 136 xchg ax, dx ; Hiword to AX, loword to DX 167 137 mul cl ; AX = hiword * Sectors per Track … … 176 146 add ax, bx ; Add to loword 177 147 adc dl, bh ; Add possible carry to byte2, BH=zero 148 149 ; Copy DX:AX to proper return registers 150 xchg bx, ax ; BL = Sector Number Register (LBA 7...0) 151 mov cl, bh ; Low Cylinder Register (LBA 15...8) 152 mov ch, dl ; High Cylinder Register (LBA 23...16) 153 mov bh, dh ; Drive and Head Register (LBA 27...24) 178 154 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm
r148 r150 6 6 7 7 ;-------------------------------------------------------------------- 8 ; HTimer_InitializeTimeoutWithTicksInC L8 ; HTimer_InitializeTimeoutWithTicksInCX 9 9 ; Parameters: 10 ; C L: Timeout value in system timer ticks10 ; CX: Timeout value in system timer ticks 11 11 ; DS: Segment to RAMVARS 12 12 ; Returns: … … 16 16 ;-------------------------------------------------------------------- 17 17 ALIGN JUMP_ALIGN 18 HTimer_InitializeTimeoutWithTicksInCL: 19 xor ch, ch ; Timeout ticks now in CX 18 HTimer_InitializeTimeoutWithTicksInCX: 20 19 mov [RAMVARS.wTimeoutCounter], cx ; Store timeout ticks 21 20 call ReadTimeFromBdaToCX … … 55 54 HTimer_DelayMicrosecondsFromAX: 56 55 %ifndef USE_AT 57 mov ax, 156 mov ax, 2 58 57 ; Fall to Delay_TimerTicksFromAX 59 58 %else
Note:
See TracChangeset
for help on using the changeset viewer.