Changeset 223 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device
- Timestamp:
- Jan 25, 2012, 8:20:06 PM (13 years ago)
- google:author:
- krille_n_@hotmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r218 r223 8 8 .wWordsLeft resb 2 ; 2, WORDs left to transfer 9 9 .wWordsDone resb 2 ; 4, Number of sectors xferred 10 resb 1 ; 6, 10 resb 1 ; 6, 11 11 resb 1 ; 7, IDEPACK.bDeviceControl 12 12 .wDataPort resb 2 ; 8, IDE Data Port … … 327 327 %ifdef USE_186 ; OUTS instruction available 328 328 shl cx, 1 ; WORD count to BYTE count 329 e SEG es; Source is ES segment329 es ; Source is ES segment 330 330 rep outsb 331 331 %else ; If 8088/8086 … … 369 369 ALIGN JUMP_ALIGN 370 370 WordWrite: 371 e SEG es; Source is ES segment371 es ; Source is ES segment 372 372 rep 373 373 db 6Fh ; OUTSW (we want this in XT build) … … 377 377 DWordWrite: 378 378 shr cx, 1 ; WORD count to DWORD count 379 e SEG es; Source is ES segment379 es ; Source is ES segment 380 380 rep 381 381 db 66h ; Override operand size to 32-bit -
trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
r220 r223 151 151 ; 152 152 mov bl,dl ; setup BL with proper values for read/write loops (BH comes later) 153 153 154 154 mov al,83h 155 155 add dl,SerialCommand_UART_lineControl … … 202 202 mov cx,4 ; writing 3 words (plus 1) 203 203 204 cli ; interrupts off... 204 cli ; interrupts off... 205 205 206 206 call SerialCommand_WriteProtocol.entry … … 215 215 ;;; more than 128 sectors (and for 128 specifically, the pointer must be segment aligned). 216 216 ;;; See comments below at the point this entry point was called for more details... 217 .nextSectorNormalize: 217 .nextSectorNormalize: 218 218 call Registers_NormalizeESDI 219 219 %endif 220 220 221 221 pop ax ; load command byte (done before call to .nextSector on subsequent iterations) 222 222 push ax … … 249 249 .readTimeout: 250 250 push ax ; not only does this push preserve AX (which we need), but it also 251 ; means the stack has the same number of bytes on it as when we are 251 ; means the stack has the same number of bytes on it as when we are 252 252 ; sending a packet, important for error cleanup and exit 253 253 mov ah,1 … … 256 256 test dl,1 257 257 jz .readByte1Ready 258 jmp .readByte2Ready 258 jmp .readByte2Ready 259 259 260 260 ;---------------------------------------------------------------------------- … … 275 275 adc si, 0 276 276 277 .readEntry: 277 .readEntry: 278 278 mov dl,bh 279 279 in al,dx … … 325 325 326 326 pop ax ; sector count and command byte 327 dec al ; decreme mnt sector count327 dec al ; decrement sector count 328 328 push ax ; save 329 329 jz SerialCommand_OutputWithParameters_ReturnCodeInALCF ; CF=0 from "cmp ax,bp" returning Zero above … … 336 336 ;;; This code is no longer needed as we do not support more than 128 sectors, and for 128 the pointer 337 337 ;;; must be segment aligned. If we ever do want to support more sectors, the code can help... 338 338 339 339 ; 340 340 ; Normalize buffer pointer for next go round, if needed. 341 341 ; 342 ; We need to re-no mrlize the pointer in ES:DI after processing every 7f sectors. That number could342 ; We need to re-normalize the pointer in ES:DI after processing every 7f sectors. That number could 343 343 ; have been 80 if we knew the offset was on a segment boundary, but this may not be the case. 344 344 ; … … 347 347 ; b) on transitions from FF to FE, very rare case for writing 255 or 256 sectors 348 348 ; c) on transitions from 80 to 7F, a large read/write 349 ; d) on transitions from 00 to FF, very, very rare case of writing 256 sec otrs350 ; We don't need to renormalize in this case, but it isn't worth the memory/effort to not do 349 ; d) on transitions from 00 to FF, very, very rare case of writing 256 sectors 350 ; We don't need to renormalize in this case, but it isn't worth the memory/effort to not do 351 351 ; the extra work, and it does no harm. 352 352 ; … … 354 354 ; for more than 127 sectors. Back in the day, it appears that some BIOS could not support more than 127 355 355 ; sectors, so that may be the practical limit for OS and application developers. The Extended BIOS 356 ; function also appear to be capped at 127 sectors. So although this can support the full 256 sectors 356 ; function also appear to be capped at 127 sectors. So although this can support the full 256 sectors 357 357 ; if needed, we are optimized for that 1-127 range. 358 358 ; … … 373 373 ; (0-7e kicked out before we get here) 374 374 ; 7f moves to 81 and OF=1, so OF=SF 375 ; fe moves to 0 and OF=0, SF=0, so OF=SF 375 ; fe moves to 0 and OF=0, SF=0, so OF=SF 376 376 ; ff moves to 1 and OF=0, SF=0, so OF=SF 377 377 ; 80-fd moves to 82-ff and OF=0, so OF<>SF … … 387 387 388 388 %else 389 390 jmp short .nextSector 391 389 390 jmp short .nextSector 391 392 392 %endif 393 393 … … 425 425 jc .clearBuffer ; note CF from shr above 426 426 427 .clearBufferComplete: 427 .clearBufferComplete: 428 428 stc 429 429 mov al,1 … … 448 448 ; SerialCommand_WriteProtocol 449 449 ; 450 ; NOTE: As with its read counterpart, this loop is very time sensitive. 451 ; Although it will still function, adding additional instructions will 452 ; impact the write throug put, especially on slower machines.450 ; NOTE: As with its read counterpart, this loop is very time sensitive. 451 ; Although it will still function, adding additional instructions will 452 ; impact the write throughput, especially on slower machines. 453 453 ; 454 454 ; Parameters: … … 514 514 mov ah,dl 515 515 jmp .writeByte2Ready 516 516 517 517 .writeTimeout1: 518 %ifndef USE_186 518 519 mov ax,.writeByte1Ready 519 520 push ax ; return address for ret at end of SC_writeTimeout2 521 %else 522 push .writeByte1Ready 523 %endif 520 524 ;;; fall-through 521 525 … … 527 531 ; One entry point fills in AH with 20h for write 528 532 ; DX: Port address (OK if already incremented to UART_lineStatus) 529 ; BX: 533 ; BX: 530 534 ; Stack: 2 words on the stack below the command/count word 531 535 ; Returns: … … 553 557 xor cx,cx 554 558 .readTimeoutLoop: 555 mov dl,bh 559 mov dl,bh 556 560 in al,dx 557 561 test al,ah … … 588 592 ; Returns: 589 593 ; AH: INT 13h Error Code 590 ; NOTE: Not set (or checked) during drive detection 594 ; NOTE: Not set (or checked) during drive detection 591 595 ; CF: Cleared if success, Set if error 592 596 ; Corrupts registers: … … 596 600 SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH: 597 601 ; 598 ; To improve boot time, we do our best to avoid looking for slave serial drives when we already know the results 599 ; from the looking for a master. This is particu arly true when doing a COM port scan, as we will end up running600 ; through all the COM ports and baud rates a second time. 601 ; 602 ; But drive detection isn't the only case - we also need to get the right drive when called on int13h/25h. 602 ; To improve boot time, we do our best to avoid looking for slave serial drives when we already know the results 603 ; from the looking for a master. This is particularly true when doing a COM port scan, as we will end up running 604 ; through all the COM ports and baud rates a second time. 605 ; 606 ; But drive detection isn't the only case - we also need to get the right drive when called on int13h/25h. 603 607 ; 604 608 ; The decision tree: … … 606 610 ; Master: 607 611 ; bSerialPackedPortAndBaud Non-Zero: -> Continue with bSerialPackedAndBaud (1) 608 ; bSerialPackedPortAndBaud Zero: 612 ; bSerialPackedPortAndBaud Zero: 609 613 ; bLastSerial Zero: -> Scan (2) 610 614 ; bLastSerial Non-Zero: -> Continue with bLastSerial (3) 611 ; 615 ; 612 616 ; Slave: 613 ; bSerialPackedPortAndBaud Non-Zero: 617 ; bSerialPackedPortAndBaud Non-Zero: 614 618 ; bLastSerial Zero: -> Error - Not Found (4) 615 619 ; bLastSerial Non-Zero: -> Continue with bSerialPackedAndBaud (5) 616 ; bSerialPackedPortAndBaud Zero: 620 ; bSerialPackedPortAndBaud Zero: 617 621 ; bLastSerial Zero: -> Error - Not Found (4) 618 622 ; bLastSerial Non-Zero: -> Continue with bLastSerial (6) 619 623 ; 620 ; (1) This was a port/baud that was explici lty set with the configurator. In the drive detection case, as this621 ; is the Master, we are checking out a new controller, and so don't care about the value of bLastSerial. 624 ; (1) This was a port/baud that was explicitly set with the configurator. In the drive detection case, as this 625 ; is the Master, we are checking out a new controller, and so don't care about the value of bLastSerial. 622 626 ; And as with the int13h/25h case, we just go off and get the needed information using the user's setting. 623 ; (2) We are using the special .ideVarsSerialAuto struc utre. During drive detection, we would only be here627 ; (2) We are using the special .ideVarsSerialAuto structure. During drive detection, we would only be here 624 628 ; if bLastSerial is zero (since we only scan if no explicit drives are set), so we go off to scan. 625 ; (3) We are using the special .ideVarsSerialAuto struc utre. We won't get here during drive detection, but629 ; (3) We are using the special .ideVarsSerialAuto structure. We won't get here during drive detection, but 626 630 ; we might get here on an int13h/25h call. If we have scanned COM drives, they are the ONLY serial drives 627 631 ; in use, and so bLastSerial will reflect the port/baud setting for the scanned COM drives. 628 ; (4) No master has been found yet, therefore no slave should be found. Avoiding the slave reduces boot time, 632 ; (4) No master has been found yet, therefore no slave should be found. Avoiding the slave reduces boot time, 629 633 ; especially in the full COM port scan case. Note that this is different from the hardware IDE, where we 630 634 ; will scan for a slave even if a master is not present. Note that if ANY master had been previously found, 631 ; we will do the slave scan, which isn't harmful, it just wa tes time. But the most common case (by a wide635 ; we will do the slave scan, which isn't harmful, it just wastes time. But the most common case (by a wide 632 636 ; margin) will be just one serial controller. 633 637 ; (5) A COM port scan for a master had been previously completed, and a drive was found. In a multiple serial 634 ; controller scenario being called with int13h/25h, we need to use the value in bSerialPackedPortAndBaud 638 ; controller scenario being called with int13h/25h, we need to use the value in bSerialPackedPortAndBaud 635 639 ; to make sure we get the proper drive. 636 ; (6) A COM port scan for a master had been previously completed, and a drive was found. We would only get here 637 ; if no serial drive was explicitly set by the user in the configurator or that drive had not been found. 638 ; Instead of performing the full COM port scan for the slave, use the port/baud value stored during the 640 ; (6) A COM port scan for a master had been previously completed, and a drive was found. We would only get here 641 ; if no serial drive was explicitly set by the user in the configurator or that drive had not been found. 642 ; Instead of performing the full COM port scan for the slave, use the port/baud value stored during the 639 643 ; master scan. 640 ; 641 mov dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud] 644 ; 645 mov dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud] 642 646 mov al, byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial] 643 647 644 648 test bh, FLG_DRVNHEAD_DRV 645 649 jz .master 646 650 647 test al,al ; Take care of the case that is different between master and slave. 651 test al,al ; Take care of the case that is different between master and slave. 648 652 jz .error ; Because we do this here, the jz after the "or" below will not be taken 649 653 650 654 ; fall-through 651 .master: 655 .master: 652 656 test dl,dl 653 657 jnz .identifyDeviceInDL … … 655 659 or dl,al ; Move bLast into position in dl, as well as test for zero 656 660 jz .scanSerial 657 661 658 662 ; fall-through 659 .identifyDeviceInDL: 663 .identifyDeviceInDL: 660 664 661 665 push bp ; setup fake IDEREGS_AND_INTPACK … … 680 684 681 685 pop bp 682 ; 686 ; 683 687 ; place packed port/baud in RAMVARS, read by FinalizeDPT and DetectDrives 684 688 ; 685 689 ; Note that this will be set during an int13h/25h call as well. Which is OK since it is only used (at the 686 ; top of this routine) for drives found during a COM scan, and we only COM scan if there were no other 690 ; top of this routine) for drives found during a COM scan, and we only COM scan if there were no other 687 691 ; COM drives found. So we will only reaffirm the port/baud for the one COM port/baud that has a drive. 688 ; 692 ; 689 693 jc .notFound ; only store bLastSerial if success 690 694 mov byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial], dl 691 695 692 .notFound: 696 .notFound: 693 697 ret 694 698 … … 715 719 .nextPort: 716 720 inc di ; load next port address 721 xor dh, dh 717 722 mov dl,[cs:di] 718 719 mov dh,0 ; shift from one byte to two 720 eSHL_IM dx, 2 723 eSHL_IM dx, 2 ; shift from one byte to two 721 724 jz .error 722 725 … … 762 765 ret 763 766 764 .error: 767 .error: 765 768 stc 766 769 %if 0
Note:
See TracChangeset
for help on using the changeset viewer.