[128] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Int 13h function AH=0h, Disk Controller Reset. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; Int 13h function AH=0h, Disk Controller Reset. |
---|
| 9 | ; |
---|
| 10 | ; AH0h_HandlerForDiskControllerReset |
---|
| 11 | ; Parameters: |
---|
[148] | 12 | ; DL: Translated Drive number (ignored so all drives are reset) |
---|
[3] | 13 | ; If bit 7 is set all hard disks and floppy disks reset. |
---|
[148] | 14 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 15 | ; SS:BP: Ptr to INTPACK |
---|
| 16 | ; Returns with INTPACK in SS:BP: |
---|
[23] | 17 | ; AH: Int 13h return status (from drive requested in DL) |
---|
[3] | 18 | ; CF: 0 if succesfull, 1 if error |
---|
| 19 | ;-------------------------------------------------------------------- |
---|
| 20 | ALIGN JUMP_ALIGN |
---|
| 21 | AH0h_HandlerForDiskControllerReset: |
---|
[23] | 22 | eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors |
---|
[26] | 23 | call ResetFloppyDrivesWithInt40h |
---|
[128] | 24 | test bl, bl |
---|
| 25 | jns SHORT .SkipHardDiskReset |
---|
[26] | 26 | call ResetForeignHardDisks |
---|
[27] | 27 | call AH0h_ResetHardDisksHandledByOurBIOS |
---|
[26] | 28 | .SkipHardDiskReset: |
---|
[148] | 29 | mov ah, bh |
---|
| 30 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
[3] | 31 | |
---|
| 32 | |
---|
| 33 | ;-------------------------------------------------------------------- |
---|
[26] | 34 | ; ResetFloppyDrivesWithInt40h |
---|
[3] | 35 | ; Parameters: |
---|
[23] | 36 | ; BL: Requested drive (DL when entering AH=00h) |
---|
| 37 | ; Returns: |
---|
| 38 | ; BH: Error code from requested drive (if available) |
---|
| 39 | ; Corrupts registers: |
---|
[27] | 40 | ; AX, DL, DI |
---|
[128] | 41 | ;-------------------------------------------------------------------- |
---|
[23] | 42 | ALIGN JUMP_ALIGN |
---|
[26] | 43 | ResetFloppyDrivesWithInt40h: |
---|
[27] | 44 | call GetDriveNumberForForeignBiosesToDL |
---|
| 45 | and dl, 7Fh ; Clear hard disk bit |
---|
[26] | 46 | xor ah, ah ; Disk Controller Reset |
---|
[148] | 47 | int BIOS_DISKETTE_INTERRUPT_40h |
---|
[26] | 48 | jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH |
---|
[23] | 49 | |
---|
| 50 | |
---|
| 51 | ;-------------------------------------------------------------------- |
---|
[26] | 52 | ; ResetForeignHardDisks |
---|
[23] | 53 | ; Parameters: |
---|
| 54 | ; BL: Requested drive (DL when entering AH=00h) |
---|
[3] | 55 | ; DS: RAMVARS segment |
---|
| 56 | ; Returns: |
---|
[23] | 57 | ; BH: Error code from requested drive (if available) |
---|
[3] | 58 | ; Corrupts registers: |
---|
[27] | 59 | ; AX, DL, DI |
---|
[128] | 60 | ;-------------------------------------------------------------------- |
---|
[23] | 61 | ALIGN JUMP_ALIGN |
---|
[26] | 62 | ResetForeignHardDisks: |
---|
[27] | 63 | call GetDriveNumberForForeignBiosesToDL |
---|
| 64 | xor ah, ah ; Disk Controller Reset |
---|
[32] | 65 | call Int13h_CallPreviousInt13hHandler |
---|
[26] | 66 | jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH |
---|
[23] | 67 | |
---|
[26] | 68 | |
---|
[3] | 69 | ;-------------------------------------------------------------------- |
---|
[27] | 70 | ; GetDriveNumberForForeignBiosesToDL |
---|
| 71 | ; Parameters: |
---|
| 72 | ; BL: Requested drive (DL when entering AH=00h) |
---|
| 73 | ; DS: RAMVARS segment |
---|
| 74 | ; Returns: |
---|
| 75 | ; DL: BL if foreign drive |
---|
| 76 | ; 80h if our drive |
---|
| 77 | ; Corrupts registers: |
---|
| 78 | ; DI |
---|
[128] | 79 | ;-------------------------------------------------------------------- |
---|
[27] | 80 | ALIGN JUMP_ALIGN |
---|
| 81 | GetDriveNumberForForeignBiosesToDL: |
---|
| 82 | mov dl, bl |
---|
| 83 | call RamVars_IsDriveHandledByThisBIOS |
---|
[84] | 84 | jnc SHORT .Return ; Return what was in BL unmodified |
---|
| 85 | mov dl, 80h |
---|
| 86 | .Return: |
---|
[27] | 87 | ret |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | ;-------------------------------------------------------------------- |
---|
[26] | 91 | ; ResetHardDisksHandledByOurBIOS |
---|
[23] | 92 | ; Parameters: |
---|
| 93 | ; BL: Requested drive (DL when entering AH=00h) |
---|
| 94 | ; DS: RAMVARS segment |
---|
| 95 | ; Returns: |
---|
| 96 | ; BH: Error code from requested drive (if available) |
---|
| 97 | ; Corrupts registers: |
---|
[27] | 98 | ; AX, CX, DX, DI |
---|
[23] | 99 | ;-------------------------------------------------------------------- |
---|
[3] | 100 | ALIGN JUMP_ALIGN |
---|
[27] | 101 | AH0h_ResetHardDisksHandledByOurBIOS: |
---|
[26] | 102 | mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH |
---|
| 103 | test dh, dh |
---|
| 104 | jz SHORT .AllDrivesReset ; Return if no drives |
---|
| 105 | mov dl, [RAMVARS.bFirstDrv] ; Load number of first our drive |
---|
| 106 | add dh, dl ; DH = one past last drive to reset |
---|
[3] | 107 | ALIGN JUMP_ALIGN |
---|
[26] | 108 | .DriveResetLoop: |
---|
| 109 | call AHDh_ResetDrive |
---|
[27] | 110 | call .BackupErrorCodeFromMasterOrSlaveToBH |
---|
[26] | 111 | inc dx |
---|
| 112 | cmp dl, dh ; All done? |
---|
| 113 | jb SHORT .DriveResetLoop ; If not, reset next drive |
---|
| 114 | .AllDrivesReset: |
---|
[3] | 115 | ret |
---|
| 116 | |
---|
| 117 | ;-------------------------------------------------------------------- |
---|
[27] | 118 | ; .BackupErrorCodeFromMasterOrSlaveToBH |
---|
[3] | 119 | ; Parameters: |
---|
[27] | 120 | ; AH: Error code for drive DL reset |
---|
| 121 | ; BL: Requested drive (DL when entering AH=00h) |
---|
[26] | 122 | ; DL: Drive just resetted |
---|
[3] | 123 | ; DS: RAMVARS segment |
---|
| 124 | ; Returns: |
---|
[27] | 125 | ; BH: Backuped error code |
---|
[26] | 126 | ; DL: Incremented if next drive is slave drive |
---|
| 127 | ; (=already resetted) |
---|
[3] | 128 | ; Corrupts registers: |
---|
[27] | 129 | ; CX, DI |
---|
[3] | 130 | ;-------------------------------------------------------------------- |
---|
| 131 | ALIGN JUMP_ALIGN |
---|
[27] | 132 | .BackupErrorCodeFromMasterOrSlaveToBH: |
---|
| 133 | call BackupErrorCodeFromTheRequestedDriveToBH |
---|
| 134 | mov cx, [RAMVARS.wIdeBase] ; Load base port for resetted drive |
---|
[26] | 135 | |
---|
[27] | 136 | inc dx ; DL to next drive |
---|
| 137 | call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS |
---|
| 138 | jnc SHORT .NoMoreDrivesOrNoSlaveDrive |
---|
| 139 | cmp cx, [RAMVARS.wIdeBase] ; Next drive is from same controller? |
---|
| 140 | je SHORT BackupErrorCodeFromTheRequestedDriveToBH |
---|
| 141 | .NoMoreDrivesOrNoSlaveDrive: |
---|
| 142 | dec dx |
---|
[3] | 143 | ret |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | ;-------------------------------------------------------------------- |
---|
[26] | 147 | ; BackupErrorCodeFromTheRequestedDriveToBH |
---|
[3] | 148 | ; Parameters: |
---|
[23] | 149 | ; AH: Error code from the last resetted drive |
---|
| 150 | ; DL: Drive last resetted |
---|
| 151 | ; BL: Requested drive (DL when entering AH=00h) |
---|
[3] | 152 | ; Returns: |
---|
[23] | 153 | ; BH: Backuped error code |
---|
[3] | 154 | ; Corrupts registers: |
---|
| 155 | ; Nothing |
---|
| 156 | ;-------------------------------------------------------------------- |
---|
| 157 | ALIGN JUMP_ALIGN |
---|
[26] | 158 | BackupErrorCodeFromTheRequestedDriveToBH: |
---|
| 159 | cmp dl, bl ; Requested drive? |
---|
[148] | 160 | eCMOVE bh, ah |
---|
[3] | 161 | ret |
---|