Changeset 203 in xtideuniversalbios


Ignore:
Timestamp:
Nov 23, 2011, 8:42:19 PM (10 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
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc

    r179 r203  
    1313    .bHDSwap        resb    1   ; Hard Drive to swap to 80h and vice versa
    1414    .bXlatedDrv     resb    1   ; Drive number after translation
    15                     resb    1   ; For WORD alignment
     15%ifdef MODULE_SERIAL
     16    .bLastSerial    resb    1   ; Packed Port and Baud for last serial drive detected
     17                                ; (using space of an alignment byte,
     18                                ; used during and after boot (int13/25h case))
     19%else
     20                    resb    1   ; alignment
     21%endif
    1622endstruc
    1723
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r200 r203  
    100100;   baud rate = b, where 00 = 2400, 01 = 9600, 10 = 38.4K, 11 = 115.2K
    101101;
    102 ; 240h/2400baud corresponds to 0 for a PackedPortAndBaud value, which is reserved (in case we need
    103 ; it to know if a value has been set).  Which is why ..._MINPORT is 248h.
     102; 240h/2400baud corresponds to 0 for a PackedPortAndBaud value, which triggers auto detect code.
     103; Which means 240h is not usable, and is why ..._MINPORT is 248h.  A value is reserved at the upper
     104; end of the spectrum in case it is needed (whcih is why it is 430h instead of 438h).
    104105;
    105106DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK            EQU     0fch
     
    107108DEVICE_SERIAL_PACKEDPORTANDBAUD_PORT_FIELD_POSITION EQU     2
    108109DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT        EQU     240h
    109 DEVICE_SERIAL_PACKEDPORTANDBAUD_MINPORT             EQU     248h        ; minimum port value that the user can set
    110 DEVICE_SERIAL_PACKEDPORTANDBAUD_MAXPORT             EQU     438h        ; or (..._PORTMASK << 1) + ..._STARTINGPORT
     110DEVICE_SERIAL_PACKEDPORTANDBAUD_MINPORT             EQU     248h    ; minimum port value that the user can set
     111DEVICE_SERIAL_PACKEDPORTANDBAUD_MAXPORT             EQU     430h    ; or ((..._PORTMASK-1) << 1) + ..._STARTINGPORT
    111112
    112113DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK            EQU     3h
  • 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
  • trunk/XTIDE_Universal_BIOS/makefile

    r197 r203  
    8787TARGET = $(BUILD_DIR)/$(PROG)
    8888
     89# Target size of the ROM, used by checksum Perl script 
     90ROMSIZE = 8192
    8991
    9092#########################
     
    140142    @echo Deleted "(*.*)" from "$(BUILD_DIR)/"
    141143
     144checksum:  all
     145    @perl ..\tools\checksum.pl $(TARGET)_at.bin $(ROMSIZE)
     146    @perl ..\tools\checksum.pl $(TARGET)_xtp.bin $(ROMSIZE)
     147    @perl ..\tools\checksum.pl $(TARGET)_xt.bin $(ROMSIZE)
     148
    142149src\StringsCompressed.asm:  src\Strings.asm
    143     $(AS) src\Strings.asm $(ASFLAGS) $(DEFS_XT) -DMODULE_STRINGS_COMPRESSED_PRECOMPRESS -o build\Strings.bin -l build\StringsPrecompress.lst
    144     perl ..\tools\StringsCompress.pl < build\StringsPrecompress.lst > src\StringsCompressed.asm
     150    @$(AS) src\Strings.asm $(ASFLAGS) $(DEFS_XT) -DMODULE_STRINGS_COMPRESSED_PRECOMPRESS -o build\Strings.bin -l build\StringsPrecompress.lst
     151    @perl ..\tools\StringsCompress.pl < build\StringsPrecompress.lst > src\StringsCompressed.asm
     152    @echo StringsCompressed.asm updated!
    145153
    146154$(SRC_ASM):     src\StringsCompressed.asm
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Help/IDE_SerialPort.txt

    r202 r203  
    1 Select a serial port by I/O address. Supported values are between 240h and 438h, and must be on an 8-byte boundary. If the entered value corresponds to one of the established COM port numbers, then the selection of serial port will use COM numbers instead.
     1Select a serial port by I/O address. Supported values are between 240h and 430h, and must be on an 8-byte boundary. If the entered value corresponds to one of the established COM port numbers, then the selection of serial port will use COM numbers instead.
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm

    r200 r203  
    134134g_szNfoIdeIRQ:          db  "IRQ channel to use.",NULL
    135135g_szNfoIdeSerialCOM:    db  "Select a COM port by number.",NULL
    136 g_szNfoIdeSerialBaud:   db  "Select the COM port's Baud Rate. The server must match this speed. Note UART clock multipliers may impact the actual speed.",NULL
    137 g_szNfoIdeSerialPort:   db  "Select a COM port by custom I/O port address. Address must be in the range 248h to 438h and be on an 8-byte boundary.", NULL
     136g_szNfoIdeSerialBaud:   db  "Select the COM port's Baud Rate. The server must match this speed. Note that UART clock multipliers may impact the actual speed.",NULL
     137g_szNfoIdeSerialPort:   db  "Select a COM port by custom I/O port address. Address must be in the range 248h to 430h and be on an 8-byte boundary.", NULL
    138138
    139139g_szHelpIdeCmdPort:     incbin  "IDE_CommandPort.txt"
     
    254254g_szNfoBootFloppyDrvs:  db  "Number of Floppy Drives to display on boot menu.",NULL
    255255g_szNfoBootSwap:        db  "Drive Number Translation (swap first drive with selected).",NULL
    256 g_szNfoSerialDetect:    db  "Will scan COM ports for a serial drive. Can also be invoked by holding down ALT at the end of standard drive detection.",NULL
     256g_szNfoSerialDetect:    db  "Scans all standard COM ports for serial drives. This can also be invoked by holding down ALT at the end of normal drive detection.",NULL
    257257
    258258g_szHelpBootTimeout:    incbin  "Bootmenu_Timeout.txt"
Note: See TracChangeset for help on using the changeset viewer.