Changeset 258 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Timestamp:
- Feb 22, 2012, 7:01:53 PM (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
r227 r258 63 63 .StoreFlags: 64 64 mov [di+DPT.wFlags], ax 65 66 %ifdef MODULE_SERIAL67 cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT68 jnz .StoreAddressing69 or byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE70 %endif71 65 ; Fall to .StoreAddressing 72 66 … … 205 199 .StoreDeviceSpecificParameters: 206 200 call Device_FinalizeDPT 201 202 %ifdef MODULE_SERIAL_FLOPPY 203 ; 204 ; These two instructions serve two purposes: 205 ; 1. If the drive is a floppy drive (CF set), then we effectively increment the counter. 206 ; 2. If this is a hard disk, and there have been any floppy drives previously added, then the hard disk is 207 ; effectively discarded. This is more of a safety check then code that should ever normally be hit (see below). 208 ; Since the floppy DPT's come after the hard disk DPT's, without expensive (code size) code to relocate a DPT, 209 ; this was necessary. Now, this situation shouldn't happen in normal operation, for a couple of reasons: 210 ; A. xtidecfg always puts configured serial ports at the end fo the IDEVARS list 211 ; B. the auto serial code is always executed last 212 ; C. the serial server always returns floppy drives last 213 ; 214 adc byte [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt], 0 215 jnz .AllDone 216 %else 217 ; 218 ; Even without floppy support enabled, we shouldn't try to mount a floppy image as a hard disk, which 219 ; could lead to unpredictable results since no MBR will be present, etc. The server doesn't know that 220 ; floppies are supported, so it is important to still fail here if a floppy is seen during the drive scan. 221 ; 222 jc .AllDone 223 %endif 224 207 225 ; Fall to .StoreDriveNumberAndUpdateDriveCount 208 226 … … 230 248 ja SHORT .AllDone ; If so, return 231 249 mov [RAMVARS.bFirstDrv], dl ; Store first drive number 250 251 .AllDone: 232 252 clc 233 .AllDone:234 253 ret 254 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
r233 r258 14 14 ; DS:DI: Ptr to first unused DPT 15 15 ; Corrupts registers: 16 ; D L16 ; DX 17 17 ;-------------------------------------------------------------------- 18 18 ALIGN JUMP_ALIGN 19 19 FindDPT_ForNewDriveToDSDI: 20 mov dl, [RAMVARS.bFirstDrv] 21 add dl, [RAMVARS.bDrvCnt] 20 mov ax, [RAMVARS.wDrvCntAndFirst] 21 add al, ah 22 %ifdef MODULE_SERIAL_FLOPPY 23 add al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt] 24 %endif 25 xchg ax, dx 22 26 ; Fall to FindDPT_ForDriveNumber 23 27 … … 41 45 xchg di, ax ; Save the contents of AX in DI 42 46 47 %ifdef MODULE_SERIAL_FLOPPY 48 mov ax, [RAMVARS.wDrvCntAndFirst] 49 50 test dl, dl 51 js .harddisk 52 53 call RamVars_UnpackFlopCntAndFirstToAL 54 add dl, ah ; add in end of hard disk DPT list, floppies start immediately after 55 .harddisk: 56 sub dl, al ; subtract off beginning of either hard disk or floppy list (as appropriate) 57 %else 58 sub dl, [RAMVARS.bFirstDrv] ; subtract off beginning of hard disk list 59 %endif 60 43 61 mov al, LARGEST_DPT_SIZE 44 sub dl, [RAMVARS.bFirstDrv]62 45 63 mul dl 46 64 add ax, BYTE RAMVARS_size 47 65 48 xchg di, ax ; Restore AX and put result in DI66 xchg di, ax ; Restore AX and put result in DI 49 67 pop dx 50 68 ret … … 89 107 ; IterateToMasterAtPortCallback 90 108 ; Parameters: 91 ; CH: Drive number92 109 ; DX: IDE Base Port address 93 110 ; DS:DI: Ptr to DPT to examine 94 111 ; Returns: 95 ; DL: Drive number if correct DPT96 112 ; CF: Set if wanted DPT found 97 113 ; Cleared if wrong DPT … … 116 132 pop bx 117 133 jne SHORT ReturnWrongDPT 118 mov dl, ch ; Return drive number in DL119 134 120 135 ReturnRightDPT: … … 187 202 ; Returns: 188 203 ; DS:DI: Ptr to wanted DPT (if found) 204 ; If not found, points to first empty DPT 189 205 ; CF: Set if wanted DPT found 190 206 ; Cleared if DPT not found, or no DPTs present … … 195 211 IterateAllDPTs: 196 212 push cx 197 mov cx, [RAMVARS.wDrvCntAndFirst] 213 214 mov cl, [RAMVARS.bDrvCnt] 215 mov ch, 0 216 217 mov di, RAMVARS_size ; Point DS:DI to first DPT 218 198 219 jcxz .NotFound ; Return if no drives 199 mov di, RAMVARS_size ; Point DS:DI to first DPT220 200 221 ALIGN JUMP_ALIGN 201 222 .LoopWhileDPTsLeft: 202 223 call si ; Is wanted DPT? 203 224 jc SHORT .AllDptsIterated ; If so, return 204 inc ch ; Increment drive number205 225 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT 206 dec cl ; Decrement drives left207 jnz SHORT .LoopWhileDPTsLeft226 loop .LoopWhileDPTsLeft 227 208 228 .NotFound: 209 229 clc ; Clear CF since DPT not found 230 210 231 ALIGN JUMP_ALIGN 211 232 .AllDptsIterated: -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r241 r258 123 123 ; DS: RAMVARS segment 124 124 ; Returns: 125 ; CF: Setif function is handled by this BIOS126 ; Clearedif function belongs to some other BIOS125 ; CF: Cleared if function is handled by this BIOS 126 ; Set if function belongs to some other BIOS 127 127 ; Corrupts registers: 128 128 ; Nothing … … 131 131 RamVars_IsFunctionHandledByThisBIOS: 132 132 test ah, ah ; Reset for all floppy and hard disk drives? 133 jz SHORT .FunctionIsHandledByOurBIOS134 cmp ah, 08h ; Read Disk Drive Parameters?135 jne SHORT RamVars_IsDriveHandledByThisBIOS 136 test dl, dl ; We do not handle floppy drives137 j ns SHORT .FunctionIsNotHandledByOurBIOS138 ALIGN JUMP_ALIGN 139 .FunctionIsHandledByOurBIOS: 140 stc141 .FunctionIsNotHandledByOurBIOS: 142 ret 143 133 jz SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS 134 cmp ah, 08h 135 %ifdef MODULE_SERIAL_FLOPPY 136 ; we handle all traffic for function 08h, as we need to wrap both hard disk and floppy drive counts 137 je SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS 138 %else 139 ; we handle all *hard disk* traffic for function 08h, as we need to wrap the hard disk drive count 140 je SHORT RamVars_IsDriveHandledByThisBIOS.IsDriveAHardDisk 141 %endif 142 ;;; fall-through 143 144 144 ;-------------------------------------------------------------------- 145 145 ; Checks if drive is handled by this BIOS. … … 150 150 ; DS: RAMVARS segment 151 151 ; Returns: 152 ; CF: Setif drive is handled by this BIOS153 ; Clearedif drive belongs to some other BIOS152 ; CF: Cleared if drive is handled by this BIOS 153 ; Set if drive belongs to some other BIOS 154 154 ; Corrupts registers: 155 155 ; Nothing … … 158 158 RamVars_IsDriveHandledByThisBIOS: 159 159 push ax 160 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AL, First number to AH 161 add al, ah ; One past last drive to AL 162 cmp dl, al ; Above last supported? 163 jae SHORT .DriveNotHandledByThisBIOS 164 cmp ah, dl ; Below first supported? 165 ja SHORT .DriveNotHandledByThisBIOS 166 stc 167 .DriveNotHandledByThisBIOS: 160 161 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AH, First number to AL 162 add ah, al ; One past last drive to AH 163 cmp dl, ah ; Above last supported? 164 jae SHORT .HardDiskIsNotHandledByThisBIOS 165 .TestLowLimit: 166 cmp dl, al ; Below first supported? 167 jae SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX ; note that CF is clear if the branch is taken 168 169 .HardDiskIsNotHandledByThisBIOS: 170 %ifdef MODULE_SERIAL_FLOPPY 171 call RamVars_UnpackFlopCntAndFirstToAL 172 cbw ; normally 0h, could be ffh if no drives present 173 adc ah, al ; if no drives present, still ffh (ffh + ffh + 1 = ffh) 174 js SHORT .DiskIsNotHandledByThisBIOS 175 cmp ah, dl 176 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX 177 cmp al, dl 178 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX 179 .DiskIsNotHandledByThisBIOS: 180 %endif 181 182 stc ; Is not supported by our BIOS 183 184 .CFAlreadyClear_IsHandledByOurBIOS_PopAX: 168 185 pop ax 169 ret 170 171 172 ;-------------------------------------------------------------------- 173 ; RamVars_GetHardDiskCountFromBDAtoCX 174 ; Parameters: 175 ; DS: RAMVARS segment 176 ; Returns: 177 ; CX: Total hard disk count 178 ; Corrupts registers: 179 ; Nothing 180 ;-------------------------------------------------------------------- 181 ALIGN JUMP_ALIGN 182 RamVars_GetHardDiskCountFromBDAtoCX: 186 .CFAlreadyClear_IsHandledByOurBIOS: 187 ret 188 189 %ifndef MODULE_SERIAL_FLOPPY 190 ; 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 routine 196 mov al, 80h ; to catch all hard disks, lower limit is 80h vs. bFirstDrv 197 jmp .TestLowLimit ; and there is no need to test a high limit 198 %endif 199 200 ;-------------------------------------------------------------------- 201 ; RamVars_GetHardDiskCountFromBDAtoAX 202 ; Parameters: 203 ; DS: RAMVARS segment 204 ; Returns: 205 ; AX: Total hard disk count 206 ; Corrupts registers: 207 ; CX 208 ;-------------------------------------------------------------------- 209 ALIGN JUMP_ALIGN 210 RamVars_GetHardDiskCountFromBDAtoAX: 183 211 push es 184 push dx 185 186 LOAD_BDA_SEGMENT_TO es, cx, ! ; Zero CX 187 call RamVars_GetCountOfKnownDrivesToDL 212 213 LOAD_BDA_SEGMENT_TO es, ax 214 call RamVars_GetCountOfKnownDrivesToAX 188 215 mov cl, [es:BDA.bHDCount] 189 MAX_U cl, dl 190 191 pop dx 216 MAX_U al, cl 217 192 218 pop es 193 219 ret 194 220 195 221 ;-------------------------------------------------------------------- 196 ; RamVars_GetCountOfKnownDrivesTo DL197 ; Parameters: 198 ; DS: RAMVARS segment 199 ; Returns: 200 ; DL: Total hard disk count201 ; Corrupts registers: 202 ; No thing203 ;-------------------------------------------------------------------- 204 ALIGN JUMP_ALIGN 205 RamVars_GetCountOfKnownDrivesTo DL:206 mov dl, [RAMVARS.bFirstDrv] ; Number for our first drive207 add dl, [RAMVARS.bDrvCnt] ; Our drives208 and dl, 7Fh ; Clear HD bit for drive count209 ret210 211 222 ; RamVars_GetCountOfKnownDrivesToAX 223 ; Parameters: 224 ; DS: RAMVARS segment 225 ; Returns: 226 ; AX: Total hard disk count 227 ; Corrupts registers: 228 ; None 229 ;-------------------------------------------------------------------- 230 ALIGN JUMP_ALIGN 231 RamVars_GetCountOfKnownDrivesToAX: 232 mov ax, [RAMVARS.wDrvCntAndFirst] 233 add al, ah 234 and al, 7fh 235 cbw 236 ret 237 212 238 ;-------------------------------------------------------------------- 213 239 ; RamVars_GetIdeControllerCountToCX … … 219 245 ; Nothing 220 246 ;-------------------------------------------------------------------- 247 ALIGN JUMP_ALIGN 221 248 RamVars_GetIdeControllerCountToCX: 222 249 eMOVZX cx, BYTE [cs:ROMVARS.bIdeCnt] 223 250 ret 251 252 %ifdef MODULE_SERIAL_FLOPPY 253 ;-------------------------------------------------------------------- 254 ; RamVars_UnpackFlopCntAndFirstToAL 255 ; Parameters: 256 ; Nothing 257 ; Returns: 258 ; AL: First floppy drive number supported 259 ; CF: Number of floppy drives supported (clear = 1, set = 2) 260 ; Corrupts registers: 261 ; Nothing 262 ;-------------------------------------------------------------------- 263 ALIGN JUMP_ALIGN 264 RamVars_UnpackFlopCntAndFirstToAL: 265 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst] 266 sar al, 1 267 ret 268 %endif
Note:
See TracChangeset
for help on using the changeset viewer.