Ignore:
Timestamp:
Jan 25, 2012, 8:20:06 PM (12 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Fixed what appears to be a mistake in EBIOS.inc
  • Added a 'release' option to the makefile of the Serial Server (invokes UPX)
  • Some very minor optimizations
  • Removed the eSEG macro and did some other cleanups (fixed typos etc)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm

    r220 r223  
    151151;
    152152        mov     bl,dl           ; setup BL with proper values for read/write loops (BH comes later)
    153        
     153
    154154        mov     al,83h
    155155        add     dl,SerialCommand_UART_lineControl
     
    202202        mov     cx,4            ; writing 3 words (plus 1)
    203203
    204         cli                     ; interrupts off... 
     204        cli                     ; interrupts off...
    205205
    206206        call    SerialCommand_WriteProtocol.entry
     
    215215;;; more than 128 sectors (and for 128 specifically, the pointer must be segment aligned).
    216216;;; See comments below at the point this entry point was called for more details...
    217 .nextSectorNormalize:           
     217.nextSectorNormalize:
    218218        call    Registers_NormalizeESDI
    219219%endif
    220        
     220
    221221        pop     ax              ; load command byte (done before call to .nextSector on subsequent iterations)
    222222        push    ax
     
    249249.readTimeout:
    250250        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
    252252                                ; sending a packet, important for error cleanup and exit
    253253        mov     ah,1
     
    256256        test    dl,1
    257257        jz      .readByte1Ready
    258         jmp     .readByte2Ready     
     258        jmp     .readByte2Ready
    259259
    260260;----------------------------------------------------------------------------
     
    275275        adc     si, 0
    276276
    277 .readEntry:     
     277.readEntry:
    278278        mov     dl,bh
    279279        in      al,dx
     
    325325
    326326        pop     ax              ; sector count and command byte
    327         dec     al              ; decrememnt sector count
     327        dec     al              ; decrement sector count
    328328        push    ax              ; save
    329329        jz      SerialCommand_OutputWithParameters_ReturnCodeInALCF    ; CF=0 from "cmp ax,bp" returning Zero above
     
    336336;;; This code is no longer needed as we do not support more than 128 sectors, and for 128 the pointer
    337337;;; must be segment aligned.  If we ever do want to support more sectors, the code can help...
    338        
     338
    339339;
    340340; Normalize buffer pointer for next go round, if needed.
    341341;
    342 ; We need to re-nomrlize the pointer in ES:DI after processing every 7f sectors.  That number could
     342; We need to re-normalize the pointer in ES:DI after processing every 7f sectors.  That number could
    343343; have been 80 if we knew the offset was on a segment boundary, but this may not be the case.
    344344;
     
    347347;    b) on transitions from FF to FE, very rare case for writing 255 or 256 sectors
    348348;    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 secotrs
    350 ;       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
    351351;       the extra work, and it does no harm.
    352352;
     
    354354; for more than 127 sectors.  Back in the day, it appears that some BIOS could not support more than 127
    355355; 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
    357357; if needed, we are optimized for that 1-127 range.
    358358;
     
    373373                                        ; (0-7e kicked out before we get here)
    374374                                        ; 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
    376376                                        ; ff moves to 1 and OF=0, SF=0, so OF=SF
    377377                                        ; 80-fd moves to 82-ff and OF=0, so OF<>SF
     
    387387
    388388%else
    389        
    390         jmp     short .nextSector       
    391        
     389
     390        jmp     short .nextSector
     391
    392392%endif
    393393
     
    425425        jc      .clearBuffer    ; note CF from shr above
    426426
    427 .clearBufferComplete:           
     427.clearBufferComplete:
    428428        stc
    429429        mov     al,1
     
    448448; SerialCommand_WriteProtocol
    449449;
    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 througput, 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.
    453453;
    454454;   Parameters:
     
    514514        mov     ah,dl
    515515        jmp     .writeByte2Ready
    516        
     516
    517517.writeTimeout1:
     518%ifndef USE_186
    518519        mov     ax,.writeByte1Ready
    519520        push    ax              ; return address for ret at end of SC_writeTimeout2
     521%else
     522        push    .writeByte1Ready
     523%endif
    520524;;; fall-through
    521525
     
    527531;               One entry point fills in AH with 20h for write
    528532;       DX:     Port address (OK if already incremented to UART_lineStatus)
    529 ;       BX:   
     533;       BX:
    530534;       Stack:  2 words on the stack below the command/count word
    531535;   Returns:
     
    553557        xor     cx,cx
    554558.readTimeoutLoop:
    555         mov     dl,bh               
     559        mov     dl,bh
    556560        in      al,dx
    557561        test    al,ah
     
    588592;   Returns:
    589593;       AH:     INT 13h Error Code
    590 ;               NOTE: Not set (or checked) during drive detection 
     594;               NOTE: Not set (or checked) during drive detection
    591595;       CF:     Cleared if success, Set if error
    592596;   Corrupts registers:
     
    596600SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
    597601;
    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 particuarly true when doing a COM port scan, as we will end up running
    600 ; 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.
    603607;
    604608; The decision tree:
     
    606610;    Master:
    607611;          bSerialPackedPortAndBaud Non-Zero:   -> Continue with bSerialPackedAndBaud (1)
    608 ;          bSerialPackedPortAndBaud Zero: 
     612;          bSerialPackedPortAndBaud Zero:
    609613;                         bLastSerial Zero:     -> Scan (2)
    610614;                         bLastSerial Non-Zero: -> Continue with bLastSerial (3)
    611 ;                                   
     615;
    612616;    Slave:
    613 ;          bSerialPackedPortAndBaud Non-Zero: 
     617;          bSerialPackedPortAndBaud Non-Zero:
    614618;                         bLastSerial Zero:     -> Error - Not Found (4)
    615619;                         bLastSerial Non-Zero: -> Continue with bSerialPackedAndBaud (5)
    616 ;          bSerialPackedPortAndBaud Zero:     
     620;          bSerialPackedPortAndBaud Zero:
    617621;                         bLastSerial Zero:     -> Error - Not Found (4)
    618622;                         bLastSerial Non-Zero: -> Continue with bLastSerial (6)
    619623;
    620 ; (1) This was a port/baud that was explicilty set with the configurator.  In the drive detection case, as this
    621 ;     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.
    622626;     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 strucutre.  During drive detection, we would only be here
     627; (2) We are using the special .ideVarsSerialAuto structure.  During drive detection, we would only be here
    624628;     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 strucutre.  We won't get here during drive detection, but
     629; (3) We are using the special .ideVarsSerialAuto structure.  We won't get here during drive detection, but
    626630;     we might get here on an int13h/25h call.  If we have scanned COM drives, they are the ONLY serial drives
    627631;     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,
    629633;     especially in the full COM port scan case.  Note that this is different from the hardware IDE, where we
    630634;     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 wates time.  But the most common case (by a wide
     635;     we will do the slave scan, which isn't harmful, it just wastes time.  But the most common case (by a wide
    632636;     margin) will be just one serial controller.
    633637; (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
    635639;     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
    639643;     master scan.
    640 ;       
    641         mov     dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud]     
     644;
     645        mov     dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud]
    642646        mov     al, byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial]
    643                
     647
    644648        test    bh, FLG_DRVNHEAD_DRV
    645649        jz      .master
    646650
    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.
    648652        jz      .error          ; Because we do this here, the jz after the "or" below will not be taken
    649653
    650654; fall-through
    651 .master:       
     655.master:
    652656        test    dl,dl
    653657        jnz     .identifyDeviceInDL
     
    655659        or      dl,al           ; Move bLast into position in dl, as well as test for zero
    656660        jz      .scanSerial
    657        
     661
    658662; fall-through
    659 .identifyDeviceInDL:   
     663.identifyDeviceInDL:
    660664
    661665        push    bp              ; setup fake IDEREGS_AND_INTPACK
     
    680684
    681685        pop     bp
    682 ; 
     686;
    683687; place packed port/baud in RAMVARS, read by FinalizeDPT and DetectDrives
    684688;
    685689; 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
    687691; COM drives found.  So we will only reaffirm the port/baud for the one COM port/baud that has a drive.
    688 ; 
     692;
    689693        jc      .notFound                                           ; only store bLastSerial if success
    690694        mov     byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial], dl
    691695
    692 .notFound:     
     696.notFound:
    693697        ret
    694698
     
    715719.nextPort:
    716720        inc     di              ; load next port address
     721        xor     dh, dh
    717722        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
    721724        jz      .error
    722725
     
    762765        ret
    763766
    764 .error: 
     767.error:
    765768        stc
    766769%if 0
Note: See TracChangeset for help on using the changeset viewer.