Changeset 262 in xtideuniversalbios


Ignore:
Timestamp:
Feb 24, 2012, 10:28:31 AM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

More optimizations. Merged RamVars_IsFunction/DriveHandledByThisBIOS in with FindDPT_ForDriveNumber, since they are often used together, making a returned NULL DI pointer indicate a foreign drive in many places. Revamped the iteration done in the handlers for int13/0dh and int13h/0h. Added serial specific print string during drive detection.

Location:
trunk/XTIDE_Universal_BIOS
Files:
15 edited

Legend:

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

    r258 r262  
    1010; Variables for translating drive numbers.
    1111struc XLATEVARS
    12     .wFDandHDswap:
    13     .bFDSwap            resb    1   ; Floppy Drive to swap to 00h and vice versa
    14     .bHDSwap            resb    1   ; Hard Drive to swap to 80h and vice versa
    15     .bXlatedDrv         resb    1   ; Drive number after translation
    1612%ifdef MODULE_SERIAL_FLOPPY
    1713    .bFlopCreateCnt:
     
    2319                        resb    1   ; alignment
    2420%endif
     21    .bXlatedDrv         resb    1   ; Drive number after translation
     22    .wFDandHDswap:
     23    .bFDSwap            resb    1   ; Floppy Drive to swap to 00h and vice versa
     24    .bHDSwap            resb    1   ; Hard Drive to swap to 80h and vice versa
    2525endstruc
    2626
     
    3636    .wDrvCntAndFirst:
    3737    .bFirstDrv          resb    1   ; Number of first drive for this BIOS
     38    .wDrvCntAndFlopCnt:             ; Both the hard disk and floppy counts in one word
     39                                    ; (yes, misaligned, but it is only used this way during initialization)
    3840    .bDrvCnt            resb    1   ; Number of drives handled by this BIOS
    3941
     
    4143    .xlateVars      resb    XLATEVARS_size
    4244endstruc
     45
     46%ifdef MODULE_SERIAL_FLOPPY
     47  %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
     48    %if RAMVARS.xlateVars != RAMVARS.bDrvCnt+1 || XLATEVARS.bFlopCreateCnt != 0
     49        %error "bFlopCreateCnt needs to be the first thing in XLATEVARS, and .xlateVars needs to come immediately after .bDrvCnt.  In at least one place, we read .wDrvCntAndFlopCnt to get both counts in one fetch"
     50    %endif
     51  %endif
     52%endif
    4353
    4454RAMVARS_SIGNATURE       EQU "Xu"    ; RAMVARS signature for .wSignature
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r259 r262  
    2323    mov     bp, sp
    2424
    25     call    RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber
     25    call    FindDPT_ForDriveNumberInDL
    2626    jc      .notOurs
    2727
     
    111111    mov     si, g_szCapacity                            ; Setup print string now, carries through to print call
    112112
    113     xor     di, di                                      ; Zero DI for checks for our drive later on
    114     call    RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber
    115 
    116     test    dl, dl                                      ; are we a hard disk?
    117     js      BootMenuPrint_HardDiskRefreshInformation   
    118 
    119     test    di, di
    120     jnz     .ours                                       ; Based on CF from RamVars_IsDriveHandledByThisBIOS above
     113    call    FindDPT_ForDriveNumberInDL
     114
     115    inc     dl                                          ; are we a hard disk?
     116    dec     dl                                          ; inc/dec will set SF, without modifying CF or DL
     117    js      .HardDiskRefreshInformation
     118
     119    jnc     .ours                                       ; Based on CF from FindDPT_ForDriveNumberInDL above
    121120    call    FloppyDrive_GetType                         ; Get Floppy Drive type to BX
    122121    jmp     .around
     
    190189;--------------------------------------------------------------------
    191190ALIGN JUMP_ALIGN
    192 BootMenuPrint_HardDiskRefreshInformation:       
    193     test    di, di
    194     jz      .HardDiskMenuitemInfoForForeignDrive       
     191.HardDiskRefreshInformation:       
     192    jc      .HardDiskMenuitemInfoForForeignDrive        ; Based on CF from FindDPT_ForDriveNumberInDL (way) above
    195193
    196194.HardDiskMenuitemInfoForOurDrive:
    197     ePUSH_T ax, g_szInformation                     ; Add substring for our hard disk information
    198     call    BootMenuInfo_GetTotalSectorCount        ; Get Total LBA Size
     195    ePUSH_T ax, g_szInformation                         ; Add substring for our hard disk information
     196    call    BootMenuInfo_GetTotalSectorCount            ; Get Total LBA Size
    199197    jmp     .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    200198       
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm

    r258 r262  
    639639        pop     si
    640640%ifdef MODULE_SERIAL_FLOPPY
    641         jc      .founddpt
     641        jnc     .founddpt
    642642;
    643643; If not found above with FindDPT_ToDSDIforSerialDevice, DI will point to the DPT after the last hard disk DPT
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r260 r262  
    2626
    2727    call    RamVars_GetSegmentToDS
     28       
    2829    call    DriveXlate_ToOrBack
    2930    mov     [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl
    30     call    RamVars_IsFunctionHandledByThisBIOS
    31     jc      SHORT Int13h_DirectCallToAnotherBios
    32 
    33     call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    34 
     31       
     32    call    FindDPT_ForDriveNumberInDL              ; DS:DI points to our DPT, or NULL if not our drive
     33    jnc     SHORT .OurFunction                      ; DPT found, this is one of our drives, and thus our function
     34
     35    cmp     ah, 0
     36    jz      short .OurFunction                      ; we handle all function 0h requests (resets)
     37    cmp     ah, 8
     38%ifdef MODULE_SERIAL_FLOPPY
     39    jnz     SHORT Int13h_DirectCallToAnotherBios    ; we handle all traffic for function 08h,
     40                                                    ; as we need to wrap both hard disk and floppy drive counts
     41%else
     42    jz      SHORT .WeHandleTheFunction              ; we handle all *hard disk* (only) traffic for function 08h,
     43                                                    ; as we need to wrap the hard disk drive count
     44    test    dl, dl
     45    jns     SHORT Int13h_DirectCallToAnotherBios
     46%endif     
     47               
     48.OurFunction:   
    3549    ; Jump to correct BIOS function
    3650    eMOVZX  bx, ah
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm

    r259 r262  
    121121GetDriveNumberForForeignBiosesToDL:
    122122    mov     dl, bl
    123     call    RamVars_IsDriveHandledByThisBIOS
    124     jc      SHORT .Return               ; Return what was in BL unmodified
     123    test    di, di
     124    jz      SHORT .Return               ; Return what was in BL unmodified
    125125    mov     dl, 80h
    126126.Return:
     
    141141ALIGN JUMP_ALIGN
    142142AH0h_ResetHardDisksHandledByOurBIOS:
    143     mov     dx, [RAMVARS.wDrvCntAndFirst]   ; DL = drive number, DH = drive count
    144     test    dh, dh
    145     jz      SHORT .AllDrivesReset       ; Return if no drives
    146     add     dh, dl                      ; DH = one past last drive to reset
    147 ALIGN JUMP_ALIGN
    148 .DriveResetLoop:
    149     call    AHDh_ResetDrive
    150     call    .BackupErrorCodeFromMasterOrSlaveToBH
    151     inc     dx
    152     cmp     dl, dh                      ; All done?
    153     jb      SHORT .DriveResetLoop       ;  If not, reset next drive
    154 .AllDrivesReset:
     143    mov     bl, [di+DPT.bIdevarsOffset]                 ; replace drive number with Idevars pointer for comparisons
     144    mov     cl, [cs:ROMVARS.bIdeCnt]                    ; get count of ide controllers
     145    mov     ch, 0                                       
     146    mov     dl, 0                                       ; starting Idevars offset
     147    mov     si, IterateFindFirstDPTforIdevars           ; iteration routine
     148.loop:
     149    call    IterateAllDPTs                              ; look for the first drive on this controller, if any
     150    jc      .notFound
     151    call    AHDh_ResetDrive                             ; reset master and slave on that controller
     152    call    BackupErrorCodeFromTheRequestedDriveToBH    ; save error code if same controller as initial request
     153.notFound:
     154    add     dl, IDEVARS_size                            ; move pointer forward
     155    loop    .loop                                       ; and repeat
    155156    ret
    156157
    157                
    158158;--------------------------------------------------------------------
    159 ; .BackupErrorCodeFromMasterOrSlaveToBH
    160 ;   Parameters:
    161 ;       AH:     Error code for drive DL reset
    162 ;       BL:     Requested drive (DL when entering AH=00h)
    163 ;       DL:     Drive just resetted
    164 ;       DS:     RAMVARS segment
    165 ;   Returns:
    166 ;       BH:     Backuped error code
    167 ;       DL:     Incremented if next drive is slave drive
    168 ;               (=already resetted)
    169 ;   Corrupts registers:
    170 ;       CX, DI
     159; Iteration routine for AH0h_ResetHardDisksHandledByOurBIOS,
     160; for use with IterateAllDPTs
     161;
     162; Returns when DPT is found on the controller with Idevars offset in DL
    171163;--------------------------------------------------------------------
    172 ALIGN JUMP_ALIGN
    173 .BackupErrorCodeFromMasterOrSlaveToBH:
    174     call    BackupErrorCodeFromTheRequestedDriveToBH
    175     call    GetBasePortToCX             ; Load base port for resetted drive
    176     push    cx
    177     inc     dx                          ; DL to next drive
    178     call    GetBasePortToCX
    179     pop     di
    180     cmp     cx, di                      ; Next drive is from same controller?
    181     je      SHORT BackupErrorCodeFromTheRequestedDriveToBH
    182 .NoMoreDrivesOrNoSlaveDrive:
    183     dec     dx
     164IterateFindFirstDPTforIdevars:     
     165    cmp     dl, [di+DPT.bIdevarsOffset]         ; Clears CF if matched
     166    jz      .done
     167    stc                                         ; Set CF for not found
     168.done: 
    184169    ret
    185 
    186        
    187 ;--------------------------------------------------------------------
    188 ; GetBasePortToCX
    189 ;   Parameters:
    190 ;       DL:     Drive number
    191 ;       DS:     RAMVARS segment
    192 ;   Returns:
    193 ;       CX:     Base port address
    194 ;       CF:     Set if valid drive number
    195 ;               Cleared if invalid drive number
    196 ;   Corrupts registers:
    197 ;       DI
    198 ;--------------------------------------------------------------------
    199 ALIGN JUMP_ALIGN
    200 GetBasePortToCX:
    201     xchg    cx, bx
    202     xor     bx, bx
    203     call    FindDPT_ForDriveNumber
    204     mov     bl, [di+DPT.bIdevarsOffset]
    205     mov     bx, [cs:bx+IDEVARS.wPort]
    206     xchg    bx, cx
    207     ret
    208 
    209 
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm

    r261 r262  
    2525;--------------------------------------------------------------------
    2626AH8h_HandlerForReadDiskDriveParameters:
    27 
    28     call    RamVars_IsDriveHandledByThisBIOS
    29     jnc     SHORT .OurDrive
     27    test    di,di
     28    jnz     SHORT .OurDrive
    3029
    3130    call    Int13h_CallPreviousInt13hHandler
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r200 r262  
    4040;       CF:     0 if succesfull, 1 if error
    4141;   Corrupts registers:
    42 ;       AL, CX, SI, DI
     42;       AL, CX, SI
    4343;--------------------------------------------------------------------
    4444;ALIGN JUMP_ALIGN
     
    4646    push    dx
    4747    push    bx
     48    push    di
    4849
    49     call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    5050    call    Interrupts_UnmaskInterruptControllerForDriveInDSDI
    5151    call    Device_ResetMasterAndSlaveController
    52     ;jc     SHORT .ReturnError          ; CF would be set if slave drive present without master
    53                                         ; (error register has special values after reset)
     52    ;jc     SHORT .ReturnError                  ; CF would be set if slave drive present without master
     53                                                ; (error register has special values after reset)
    5454
    5555    ; Initialize Master and Slave drives
    56     eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
    57     mov     dx, [cs:bx+IDEVARS.wPort]
    58     call    InitializeMasterAndSlaveDriveFromPortInDX
     56    mov     al, [di+DPT.bIdevarsOffset]         ; pointer to controller we are looking to reset
     57    mov     ah, 0                               ; initialize error code, assume success
     58       
     59    mov     si, IterateAndResetDrives
     60    call    IterateAllDPTs
    5961
     62    shr     ah, 1                               ; Move error code and CF into proper position
     63
     64    pop     di
    6065    pop     bx
    6166    pop     dx
    6267    ret
    6368
    64 
    6569;--------------------------------------------------------------------
    66 ; InitializeMasterAndSlaveDriveFromPortInDX
    67 ;   Parameters:
    68 ;       DX:     IDE Base Port address
    69 ;       SS:BP:  Ptr to IDEPACK
    70 ;   Returns:
    71 ;       AH:     Error code
    72 ;       CF:     0 if initialization succesfull
    73 ;               1 if any error
    74 ;   Corrupts registers:
    75 ;       AL, BX, CX, DX, SI, DI
     70; IterateAndResetDrives: Iteration routine for use with IterateAllDPTs.
     71;
     72; When a drive on the controller is found, it is reset, and the error code
     73; merged into overall error code for this controller.  Master will be reset
     74; first.  Note that the iteration will go until the end of the DPT list.
    7675;--------------------------------------------------------------------
    77 ALIGN JUMP_ALIGN
    78 InitializeMasterAndSlaveDriveFromPortInDX:
    79     push    dx                          ; Store base port address
    80     xor     cx, cx                      ; Assume no errors
    81     FindDPT_ToDSDIForIdeMasterAtPortDX
    82     jnc     SHORT .InitializeSlave      ; Master drive not present
    83     call    AH9h_InitializeDriveForUse
    84     mov     cl, ah                      ; Copy error code to CL
    85 .InitializeSlave:
    86     pop     dx                          ; Restore base port address
    87     FindDPT_ToDSDIForIdeSlaveAtPortDX
    88     jnc     SHORT .CombineErrors        ; Slave drive not present
    89     call    AH9h_InitializeDriveForUse
    90     mov     ch, ah                      ; Copy error code to CH
    91 .CombineErrors:
    92     or      cl, ch                      ; OR error codes, clear CF
    93     jz      SHORT .Return
    94     mov     ah, RET_HD_RESETFAIL        ; Load Reset Failed error code
    95     stc
    96 .Return:
     76IterateAndResetDrives:
     77    cmp     al, [di+DPT.bIdevarsOffset]         ; The right controller?
     78    jnz     .done
     79    push    ax
     80    call    AH9h_InitializeDriveForUse          ; Reset Master and Slave (Master will come first in DPT list)
     81    pop     ax     
     82    jc      .done
     83    or      ah, (RET_HD_RESETFAIL << 1) | 1     ; OR in Reset Failed error code and CF, will SHR into position later
     84.done:
     85    stc                                         ; From IterateAllDPTs perspective, the DPT is never found
    9786    ret
     87       
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm

    r261 r262  
    3737
    3838%ifdef MODULE_SERIAL
    39     jcxz    .done                           ; Set to zero on .ideVarsSerialAuto iteration (if any)
     39    jcxz    .AddHardDisks                   ; Set to zero on .ideVarsSerialAuto iteration (if any)
    4040%endif
    4141
     
    4848;
    4949    call    FindDPT_ToDSDIforSerialDevice
    50     jc      .done
     50    jnc     .AddHardDisks
    5151
    5252    mov     bp, ROMVARS.ideVarsSerialAuto   ; Point to our special IDEVARS structure, just for serial scans
     
    5858%endif
    5959
    60 .done: 
    61 %ifdef MODULE_SERIAL_FLOPPY
     60.AddHardDisks:
    6261;----------------------------------------------------------------------
    6362;
    64 ; Add in any emulated serial floppy drives.
    65 ;
    66     mov     al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt]
    67     dec     al
    68     mov     cl, al
    69     js      .NoFloppies                     ; if no drives are present, we store 0ffh
     63; Add in hard disks to BDA, finalize our Count and First variables
     64;
     65    mov     cx, [RAMVARS.wDrvCntAndFlopCnt]     ; Our count of hard disks
     66    test    cl, cl
     67    jz      .AddFloppies                ; If none, nothing more to do
     68
     69    mov     al, [es:BDA.bHDCount]
     70    add     cl, al                      ; Add our drives to the system count
     71    mov     [es:BDA.bHDCount], cl       
     72    or      al, 80h                     ; Or in hard disk flag     
     73    mov     [RAMVARS.bFirstDrv], al     ; Store first drive number     
     74
     75
     76.AddFloppies:       
     77;%ifdef MODULE_SERIAL_FLOPPY       
     78;----------------------------------------------------------------------
     79;
     80; Add in any emulated serial floppy drives, finalize our packed Count and First variables
     81;
     82    dec     ch
     83    mov     al, ch
     84    js      .NoFloppies                     ; if no drives are present, we store 0ffh       
    7085
    7186    call    FloppyDrive_GetCountFromBIOS_or_BDA
     
    7388    push    ax
    7489
    75     add     al, cl                          ; Add our drives to existing drive count
     90    add     al, ch                          ; Add our drives to existing drive count
    7691    cmp     al, 3                           ; For BDA, max out at 4 drives (ours is zero based)
    7792    jl      .MaxBDAFloppiesExceeded
     
    92107    pop     ax
    93108
    94     shr     cl, 1                           ; number of drives, 1 or 2 only, to CF flag (clear=1, set=2)
     109    shr     ch, 1                           ; number of drives, 1 or 2 only, to CF flag (clear=1, set=2)
    95110    rcl     al, 1                           ; starting drive number in upper 7 bits, number of drives in low bit
    96111.NoFloppies:   
    97112    mov     [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], al
    98 %endif
     113;%endif
    99114       
    100115    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r254 r262  
    4343    mov     dx, [cs:bp+IDEVARS.bDevice-1]   ; for Serial: AL=port address>>2, AH=baud rate
    4444                                            ;             DL=COM number character, DH=.bDevice
    45 
     45       
     46    mov     si, g_szDetectOuter             ; Load SI with default wrapper string "IDE %s at %s: "
     47       
    4648    push    bp                              ; setup stack for call to
    4749    mov     bp, sp                          ; BootMenuPrint_FormatCSSIfromParamsInSSBP
     
    7274
    7375    test    dl, dl                          ; Check if serial port "Auto"
    74     jz      .pushAndPrint                   ; CX = string to print, AX and DX won't be used
     76    jz      .pushAndPrintSerial             ; CX = string to print, AX and DX won't be used
    7577
    7678    mov     cl, (g_szDetectCOMLarge-$$) & 0xff  ; Setup secondary print string for "COMn/xx.yK"
     
    8890
    8991    cmp     ax,si                           ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
    90     jae     .pushAndPrint
     92    jae     .pushAndPrintSerial
    9193
    9294    mov     cl, (g_szDetectCOMSmall-$$) & 0xff  ; Setup secondary print string for "COMn/XXy00"
     95
     96.pushAndPrintSerial:   
     97    mov     si, g_szDetectOuterSerial       ; Finally load SI with wrapper string "Serial %s on %s: "       
    9398
    9499.pushAndPrint:
     
    96101    push    ax                              ; Push high order digits, or port address, or N/A
    97102    push    dx                              ; Push low order digit, or N/A
    98 
    99     mov     si, g_szDetectOuter             ; Finally load SI with wrapper string "IDE %s at %s: "
    100103
    101104    jmp     short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r259 r262  
    7272.StoreDptPointersToIntVectors:
    7373    mov     dl, 80h
    74     call    RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber   ; DPT to DS:DI
     74    call    FindDPT_ForDriveNumberInDL   ; DPT to DS:DI
    7575    jc      SHORT .FindForDrive81h  ; Store nothing if not our drive
    7676    mov     [es:HD0_DPT_POINTER_41h*4], di
     
    7878.FindForDrive81h:
    7979    inc     dx
    80     call    RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber
     80    call    FindDPT_ForDriveNumberInDL
    8181    jc      SHORT .ResetDetectedDrives
    8282    mov     [es:HD1_DPT_POINTER_46h*4], di
  • trunk/XTIDE_Universal_BIOS/Src/Strings.asm

    r252 r262  
    1717g_szDetectSlave:        db  "Slave ",NULL
    1818g_szDetectOuter:        db  "IDE %s at %s: ",NULL
     19g_szDetectOuterSerial:  db  "Serial %s on %s: ",NULL       
    1920g_szDetectPort:         db  "%x",NULL                       ; IDE Master at 1F0h:
    2021g_szDetectCOM:          db  "COM%c%s",NULL
    21 g_szDetectCOMAuto:      db  " Auto",NULL
     22g_szDetectCOMAuto:      db  " Detect",NULL
    2223g_szDetectCOMSmall:     db  "/%u%u00",NULL                  ; IDE Master at COM1/9600:
    2324g_szDetectEnd:
     
    7071    db  "Addr.",SINGLE_VERTICAL,"Block",SINGLE_VERTICAL,"Bus",SINGLE_VERTICAL,  "IRQ",SINGLE_VERTICAL,"Reset",LF,CR
    7172    db     "%s",SINGLE_VERTICAL, "%5-u",SINGLE_VERTICAL, "%s",SINGLE_VERTICAL," %2-I",SINGLE_VERTICAL,"%5-x" ,NULL
    72 
    73 ; Boot Menu Floppy Disk strings
    74 ;
    75 ; The following strings are used by BootMenuPrint_RefreshInformation
    76 ; To support optimizations in that code, these strings must start on the same 256 byte page,
    77 ; which is checked at assembly time below.
    78 ;
    79 g_szFddStart:
    80 g_szFddUnknown: db  "Unknown",NULL
    81 g_szFddSizeOr:  db  "5",ONE_QUARTER,QUOTATION_MARK," or 3",ONE_HALF,QUOTATION_MARK," DD",NULL
    82 g_szFddSize:    db  "%s",QUOTATION_MARK,", %u kiB",NULL ; 3½", 1440 kiB
    83 g_szFddThreeHalf:       db  "3",ONE_HALF,NULL
    84 g_szFddEnd:
    85 g_szFddFiveQuarter:     db  "5",ONE_QUARTER,NULL
    86 
    87 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    88     %if ((g_szFddStart-$$) & 0xff00) <> ((g_szFddEnd-$$) & 0xff00)
    89         %error "g_szFdd* strings must start on the same 256 byte page, required by the BootMenuPrint_RefreshInformation routines for floppy drives.  Please move this block up or down within strings.asm"
    90     %endif
    91 %endif
    9273
    9374g_szAddressingModes:
     
    151132g_szDashForZero:        db      "- ",NULL
    152133
     134; Boot Menu Floppy Disk strings
     135;
     136; The following strings are used by BootMenuPrint_RefreshInformation
     137; To support optimizations in that code, these strings must start on the same 256 byte page,
     138; which is checked at assembly time below.
     139;
     140g_szFddStart:
     141g_szFddUnknown: db  "Unknown",NULL
     142g_szFddSizeOr:  db  "5",ONE_QUARTER,QUOTATION_MARK," or 3",ONE_HALF,QUOTATION_MARK," DD",NULL
     143g_szFddSize:    db  "%s",QUOTATION_MARK,", %u kiB",NULL ; 3½", 1440 kiB
     144g_szFddThreeHalf:       db  "3",ONE_HALF,NULL
     145g_szFddEnd:
     146g_szFddFiveQuarter:     db  "5",ONE_QUARTER,NULL
     147
     148%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
     149    %if ((g_szFddStart-$$) & 0xff00) <> ((g_szFddEnd-$$) & 0xff00)
     150        %error "g_szFdd* strings must start on the same 256 byte page, required by the BootMenuPrint_RefreshInformation routines for floppy drives.  Please move this block up or down within strings.asm"
     151    %endif
     152%endif
    153153
    154154;------------------------------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/StringsCompressed.asm

    r252 r262  
    3434                          db     4fh,  4ah, 0cbh,  3eh,  20h,  67h, 0fah,  3eh,  40h,  00h                                  ; compressed
    3535
     36g_szDetectOuterSerial:  ; db    "Serial %s on %s: ",NULL       
     37                        ; db     53h,  65h,  72h,  69h,  61h,  6ch,  20h,  25h,  73h,  20h,  6fh,  6eh,  20h,  25h,  73h,  3ah,  20h,  00h    ; uncompressed
     38                          db     59h,  6bh,  78h,  6fh,  67h, 0f2h,  3eh,  20h,  75h, 0f4h,  3eh,  40h,  00h                                  ; compressed
     39
    3640g_szDetectPort:         ; db    "%x",NULL                       ; IDE Master at 1F0h:
    3741                        ; db     25h,  78h,  00h    ; uncompressed
     
    4246                          db   49h,  55h,  53h,  35h,  1eh                      ; compressed
    4347
    44 g_szDetectCOMAuto:      ; db    " Auto",NULL
    45                         ; db     20h,  41h,  75h,  74h,  6fh,  00h    ; uncompressed
    46                           db     20h,  47h,  7bh,  7ah, 0b5h          ; compressed
     48g_szDetectCOMAuto:      ; db    " Detect",NULL
     49                        ; db     20h,  44h,  65h,  74h,  65h,  63h,  74h,  00h    ; uncompressed
     50                          db     20h,  4ah,  6bh,  7ah,  6bh,  69h, 0bah          ; compressed
    4751
    4852g_szDetectCOMSmall:     ; db    "/%u%u00",NULL                  ; IDE Master at COM1/9600:
     
    157161
    158162
     163g_szAddressingModes:
     164g_szLCHS:       ; db    "L-CHS",NULL
     165                ; db     4ch,  2dh,  43h,  48h,  53h,  00h    ; uncompressed
     166                  db     52h,  28h,  49h,  4eh,  99h          ; compressed
     167
     168g_szPCHS:       ; db    "P-CHS",NULL
     169                ; db     50h,  2dh,  43h,  48h,  53h,  00h    ; uncompressed
     170                  db     56h,  28h,  49h,  4eh,  99h          ; compressed
     171
     172g_szLBA28:      ; db    "LBA28",NULL
     173                ; db     4ch,  42h,  41h,  32h,  38h,  00h    ; uncompressed
     174                  db     52h,  48h,  47h,  2ch,  11h          ; compressed
     175
     176g_szLBA48:      ; db    "LBA48",NULL
     177                ; db     4ch,  42h,  41h,  34h,  38h,  00h    ; uncompressed
     178                  db     52h,  48h,  47h,  2eh,  11h          ; compressed
     179
     180g_szAddressingModes_Displacement equ (g_szPCHS - g_szAddressingModes)
     181;
     182; Ensure that addressing modes are correctly spaced in memory
     183;
     184%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
     185%if g_szLCHS <> g_szAddressingModes
     186%error "g_szAddressingModes Displacement Incorrect 1"
     187%endif
     188%if g_szPCHS <> g_szLCHS + g_szAddressingModes_Displacement
     189%error "g_szAddressingModes Displacement Incorrect 2"
     190%endif
     191%if g_szLBA28 <> g_szPCHS + g_szAddressingModes_Displacement
     192%error "g_szAddressingModes Displacement Incorrect 3"
     193%endif
     194%if g_szLBA48 <> g_szLBA28 + g_szAddressingModes_Displacement
     195%error "g_szAddressingModes Displacement Incorrect 4"
     196%endif
     197%endif
     198
     199g_szBusTypeValues:
     200g_szBusTypeValues_8Dual:        ; db        "D8 ",NULL
     201                                ; db         44h,  38h,  20h,  00h    ; uncompressed
     202                                  db         4ah,  31h,  00h          ; compressed
     203
     204g_szBusTypeValues_8Reversed:    ; db        "X8 ",NULL
     205                                ; db         58h,  38h,  20h,  00h    ; uncompressed
     206                                  db         5eh,  31h,  00h          ; compressed
     207
     208g_szBusTypeValues_8Single:      ; db        "S8 ",NULL
     209                                ; db         53h,  38h,  20h,  00h    ; uncompressed
     210                                  db         59h,  31h,  00h          ; compressed
     211
     212g_szBusTypeValues_16:           ; db        " 16",NULL
     213                                ; db         20h,  31h,  36h,  00h    ; uncompressed
     214                                  db         20h,  2bh,  10h          ; compressed
     215
     216g_szBusTypeValues_32:           ; db        " 32",NULL
     217                                ; db         20h,  33h,  32h,  00h    ; uncompressed
     218                                  db         20h,  2dh,  0ch          ; compressed
     219
     220g_szBusTypeValues_Serial:       ; db        "SER",NULL
     221                                ; db         53h,  45h,  52h,  00h    ; uncompressed
     222                                  db         59h,  4bh,  98h          ; compressed
     223
     224g_szBusTypeValues_Displacement equ (g_szBusTypeValues_8Reversed - g_szBusTypeValues)
     225;
     226; Ensure that bus type strings are correctly spaced in memory
     227;
     228%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
     229%if g_szBusTypeValues_8Dual <> g_szBusTypeValues
     230%error "g_szBusTypeValues Displacement Incorrect 1"
     231%endif
     232%if g_szBusTypeValues_8Reversed <> g_szBusTypeValues + g_szBusTypeValues_Displacement
     233%error "g_szBusTypeValues Displacement Incorrect 2"
     234%endif
     235%if g_szBusTypeValues_8Single <> g_szBusTypeValues_8Reversed + g_szBusTypeValues_Displacement
     236%error "g_szBusTypeValues Displacement Incorrect 3"
     237%endif
     238%if g_szBusTypeValues_16 <> g_szBusTypeValues_8Single + g_szBusTypeValues_Displacement
     239%error "g_szBusTypeValues Displacement Incorrect 4"
     240%endif
     241%if g_szBusTypeValues_32 <> g_szBusTypeValues_16 + g_szBusTypeValues_Displacement
     242%error "g_szBusTypeValues Displacement Incorrect 5"
     243%endif
     244%if g_szBusTypeValues_Serial <> g_szBusTypeValues_32 + g_szBusTypeValues_Displacement
     245%error "g_szBusTypeValues Displacement Incorrect 6"
     246%endif
     247%endif
     248
     249g_szSelectionTimeout:   ; db        DOUBLE_BOTTOM_LEFT_CORNER,DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL,"%ASelection in %2-u s",NULL
     250                        ; db        0c8h, 0b5h,  25h,  41h,  53h,  65h,  6ch,  65h,  63h,  74h,  69h,  6fh,  6eh,  20h,  69h,  6eh,  20h,  25h,  32h,  2dh,  75h,  20h,  73h,  00h    ; uncompressed
     251                          db         32h,  33h,  3dh,  59h,  6bh,  72h,  6bh,  69h,  7ah,  6fh,  75h, 0f4h,  6fh, 0f4h,  3ch,  20h, 0b9h                                              ; compressed
     252
     253
     254g_szDashForZero:        ; db        "- ",NULL
     255                        ; db         2dh,  20h,  00h    ; uncompressed
     256                          db         28h,  00h          ; compressed
     257
     258
    159259; Boot Menu Floppy Disk strings
    160260;
     
    191291%endif
    192292%endif
    193 
    194 g_szAddressingModes:
    195 g_szLCHS:       ; db    "L-CHS",NULL
    196                 ; db     4ch,  2dh,  43h,  48h,  53h,  00h    ; uncompressed
    197                   db     52h,  28h,  49h,  4eh,  99h          ; compressed
    198 
    199 g_szPCHS:       ; db    "P-CHS",NULL
    200                 ; db     50h,  2dh,  43h,  48h,  53h,  00h    ; uncompressed
    201                   db     56h,  28h,  49h,  4eh,  99h          ; compressed
    202 
    203 g_szLBA28:      ; db    "LBA28",NULL
    204                 ; db     4ch,  42h,  41h,  32h,  38h,  00h    ; uncompressed
    205                   db     52h,  48h,  47h,  2ch,  11h          ; compressed
    206 
    207 g_szLBA48:      ; db    "LBA48",NULL
    208                 ; db     4ch,  42h,  41h,  34h,  38h,  00h    ; uncompressed
    209                   db     52h,  48h,  47h,  2eh,  11h          ; compressed
    210 
    211 g_szAddressingModes_Displacement equ (g_szPCHS - g_szAddressingModes)
    212 ;
    213 ; Ensure that addressing modes are correctly spaced in memory
    214 ;
    215 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    216 %if g_szLCHS <> g_szAddressingModes
    217 %error "g_szAddressingModes Displacement Incorrect 1"
    218 %endif
    219 %if g_szPCHS <> g_szLCHS + g_szAddressingModes_Displacement
    220 %error "g_szAddressingModes Displacement Incorrect 2"
    221 %endif
    222 %if g_szLBA28 <> g_szPCHS + g_szAddressingModes_Displacement
    223 %error "g_szAddressingModes Displacement Incorrect 3"
    224 %endif
    225 %if g_szLBA48 <> g_szLBA28 + g_szAddressingModes_Displacement
    226 %error "g_szAddressingModes Displacement Incorrect 4"
    227 %endif
    228 %endif
    229 
    230 g_szBusTypeValues:
    231 g_szBusTypeValues_8Dual:        ; db        "D8 ",NULL
    232                                 ; db         44h,  38h,  20h,  00h    ; uncompressed
    233                                   db         4ah,  31h,  00h          ; compressed
    234 
    235 g_szBusTypeValues_8Reversed:    ; db        "X8 ",NULL
    236                                 ; db         58h,  38h,  20h,  00h    ; uncompressed
    237                                   db         5eh,  31h,  00h          ; compressed
    238 
    239 g_szBusTypeValues_8Single:      ; db        "S8 ",NULL
    240                                 ; db         53h,  38h,  20h,  00h    ; uncompressed
    241                                   db         59h,  31h,  00h          ; compressed
    242 
    243 g_szBusTypeValues_16:           ; db        " 16",NULL
    244                                 ; db         20h,  31h,  36h,  00h    ; uncompressed
    245                                   db         20h,  2bh,  10h          ; compressed
    246 
    247 g_szBusTypeValues_32:           ; db        " 32",NULL
    248                                 ; db         20h,  33h,  32h,  00h    ; uncompressed
    249                                   db         20h,  2dh,  0ch          ; compressed
    250 
    251 g_szBusTypeValues_Serial:       ; db        "SER",NULL
    252                                 ; db         53h,  45h,  52h,  00h    ; uncompressed
    253                                   db         59h,  4bh,  98h          ; compressed
    254 
    255 g_szBusTypeValues_Displacement equ (g_szBusTypeValues_8Reversed - g_szBusTypeValues)
    256 ;
    257 ; Ensure that bus type strings are correctly spaced in memory
    258 ;
    259 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    260 %if g_szBusTypeValues_8Dual <> g_szBusTypeValues
    261 %error "g_szBusTypeValues Displacement Incorrect 1"
    262 %endif
    263 %if g_szBusTypeValues_8Reversed <> g_szBusTypeValues + g_szBusTypeValues_Displacement
    264 %error "g_szBusTypeValues Displacement Incorrect 2"
    265 %endif
    266 %if g_szBusTypeValues_8Single <> g_szBusTypeValues_8Reversed + g_szBusTypeValues_Displacement
    267 %error "g_szBusTypeValues Displacement Incorrect 3"
    268 %endif
    269 %if g_szBusTypeValues_16 <> g_szBusTypeValues_8Single + g_szBusTypeValues_Displacement
    270 %error "g_szBusTypeValues Displacement Incorrect 4"
    271 %endif
    272 %if g_szBusTypeValues_32 <> g_szBusTypeValues_16 + g_szBusTypeValues_Displacement
    273 %error "g_szBusTypeValues Displacement Incorrect 5"
    274 %endif
    275 %if g_szBusTypeValues_Serial <> g_szBusTypeValues_32 + g_szBusTypeValues_Displacement
    276 %error "g_szBusTypeValues Displacement Incorrect 6"
    277 %endif
    278 %endif
    279 
    280 g_szSelectionTimeout:   ; db        DOUBLE_BOTTOM_LEFT_CORNER,DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL,"%ASelection in %2-u s",NULL
    281                         ; db        0c8h, 0b5h,  25h,  41h,  53h,  65h,  6ch,  65h,  63h,  74h,  69h,  6fh,  6eh,  20h,  69h,  6eh,  20h,  25h,  32h,  2dh,  75h,  20h,  73h,  00h    ; uncompressed
    282                           db         32h,  33h,  3dh,  59h,  6bh,  72h,  6bh,  69h,  7ah,  6fh,  75h, 0f4h,  6fh, 0f4h,  3ch,  20h, 0b9h                                              ; compressed
    283 
    284 
    285 g_szDashForZero:        ; db        "- ",NULL
    286                         ; db         2dh,  20h,  00h    ; uncompressed
    287                           db         28h,  00h          ; compressed
    288 
    289 
    290293
    291294;------------------------------------------------------------------------------------------
     
    421424;; translated usage stats
    422425;; 33:1
    423 ;; 32:30
     426;; 32:32
    424427;; 181:1
    425428;; 53:2
     
    448451;; 5-u:2
    449452;; x:7
    450 ;; s:12
     453;; s:14
    451454;; 5-x:1
    452455;; nl:6
     
    458461
    459462;; alphabet usage stats
    460 ;; 58,::2
     463;; 58,::3
    461464;; 59,;:
    462465;; 60,<:
     
    465468;; 63,?:
    466469;; 64,@:1
    467 ;; 65,A:4
     470;; 65,A:3
    468471;; 66,B:9
    469472;; 67,C:4
    470 ;; 68,D:10
     473;; 68,D:11
    471474;; 69,E:3
    472475;; 70,F:3
     
    483486;; 81,Q:1
    484487;; 82,R:4
    485 ;; 83,S:6
     488;; 83,S:7
    486489;; 84,T:
    487490;; 85,U:1
     
    497500;; 95,_:
    498501;; 96,`:
    499 ;; 97,a:6
     502;; 97,a:7
    500503;; 98,b:
    501 ;; 99,c:4
     504;; 99,c:5
    502505;; 100,d:4
    503 ;; 101,e:9
     506;; 101,e:12
    504507;; 102,f:2
    505508;; 103,g:2
    506509;; 104,h:
    507 ;; 105,i:9
     510;; 105,i:10
    508511;; 106,j:
    509512;; 107,k:4
    510 ;; 108,l:4
     513;; 108,l:5
    511514;; 109,m:1
    512 ;; 110,n:9
     515;; 110,n:10
    513516;; 111,o:18
    514517;; 112,p:3
    515518;; 113,q:
    516 ;; 114,r:11
     519;; 114,r:12
    517520;; 115,s:6
    518 ;; 116,t:11
    519 ;; 117,u:3
     521;; 116,t:12
     522;; 117,u:2
    520523;; 118,v:2
    521524;; 119,w:1
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r258 r262  
    200200    call    Device_FinalizeDPT
    201201
     202;----------------------------------------------------------------------
     203; Update drive counts (hard and floppy)
     204;----------------------------------------------------------------------
     205       
    202206%ifdef MODULE_SERIAL_FLOPPY
    203207;
     
    223227%endif
    224228
    225     ; Fall to .StoreDriveNumberAndUpdateDriveCount
    226 
    227 ;--------------------------------------------------------------------
    228 ; .StoreDriveNumberAndUpdateDriveCount
    229 ;   Parameters:
    230 ;       DS:DI:  Ptr to Disk Parameter Table
    231 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    232 ;       CS:BP:  Ptr to IDEVARS for the controller
    233 ;       ES:     BDA Segment
    234 ;   Returns:
    235 ;       DL:     Drive number for new drive
    236 ;       CF:     Always cleared
    237 ;   Corrupts registers:
    238 ;       Nothing
    239 ;--------------------------------------------------------------------
    240 .StoreDriveNumberAndUpdateDriveCount:
    241     mov     dl, [es:BDA.bHDCount]
    242     or      dl, 80h                     ; Set bit 7 since hard disk
    243 
    244229    inc     BYTE [RAMVARS.bDrvCnt]      ; Increment drive count to RAMVARS
    245     inc     BYTE [es:BDA.bHDCount]      ; Increment drive count to BDA
    246 
    247     cmp     BYTE [RAMVARS.bFirstDrv], 0 ; First drive set?
    248     ja      SHORT .AllDone              ;  If so, return
    249     mov     [RAMVARS.bFirstDrv], dl     ; Store first drive number
    250 
    251 .AllDone:
     230       
     231.AllDone:               
    252232    clc
    253233    ret
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm

    r259 r262  
    66
    77;--------------------------------------------------------------------
    8 ; Finds pointer to first unused Disk Parameter Table.
    9 ;
    10 ; FindDPT_ForNewDriveToDSDI
    11 ;   Parameters:
    12 ;       DS:     RAMVARS segment
    13 ;   Returns:
    14 ;       DS:DI:  Ptr to first unused DPT
    15 ;   Corrupts registers:
    16 ;       DX
    17 ;--------------------------------------------------------------------
    18 ALIGN JUMP_ALIGN
    19 FindDPT_ForNewDriveToDSDI:
    20     mov     ax, [RAMVARS.wDrvCntAndFirst]
    21     add     al, ah
     8; Checks if drive is handled by this BIOS, and return DPT pointer.
     9;
     10; FindDPT_ForDriveNumberInDL       
     11;   Parameters:
     12;       DL:     Drive number
     13;       DS:     RAMVARS segment
     14;   Returns:
     15;       CF:     Cleared if drive is handled by this BIOS
     16;               Set if drive belongs to some other BIOS
     17;       DI:     DPT Pointer if drive is handled by this BIOS
     18;               Zero if drive belongs to some other BIOS
     19;   Corrupts registers:
     20;       Nothing
     21;--------------------------------------------------------------------
     22ALIGN JUMP_ALIGN
     23FindDPT_ForDriveNumberInDL:     
     24    xchg    di, ax                              ; Save the contents of AX in DI
     25
     26;
     27; Check Our Hard Disks
     28;
     29    mov     ax, [RAMVARS.wDrvCntAndFirst]       ; Drive count to AH, First number to AL
     30    add     ah, al                              ; One past last drive to AH
     31
    2232%ifdef MODULE_SERIAL_FLOPPY
    23     add     al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt]
     33    cmp     dl, ah                              ; Above last supported?
     34    jae     SHORT .HardDiskNotHandledByThisBIOS
     35       
     36    cmp     dl, al                              ; Below first supported?
     37    jae     SHORT .CalcDPTForDriveNumber
     38
     39ALIGN JUMP_ALIGN               
     40.HardDiskNotHandledByThisBIOS: 
     41;
     42; Check Our Floppy Disks
     43;
     44    call    RamVars_UnpackFlopCntAndFirstToAL
     45    cbw                                         ; normally 0h, could be ffh if no drives present
     46    adc     ah, al                              ; if no drives present, still ffh (ffh + ffh + 1 = ffh)
     47    js      SHORT .DiskIsNotHandledByThisBIOS
     48    cmp     ah, dl                              ; Check second drive if two, first drive if only one
     49    jz      SHORT .CalcDPTForDriveNumber
     50    cmp     al, dl                              ; Check first drive in all cases, redundant but OK to repeat
     51    jnz     SHORT .DiskIsNotHandledByThisBIOS           
     52%else
     53    cmp     dl, ah                              ; Above last supported?     
     54    jae     SHORT .DiskIsNotHandledByThisBIOS
     55       
     56    cmp     dl, al                              ; Below first supported?
     57    jb      SHORT .DiskIsNotHandledByThisBIOS           
    2458%endif
    25     xchg    ax, dx
    26     ; fall-through to FindDPT_ForDriveNumber
     59    ; fall-through to CalcDPTForDriveNumber
    2760
    2861;--------------------------------------------------------------------
    2962; Finds Disk Parameter Table for drive number.
    30 ; IDE Base Port address will be stored to RAMVARS if correct DPT is found.
    31 ;
    32 ; FindDPT_ForDriveNumber
     63; Note intended to be called except by FindDPT_ForDriveNumber
     64;
     65; CalcDPTForDriveNumber
    3366;   Parameters:
    3467;       DL:     Drive number
    3568;       DS:     RAMVARS segment
     69;       DI:     Saved copy of AX from entry at FindDPT_ForDriveNumber
    3670;   Returns:
    3771;       DS:DI:  Ptr to DPT
     72;       CF:     Clear
    3873;   Corrupts registers:
    3974;       Nothing
    4075;--------------------------------------------------------------------
    4176ALIGN JUMP_ALIGN
    42 FindDPT_ForDriveNumber:
     77.CalcDPTForDriveNumber:
    4378    push    dx
    44     xchg    di, ax  ; Save the contents of AX in DI
    4579
    4680%ifdef MODULE_SERIAL_FLOPPY
     
    5286    call    RamVars_UnpackFlopCntAndFirstToAL
    5387    add     dl, ah                      ; add in end of hard disk DPT list, floppies start immediately after
     88       
     89ALIGN JUMP_ALIGN               
    5490.harddisk:
    5591    sub     dl, al                      ; subtract off beginning of either hard disk or floppy list (as appropriate)
     
    5793    sub     dl, [RAMVARS.bFirstDrv]     ; subtract off beginning of hard disk list
    5894%endif
    59        
     95
     96.CalcDPTForNewDrive:               
    6097    mov     al, LARGEST_DPT_SIZE
    6198       
    6299    mul     dl
    63     add     ax, BYTE RAMVARS_size
    64 
    65     xchg    di, ax                      ; Restore AX and put result in DI
     100    add     ax, BYTE RAMVARS_size       ; Clears CF (will not oveflow)
     101
    66102    pop     dx
    67        
    68     ret
    69 
    70 ;--------------------------------------------------------------------
    71 ; Consolidator for checking the result from RamVars_IsDriveHandledByThisBIOS
    72 ; and then if it is our drive, getting the DPT with FindDPT_ForDriveNumber
    73 ;
    74 ; RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber
    75 ;   Parameters:
    76 ;       DL:     Drive number
    77 ;       DS:     RAMVARS segment
    78 ;   Returns:
    79 ;       DS:DI:  Ptr to DPT, if it is our drive
    80 ;       CF:     Set if not our drive, clear if it is our drive
    81 ;   Corrupts registers:
    82 ;       Nothing
    83 ;--------------------------------------------------------------------
    84 ALIGN JUMP_ALIGN
    85 RamVars_IsDriveHandledByThisBIOS_And_FindDPT_ForDriveNumber:
    86     call    RamVars_IsDriveHandledByThisBIOS
    87     jnc     FindDPT_ForDriveNumber
    88     ret
    89 
    90 
    91 ;--------------------------------------------------------------------
    92 ; Finds Disk Parameter Table for
    93 ; Master or Slave drive at wanted port.
    94 ;
    95 ; FindDPT_ToDSDIForIdeMasterAtPortDX
    96 ; FindDPT_ToDSDIForIdeSlaveAtPortDX
    97 ;   Parameters:
    98 ;       DX:     IDE Base Port address
    99 ;       DS:     RAMVARS segment
    100 ;   Returns:
    101 ;       DL:     Drive number (if DPT found)
    102 ;       DS:DI:  Ptr to DPT
    103 ;       CF:     Set if wanted DPT found
    104 ;               Cleared if DPT not found
    105 ;   Corrupts registers:
    106 ;       SI
    107 ;
    108 ; Converted to macros since there is only once call site for each of these
    109 ;
    110 ;--------------------------------------------------------------------
    111    
    112 %macro FindDPT_ToDSDIForIdeMasterAtPortDX 0
    113     mov     si, IterateToMasterAtPortCallback
    114     call    IterateAllDPTs
    115 %endmacro
    116 
    117 %macro FindDPT_ToDSDIForIdeSlaveAtPortDX 0
    118     mov     si, IterateToSlaveAtPortCallback
    119     call    IterateAllDPTs
    120 %endmacro
    121 
    122        
    123 ;--------------------------------------------------------------------
    124 ; Iteration callback for finding DPT using
    125 ; IDE base port for Master or Slave drive.
    126 ;
    127 ; IterateToSlaveAtPortCallback
    128 ; IterateToMasterAtPortCallback
    129 ;   Parameters:
    130 ;       DX:     IDE Base Port address
    131 ;       DS:DI:  Ptr to DPT to examine
    132 ;   Returns:
    133 ;       CF:     Set if wanted DPT found
    134 ;               Cleared if wrong DPT
    135 ;   Corrupts registers:
    136 ;       Nothing
    137 ;--------------------------------------------------------------------
    138 ALIGN JUMP_ALIGN
    139 IterateToSlaveAtPortCallback:
    140     test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE ; Clears CF
    141     jnz     SHORT CompareBasePortAddress
    142     ret     ; Wrong DPT
    143 
    144 ALIGN JUMP_ALIGN
    145 IterateToMasterAtPortCallback:
    146     test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
    147     jnz     SHORT ReturnWrongDPT                ; Return if slave drive
    148 
    149 CompareBasePortAddress:
    150     push    bx
    151     eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]    ; CS:BX now points to IDEVARS
    152     cmp     dx, [cs:bx+IDEVARS.wPort]           ; Wanted port?
    153     pop     bx
    154     jne     SHORT ReturnWrongDPT
    155 
    156 ReturnRightDPT:
    157     stc                                         ; Set CF since wanted DPT
    158     ret
    159 
     103
     104    xchg    di, ax                      ; Restore AX from entry at FindDPT_ForDriveNumber, put DPT pointer in DI
     105    ret
     106
     107ALIGN JUMP_ALIGN       
     108.DiskIsNotHandledByThisBIOS:           
     109;
     110; Drive not found...
     111;
     112    xor     ax, ax                              ; Clear DPT pointer
     113    stc                                         ; Is not supported by our BIOS     
     114       
     115    xchg    di, ax                              ; Restore AX from save at top
     116    ret
     117
     118;--------------------------------------------------------------------
     119; Finds pointer to first unused Disk Parameter Table.
     120; Should only be used before DetectDrives is complete (not valid after this time).
     121;
     122; FindDPT_ForNewDriveToDSDI
     123;   Parameters:
     124;       DS:     RAMVARS segment
     125;   Returns:
     126;       DS:DI:  Ptr to first unused DPT
     127;   Corrupts registers:
     128;       AX
     129;--------------------------------------------------------------------
     130ALIGN JUMP_ALIGN
     131FindDPT_ForNewDriveToDSDI:
     132    push    dx
     133       
     134%ifdef MODULE_SERIAL_FLOPPY
     135    mov     dx, [RAMVARS.wDrvCntAndFlopCnt]
     136    add     dl, dh
     137%else
     138    mov     dl, [RAMVARS.bDrvCnt]
     139%endif
     140       
     141    jmp     short FindDPT_ForDriveNumberInDL.CalcDPTForNewDrive
    160142
    161143;--------------------------------------------------------------------
     
    165147;       BL:     Bit(s) to test in DPT.bFlagsHigh
    166148;   Returns:
    167 ;       CF:     Set if wanted DPT found
    168 ;               Cleared if wrong DPT
     149;       CF:     Clear if wanted DPT found
     150;               Set if wrong DPT
    169151;   Corrupts registers:
    170152;       Nothing
     
    172154ALIGN JUMP_ALIGN
    173155IterateToDptWithFlagsHighInBL:     
    174     test    BYTE [di+DPT.bFlagsHigh], bl        ; Clears CF (but we need the clc
    175                                                 ; below anyway for callers above)
    176     jnz     SHORT ReturnRightDPT
    177 
    178 ReturnWrongDPT:
    179     clc                                     ; Clear CF since wrong DPT
     156    test    BYTE [di+DPT.bFlagsHigh], bl        ; Clears CF
     157    jnz     SHORT .ReturnRightDPT
     158    stc
     159.ReturnRightDPT:       
    180160    ret
    181161
     
    220200;       AX,BX,DX:   Parameters to callback function
    221201;       CS:SI:      Ptr to callback function
     202;                   Callback routine should return CF=clear if found
    222203;       DS:         RAMVARS segment
    223204;   Returns:
    224205;       DS:DI:      Ptr to wanted DPT (if found)
    225206;                   If not found, points to first empty DPT
    226 ;       CF:         Set if wanted DPT found
    227 ;                   Cleared if DPT not found, or no DPTs present
     207;       CF:         Clear if wanted DPT found
     208;                   Set if DPT not found, or no DPTs present
    228209;   Corrupts registers:
    229210;       Nothing unless corrupted by callback function
     
    238219    xor     ch, ch                      ; Clears CF 
    239220       
    240     jcxz    .AllDptsIterated            ; Return if no drives, CF will be clear from xor above
     221    jcxz    .NotFound                   ; Return if no drives
    241222       
    242223ALIGN JUMP_ALIGN
    243224.LoopWhileDPTsLeft:
    244225    call    si                          ; Is wanted DPT?
    245     jc      SHORT .AllDptsIterated      ;  If so, return
    246     add     di, BYTE LARGEST_DPT_SIZE   ; Point to next DPT, clears CF
     226    jnc     SHORT .Found                ;  If so, return
     227    add     di, BYTE LARGEST_DPT_SIZE   ; Point to next DPT
    247228    loop    .LoopWhileDPTsLeft
    248    
    249     ; fall-through: DPT was not found, CF is already clear from ADD di inside the loop
    250        
    251 ALIGN JUMP_ALIGN
    252 .AllDptsIterated:
     229
     230ALIGN JUMP_ALIGN
     231.NotFound:
     232    stc
     233
     234ALIGN JUMP_ALIGN
     235.Found:
    253236    pop     cx
    254237    ret
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm

    r258 r262  
    115115
    116116;--------------------------------------------------------------------
    117 ; Checks if INT 13h function is handled by this BIOS.
    118 ;
    119 ; RamVars_IsFunctionHandledByThisBIOS
    120 ;   Parameters:
    121 ;       AH:     INT 13h function number
    122 ;       DL:     Drive number
    123 ;       DS:     RAMVARS segment
    124 ;   Returns:
    125 ;       CF:     Cleared if function is handled by this BIOS
    126 ;               Set if function belongs to some other BIOS
    127 ;   Corrupts registers:
    128 ;       Nothing
    129 ;--------------------------------------------------------------------
    130 ALIGN JUMP_ALIGN
    131 RamVars_IsFunctionHandledByThisBIOS:
    132     test    ah, ah          ; Reset for all floppy and hard disk drives?
    133     jz      SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS
    134     cmp     ah, 08h
    135 %ifdef MODULE_SERIAL_FLOPPY
    136 ; we handle all traffic for function 08h, as we need to wrap both hard disk and floppy drive counts
    137     je      SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS
    138 %else
    139 ; we handle all *hard disk* traffic for function 08h, as we need to wrap the hard disk drive count
    140     je      SHORT RamVars_IsDriveHandledByThisBIOS.IsDriveAHardDisk
    141 %endif
    142 ;;; fall-through           
    143        
    144 ;--------------------------------------------------------------------
    145 ; Checks if drive is handled by this BIOS.
    146 ;
    147 ; RamVars_IsDriveHandledByThisBIOS
    148 ;   Parameters:
    149 ;       DL:     Drive number
    150 ;       DS:     RAMVARS segment
    151 ;   Returns:
    152 ;       CF:     Cleared if drive is handled by this BIOS
    153 ;               Set if drive belongs to some other BIOS
    154 ;   Corrupts registers:
    155 ;       Nothing
    156 ;--------------------------------------------------------------------
    157 ALIGN JUMP_ALIGN
    158 RamVars_IsDriveHandledByThisBIOS:
    159     push    ax
    160 
    161     mov     ax, [RAMVARS.wDrvCntAndFirst]       ; Drive count to AH, First number to AL
    162     add     ah, al                              ; One past last drive to AH
    163     cmp     dl, ah                              ; Above last supported?
    164     jae     SHORT .HardDiskIsNotHandledByThisBIOS
    165 .TestLowLimit:
    166     cmp     dl, al                              ; Below first supported?
    167     jae     SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX  ; note that CF is clear if the branch is taken
    168 
    169 .HardDiskIsNotHandledByThisBIOS:
    170 %ifdef MODULE_SERIAL_FLOPPY
    171     call    RamVars_UnpackFlopCntAndFirstToAL
    172     cbw                                         ; normally 0h, could be ffh if no drives present
    173     adc     ah, al                              ; if no drives present, still ffh (ffh + ffh + 1 = ffh)
    174     js      SHORT .DiskIsNotHandledByThisBIOS
    175     cmp     ah, dl
    176     jz      SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX
    177     cmp     al, dl
    178     jz      SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX
    179 .DiskIsNotHandledByThisBIOS:           
    180 %endif
    181 
    182     stc                                         ; Is not supported by our BIOS
    183        
    184 .CFAlreadyClear_IsHandledByOurBIOS_PopAX:               
    185     pop     ax
    186 .CFAlreadyClear_IsHandledByOurBIOS:
    187     ret
    188 
    189 %ifndef MODULE_SERIAL_FLOPPY       
    190 ;
    191 ; Note that we could have just checked for the high order bit in dl, but with the needed STC and jumps,
    192 ; leveraging the code above resulted in space savings.
    193 ;
    194 .IsDriveAHardDisk:     
    195     push    ax                                  ; match stack at the top of routine
    196     mov     al, 80h                             ; to catch all hard disks, lower limit is 80h vs. bFirstDrv
    197     jmp     .TestLowLimit                       ; and there is no need to test a high limit
    198 %endif
    199 
    200 ;--------------------------------------------------------------------
    201117; RamVars_GetHardDiskCountFromBDAtoAX
    202118;   Parameters:
Note: See TracChangeset for help on using the changeset viewer.