Changeset 43 for trunk/BOOTCODE/REGULAR/DRIVEIO.ASM
- Timestamp:
- Apr 11, 2014, 11:48:01 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BOOTCODE/REGULAR/DRIVEIO.ASM
r40 r43 35 35 ; Will only load base-configuration, will NOT load IPT nor Hide-Config 36 36 ; Those are originally loaded on startup and will NOT get reloaded. 37 DriveIO_LoadConfiguration 38 mov ax, cs39 mov es, ax40 mov bx, offset Configuration41 mov dx, 0080h ; First harddrive, Sector 55...42 mov cx, 0037h43 mov ax, 0201h ; Function 02, read 1 sector...44 int 13h45 jnc DIOLC_NoError46 call MBR_LoadError ; Will Abort BootUp47 DIOLC_NoError:48 ret49 DriveIO_LoadConfiguration 50 51 DriveIO_SaveConfiguration 52 mov ax, cs53 mov ds, ax54 mov es, ax ; Safety first (CS==DS==ES)55 ; --- Overwrite Floppy-Name with "FloppyDrive"56 mov si, offset TXT_Floppy_Drive57 mov di, offset PartitionTable58 sub di, 30 ; Adjust to Floppy-Name59 mov cx, 1160 rep movsb61 mov si, offset Configuration ; Calculate new checksum62 xor bx, bx63 64 ; Changed from 5 to calculated value (not here, see compat. issue below)65 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"66 ; Size of the ab-configuration in 512 byte sectors67 ;mov cx, (MBR_BackUpMBR - Configuration) / 200h68 69 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.70 ; AB v1.0.8 *should* stores a 7 sector configuration with a71 ; 7 sector checksum.72 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.873 ; config as corrupted, while this is not the case.74 ; So, for compatibility reasons, in v1.0.8, the checksum stored is over75 ; 5 sectors, to be compatible with v1.07.76 ; This may change (be corrected) in future versions !77 mov cx,578 79 mov dx, [CFG_CheckConfig]80 mov [CFG_CheckConfig], bx81 DIOSC_Loop:82 call MBR_GetCheckOfSector83 loop DIOSC_Loop84 mov [CFG_CheckConfig], bx85 ; --------------------------------------------------------------------86 ; ES == CS87 mov bx, offset Configuration88 mov dx, 0080h ; First harddrive, Sector 55...89 mov cx, 0037h90 91 ; Changed from 5 to calculated value92 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"93 ; Size of the ab-configuration in 512 byte sectors94 mov al, (MBR_BackUpMBR - Configuration) / 200h95 mov ah,03h96 97 int 13h98 jnc DIOSC_NoError99 call MBR_SaveError ; Will Abort BootUp100 DIOSC_NoError:101 ret102 DriveIO_SaveConfiguration 103 104 DriveIO_UpdateFloppyName 105 mov ax, cs106 mov ds, ax107 mov es, ax108 109 mov ah, 00h ; Function 2 - Reset Drive110 xor dl, dl111 int 13h112 xor dx, dx ; Cylinder=0, Head=0113 mov cx, 1 ; Sector=1, Drive=0114 mov bx, offset TmpSector ; ES:BX - TmpSector115 mov ax, 0201h ; Function 2 - Load Sector116 int 13h117 jnc DIOUFN_AllFine118 119 ; --- Overwrite Floppy-Name with "No Disc"120 mov si, offset TXT_Floppy_NoDisc121 xor ax, ax122 DIOUFN_WriteFloppyName:123 mov di, offset PartitionTable124 sub di, 30 ; Adjust to Floppy-Name125 mov cl, 11126 rep movsb127 ret ; AX=-1 -> GotDisc, =0 -> NoDisc128 129 ; --- Floppy found and read, data in TempSector130 DIOUFN_AllFine:131 mov ax, -1132 mov si, offset TXT_Floppy_NoName133 cmp wptr es:[bx+54], 'AF'134 jne DIOUFN_WriteFloppyName135 cmp wptr es:[bx+56], '1T'136 jne DIOUFN_WriteFloppyName137 cmp bptr es:[bx+58], '2'138 jne DIOUFN_WriteFloppyName139 mov si, bx140 add si, 43 ; FAT12 - Volume Label Location141 jmp DIOUFN_WriteFloppyName142 DriveIO_UpdateFloppyName 37 DriveIO_LoadConfiguration Proc Near Uses ax bx cx dx es 38 mov ax, cs 39 mov es, ax 40 mov bx, offset Configuration 41 mov dx, 0080h ; First harddrive, Sector 55... 42 mov cx, 0037h 43 mov ax, 0201h ; Function 02, read 1 sector... 44 int 13h 45 jnc DIOLC_NoError 46 call MBR_LoadError ; Will Abort BootUp 47 DIOLC_NoError: 48 ret 49 DriveIO_LoadConfiguration EndP 50 51 DriveIO_SaveConfiguration Proc Near Uses ax bx cx dx ds es si 52 mov ax, cs 53 mov ds, ax 54 mov es, ax ; Safety first (CS==DS==ES) 55 ; --- Overwrite Floppy-Name with "FloppyDrive" 56 mov si, offset TXT_Floppy_Drive 57 mov di, offset PartitionTable 58 sub di, 30 ; Adjust to Floppy-Name 59 mov cx, 11 60 rep movsb 61 mov si, offset Configuration ; Calculate new checksum 62 xor bx, bx 63 64 ; Changed from 5 to calculated value (not here, see compat. issue below) 65 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter" 66 ; Size of the ab-configuration in 512 byte sectors 67 ;mov cx, (MBR_BackUpMBR - Configuration) / 200h 68 69 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum. 70 ; AB v1.0.8 *should* stores a 7 sector configuration with a 71 ; 7 sector checksum. 72 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8 73 ; config as corrupted, while this is not the case. 74 ; So, for compatibility reasons, in v1.0.8, the checksum stored is over 75 ; 5 sectors, to be compatible with v1.07. 76 ; This may change (be corrected) in future versions ! 77 mov cx,5 78 79 mov dx, [CFG_CheckConfig] 80 mov [CFG_CheckConfig], bx 81 DIOSC_Loop: 82 call MBR_GetCheckOfSector 83 loop DIOSC_Loop 84 mov [CFG_CheckConfig], bx 85 ; -------------------------------------------------------------------- 86 ; ES == CS 87 mov bx, offset Configuration 88 mov dx, 0080h ; First harddrive, Sector 55... 89 mov cx, 0037h 90 91 ; Changed from 5 to calculated value 92 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter" 93 ; Size of the ab-configuration in 512 byte sectors 94 mov al, (MBR_BackUpMBR - Configuration) / 200h 95 mov ah,03h 96 97 int 13h 98 jnc DIOSC_NoError 99 call MBR_SaveError ; Will Abort BootUp 100 DIOSC_NoError: 101 ret 102 DriveIO_SaveConfiguration EndP 103 104 DriveIO_UpdateFloppyName Proc Near Uses bx cx dx ds si es di 105 mov ax, cs 106 mov ds, ax 107 mov es, ax 108 109 mov ah, 00h ; Function 2 - Reset Drive 110 xor dl, dl 111 int 13h 112 xor dx, dx ; Cylinder=0, Head=0 113 mov cx, 1 ; Sector=1, Drive=0 114 mov bx, offset TmpSector ; ES:BX - TmpSector 115 mov ax, 0201h ; Function 2 - Load Sector 116 int 13h 117 jnc DIOUFN_AllFine 118 119 ; --- Overwrite Floppy-Name with "No Disc" 120 mov si, offset TXT_Floppy_NoDisc 121 xor ax, ax 122 DIOUFN_WriteFloppyName: 123 mov di, offset PartitionTable 124 sub di, 30 ; Adjust to Floppy-Name 125 mov cl, 11 126 rep movsb 127 ret ; AX=-1 -> GotDisc, =0 -> NoDisc 128 129 ; --- Floppy found and read, data in TempSector 130 DIOUFN_AllFine: 131 mov ax, -1 132 mov si, offset TXT_Floppy_NoName 133 cmp wptr es:[bx+54], 'AF' 134 jne DIOUFN_WriteFloppyName 135 cmp wptr es:[bx+56], '1T' 136 jne DIOUFN_WriteFloppyName 137 cmp bptr es:[bx+58], '2' 138 jne DIOUFN_WriteFloppyName 139 mov si, bx 140 add si, 43 ; FAT12 - Volume Label Location 141 jmp DIOUFN_WriteFloppyName 142 DriveIO_UpdateFloppyName EndP 143 143 144 144 ; ============================================================================= … … 152 152 ; Internal access (to AiR-BOOT) is always done via INT 13h/CHS. 153 153 154 DriveIO_GetHardDriveCount 155 push ds156 push si157 push 0040h158 pop ds159 mov si, 0075h160 mov dh, ds:[si] ; 40:75 -> POST: Total Harddiscs == DL161 pop si162 pop ds163 mov TotalHarddiscs, dh164 ret165 DriveIO_GetHardDriveCount 154 DriveIO_GetHardDriveCount Proc Near Uses ds si 155 push ds 156 push si 157 push 0040h 158 pop ds 159 mov si, 0075h 160 mov dh, ds:[si] ; 40:75 -> POST: Total Harddiscs == DL 161 pop si 162 pop ds 163 mov TotalHarddiscs, dh 164 ret 165 DriveIO_GetHardDriveCount EndP 166 166 167 167 … … 170 170 ; This is calculated by Sector*Heads. Comparing will get done with Bit 25-10 171 171 ; on LBA sectors, so we actually divide sector number by 1024. 172 DriveIO_InitLBASwitchTable 173 mov di, offset LBASwitchTable174 mov dh, TotalHarddiscs175 mov dl, 80h176 DIOILUT_DriveLoop:177 push dx178 push di179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 pop di196 pop dx197 mov bptr ds:[di], ah ; Save that value198 inc di ; Go to next BYTE199 inc dl200 dec dh201 jnz DIOILUT_DriveLoop202 ret203 DriveIO_InitLBASwitchTable 172 DriveIO_InitLBASwitchTable Proc Near Uses es di 173 mov di, offset LBASwitchTable 174 mov dh, TotalHarddiscs 175 mov dl, 80h 176 DIOILUT_DriveLoop: 177 push dx 178 push di 179 mov ah, 08h 180 int 13h ; DISK - GET DRIVE PARAMETERS 181 mov ah, 0FBh ; Assume 255 heads/63 sectors, if error 182 jc DIOILUT_Error 183 and cl, 111111b ; Isolate lower 6 bits of CL -> sector count 184 185 ;movzx ax, cl 186 mov al,cl 187 mov ah,0 188 189 mov bl, dh ; DH -> max head number 190 mul bl ; AX = Sectors*Heads 191 shl ah, 1 192 shl ah, 1 ; Shift 2 bits, so we are able to compare to 193 ; bit 16-23 of the LBA address 194 DIOILUT_Error: 195 pop di 196 pop dx 197 mov bptr ds:[di], ah ; Save that value 198 inc di ; Go to next BYTE 199 inc dl 200 dec dh 201 jnz DIOILUT_DriveLoop 202 ret 203 DriveIO_InitLBASwitchTable EndP 204 204 205 205 … … 212 212 DriveIO_LVMAdjustToInfoSector Proc Near 213 213 214 215 216 ; pusha 217 ; call AuxIO_TeletypeNL 218 219 ; LBA 220 ; xchg dx,bx 221 ; call AuxIO_TeletypeHexDWord 222 ; call AuxIO_TeletypeNL 223 ; xchg bx,dx 224 225 ; CYL 226 ; mov al,ch 227 ; call AuxIO_TeletypeHexByte 228 ; call AuxIO_TeletypeNL 229 230 ; HEAD 231 ; mov al,dh 232 ; call AuxIO_TeletypeHexByte 233 ; call AuxIO_TeletypeNL 234 235 ; SEC 236 ; mov al,cl 237 ; call AuxIO_TeletypeHexByte 238 ; call AuxIO_TeletypeNL 239 240 ; DRIVE 241 ; mov al,dl 242 ; call AuxIO_TeletypeHexByte 243 ; call AuxIO_TeletypeNL 244 245 ; popa 246 247 248 ;local ts:word 249 ;local ts2:word 250 251 pusha 252 253 ; Dump drive 254 mov si,offset drive 255 ; call AuxIO_Print 256 xchg al,dl 257 ; call AuxIO_TeletypeHexByte 258 ; call AuxIO_TeletypeNL 259 xchg dl,al 260 261 ; Dump SPT 262 mov si,offset spt_used 263 ; call AuxIO_Print 264 push dx 265 push bx 214 ;~ pusha 215 ;~ call AuxIO_TeletypeNL 216 ;~ 217 ;~ ; LBA 218 ;~ xchg dx,bx 219 ;~ call AuxIO_TeletypeHexDWord 220 ;~ call AuxIO_TeletypeNL 221 ;~ xchg bx,dx 222 ;~ 223 ;~ ; CYL 224 ;~ mov al,ch 225 ;~ call AuxIO_TeletypeHexByte 226 ;~ call AuxIO_TeletypeNL 227 ;~ 228 ;~ ; HEAD 229 ;~ mov al,dh 230 ;~ call AuxIO_TeletypeHexByte 231 ;~ call AuxIO_TeletypeNL 232 ;~ 233 ;~ ; SEC 234 ;~ mov al,cl 235 ;~ call AuxIO_TeletypeHexByte 236 ;~ call AuxIO_TeletypeNL 237 ;~ 238 ;~ ; DRIVE 239 ;~ mov al,dl 240 ;~ call AuxIO_TeletypeHexByte 241 ;~ call AuxIO_TeletypeNL 242 ;~ popa 243 ;~ 244 ;~ ;local ts:word 245 ;~ ;local ts2:word 246 247 pusha 248 249 ; Dump drive 250 mov si,offset drive 251 ;call AuxIO_Print 252 xchg al,dl 253 ;call AuxIO_TeletypeHexByte 254 ;call AuxIO_TeletypeNL 255 xchg dl,al 256 257 ; Dump SPT 258 mov si,offset spt_used 259 ;call AuxIO_Print 260 push dx 261 push bx 262 xor dh,dh 263 and dl,01111111b 264 shl dx,1 265 shl dx,1 266 mov bx, offset TrueSecs 267 add bx,dx 268 mov ax,word ptr [bx] 269 ;mov [ts],ax 270 ;call AuxIO_TeletypeHexWord 271 ;call AuxIO_TeletypeNL 272 pop bx 273 pop dx 274 275 pusha 276 push dx 277 ; Location of extended position 278 mov dx,word ptr [ExtendedAbsPos+02] 279 mov ax,word ptr [ExtendedAbsPos+00] 280 ;call AuxIO_TeletypeHexDWord 281 ;call AuxIO_TeletypeNL 282 pop dx 283 284 xor dh,dh 285 and dl,01111111b 286 shl dx,1 287 shl dx,1 288 mov bx, offset TrueSecs 289 add bx,dx 290 291 mov ax, word ptr[bx] 292 ;call AuxIO_TeletypeHexWord 293 ;call AuxIO_TeletypeNL 294 mov al,[ExtendedAbsPosSet] ; if true -> 1st sector of extpart (EBR), not logpart(BPB) 295 ;call AuxIO_TeletypeHexByte 296 ;call AuxIO_TeletypeNL 297 ;mov si,offset PartitionSector 298 ;call AuxIO_DumpSector 299 popa 300 301 ; LBA 302 mov si,offset before_lvm_adjust 303 ;call AuxIO_Print 304 305 xchg dx,bx 306 ;call AuxIO_TeletypeHexDWord 307 ;call AuxIO_TeletypeNL 308 xchg bx,dx 309 popa 310 311 312 ;or bx,ax 313 test [ExtendedAbsPosSet],1 314 jz pri 315 316 317 318 319 pusha 320 mov si,offset before_lvm_adjust_log 321 ;call AuxIO_Print 322 ; LBA 323 xchg dx,bx 324 ;call AuxIO_TeletypeHexDWord 325 ;call AuxIO_TeletypeNL 326 xchg bx,dx 327 popa 328 329 330 push dx 331 push bx 332 266 333 xor dh,dh 267 334 and dl,01111111b 268 335 shl dx,1 269 336 shl dx,1 270 mov bx, 337 mov bx,offset TrueSecs 271 338 add bx,dx 272 mov ax,word ptr [bx] 273 274 ;mov [ts],ax 275 276 ; call AuxIO_TeletypeHexWord 277 ; call AuxIO_TeletypeNL 278 pop bx 279 pop dx 280 281 pusha 282 push dx 283 ; Location of extended position 284 mov dx,word ptr [ExtendedAbsPos+02] 285 mov ax,word ptr [ExtendedAbsPos+00] 286 ; call AuxIO_TeletypeHexDWord 287 ; call AuxIO_TeletypeNL 288 pop dx 289 290 xor dh,dh 291 and dl,01111111b 292 shl dx,1 293 shl dx,1 294 mov bx, offset TrueSecs 295 add bx,dx 296 297 mov ax, word ptr[bx] 298 ; call AuxIO_TeletypeHexWord 299 ; call AuxIO_TeletypeNL 300 mov al,[ExtendedAbsPosSet] ; if true -> 1st sector of extpart (EBR), not logpart(BPB) 301 ; call AuxIO_TeletypeHexByte 302 ; call AuxIO_TeletypeNL 303 ; mov si,offset PartitionSector 304 ; call AuxIO_DumpSector 305 popa 306 307 ; LBA 308 mov si,offset before_lvm_adjust 309 ; call AuxIO_Print 310 311 xchg dx,bx 312 ; call AuxIO_TeletypeHexDWord 313 ; call AuxIO_TeletypeNL 314 xchg bx,dx 315 popa 316 317 318 ;or bx,ax 319 test [ExtendedAbsPosSet],1 320 jz pri 321 322 323 324 325 pusha 326 mov si,offset before_lvm_adjust_log 327 ; call AuxIO_Print 328 ; LBA 329 xchg dx,bx 330 ; call AuxIO_TeletypeHexDWord 331 ; call AuxIO_TeletypeNL 332 xchg bx,dx 333 popa 334 335 336 push dx 337 push bx 338 xor dh,dh 339 and dl,01111111b 340 shl dx,1 341 shl dx,1 342 mov bx,offset TrueSecs 343 add bx,dx 344 mov dx,[bx] 345 dec dx 346 add ax,dx 347 pop bx 348 pop dx 349 adc bx,0 350 351 352 pusha 353 mov si,offset after_lvm_adjust_log 354 ; call AuxIO_Print 355 ; LBA 356 xchg dx,bx 357 ; call AuxIO_TeletypeHexDWord 358 ; call AuxIO_TeletypeNL 359 xchg bx,dx 360 popa 361 362 jmp done 363 364 365 366 367 pri: 368 369 370 push ax 371 push cx 372 xor ch, ch ; Zero out upper-byte 373 374 push dx 375 xor dh,dh 376 and dl,01111111b 377 shl dx,1 378 shl dx,1 379 push bx 380 mov bx,offset TrueSecs 381 add bx,dx 382 mov ax,[bx] 383 ;mov [ts2],ax 384 pop bx 385 pop dx 386 387 388 389 ;mov al, 63 390 ;call VideoIO_PrintByteDynamicNumber 391 ;self: jmp self 392 393 394 395 ; DEZE WERKT SOMS NIET GOED 396 ; ROMMELT MET CYLINDERS 397 ; ALLEEN TOEPASSEN ALS INT13X NIET ACTIEF ! 398 399 and cl, al ; Isolate lower bits, because upper 400 mov ah, 0 401 mov si, ax ; ones may be used for cylinder 402 sub si, cx 403 404 pop cx 405 pop ax 406 407 or cl, al ; Set sector to last sector 408 409 add ax, si ; Adjust lower LBA 410 adc bx, 0 ; Adjust LBA Sector (BX:AX) 411 412 413 414 ;push ax 415 ;call AuxIO_TeletypeHexWord 416 ;call AuxIO_TeletypeNL 417 ;mov ax,[ts] 418 ;call AuxIO_TeletypeHexWord 419 ;call AuxIO_TeletypeNL 420 ;mov ax,[ts2] 421 ;call AuxIO_TeletypeHexWord 422 ;call AuxIO_TeletypeNL 423 ;pop ax 424 425 ;and ax,[ts] 339 mov dx,[bx] 340 dec dx 341 add ax,dx 342 343 pop bx 344 pop dx 345 adc bx,0 346 347 348 pusha 349 mov si,offset after_lvm_adjust_log 350 ;call AuxIO_Print 351 ; LBA 352 xchg dx,bx 353 ;call AuxIO_TeletypeHexDWord 354 ;call AuxIO_TeletypeNL 355 xchg bx,dx 356 popa 357 358 jmp done 359 360 361 362 363 pri: 364 365 366 push ax 367 push cx 368 xor ch, ch ; Zero out upper-byte 369 370 push dx 371 xor dh,dh 372 and dl,01111111b 373 shl dx,1 374 shl dx,1 375 376 push bx 377 mov bx,offset TrueSecs 378 add bx,dx 379 mov ax,[bx] 380 ;mov [ts2],ax 381 pop bx 382 pop dx 383 384 385 386 ;~ mov al, 63 387 ;~ call VideoIO_PrintByteDynamicNumber 388 ;~ self: jmp self 389 390 391 392 ; DEZE WERKT SOMS NIET GOED 393 ; ROMMELT MET CYLINDERS 394 ; ALLEEN TOEPASSEN ALS INT13X NIET ACTIEF ! 395 396 and cl, al ; Isolate lower bits, because upper 397 mov ah, 0 398 mov si, ax ; ones may be used for cylinder 399 sub si, cx 400 401 pop cx 402 pop ax 403 404 or cl, al ; Set sector to last sector 405 add ax, si ; Adjust lower LBA 406 adc bx, 0 ; Adjust LBA Sector (BX:AX) 407 408 409 410 ;~ push ax 411 ;~ call AuxIO_TeletypeHexWord 412 ;~ call AuxIO_TeletypeNL 413 ;~ mov ax,[ts] 414 ;~ call AuxIO_TeletypeHexWord 415 ;~ call AuxIO_TeletypeNL 416 ;~ mov ax,[ts2] 417 ;~ call AuxIO_TeletypeHexWord 418 ;~ call AuxIO_TeletypeNL 419 ;~ pop ax 420 421 ;~ and ax,[ts] 426 422 427 423 jmp done … … 429 425 430 426 431 done: 432 433 434 435 pusha 436 mov si,offset after_lvm_adjust 437 ; call AuxIO_Print 438 ; LBA 439 xchg dx,bx 440 ; call AuxIO_TeletypeHexDWord 441 ; call AuxIO_TeletypeNL 442 xchg bx,dx 443 popa 444 445 446 447 ; pusha 448 ; call AuxIO_TeletypeNL 449 450 ; CYL 451 ; mov al,ch 452 ; call AuxIO_TeletypeHexByte 453 ; call AuxIO_TeletypeNL 454 455 ; HEAD 456 ; mov al,dh 457 ; call AuxIO_TeletypeHexByte 458 ; call AuxIO_TeletypeNL 459 460 ; SEC 461 ; mov al,cl 462 ; call AuxIO_TeletypeHexByte 463 ; call AuxIO_TeletypeNL 464 465 ; DRIVE 466 ; mov al,dl 467 ; call AuxIO_TeletypeHexByte 468 ; call AuxIO_TeletypeNL 469 470 ; popa 471 472 427 done: 428 429 pusha 430 mov si,offset after_lvm_adjust 431 ;~ call AuxIO_Print 432 ; LBA 433 xchg dx,bx 434 ;~ call AuxIO_TeletypeHexDWord 435 ;~ call AuxIO_TeletypeNL 436 xchg bx,dx 437 popa 438 439 ;~ pusha 440 ;~ call AuxIO_TeletypeNL 441 ;~ 442 ;~ ; CYL 443 ;~ mov al,ch 444 ;~ call AuxIO_TeletypeHexByte 445 ;~ call AuxIO_TeletypeNL 446 ;~ 447 ;~ ; HEAD 448 ;~ mov al,dh 449 ;~ call AuxIO_TeletypeHexByte 450 ;~ call AuxIO_TeletypeNL 451 ;~ 452 ;~ ; SEC 453 ;~ mov al,cl 454 ;~ call AuxIO_TeletypeHexByte 455 ;~ call AuxIO_TeletypeNL 456 ;~ 457 ;~ ; DRIVE 458 ;~ mov al,dl 459 ;~ call AuxIO_TeletypeHexByte 460 ;~ call AuxIO_TeletypeNL 461 ;~ popa 473 462 474 463 ret 475 464 DriveIO_LVMAdjustToInfoSector EndP 465 466 476 467 477 468 drive db 'drive : ',0 … … 492 483 ; Preserve: all registers 493 484 ; ######################################################################### 494 DriveIO_LoadPartition 495 mov wptr cs:[CurPartition_Location+0], ax496 mov wptr cs:[CurPartition_Location+2], bx497 mov wptr cs:[CurPartition_Location+4], dx498 mov wptr cs:[CurPartition_Location+6], cx ; Saves the location499 mov si, offset PartitionSector ; DS:SI - ExecBase500 call DriveIO_LoadSector501 clc502 cmp wptr [si+LocBR_Magic], 0AA55h503 je DIOLP_Success504 ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1505 ; we will display a "bad partition table" message and halt the system.506 cmp cx, 0001h507 jne DIOLP_Failed508 or dh, dh509 jnz DIOLP_Failed510 stc ; Set carry, so no partition table511 DIOLP_Success:512 513 IFDEF AuxDebug 514 ; show current partition location515 pushf516 pusha517 call AuxIO_TeletypeNL518 mov si,offset db_curpartloc519 call AuxIO_Print520 mov dx,word ptr [CurPartition_Location+02]521 mov ax,word ptr [CurPartition_Location+00]522 call AuxIO_TeletypeHexDWord523 call AuxIO_TeletypeNL524 mov si,offset PartitionSector525 call AuxIO_DumpSector526 call AuxIO_TeletypeNL527 popa528 popf529 ENDIF530 531 ret532 DIOLP_Failed:533 jmp DriveIO_GotLoadError534 DriveIO_LoadPartition 485 DriveIO_LoadPartition Proc Near Uses si 486 mov wptr cs:[CurPartition_Location+0], ax 487 mov wptr cs:[CurPartition_Location+2], bx 488 mov wptr cs:[CurPartition_Location+4], dx 489 mov wptr cs:[CurPartition_Location+6], cx ; Saves the location 490 mov si, offset PartitionSector ; DS:SI - ExecBase 491 call DriveIO_LoadSector 492 clc 493 cmp wptr [si+LocBR_Magic], 0AA55h 494 je DIOLP_Success 495 ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1 496 ; we will display a "bad partition table" message and halt the system. 497 cmp cx, 0001h 498 jne DIOLP_Failed 499 or dh, dh 500 jnz DIOLP_Failed 501 stc ; Set carry, so no partition table 502 DIOLP_Success: 503 504 IFDEF AUX_DEBUG 505 ; show current partition location 506 ;~ pushf 507 ;~ pusha 508 ;~ call AuxIO_TeletypeNL 509 ;~ mov si,offset db_curpartloc 510 ;~ call AuxIO_Print 511 ;~ mov dx,word ptr [CurPartition_Location+02] 512 ;~ mov ax,word ptr [CurPartition_Location+00] 513 ;~ call AuxIO_TeletypeHexDWord 514 ;~ call AuxIO_TeletypeNL 515 ;~ mov si,offset PartitionSector 516 ;~ call AuxIO_DumpSector 517 ;~ call AuxIO_TeletypeNL 518 ;~ popa 519 ;~ popf 520 ENDIF 521 522 ret 523 DIOLP_Failed: 524 jmp DriveIO_GotLoadError 525 DriveIO_LoadPartition EndP 535 526 536 527 ; ######################################################################### … … 541 532 ; Preserve: all registers 542 533 ; ######################################################################### 543 DriveIO_SavePartition 544 mov ax, wptr cs:[CurPartition_Location+0]545 mov bx, wptr cs:[CurPartition_Location+2]546 mov dx, wptr cs:[CurPartition_Location+4]547 mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location548 mov si, offset PartitionSector ; DS:SI - ExecBase549 cmp wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found550 jne DIOSP_SevereError ; we assume a really bad error551 call DriveIO_SaveSector552 DIOSP_SevereError:553 ret554 DriveIO_SavePartition 534 DriveIO_SavePartition Proc Near Uses ax bx cx dx si 535 mov ax, wptr cs:[CurPartition_Location+0] 536 mov bx, wptr cs:[CurPartition_Location+2] 537 mov dx, wptr cs:[CurPartition_Location+4] 538 mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location 539 mov si, offset PartitionSector ; DS:SI - ExecBase 540 cmp wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found 541 jne DIOSP_SevereError ; we assume a really bad error 542 call DriveIO_SaveSector 543 DIOSP_SevereError: 544 ret 545 DriveIO_SavePartition EndP 555 546 556 547 ; Keeps DS:SI for caller 557 DriveIO_LoadTmpSector 558 mov si, offset TmpSector559 call DriveIO_LoadSector ; Uses INT13X if needed560 ret561 DriveIO_LoadTmpSector 548 DriveIO_LoadTmpSector Proc Near 549 mov si, offset TmpSector 550 call DriveIO_LoadSector 551 ret 552 DriveIO_LoadTmpSector EndP 562 553 563 554 ; Keeps DS:SI for caller 564 DriveIO_SaveTmpSector 565 mov si, offset TmpSector566 call DriveIO_SaveSector567 ret568 DriveIO_SaveTmpSector 555 DriveIO_SaveTmpSector Proc Near 556 mov si, offset TmpSector 557 call DriveIO_SaveSector 558 ret 559 DriveIO_SaveTmpSector EndP 569 560 570 561 ; Keeps DS:SI for caller, sets carry if valid LVM sector encountered 571 DriveIO_LoadLVMSector 572 test [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so573 jnz DIOLLVMS_NoLVMSector ; don't load but declare as bad!574 mov ax, wptr cs:[CurPartition_Location+0]575 mov bx, wptr cs:[CurPartition_Location+2]576 mov dx, wptr cs:[CurPartition_Location+4]577 mov cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location578 579 call DriveIO_LVMAdjustToInfoSector580 581 mov si, offset LVMSector582 call DriveIO_LoadSector583 584 IFDEF AuxDebug 585 ; show current partition location586 pushf587 pusha588 ; callAuxIO_TeletypeNL589 movsi,offset db_curlvmsec590 ; callAuxIO_Print591 movdx,bx592 ; callAuxIO_TeletypeHexDWord593 ; callAuxIO_TeletypeNL594 movsi,offset LVMSector595 ; callAuxIO_DumpSector596 ; callAuxIO_TeletypeNL597 popa598 popf599 ENDIF600 601 call LVM_CheckSectorSignature602 jnc DIOLLVMS_NoLVMSector603 call LVM_CheckSectorCRC604 jnc DIOLLVMS_NoLVMSector605 ret606 ; This here is called, if an invalid (or no) LVM information sector is found607 ; It will truncate the first byte of the sector, so all other routines608 ; will notice it easily by just comparing the first byte.609 DIOLLVMS_NoLVMSector:610 mov bptr [si+LocLVM_SignatureStart], 0611 ret612 DriveIO_LoadLVMSector 562 DriveIO_LoadLVMSector Proc Near Uses ax bx cx dx 563 test [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so 564 jnz DIOLLVMS_NoLVMSector ; don't load but declare as bad! 565 mov ax, wptr cs:[CurPartition_Location+0] 566 mov bx, wptr cs:[CurPartition_Location+2] 567 mov dx, wptr cs:[CurPartition_Location+4] 568 mov cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location 569 570 call DriveIO_LVMAdjustToInfoSector 571 572 mov si, offset LVMSector 573 call DriveIO_LoadSector 574 575 IFDEF AUX_DEBUG 576 ; show current partition location 577 pushf 578 pusha 579 ;~ call AuxIO_TeletypeNL 580 ;~ mov si,offset db_curlvmsec 581 ;~ call AuxIO_Print 582 mov dx,bx 583 ;~ call AuxIO_TeletypeHexDWord 584 ;~ call AuxIO_TeletypeNL 585 mov si,offset LVMSector 586 ;~ call AuxIO_DumpSector 587 ;~ call AuxIO_TeletypeNL 588 popa 589 popf 590 ENDIF 591 592 call LVM_CheckSectorSignature 593 jnc DIOLLVMS_NoLVMSector 594 call LVM_CheckSectorCRC 595 jnc DIOLLVMS_NoLVMSector 596 ret 597 ; This here is called, if an invalid (or no) LVM information sector is found 598 ; It will truncate the first byte of the sector, so all other routines 599 ; will notice it easily by just comparing the first byte. 600 DIOLLVMS_NoLVMSector: 601 mov bptr [si+LocLVM_SignatureStart], 0 602 ret 603 DriveIO_LoadLVMSector EndP 613 604 614 605 ; Keeps DS:SI for caller, saves at anytime w/o checks (!) 615 DriveIO_SaveLVMSector Proc Near Uses ax bx cx dx 616 test [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so 617 jnz DIOSLVMS_SevereError ; don't save at anytime (security!) 618 mov ax, wptr cs:[CurPartition_Location+0] 619 mov bx, wptr cs:[CurPartition_Location+2] 620 mov dx, wptr cs:[CurPartition_Location+4] 621 mov cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location 622 call LVM_CheckSectorSignature 623 jnc DIOSLVMS_SevereError ; LVM Signature must be there 624 call DriveIO_LVMAdjustToInfoSector 625 mov si, offset LVMSector 626 call DriveIO_SaveSector 627 DIOSLVMS_SevereError: 628 ret 629 DriveIO_SaveLVMSector EndP 606 DriveIO_SaveLVMSector Proc Near Uses ax bx cx dx 607 test [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so 608 jnz DIOSLVMS_SevereError ; don't save at anytime (security!) 609 mov ax, wptr cs:[CurPartition_Location+0] 610 mov bx, wptr cs:[CurPartition_Location+2] 611 mov dx, wptr cs:[CurPartition_Location+4] 612 mov cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location 613 call LVM_CheckSectorSignature 614 jnc DIOSLVMS_SevereError ; LVM Signature must be there 615 call DriveIO_LVMAdjustToInfoSector 616 mov si, offset LVMSector 617 call DriveIO_SaveSector 618 DIOSLVMS_SevereError: 619 ret 620 DriveIO_SaveLVMSector EndP 621 622 ; Rousseau: Move this to BSS and merge with int13xbuf there. 630 623 631 624 ; Memory-Block that holds information for LBA-access via INT 13h 632 DriveIO_DAP db 10h; Size of paket633 db0 ; Reserved634 DriveIO_DAP_NumBlocks dw0 ; Number of blocks635 DriveIO_DAP_Transfer dd0 ; Transfer Adress636 DriveIO_DAP_Absolute dd0 ; Absolute Sector637 dd0 ; Second Part of QWORD625 DriveIO_DAP db 10h ; Size of paket 626 db 0 ; Reserved 627 DriveIO_DAP_NumBlocks dw 0 ; Number of blocks 628 DriveIO_DAP_Transfer dd 0 ; Transfer Adress 629 DriveIO_DAP_Absolute dd 0 ; Absolute Sector 630 dd 0 ; Second Part of QWORD 638 631 639 632 ; Special error message instead of "LOAD ERROR" during partition scanning, 640 633 ; so users will notice that something is bad with their partition table(s) 641 DriveIO_GotLoadError 642 test cs:CurIO_Scanning, 1 ; Must be CS:, cause DS!=CS maybe here643 jnz InScanMode644 jmp MBR_LoadError645 InScanMode:646 mov si, offset TXT_BrokenPartitionTable647 push cs648 pop ds649 call MBR_Teletype650 mov si, offset BrokenHDD651 sub dl, 50h ; 80h -> '0'652 cmp dl, 39h653 jbe DIOGLE_BelowA654 add dl, 7 ; 3Ah -> 'A'655 DIOGLE_BelowA:656 mov bptr [si+5], dl657 call MBR_Teletype658 659 ; JWasm: cannot jump to local label inprocedure.660 ; Changed to halt here.661 ;jmp MBRLE_Halt662 DriveIO_GotLoadError_halt:663 jmp DriveIO_GotLoadError_halt664 DriveIO_GotLoadError 634 DriveIO_GotLoadError Proc Near 635 test cs:CurIO_Scanning, 1 ; Must be CS:, cause DS!=CS maybe here 636 jnz InScanMode 637 jmp MBR_LoadError 638 InScanMode: 639 mov si, offset TXT_BrokenPartitionTable 640 push cs 641 pop ds 642 call MBR_Teletype 643 mov si, offset BrokenHDD 644 sub dl, 50h ; 80h -> '0' 645 cmp dl, 39h 646 jbe DIOGLE_BelowA 647 add dl, 7 ; 3Ah -> 'A' 648 DIOGLE_BelowA: 649 mov bptr [si+5], dl 650 call MBR_Teletype 651 652 ; JWasm: cannot jump to local label in other procedure. 653 ; Changed to halt here. 654 ;jmp MBRLE_Halt 655 DriveIO_GotLoadError_halt: 656 jmp DriveIO_GotLoadError_halt 657 DriveIO_GotLoadError EndP 665 658 666 659 ; ######################################################################### … … 673 666 ; Preserve: all registers 674 667 ; ######################################################################### 675 DriveIO_LoadSector 676 ; Is the drive not a harddrive?677 cmpdl, 80h678 jbDIOLS_UseNormal679 680 testcs:[CurIO_UseExtension], 1681 jzDIOLS_UseNormal682 ; Are we forced do use LBA via Setting?683 jnzDIOLS_UseExtension684 685 ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)686 orbh, bh687 jnzDIOLS_UseExtension688 ; Compare Switch-Table value to bit 16-23 of LBA-address689 movdi, dx690 anddi, 007Fh691 cmpbptr cs:[LBASwitchTable+di], bl692 jbeDIOLS_UseExtension693 DIOLS_UseNormal:694 movdi, 3695 696 pushds697 popes698 movbx, si ; ES:BX - Destination699 movax, 0201h ; Function 2 - Load Sector700 int13h701 jncDIOLS_Success702 decdi703 jnzDIOLS_ErrorLoop704 ; Sector load failed...705 jmpDriveIO_GotLoadError706 707 DIOLS_UseExtension:708 push cx709 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector710 mov wptr cs:[DriveIO_DAP_Transfer+0], si711 mov cx, ds712 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress713 mov wptr cs:[DriveIO_DAP_Absolute+0], ax714 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector715 push cs716 pop ds717 mov si, offset DriveIO_DAP718 mov ah, 42h ; Extended Read719 int 13h720 pop cx721 jnc DIOLS_Success722 ; Sector load failed...723 jmp DriveIO_GotLoadError724 725 DIOLS_Success:726 ret727 DriveIO_LoadSector 668 DriveIO_LoadSector Proc Near Uses ax bx ds si es di 669 ; Is the drive not a harddrive? 670 cmp dl, 80h 671 jb DIOLS_UseNormal 672 673 test cs:[CurIO_UseExtension], 1 674 jz DIOLS_UseNormal 675 ; Are we forced do use LBA via Setting? 676 jnz DIOLS_UseExtension 677 678 ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h) 679 or bh, bh 680 jnz DIOLS_UseExtension 681 ; Compare Switch-Table value to bit 16-23 of LBA-address 682 mov di, dx 683 and di, 007Fh 684 cmp bptr cs:[LBASwitchTable+di], bl 685 jbe DIOLS_UseExtension 686 DIOLS_UseNormal: 687 mov di, 3 688 DIOLS_ErrorLoop: 689 push ds 690 pop es 691 mov bx, si ; ES:BX - Destination 692 mov ax, 0201h ; Function 2 - Load Sector 693 int 13h 694 jnc DIOLS_Success 695 dec di 696 jnz DIOLS_ErrorLoop 697 ; Sector load failed... 698 jmp DriveIO_GotLoadError 699 700 DIOLS_UseExtension: 701 push cx 702 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector 703 mov wptr cs:[DriveIO_DAP_Transfer+0], si 704 mov cx, ds 705 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress 706 mov wptr cs:[DriveIO_DAP_Absolute+0], ax 707 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector 708 push cs 709 pop ds 710 mov si, offset DriveIO_DAP 711 mov ah, 42h ; Extended Read 712 int 13h 713 pop cx 714 jnc DIOLS_Success 715 ; Sector load failed... 716 jmp DriveIO_GotLoadError 717 718 DIOLS_Success: 719 ret 720 DriveIO_LoadSector EndP 728 721 729 722 … … 744 737 ; AX = Error code 745 738 ; 746 DriveIO_LoadSectorLBA 747 ; Get one sector748 mov cs:[DriveIO_DAP_NumBlocks], 1749 750 ; Setup buffer address751 mov wptr cs:[DriveIO_DAP_Transfer+0], si752 mov wptr cs:[DriveIO_DAP_Transfer+2], di753 754 ; Setup LBA address of requested sector755 mov wptr cs:[DriveIO_DAP_Absolute+0], cx756 mov wptr cs:[DriveIO_DAP_Absolute+2], bx757 mov wptr cs:[DriveIO_DAP_Absolute+4], 0758 mov wptr cs:[DriveIO_DAP_Absolute+6], 0759 760 ; Address of packet761 mov si, offset DriveIO_DAP762 763 ; Do the extended read764 mov ah, 42h765 int 13h766 767 ; Looking good so far768 jnc DriveIO_LoadSectorLBA_succes1769 770 ; AH should not be zero, if it is then set to undefined and set carry771 test ah,ah772 jnz DriveIO_LoadSectorLBA_error1773 mov ah, 0bbh ; Undefined error774 DriveIO_LoadSectorLBA_error1:775 stc776 jmp DriveIO_LoadSectorLBA_exit777 778 ; AL should be zero, if not then set to undefined and set carry779 DriveIO_LoadSectorLBA_succes1:780 test ah,ah781 jz DriveIO_LoadSectorLBA_exit782 stc783 jmp DriveIO_LoadSectorLBA_exit784 785 ; Return to caller786 DriveIO_LoadSectorLBA_exit:787 ret788 DriveIO_LoadSectorLBA 739 DriveIO_LoadSectorLBA Proc Near Uses bx cx dx si di ds es 740 ; Get one sector 741 mov cs:[DriveIO_DAP_NumBlocks], 1 742 743 ; Setup buffer address 744 mov wptr cs:[DriveIO_DAP_Transfer+0], si 745 mov wptr cs:[DriveIO_DAP_Transfer+2], di 746 747 ; Setup LBA address of requested sector 748 mov wptr cs:[DriveIO_DAP_Absolute+0], cx 749 mov wptr cs:[DriveIO_DAP_Absolute+2], bx 750 mov wptr cs:[DriveIO_DAP_Absolute+4], 0 751 mov wptr cs:[DriveIO_DAP_Absolute+6], 0 752 753 ; Address of packet 754 mov si, offset DriveIO_DAP 755 756 ; Do the extended read 757 mov ah, 42h 758 int 13h 759 760 ; Looking good so far 761 jnc DriveIO_LoadSectorLBA_succes1 762 763 ; AH should not be zero, if it is then set to undefined and set carry 764 test ah,ah 765 jnz DriveIO_LoadSectorLBA_error1 766 mov ah, 0bbh ; Undefined error 767 DriveIO_LoadSectorLBA_error1: 768 stc 769 jmp DriveIO_LoadSectorLBA_exit 770 771 ; AL should be zero, if not then set to undefined and set carry 772 DriveIO_LoadSectorLBA_succes1: 773 test ah,ah 774 jz DriveIO_LoadSectorLBA_exit 775 stc 776 jmp DriveIO_LoadSectorLBA_exit 777 778 ; Return to caller 779 DriveIO_LoadSectorLBA_exit: 780 ret 781 DriveIO_LoadSectorLBA EndP 789 782 790 783 … … 801 794 ; ######################################################################### 802 795 DriveIO_SaveSector Proc Near Uses ax bx cx ds si es di 803 testcs:[CurIO_UseExtension], 1804 jzDIOSS_UseNormal805 ; Are we forced do use LBA via Setting?806 testcs:[CFG_ForceLBAUsage], 1807 jnzDIOSS_UseExtension808 ; Is the drive not a harddrive?809 cmpdl, 80h810 jbDIOSS_UseNormal811 ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)812 orbh, bh813 jnzDIOSS_UseExtension814 ; Compare Switch-Table value to bit 16-23 of LBA-address815 movdi, dx816 anddi, 007Fh817 cmpbptr cs:[LBASwitchTable+di], bl818 jbeDIOSS_UseExtension819 DIOSS_UseNormal:820 movdi, 3821 822 pushds823 popes824 movbx, si ; ES:BX - Destination825 movax, 0301h ; Function 3 - Write Sector826 int13h827 jncDIOSS_Success828 decdi829 jnzDIOSS_ErrorLoop830 callMBR_SaveError831 832 DIOSS_UseExtension:833 push cx834 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector835 mov wptr cs:[DriveIO_DAP_Transfer+0], si836 mov cx, ds837 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress838 mov wptr cs:[DriveIO_DAP_Absolute+0], ax839 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector840 push cs841 pop ds842 mov si, offset DriveIO_DAP843 mov ax, 4300h ; Extended Write (No Verify)844 int 13h845 pop cx846 jnc DIOSS_Success847 call MBR_SaveError848 849 DIOSS_Success:850 ret796 test cs:[CurIO_UseExtension], 1 797 jz DIOSS_UseNormal 798 ; Are we forced do use LBA via Setting? 799 test cs:[CFG_ForceLBAUsage], 1 800 jnz DIOSS_UseExtension 801 ; Is the drive not a harddrive? 802 cmp dl, 80h 803 jb DIOSS_UseNormal 804 ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h) 805 or bh, bh 806 jnz DIOSS_UseExtension 807 ; Compare Switch-Table value to bit 16-23 of LBA-address 808 mov di, dx 809 and di, 007Fh 810 cmp bptr cs:[LBASwitchTable+di], bl 811 jbe DIOSS_UseExtension 812 DIOSS_UseNormal: 813 mov di, 3 814 DIOSS_ErrorLoop: 815 push ds 816 pop es 817 mov bx, si ; ES:BX - Destination 818 mov ax, 0301h ; Function 3 - Write Sector 819 int 13h 820 jnc DIOSS_Success 821 dec di 822 jnz DIOSS_ErrorLoop 823 call MBR_SaveError 824 825 DIOSS_UseExtension: 826 push cx 827 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector 828 mov wptr cs:[DriveIO_DAP_Transfer+0], si 829 mov cx, ds 830 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress 831 mov wptr cs:[DriveIO_DAP_Absolute+0], ax 832 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector 833 push cs 834 pop ds 835 mov si, offset DriveIO_DAP 836 mov ax, 4300h ; Extended Write (No Verify) 837 int 13h 838 pop cx 839 jnc DIOSS_Success 840 call MBR_SaveError 841 842 DIOSS_Success: 843 ret 851 844 DriveIO_SaveSector EndP 852 845 … … 858 851 pusha 859 852 860 call 853 call LVM_CheckSectorSignature 861 854 ; NC if no signature found 862 jnc 863 864 call 855 jnc DriveIO_LVMSectorValid_End 856 857 call LVM_CheckSectorCRC 865 858 ; Force valid !!! 866 859 stc … … 889 882 ; Return CF when valid master LVM sector found, NC if not. 890 883 ; Loads sector at [LVMSector] ! 891 DriveIO_LoadMasterLVMSector 884 DriveIO_LoadMasterLVMSector Proc Near 892 885 pusha 893 886 894 ; mov si,offset db_lmlvm895 ; call AuxIO_Print896 897 ; Physical disk898 ;mov al,'<'899 ;call VideoIO_PrintSingleChar900 ;mov al,dl901 ;call VideoIO_PrintHexByte902 ;mov al,'>'903 ;call VideoIO_PrintSingleChar904 905 ; callAuxIO_TeletypeHexByte906 ; callAuxIO_TeletypeNL887 ;~ mov si,offset db_lmlvm 888 ;~ call AuxIO_Print 889 890 ;~ ; Physical disk 891 ;~ mov al,'<' 892 ;~ call VideoIO_PrintSingleChar 893 ;~ mov al,dl 894 ;~ call VideoIO_PrintHexByte 895 ;~ mov al,'>' 896 ;~ call VideoIO_PrintSingleChar 897 ;~ 898 ;~ call AuxIO_TeletypeHexByte 899 ;~ call AuxIO_TeletypeNL 907 900 908 901 909 902 ; Loop over the sector-translation table, 910 903 ; process the first three values from high (255) to low (bios spt, most likely 63) 911 mov 904 mov cx,3 912 905 DriveIO_LoadMasterLVMSector_NextTry: 913 906 ; Number of sectors to read … … 934 927 ; 935 928 936 ;push ax937 ;push ax938 ;mov al,'$'939 ;call VideoIO_PrintSingleChar940 ;pop ax941 ;call VideoIO_PrintHexByte942 ;mov al,'$'943 ;call VideoIO_PrintSingleChar944 ;pop ax945 946 IFDEF A uxDebug929 ;~ push ax 930 ;~ push ax 931 ;~ mov al,'$' 932 ;~ call VideoIO_PrintSingleChar 933 ;~ pop ax 934 ;~ call VideoIO_PrintHexByte 935 ;~ mov al,'$' 936 ;~ call VideoIO_PrintSingleChar 937 ;~ pop ax 938 939 IFDEF AUX_DEBUG 947 940 ; Dump the value 948 941 ;call AuxIO_TeletypeHexByte … … 963 956 964 957 ; See if this is a valid LVM-sector 965 call 958 call DriveIO_LVMSectorValid 966 959 967 960 ; pushf … … 980 973 jc DriveIO_LoadMasterLVMSector_Found 981 974 ; Try next location 982 loop 975 loop DriveIO_LoadMasterLVMSector_NextTry 983 976 984 977 ; No master LVM-sector found, set CF=false … … 1083 1076 ; DL contains BIOS disk-number; 80h for first, 81h for second, etc. 1084 1077 DriveIO_GatherDiskInfo Proc Near 1085 pushf1086 push bx1087 push cx1088 push dx1089 push si1090 push di1091 push es1092 1093 ; Set ES to CS for buffer clearing1094 push cs1095 pop es1096 1097 ; Clear the buffer1098 ; Don't overwrite the word of the buffersize at index 0 !1099 ; Old Phoenix BIOSses require word (flags) at 02 to be zero,1100 ; so we clear the whole buffer to be sure.1101 mov cx, i13xbuf_size1102 mov di, offset i13xbuf1103 mov [di],cx1104 inc di1105 inc di1106 xor ah,ah1107 cld1108 rep stosb1109 1110 ; Get the drive parameters1111 mov ah, 48h; Get Drive Parameters (extended version)1112 ;mov dl, 80h; Drive number1113 mov si, offset i13xbuf; Buffer for result-info1114 push dx1115 int 13h; Call the BIOS-function1116 pop dx1117 1118 ; Do some error-checking1119 or ah,ah; AH is zero if no error (ZF=1 if no error)1120 mov ax,0; Setup code for non-huge drive (does not influence ZF)1121 jz DriveIO_GatherDiskInfo_ok; Return if error (AL<>0 thus ZF=0) but CY not set, assuming non-huge drive1122 jnc DriveIO_GatherDiskInfo_ok; Return if error (CY=1), assuming non-huge drive1123 jmp DriveIO_GatherDiskInfo_ret1124 1125 1126 DriveIO_GatherDiskInfo_ok:1127 1128 ;1129 ; Store the drive geometry1130 ;1131 1132 mov si, offset i13xbuf1133 1134 xor dh,dh1135 and dl,01111111b1136 shl dx,11137 shl dx,11138 1139 ; Store number of cylinders on disk1140 mov bx, offset BIOS_Cyls1141 add bx,dx1142 mov ax,[si+04h]1143 1144 mov word ptr [bx+00],ax1145 mov ax,[si+06]1146 mov word ptr [bx+02],ax1147 1148 ; Store number of heads per cylinder1149 mov bx, offset BIOS_Heads1150 add bx,dx1151 mov ax,[si+08h]1152 mov word ptr [bx+00],ax1153 mov ax,[si+0ah]1154 mov word ptr [bx+02],ax1155 1156 ; Store number of sectors per track1157 mov bx, offset BIOS_Secs1158 add bx,dx1159 mov ax,[si+0ch]1160 mov word ptr [bx+00],ax1161 1162 ; Update first byte of translation-table to conform to BIOS SPT1163 mov byte ptr [secs_per_track_table], al1164 1165 mov ax,[si+0eh]1166 mov word ptr [bx+02],ax1167 1168 ; Store total secs1169 mov bx, offset BIOS_TotalSecs1170 add bx,dx1171 add bx,dx1172 mov ax,[si+10h]1173 1174 mov word ptr [bx+00],ax1175 mov ax,[si+12h]1176 mov word ptr [bx+02],ax1177 mov ax,[si+14h]1178 mov word ptr [bx+04],ax1179 mov ax,[si+18h]1180 mov word ptr [bx+06],ax1181 1182 ; Store number of bytes per sector1183 mov bx, offset BIOS_Bytes1184 add bx,dx1185 mov ax,[si+18h]1186 mov [bx],ax1187 1188 1189 ;1190 ; See of it's a huge drive of not1191 ;1192 1193 ; Drive is larger than 2TiB1194 mov ax,5; Drive code (5)1195 mov bx, [si+14h]; Low word of high dword of sector-count1196 or bx, [si+16h]; High word of high dword of sector-count1197 jnz DriveIO_GatherDiskInfo_ret; If non-zero we have a drive with >2^32 sectors and thus LBA48 addressing1198 1199 ; Drive is larger than max OS/2 capacity1200 dec ax; Drive code (4)1201 mov bx, [si+12h]; High word of low dword of sector-count1202 cmp bx, 0fe01h; Boundary1203 jae DriveIO_GatherDiskInfo_ret; If above or equal to boundary,1204 1205 1206 ; Drive can be completely utilized by OS/21207 dec ax; Drive code (3)1208 cmp bx, 8000h; Boundary1209 jae DriveIO_GatherDiskInfo_ret; If above or equal to boundary,1210 1211 1212 ; This is the small area between DANI 1TiB and LBA 1TiB1213 dec ax; Drive code (2)1214 cmp bx, 7e81h; Boundary1215 jae DriveIO_GatherDiskInfo_ret; If above or equal to boundary,1216 1217 1218 1219 ; DANI will use 255/127 in this area, this could impact the location of LVM-sectors ! (last sec on track)1220 dec ax; Drive code (1)1221 cmp bx, 3ec1h; Boundary1222 jae DriveIO_GatherDiskInfo_ret; If above or equal to boundary,1223 1224 1225 1226 1227 ; We have a drive that can be addressed using standard 255/63 geometry1228 dec ax ; Drive code (0)1229 1230 1231 DriveIO_GatherDiskInfo_ret:1232 pop es1233 pop di1234 pop si1235 pop dx1236 pop cx1237 pop bx1238 1239 mov [CurIO_UseExtension],11240 1241 popf1242 ret1078 pushf 1079 push bx 1080 push cx 1081 push dx 1082 push si 1083 push di 1084 push es 1085 1086 ; Set ES to CS for buffer clearing 1087 push cs 1088 pop es 1089 1090 ; Clear the buffer 1091 ; Also setup the buffer size. 1092 ; Old Phoenix BIOSses require word (flags) at 02 to be zero, 1093 ; so we clear the whole buffer to be sure. 1094 mov cx, i13xbuf_size ; Dynamically calculated by assembler. 1095 mov di, offset i13xbuf ; Points to size field. 1096 mov [di],cx ; Setup buffer-size. 1097 inc di 1098 inc di ; Now pointing at actual buffer. 1099 xor ah,ah ; Fill value. 1100 cld ; Direction up. 1101 rep stosb ; Clear buffer. 1102 1103 ; Get the drive parameters 1104 mov ah, 48h ; Get Drive Parameters (extended version) 1105 ;mov dl, 80h ; Drive number 1106 mov si, offset i13xbuf ; Buffer for result-info 1107 push dx 1108 int 13h ; Call the BIOS-function 1109 pop dx 1110 1111 ; Do some error-checking 1112 or ah,ah ; AH is zero if no error (ZF=1 if no error) 1113 mov ax,0 ; Setup code for non-huge drive (does not influence ZF) 1114 jz DriveIO_GatherDiskInfo_ok ; Return if error (AL<>0 thus ZF=0) but CY not set, assuming non-huge drive 1115 jnc DriveIO_GatherDiskInfo_ok ; Return if error (CY=1), assuming non-huge drive 1116 jmp DriveIO_GatherDiskInfo_ret 1117 1118 1119 DriveIO_GatherDiskInfo_ok: 1120 1121 ; 1122 ; Store the drive geometry 1123 ; 1124 1125 mov si, offset i13xbuf 1126 1127 xor dh,dh 1128 and dl,01111111b 1129 shl dx,1 1130 shl dx,1 1131 1132 ; Store number of cylinders on disk 1133 mov bx, offset BIOS_Cyls 1134 add bx,dx 1135 mov ax,[si+04h] 1136 1137 mov word ptr [bx+00],ax 1138 mov ax,[si+06] 1139 mov word ptr [bx+02],ax 1140 1141 ; Store number of heads per cylinder 1142 mov bx, offset BIOS_Heads 1143 add bx,dx 1144 mov ax,[si+08h] 1145 mov word ptr [bx+00],ax 1146 mov ax,[si+0ah] 1147 mov word ptr [bx+02],ax 1148 1149 ; Store number of sectors per track 1150 mov bx, offset BIOS_Secs 1151 add bx,dx 1152 mov ax,[si+0ch] 1153 mov word ptr [bx+00],ax 1154 1155 ; Update first byte of translation-table to conform to BIOS SPT 1156 mov byte ptr [secs_per_track_table], al 1157 1158 mov ax,[si+0eh] 1159 mov word ptr [bx+02],ax 1160 1161 ; Store total secs 1162 mov bx, offset BIOS_TotalSecs 1163 add bx,dx 1164 add bx,dx 1165 mov ax,[si+10h] 1166 1167 mov word ptr [bx+00],ax 1168 mov ax,[si+12h] 1169 mov word ptr [bx+02],ax 1170 mov ax,[si+14h] 1171 mov word ptr [bx+04],ax 1172 mov ax,[si+18h] 1173 mov word ptr [bx+06],ax 1174 1175 ; Store number of bytes per sector 1176 mov bx, offset BIOS_Bytes 1177 add bx,dx 1178 mov ax,[si+18h] 1179 mov [bx],ax 1180 1181 1182 ; 1183 ; See of it's a huge drive of not 1184 ; 1185 1186 ; Drive is larger than 2TiB 1187 mov ax,5 ; Drive code (5) 1188 mov bx, [si+14h] ; Low word of high dword of sector-count 1189 or bx, [si+16h] ; High word of high dword of sector-count 1190 jnz DriveIO_GatherDiskInfo_ret ; If non-zero we have a drive with >2^32 sectors and thus LBA48 addressing 1191 1192 ; Drive is larger than max OS/2 capacity 1193 dec ax ; Drive code (4) 1194 mov bx, [si+12h] ; High word of low dword of sector-count 1195 cmp bx, 0fe01h ; Boundary 1196 jae DriveIO_GatherDiskInfo_ret ; If above or equal to boundary, 1197 ; we have a drive larger than to 65536*255*255 = FE010000 sectors 1198 1199 ; Drive can be completely utilized by OS/2 1200 dec ax ; Drive code (3) 1201 cmp bx, 8000h ; Boundary 1202 jae DriveIO_GatherDiskInfo_ret ; If above or equal to boundary, 1203 ; we have a drive larger than 2^31 sectors but smaller than 65536*255*255 1204 1205 ; This is the small area between DANI 1TiB and LBA 1TiB 1206 dec ax ; Drive code (2) 1207 cmp bx, 7e81h ; Boundary 1208 jae DriveIO_GatherDiskInfo_ret ; If above or equal to boundary, 1209 ; we have a drive larger than 65536*255*127 but <65536*255*255 1210 ; DANIS506.ADD will use 255/255 extended geometry 1211 1212 ; DANI will use 255/127 in this area, this could impact the location of LVM-sectors ! (last sec on track) 1213 dec ax ; Drive code (1) 1214 cmp bx, 3ec1h ; Boundary 1215 jae DriveIO_GatherDiskInfo_ret ; If above or equal to boundary, 1216 ; we have a drive larger than 65536*255*63 sectors (OS/2 502GiB Limit!) 1217 ; DANIS506.ADD will use 255/127 extended geometry ! 1218 ; IBM1S506.ADD will use 255/255 extended geometry ! 1219 1220 ; We have a drive that can be addressed using standard 255/63 geometry 1221 dec ax ; Drive code (0) 1222 ; We have a drive smaller than 65536*255*63 = 3EC10000 sectors 1223 1224 DriveIO_GatherDiskInfo_ret: 1225 pop es 1226 pop di 1227 pop si 1228 pop dx 1229 pop cx 1230 pop bx 1231 1232 mov [CurIO_UseExtension],1 1233 1234 popf 1235 ret 1243 1236 DriveIO_GatherDiskInfo EndP 1244 1237
Note:
See TracChangeset
for help on using the changeset viewer.