Changeset 203 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src


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
Files:
5 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
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm

    r200 r203  
    2323.DriveDetectLoop:                           ; Loop through IDEVARS
    2424    mov     si, g_szDetect                  ; Setup standard print string
    25 %ifdef MODULE_SERIAL
     25%ifdef MODULE_SERIAL       
    2626    cmp     byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
    2727    jnz     .DriveNotSerial                 ; Special print string for serial drives
     
    2929.DriveNotSerial:
    3030%endif
     31
    3132    call    .DetectDrives_WithIDEVARS       ; Detect Master and Slave
    3233    add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
    3334    loop    .DriveDetectLoop
     35
     36%ifdef MODULE_SERIAL       
     37;
     38; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we have a connection)
     39; Note that XLATEVARS.bLastSerial is zero'd in RamVars_Initialize, called in Initialize_AutoDetectDrives;
     40; bLastSerial it set in the detection code of SerialCommand.asm
     41;
     42    cmp     byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial],cl   ; cx = zero after the loop above
     43                                                                ; less instruction bytes than using immediate
     44    jnz     .done                                                 
    3445       
    35 %ifdef MODULE_SERIAL
    36     call    FindDPT_ToDSDIforSerialDevice   ; Did we already find any serial drives?
    37     jc      .done                           ; Yes, do not scan
    3846    mov     al,[cs:ROMVARS.wFlags]          ; Configurator set to always scan?
    3947    or      al,[es:BDA.bKBFlgs1]            ; Or, did the user hold down the ALT key?
    4048    and     al,8                            ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
    4149    jz      .done                           
     50
    4251    mov     bp, ROMVARS.ideVarsSerialAuto   ; Point to our special IDEVARS sructure, just for serial scans
    4352    mov     si, g_szDetectCOMAuto           ; Special, special print string for serial drives during a scan
     
    7483    pop     si
    7584
    76 %ifdef MODULE_SERIAL
    77 ;
    78 ; This block of code checks to see if we found a master during a serial drives scan.  If no master
    79 ; was found, there is no point in scanning for a slave as the server will not return a slave without a master,
    80 ; as there is very little point given the drives are emulated.  Performing the slave scan will take
    81 ; time to rescan all the COM port and baud rate combinations.
    82 ;
    83     jnc     .masterFound
    84     pop     cx
    85     jcxz    .done       ; note that CX will only be zero after the .DriveDetectLoop, indicating a serial scan
    86     push    cx
    87 .masterFound:
    88 %endif
    89        
    9085    mov     ax, g_szSlave
    9186    mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
     
    106101;       ES:     Zero (BDA segment)
    107102;   Returns:
    108 ;       CF:     Set on failure, Clear on success
    109 ;               Note that this is set in the last thing both cases
    110 ;               do: printing the drive name, or printing "Not Found"
     103;       None
    111104;   Corrupts registers:
    112105;       AX, BX, CX, DX, SI, DI
     
    144137    ;call   ReadAtapiInfoFromDrive      ; Assume CD-ROM
    145138    ;jnc    SHORT _CreateBiosTablesForCDROM
    146     jmp     short DetectDrives_DriveNotFound
     139   
     140    ;jmp    short DetectDrives_DriveNotFound
     141;;; fall-through instead of previous jmp instruction
     142;--------------------------------------------------------------------
     143; DetectDrives_DriveNotFound
     144;   Parameters:
     145;       Nothing
     146;   Returns:
     147;       CF:     Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
     148;   Corrupts registers:
     149;       AX, SI
     150;--------------------------------------------------------------------
     151DetectDrives_DriveNotFound:     
     152    mov     si, g_szNotFound
     153    jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF     
    147154
    148155
     
    166173    jmp     short DetectPrint_DriveNameFromBootnfoInESBX
    167174
    168 ;--------------------------------------------------------------------
    169 ; DetectDrives_DriveNotFound
    170 ;   Parameters:
    171 ;       Nothing
    172 ;   Returns:
    173 ;       CF:     Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
    174 ;   Corrupts registers:
    175 ;       AX, SI
    176 ;--------------------------------------------------------------------
    177 DetectDrives_DriveNotFound:     
    178     mov     si, g_szNotFound
    179     jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF     
    180175
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r200 r203  
    8888    pop     bx
    8989    pop     di
    90     clc                         ; return success up through DetectDrives
    9190    ret
    9291
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm

    r200 r203  
    124124
    125125;--------------------------------------------------------------------
    126 ; IterateToDptWithFlagsHighSet:
     126; IterateToDptWithInterruptInServiceFlagSet
    127127;   Parameters:
    128128;       DS:DI:  Ptr to DPT to examine
    129 ;       AL:     Bit in bFlagsHigh to test
    130129;   Returns:
    131130;       CF:     Set if wanted DPT found
     
    135134;--------------------------------------------------------------------
    136135ALIGN JUMP_ALIGN
    137 IterateToDptWithFlagsHighSet:
    138     test    BYTE [di+DPT.bFlagsHigh], al    ; Clears CF (but we need the clc below anyway callers above)
     136IterateToDptWithInterruptInServiceFlagSet:
     137    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INTERRUPT_IN_SERVICE     ; Clears CF (but we need the clc
     138                                                                        ; below anyway for callers above)
    139139    jnz     SHORT ReturnRightDPT
    140140
     
    145145;--------------------------------------------------------------------
    146146; FindDPT_ToDSDIforInterruptInService
    147 ; FindDPT_ToDSDIforSerialDevice
    148147;   Parameters:
    149148;       DS:     RAMVARS segment
     
    153152;               Cleared if DPT not found
    154153;   Corrupts registers:
    155 ;       SI, AX, BX (for SerialDevice only)
     154;       SI
    156155;--------------------------------------------------------------------
    157156ALIGN JUMP_ALIGN
    158        
    159 %ifdef MODULE_SERIAL
    160 FindDPT_ToDSDIforSerialDevice: 
    161     mov     al, FLGH_DPT_SERIAL_DEVICE
    162 
    163     SKIP2B  bx
    164 %endif
    165        
    166 ; do not align due to SKIP2B above
    167157FindDPT_ToDSDIforInterruptInService:
    168     mov     al, FLGH_DPT_INTERRUPT_IN_SERVICE
    169 
    170     mov     si, IterateToDptWithFlagsHighSet
     158    mov     si, IterateToDptWithInterruptInServiceFlagSet
    171159    ; Fall to IterateAllDPTs
    172160
Note: See TracChangeset for help on using the changeset viewer.