Changeset 233 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Initialization


Ignore:
Timestamp:
Feb 4, 2012, 6:21:22 PM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Serial Port: split single byte port and baud into two bytes, taking advantage of the two bytes in DPT_SERIAL, which supports more serial baud rates and in particular fixed a bug where a 4x client machine couldn't talk to a 115.2K server machine. This is a wide change, touching lots of files, but most are shallow changes. DetectPrint.asm took the most significant changes, now it calculates the baud rate to display instead of using characters provided by the Configurator. The Configurator now has a new menu flag, FLG_MENUITEM_CHOICESTRINGS, for specifying that values are not linear and they should be lookedup rather than indexed. Finally, another important bug fixed here is that in some error cases, the serial port code could get into an infinite loop waiting ont the hardware; now it has a timeout.

Location:
trunk/XTIDE_Universal_BIOS/Src/Initialization
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm

    r203 r233  
    2222
    2323.DriveDetectLoop:                           ; Loop through IDEVARS
    24     mov     si, g_szDetect                  ; Setup standard print string
     24    push    cx
     25
     26    mov     cx, g_szDetectMaster
     27    mov     bh, MASK_DRVNHEAD_SET                               ; Select Master drive
     28    call    StartDetectionWithDriveSelectByteInBHandStringInAX  ; Detect and create DPT + BOOTNFO
     29
     30    mov     cx, g_szDetectSlave
     31    mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV 
     32    call    StartDetectionWithDriveSelectByteInBHandStringInAX
     33       
     34    pop     cx
     35
     36    add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
     37
    2538%ifdef MODULE_SERIAL       
    26     cmp     byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
    27     jnz     .DriveNotSerial                 ; Special print string for serial drives
    28     mov     si, g_szDetectCOM
    29 .DriveNotSerial:
     39    jcxz    .done                           ; Set to zero on .ideVarsSerialAuto iteration (if any)
    3040%endif
    31 
    32     call    .DetectDrives_WithIDEVARS       ; Detect Master and Slave
    33     add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
     41       
    3442    loop    .DriveDetectLoop
    3543
    3644%ifdef MODULE_SERIAL       
    3745;
    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
     46; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
    4147;
    42     cmp     byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial],cl   ; cx = zero after the loop above
    43                                                                 ; less instruction bytes than using immediate
    44     jnz     .done                                                 
    45        
     48    call    FindDPT_ToDSDIforSerialDevice
     49    jc      .done
     50
     51    mov     bp, ROMVARS.ideVarsSerialAuto   ; Point to our special IDEVARS sructure, just for serial scans     
     52               
    4653    mov     al,[cs:ROMVARS.wFlags]          ; Configurator set to always scan?
    4754    or      al,[es:BDA.bKBFlgs1]            ; Or, did the user hold down the ALT key?
    4855    and     al,8                            ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
    49     jz      .done                           
     56    jnz     .DriveDetectLoop                           
     57%endif
    5058
    51     mov     bp, ROMVARS.ideVarsSerialAuto   ; Point to our special IDEVARS sructure, just for serial scans
    52     mov     si, g_szDetectCOMAuto           ; Special, special print string for serial drives during a scan
    53 ;;; fall-through                   
    54 %else
     59.done:
    5560    ret
    56 %endif
    5761
    5862%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
     
    6064%endif
    6165
    62 ;--------------------------------------------------------------------
    63 ; Detects IDE hard disks by using information from IDEVARS.
    64 ;
    65 ; DetectDrives_WithIDEVARS
    66 ;   Parameters:
    67 ;       CS:BP:      Ptr to IDEVARS
    68 ;       DS:         RAMVARS segment
    69 ;       ES:         Zero (BDA segment)
    70 ;       SI:         Ptr to template string
    71 ;   Returns:
    72 ;       Nothing
    73 ;   Corrupts registers:
    74 ;       AX, BX, DX, SI, DI
    75 ;--------------------------------------------------------------------
    76 .DetectDrives_WithIDEVARS:
    77     push    cx
    78 
    79     push    si     
    80     mov     ax, g_szMaster
    81     mov     bh, MASK_DRVNHEAD_SET                               ; Select Master drive
    82     call    StartDetectionWithDriveSelectByteInBHandStringInAX  ; Detect and create DPT + BOOTNFO
    83     pop     si
    84 
    85     mov     ax, g_szSlave
    86     mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
    87     call    StartDetectionWithDriveSelectByteInBHandStringInAX
    88     pop     cx
    89        
    90 .done: 
    91     ret
    92 
    9366       
    9467;--------------------------------------------------------------------
    9568; StartDetectionWithDriveSelectByteInBHandStringInAX
    9669;   Parameters:
    97 ;       AX:     Offset to "Master" or "Slave" string
    9870;       BH:     Drive Select byte for Drive and Head Register
     71;       CX:     Offset to "Master" or "Slave" string
    9972;       CS:BP:  Ptr to IDEVARS for the drive
    10073;       DS:     RAMVARS segment
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r203 r233  
    3030; DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
    3131;   Parameters:
    32 ;       CS:AX:  Ptr to "Master" or "Slave" string
     32;       CS:CX:  Ptr to "Master" or "Slave" string
    3333;       CS:BP:  Ptr to IDEVARS
    3434;       SI:     Ptr to template string
     
    3939;--------------------------------------------------------------------
    4040DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP:
    41     push    bp
    42     mov     di, [cs:bp+IDEVARS.wPort]
    43 %ifdef MODULE_SERIAL
    44     mov     cx, [cs:bp+IDEVARS.wSerialPackedPrintBaud]
    45 %endif
     41
     42    mov     ax, [cs:bp+IDEVARS.wPort]       ; for IDE: AX=port address, DH=.bDevice
     43    mov     dx, [cs:bp+IDEVARS.bDevice-1]   ; for Serial: AL=port address>>2, AH=baud rate
     44                                            ;             DL=COM number character, DH=.bDevice
     45
     46    push    bp                              ; setup stack for call to
     47    mov     bp, sp                          ; BootMenuPrint_FormatCSSIfromParamsInSSBP
     48
     49    push    cx                              ; Push "Master" or "Slave"
    4650       
    47     mov     bp, sp
     51    mov     cl, (g_szDetectPort-$$) & 0xff  ; Setup print string for standard IDE
     52                                            ; Note that we modify only the low order bits of CX a lot here,
     53                                            ; saving code space rather than reloading CX completely.
     54                                            ; This optimization requires that all the g_szDetect* strings are
     55                                            ; on the same 256 byte page, which is checked in strings.asm.
    4856
    49     push    ax                          ; Push "Master" or "Slave"
     57    cmp     dx, DEVICE_SERIAL_PORT << 8     ; Check if this is a serial device,
     58                                            ; And also check if DL is zero, check with the jz below
     59                                            ; This optimization requires that DEVICE_SERIAL_PORT be
     60                                            ; the highest value in the DEVICE_* series, ensuring that
     61                                            ; anything less in the high order bits is a different device.
     62
     63    jl      .pushAndPrint                   ; CX = string to print, AX = port address, DX won't be used
     64
     65    mov     cl, (g_szDetectCOM-$$) & 0xff   ; Setup print string for COM ports
     66    push    cx                              ; And push now.  We use the fact that format strings can contain
     67                                            ; themselves format strings.
     68
     69    push    dx                              ; Push COM number character
     70               
     71    mov     cl, (g_szDetectCOMAuto-$$) & 0xff   ; Setup secondary print string for "Auto"
    5072       
    51     push    di                          ; Push Port address or COM port number
     73    jz      .pushAndPrint                   ; CX = string to print, AX and DX won't be used
     74       
     75    mov     cl, (g_szDetectCOMLarge-$$) & 0xff  ; Setup secondary print string for "COMn/xx.yK"
    5276
    53 %ifdef MODULE_SERIAL
    54 ;
    55 ; Print baud rate from .wSerialPackedPrintBaud, in two parts - %u and then %c
    56 ;
    57     mov     ax,cx                       ; Unpack baud rate number
    58     and     ax,DEVICE_SERIAL_PRINTBAUD_NUMBERMASK
    59     push    ax
     77    mov     al,ah                           ; baud rate divisor to AL
     78    cbw                                     ; clear AH, AL will always be less than 128
     79    xchg    si,ax                           ; move AX to SI for divide
     80    mov     ax,1152                         ; baud rate to displa is 115200/divisor, the "00" is handled
     81                                            ; in the print strings
     82    xor     dx,dx                           ; clear top 16-bits of dividend
     83    div     si                              ; and divide...  Now AX = baud rate/100, DX = 0 (always a clean divide)
     84       
     85    mov     si,10                           ; Now separate the whole portion from the fractional for "K" display
     86    div     si                              ; and divide...  Now AX = baud rate/1000, DX = low order digit
     87       
     88    cmp     ax,si                           ; <= 10: "2400", "9600", etc.; >10: "19.2K", "38.4K", etc.
     89    jae     .pushAndPrint
    6090
    61     mov     al,ch                       ; Unpack baud rate postfix ('0' or 'K')
    62     eSHR_IM al,2                        ; also effectively masks off the postfix
    63     add     al,DEVICE_SERIAL_PRINTBAUD_POSTCHARADD
    64     push    ax
    65 %endif
    66                        
     91    mov     cl, (g_szDetectCOMSmall-$$) & 0xff  ; Setup secondary print string for "COMn/XXy00"
     92       
     93.pushAndPrint: 
     94    push    cx                              ; Push print string
     95    push    ax                              ; Push high order digits, or port address, or N/A
     96    push    dx                              ; Push low order digit, or N/A
     97
     98    mov     si, g_szDetectOuter             ; Finally load SI with wrapper string "IDE %s at %s: "
     99
    67100    jmp     short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay   
    68101
     
    92125
    93126
     127
Note: See TracChangeset for help on using the changeset viewer.