Changeset 262 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Timestamp:
- Feb 24, 2012, 10:28:31 AM (13 years ago)
- google:author:
- gregli@hotmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r258 r262 200 200 call Device_FinalizeDPT 201 201 202 ;---------------------------------------------------------------------- 203 ; Update drive counts (hard and floppy) 204 ;---------------------------------------------------------------------- 205 202 206 %ifdef MODULE_SERIAL_FLOPPY 203 207 ; … … 223 227 %endif 224 228 225 ; Fall to .StoreDriveNumberAndUpdateDriveCount226 227 ;--------------------------------------------------------------------228 ; .StoreDriveNumberAndUpdateDriveCount229 ; Parameters:230 ; DS:DI: Ptr to Disk Parameter Table231 ; ES:SI: Ptr to 512-byte ATA information read from the drive232 ; CS:BP: Ptr to IDEVARS for the controller233 ; ES: BDA Segment234 ; Returns:235 ; DL: Drive number for new drive236 ; CF: Always cleared237 ; Corrupts registers:238 ; Nothing239 ;--------------------------------------------------------------------240 .StoreDriveNumberAndUpdateDriveCount:241 mov dl, [es:BDA.bHDCount]242 or dl, 80h ; Set bit 7 since hard disk243 244 229 inc BYTE [RAMVARS.bDrvCnt] ; Increment drive count to RAMVARS 245 inc BYTE [es:BDA.bHDCount] ; Increment drive count to BDA 246 247 cmp BYTE [RAMVARS.bFirstDrv], 0 ; First drive set? 248 ja SHORT .AllDone ; If so, return 249 mov [RAMVARS.bFirstDrv], dl ; Store first drive number 250 251 .AllDone: 230 231 .AllDone: 252 232 clc 253 233 ret -
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 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r258 r262 115 115 116 116 ;-------------------------------------------------------------------- 117 ; Checks if INT 13h function is handled by this BIOS.118 ;119 ; RamVars_IsFunctionHandledByThisBIOS120 ; Parameters:121 ; AH: INT 13h function number122 ; DL: Drive number123 ; DS: RAMVARS segment124 ; Returns:125 ; CF: Cleared if function is handled by this BIOS126 ; Set if function belongs to some other BIOS127 ; Corrupts registers:128 ; Nothing129 ;--------------------------------------------------------------------130 ALIGN JUMP_ALIGN131 RamVars_IsFunctionHandledByThisBIOS:132 test ah, ah ; Reset for all floppy and hard disk drives?133 jz SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS134 cmp ah, 08h135 %ifdef MODULE_SERIAL_FLOPPY136 ; we handle all traffic for function 08h, as we need to wrap both hard disk and floppy drive counts137 je SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS138 %else139 ; we handle all *hard disk* traffic for function 08h, as we need to wrap the hard disk drive count140 je SHORT RamVars_IsDriveHandledByThisBIOS.IsDriveAHardDisk141 %endif142 ;;; fall-through143 144 ;--------------------------------------------------------------------145 ; Checks if drive is handled by this BIOS.146 ;147 ; RamVars_IsDriveHandledByThisBIOS148 ; Parameters:149 ; DL: Drive number150 ; DS: RAMVARS segment151 ; Returns:152 ; CF: Cleared if drive is handled by this BIOS153 ; Set if drive belongs to some other BIOS154 ; Corrupts registers:155 ; Nothing156 ;--------------------------------------------------------------------157 ALIGN JUMP_ALIGN158 RamVars_IsDriveHandledByThisBIOS:159 push ax160 161 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AH, First number to AL162 add ah, al ; One past last drive to AH163 cmp dl, ah ; Above last supported?164 jae SHORT .HardDiskIsNotHandledByThisBIOS165 .TestLowLimit:166 cmp dl, al ; Below first supported?167 jae SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX ; note that CF is clear if the branch is taken168 169 .HardDiskIsNotHandledByThisBIOS:170 %ifdef MODULE_SERIAL_FLOPPY171 call RamVars_UnpackFlopCntAndFirstToAL172 cbw ; normally 0h, could be ffh if no drives present173 adc ah, al ; if no drives present, still ffh (ffh + ffh + 1 = ffh)174 js SHORT .DiskIsNotHandledByThisBIOS175 cmp ah, dl176 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX177 cmp al, dl178 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX179 .DiskIsNotHandledByThisBIOS:180 %endif181 182 stc ; Is not supported by our BIOS183 184 .CFAlreadyClear_IsHandledByOurBIOS_PopAX:185 pop ax186 .CFAlreadyClear_IsHandledByOurBIOS:187 ret188 189 %ifndef MODULE_SERIAL_FLOPPY190 ;191 ; Note that we could have just checked for the high order bit in dl, but with the needed STC and jumps,192 ; leveraging the code above resulted in space savings.193 ;194 .IsDriveAHardDisk:195 push ax ; match stack at the top of routine196 mov al, 80h ; to catch all hard disks, lower limit is 80h vs. bFirstDrv197 jmp .TestLowLimit ; and there is no need to test a high limit198 %endif199 200 ;--------------------------------------------------------------------201 117 ; RamVars_GetHardDiskCountFromBDAtoAX 202 118 ; Parameters:
Note:
See TracChangeset
for help on using the changeset viewer.