Changeset 262 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
- Timestamp:
- Feb 24, 2012, 10:28:31 AM (13 years ago)
- google:author:
- gregli@hotmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
r259 r262 6 6 7 7 ;-------------------------------------------------------------------- 8 ; Finds pointer to first unused Disk Parameter Table. 9 ; 10 ; FindDPT_ForNewDriveToDSDI 11 ; Parameters: 12 ; DS: RAMVARS segment 13 ; Returns: 14 ; DS:DI: Ptr to first unused DPT 15 ; Corrupts registers: 16 ; DX 17 ;-------------------------------------------------------------------- 18 ALIGN JUMP_ALIGN 19 FindDPT_ForNewDriveToDSDI: 20 mov ax, [RAMVARS.wDrvCntAndFirst] 21 add al, ah 8 ; Checks if drive is handled by this BIOS, and return DPT pointer. 9 ; 10 ; FindDPT_ForDriveNumberInDL 11 ; Parameters: 12 ; DL: Drive number 13 ; DS: RAMVARS segment 14 ; Returns: 15 ; CF: Cleared if drive is handled by this BIOS 16 ; Set if drive belongs to some other BIOS 17 ; DI: DPT Pointer if drive is handled by this BIOS 18 ; Zero if drive belongs to some other BIOS 19 ; Corrupts registers: 20 ; Nothing 21 ;-------------------------------------------------------------------- 22 ALIGN JUMP_ALIGN 23 FindDPT_ForDriveNumberInDL: 24 xchg di, ax ; Save the contents of AX in DI 25 26 ; 27 ; Check Our Hard Disks 28 ; 29 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AH, First number to AL 30 add ah, al ; One past last drive to AH 31 22 32 %ifdef MODULE_SERIAL_FLOPPY 23 add al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt] 33 cmp dl, ah ; Above last supported? 34 jae SHORT .HardDiskNotHandledByThisBIOS 35 36 cmp dl, al ; Below first supported? 37 jae SHORT .CalcDPTForDriveNumber 38 39 ALIGN JUMP_ALIGN 40 .HardDiskNotHandledByThisBIOS: 41 ; 42 ; Check Our Floppy Disks 43 ; 44 call RamVars_UnpackFlopCntAndFirstToAL 45 cbw ; normally 0h, could be ffh if no drives present 46 adc ah, al ; if no drives present, still ffh (ffh + ffh + 1 = ffh) 47 js SHORT .DiskIsNotHandledByThisBIOS 48 cmp ah, dl ; Check second drive if two, first drive if only one 49 jz SHORT .CalcDPTForDriveNumber 50 cmp al, dl ; Check first drive in all cases, redundant but OK to repeat 51 jnz SHORT .DiskIsNotHandledByThisBIOS 52 %else 53 cmp dl, ah ; Above last supported? 54 jae SHORT .DiskIsNotHandledByThisBIOS 55 56 cmp dl, al ; Below first supported? 57 jb SHORT .DiskIsNotHandledByThisBIOS 24 58 %endif 25 xchg ax, dx 26 ; fall-through to FindDPT_ForDriveNumber 59 ; fall-through to CalcDPTForDriveNumber 27 60 28 61 ;-------------------------------------------------------------------- 29 62 ; Finds Disk Parameter Table for drive number. 30 ; IDE Base Port address will be stored to RAMVARS if correct DPT is found.31 ; 32 ; FindDPT_ForDriveNumber63 ; Note intended to be called except by FindDPT_ForDriveNumber 64 ; 65 ; CalcDPTForDriveNumber 33 66 ; Parameters: 34 67 ; DL: Drive number 35 68 ; DS: RAMVARS segment 69 ; DI: Saved copy of AX from entry at FindDPT_ForDriveNumber 36 70 ; Returns: 37 71 ; DS:DI: Ptr to DPT 72 ; CF: Clear 38 73 ; Corrupts registers: 39 74 ; Nothing 40 75 ;-------------------------------------------------------------------- 41 76 ALIGN JUMP_ALIGN 42 FindDPT_ForDriveNumber:77 .CalcDPTForDriveNumber: 43 78 push dx 44 xchg di, ax ; Save the contents of AX in DI45 79 46 80 %ifdef MODULE_SERIAL_FLOPPY … … 52 86 call RamVars_UnpackFlopCntAndFirstToAL 53 87 add dl, ah ; add in end of hard disk DPT list, floppies start immediately after 88 89 ALIGN JUMP_ALIGN 54 90 .harddisk: 55 91 sub dl, al ; subtract off beginning of either hard disk or floppy list (as appropriate) … … 57 93 sub dl, [RAMVARS.bFirstDrv] ; subtract off beginning of hard disk list 58 94 %endif 59 95 96 .CalcDPTForNewDrive: 60 97 mov al, LARGEST_DPT_SIZE 61 98 62 99 mul dl 63 add ax, BYTE RAMVARS_size 64 65 xchg di, ax ; Restore AX and put result in DI 100 add ax, BYTE RAMVARS_size ; Clears CF (will not oveflow) 101 66 102 pop dx 67 68 ret 69 70 ;-------------------------------------------------------------------- 71 ; Consolidator for checking the result from RamVars_IsDriveHandledByThisBIOS 72 ; and then if it is our drive, getting the DPT with FindDPT_ForDriveNumber 73 ; 74 ; RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber 75 ; Parameters: 76 ; DL: Drive number 77 ; DS: RAMVARS segment 78 ; Returns: 79 ; DS:DI: Ptr to DPT, if it is our drive 80 ; CF: Set if not our drive, clear if it is our drive 81 ; Corrupts registers: 82 ; Nothing 83 ;-------------------------------------------------------------------- 84 ALIGN JUMP_ALIGN 85 RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber: 86 call RamVars_IsDriveHandledByThisBIOS 87 jnc FindDPT_ForDriveNumber 88 ret 89 90 91 ;-------------------------------------------------------------------- 92 ; Finds Disk Parameter Table for 93 ; Master or Slave drive at wanted port. 94 ; 95 ; FindDPT_ToDSDIForIdeMasterAtPortDX 96 ; FindDPT_ToDSDIForIdeSlaveAtPortDX 97 ; Parameters: 98 ; DX: IDE Base Port address 99 ; DS: RAMVARS segment 100 ; Returns: 101 ; DL: Drive number (if DPT found) 102 ; DS:DI: Ptr to DPT 103 ; CF: Set if wanted DPT found 104 ; Cleared if DPT not found 105 ; Corrupts registers: 106 ; SI 107 ; 108 ; Converted to macros since there is only once call site for each of these 109 ; 110 ;-------------------------------------------------------------------- 111 112 %macro FindDPT_ToDSDIForIdeMasterAtPortDX 0 113 mov si, IterateToMasterAtPortCallback 114 call IterateAllDPTs 115 %endmacro 116 117 %macro FindDPT_ToDSDIForIdeSlaveAtPortDX 0 118 mov si, IterateToSlaveAtPortCallback 119 call IterateAllDPTs 120 %endmacro 121 122 123 ;-------------------------------------------------------------------- 124 ; Iteration callback for finding DPT using 125 ; IDE base port for Master or Slave drive. 126 ; 127 ; IterateToSlaveAtPortCallback 128 ; IterateToMasterAtPortCallback 129 ; Parameters: 130 ; DX: IDE Base Port address 131 ; DS:DI: Ptr to DPT to examine 132 ; Returns: 133 ; CF: Set if wanted DPT found 134 ; Cleared if wrong DPT 135 ; Corrupts registers: 136 ; Nothing 137 ;-------------------------------------------------------------------- 138 ALIGN JUMP_ALIGN 139 IterateToSlaveAtPortCallback: 140 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE ; Clears CF 141 jnz SHORT CompareBasePortAddress 142 ret ; Wrong DPT 143 144 ALIGN JUMP_ALIGN 145 IterateToMasterAtPortCallback: 146 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE 147 jnz SHORT ReturnWrongDPT ; Return if slave drive 148 149 CompareBasePortAddress: 150 push bx 151 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 152 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port? 153 pop bx 154 jne SHORT ReturnWrongDPT 155 156 ReturnRightDPT: 157 stc ; Set CF since wanted DPT 158 ret 159 103 104 xchg di, ax ; Restore AX from entry at FindDPT_ForDriveNumber, put DPT pointer in DI 105 ret 106 107 ALIGN JUMP_ALIGN 108 .DiskIsNotHandledByThisBIOS: 109 ; 110 ; Drive not found... 111 ; 112 xor ax, ax ; Clear DPT pointer 113 stc ; Is not supported by our BIOS 114 115 xchg di, ax ; Restore AX from save at top 116 ret 117 118 ;-------------------------------------------------------------------- 119 ; Finds pointer to first unused Disk Parameter Table. 120 ; Should only be used before DetectDrives is complete (not valid after this time). 121 ; 122 ; FindDPT_ForNewDriveToDSDI 123 ; Parameters: 124 ; DS: RAMVARS segment 125 ; Returns: 126 ; DS:DI: Ptr to first unused DPT 127 ; Corrupts registers: 128 ; AX 129 ;-------------------------------------------------------------------- 130 ALIGN JUMP_ALIGN 131 FindDPT_ForNewDriveToDSDI: 132 push dx 133 134 %ifdef MODULE_SERIAL_FLOPPY 135 mov dx, [RAMVARS.wDrvCntAndFlopCnt] 136 add dl, dh 137 %else 138 mov dl, [RAMVARS.bDrvCnt] 139 %endif 140 141 jmp short FindDPT_ForDriveNumberInDL.CalcDPTForNewDrive 160 142 161 143 ;-------------------------------------------------------------------- … … 165 147 ; BL: Bit(s) to test in DPT.bFlagsHigh 166 148 ; Returns: 167 ; CF: Setif wanted DPT found168 ; Clearedif wrong DPT149 ; CF: Clear if wanted DPT found 150 ; Set if wrong DPT 169 151 ; Corrupts registers: 170 152 ; Nothing … … 172 154 ALIGN JUMP_ALIGN 173 155 IterateToDptWithFlagsHighInBL: 174 test BYTE [di+DPT.bFlagsHigh], bl ; Clears CF (but we need the clc 175 ; below anyway for callers above) 176 jnz SHORT ReturnRightDPT 177 178 ReturnWrongDPT: 179 clc ; Clear CF since wrong DPT 156 test BYTE [di+DPT.bFlagsHigh], bl ; Clears CF 157 jnz SHORT .ReturnRightDPT 158 stc 159 .ReturnRightDPT: 180 160 ret 181 161 … … 220 200 ; AX,BX,DX: Parameters to callback function 221 201 ; CS:SI: Ptr to callback function 202 ; Callback routine should return CF=clear if found 222 203 ; DS: RAMVARS segment 223 204 ; Returns: 224 205 ; DS:DI: Ptr to wanted DPT (if found) 225 206 ; If not found, points to first empty DPT 226 ; CF: Setif wanted DPT found227 ; Clearedif DPT not found, or no DPTs present207 ; CF: Clear if wanted DPT found 208 ; Set if DPT not found, or no DPTs present 228 209 ; Corrupts registers: 229 210 ; Nothing unless corrupted by callback function … … 238 219 xor ch, ch ; Clears CF 239 220 240 jcxz . AllDptsIterated ; Return if no drives, CF will be clear from xor above221 jcxz .NotFound ; Return if no drives 241 222 242 223 ALIGN JUMP_ALIGN 243 224 .LoopWhileDPTsLeft: 244 225 call si ; Is wanted DPT? 245 j c SHORT .AllDptsIterated; If so, return246 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT , clears CF226 jnc SHORT .Found ; If so, return 227 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT 247 228 loop .LoopWhileDPTsLeft 248 249 ; fall-through: DPT was not found, CF is already clear from ADD di inside the loop 250 251 ALIGN JUMP_ALIGN 252 .AllDptsIterated: 229 230 ALIGN JUMP_ALIGN 231 .NotFound: 232 stc 233 234 ALIGN JUMP_ALIGN 235 .Found: 253 236 pop cx 254 237 ret
Note:
See TracChangeset
for help on using the changeset viewer.