Changeset 203 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/Serial


Ignore:
Timestamp:
Nov 23, 2011, 8:42:19 PM (13 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Reworked the 'skip detecting the slave if there was no master' code to be more complete (includes configurator drives) and to take into account int13h/25h calls. Some of the changes in my last checkin have been rolled back as a result (they are no longer needed). I did take a byte out of RAMVARS, but there was an alignment byte available for the taking. I also added a perl script for padding and adding the checksum byte to a binary image, which can be invoked manually or with 'make checksum'.

Location:
trunk/XTIDE_Universal_BIOS/Src/Device/Serial
Files:
2 edited

Legend:

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

    r199 r203  
    3939
    4040SerialCommand_UART_scratch                      EQU     7
    41 
    42 ; note that the actual StaringPoint port address is not achievable (results in 0 which triggers auto detect)
    43 SerialCommand_PackedPortAndBaud_StartingPort    EQU     240h
    44        
    45 SerialCommand_PackedPortAndBaud_PortMask        EQU     0fch    ; upper 6 bits - 240h through 438h
    46 SerialCommand_PackedPortAndBaud_BaudMask        EQU     3       ; lower 2 bits - 4 baud rates
    4741
    4842SerialCommand_Protocol_Write                    EQU     3
     
    479473
    480474
    481 ; To return the port number and baud rate to the FinalizeDPT routine, we
    482 ; stuff the value in a "vendor" specific area of the 512-byte IdentifyDevice
    483 ; sector.
    484 ;
    485 SerialCommand_IdentifyDevice_PackedPortAndBaud  equ     (157*2)
    486 
    487475;--------------------------------------------------------------------
    488476; SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
     
    494482;   Returns:
    495483;       AH:     INT 13h Error Code
     484;               NOTE: Not set (or checked) during drive detection
    496485;       CF:     Cleared if success, Set if error
    497486;   Corrupts registers:
     
    500489ALIGN JUMP_ALIGN
    501490SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
    502 
    503         mov     dx,[cs:bp+IDEVARS.bSerialCOMDigit]
     491;
     492; To improve boot time, we do our best to avoid looking for slave serial drives when we already know the results
     493; from the looking for a master.  This is particuarly true when doing a COM port scan, as we will end up running
     494; through all the COM ports and baud rates a second time. 
     495;
     496; But drive detection isn't the only case - we also need to get the right drive when called on int13h/25h. 
     497;
     498; The decision tree:
     499;
     500;    Master:
     501;          bSerialPackedPortAndBaud Non-Zero:   -> Continue with bSerialPackedAndBaud (1)
     502;          bSerialPackedPortAndBaud Zero:
     503;                         bLastSerial Zero:     -> Scan (2)
     504;                         bLastSerial Non-Zero: -> Continue with bLastSerial (3)
     505;                                   
     506;    Slave:
     507;          bSerialPackedPortAndBaud Non-Zero:
     508;                         bLastSerial Zero:     -> Error - Not Found (4)
     509;                         bLastSerial Non-Zero: -> Continue with bSerialPackedAndBaud (5)
     510;          bSerialPackedPortAndBaud Zero:     
     511;                         bLastSerial Zero:     -> Error - Not Found (4)
     512;                         bLastSerial Non-Zero: -> Continue with bLastSerial (6)
     513;
     514; (1) This was a port/baud that was explicilty set with the configurator.  In the drive detection case, as this
     515;     is the Master, we are checking out a new controller, and so don't care about the value of bLastSerial. 
     516;     And as with the int13h/25h case, we just go off and get the needed information using the user's setting.
     517; (2) We are using the special .ideVarsSerialAuto strucutre.  During drive detection, we would only be here
     518;     if bLastSerial is zero (since we only scan if no explicit drives are set), so we go off to scan.
     519; (3) We are using the special .ideVarsSerialAuto strucutre.  We won't get here during drive detection, but
     520;     we might get here on an int13h/25h call.  If we have scanned COM drives, they are the ONLY serial drives
     521;     in use, and so bLastSerial will reflect the port/baud setting for the scanned COM drives.
     522; (4) No master has been found yet, therefore no slave should be found.  Avoiding the slave reduces boot time,
     523;     especially in the full COM port scan case.  Note that this is different from the hardware IDE, where we
     524;     will scan for a slave even if a master is not present.  Note that if ANY master had been previously found,
     525;     we will do the slave scan, which isn't harmful, it just wates time.  But the most common case (by a wide
     526;     margin) will be just one serial controller.
     527; (5) A COM port scan for a master had been previously completed, and a drive was found.  In a multiple serial
     528;     controller scenario being called with int13h/25h, we need to use the value in bSerialPackedPortAndBaud
     529;     to make sure we get the proper drive.
     530; (6) A COM port scan for a master had been previously completed, and a drive was found.  We would only get here
     531;     if no serial drive was explicitly set by the user in the configurator or that drive had not been found. 
     532;     Instead of performing the full COM port scan for the slave, use the port/baud value stored during the
     533;     master scan.
     534;       
     535        mov     dl,[cs:bp+IDEVARS.bSerialPackedPortAndBaud]     
     536        mov     al, byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial]
     537               
     538        test    bh, FLG_DRVNHEAD_DRV
     539        jz      .master
     540
     541        test    al,al           ; Take care of the case that is different between master and slave. 
     542        jz      .error          ; Because we do this here, the jz after the "or" below will not be taken
     543
     544; fall-through
     545.master:       
    504546        test    dl,dl
    505         jz      SerialCommand_AutoSerial
    506 
    507         xchg    dh,dl           ; dh (the COM character to print) will be transmitted to the server,
    508                                 ; so we know this is not an auto detect
     547        jnz     .identifyDeviceInDL
     548
     549        or      dl,al           ; Move bLast into position in dl, as well as test for zero
     550        jz      .scanSerial
    509551       
    510552; fall-through
    511 SerialCommand_IdentifyDeviceInDL_DriveInBH:
     553.identifyDeviceInDL:   
    512554
    513555        push    bp              ; setup fake IDEREGS_AND_INTPACK
     
    524566
    525567        mov     bp,sp
    526 
    527568        call    SerialCommand_OutputWithParameters_DeviceInDL
    528569
     
    533574
    534575        pop     bp
    535 
    536 ; place packed port/baud in vendor area of packet, read by FinalizeDPT
    537         mov     byte [es:si+SerialCommand_IdentifyDevice_PackedPortAndBaud], dl
    538 
     576;
     577; place packed port/baud in RAMVARS, read by FinalizeDPT and DetectDrives
     578;
     579; Note that this will be set during an int13h/25h call as well.  Which is OK since it is only used (at the
     580; top of this routine) for drives found during a COM scan, and we only COM scan if there were no other
     581; COM drives found.  So we will only reaffirm the port/baud for the one COM port/baud that has a drive.
     582;
     583        jc      .notFound                                           ; only store bLastSerial if success
     584        mov     byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial], dl
     585
     586.notFound:     
    539587        ret
    540588
     
    546594;
    547595
    548 SerialCommand_ScanPortAddresses:    db  DEVICE_SERIAL_COM7 >> 2
    549                                     db  DEVICE_SERIAL_COM6 >> 2
    550                                     db  DEVICE_SERIAL_COM5 >> 2
    551                                     db  DEVICE_SERIAL_COM4 >> 2
    552                                     db  DEVICE_SERIAL_COM3 >> 2
    553                                     db  DEVICE_SERIAL_COM2 >> 2
    554                                     db  DEVICE_SERIAL_COM1 >> 2
    555                                     db  0
     596.scanPortAddresses: db  DEVICE_SERIAL_COM7 >> 2
     597                    db  DEVICE_SERIAL_COM6 >> 2
     598                    db  DEVICE_SERIAL_COM5 >> 2
     599                    db  DEVICE_SERIAL_COM4 >> 2
     600                    db  DEVICE_SERIAL_COM3 >> 2
     601                    db  DEVICE_SERIAL_COM2 >> 2
     602                    db  DEVICE_SERIAL_COM1 >> 2
     603                    db  0
    556604
    557605ALIGN JUMP_ALIGN
    558 SerialCommand_AutoSerial:
    559         mov     di,SerialCommand_ScanPortAddresses-1
     606.scanSerial:
     607        mov     di,.scanPortAddresses-1
    560608
    561609.nextPort:
     
    565613        mov     dh,0            ; shift from one byte to two
    566614        eSHL_IM dx, 2
    567         jz      .exitNotFound
     615        jz      .error
    568616
    569617;
     
    603651
    604652.testFirstBaud:
    605         call    SerialCommand_IdentifyDeviceInDL_DriveInBH
     653        call    .identifyDeviceInDL
    606654        jc      .nextBaud
    607655
    608656        ret
    609657
    610 .exitNotFound:
     658.error:
    611659        stc
    612         mov     ah,1
    613 
     660        ; mov       ah,1        ; setting the error code is unnecessary as this path can only be taken during
     661                                ; drive detection, and drive detection works off CF and does not check AH
    614662        ret
     663
     664
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm

    r181 r203  
    1717SerialDPT_Finalize:
    1818        or      byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
    19         mov     al, byte [es:si+SerialCommand_IdentifyDevice_PackedPortAndBaud]
     19        mov     al, [RAMVARS.xlateVars+XLATEVARS.bLastSerial]
    2020        mov     byte [di+DPT.bSerialPortAndBaud], al
    2121        ret
Note: See TracChangeset for help on using the changeset viewer.