Changeset 241 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm


Ignore:
Timestamp:
Feb 9, 2012, 11:08:59 AM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Space optimizations in the Boot Menu and BootInfo routines, taking advantage of nested %s. Optimization in the init of RamVars to avoid writing the signature twice. Preparing for addition of serial floppy support, starting to break the assumption that our drives are always 80h or higher.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r200 r241  
    55SECTION .text
    66
    7 ;;;
    8 ;;; Fall-through from BootMenuEvent.asm!
    9 ;;; BootMenuPrint_FloppyMenuitem must be the first routine in this file
    10 ;;; (checked at assembler time with the code after BootMenuPrint_FloppyMenuitem)
    11 ;;;
    12 ;--------------------------------------------------------------------
    13 ; BootMenuPrint_FloppyMenuitem
     7;--------------------------------------------------------------------
     8; BootMenuPrint_RefreshItem
     9;
    1410;   Parameters:
    1511;       DL:     Untranslated Floppy Drive number
    16 ;       SF:     set for Information, clear for Item
    17 ;   Returns:
    18 ;       Nothing
    19 ;   Corrupts registers:
    20 ;       AX, DX, SI, DI
    21 ;--------------------------------------------------------------------
    22 ALIGN JUMP_ALIGN
    23 BootMenuPrint_FloppyMenuitem:
    24     js      short BootMenuPrint_FloppyMenuitemInformation
    25     call    PrintDriveNumberAfterTranslationFromDL
     12;   Returns:
     13;       Nothing
     14;   Corrupts registers:
     15;       AX, BX, DX, SI, DI
     16;--------------------------------------------------------------------
     17ALIGN JUMP_ALIGN
     18BootMenuPrint_RefreshItem:
     19    call    BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
     20    jnc     BootMenuEvent_EventCompleted            ; if no menu item selected, out we go
     21       
    2622    push    bp
    2723    mov     bp, sp
    28     mov     si, g_szFDLetter
    29     ePUSH_T ax, g_szFloppyDrv
    30     add     dl, 'A'
    31     push    dx                  ; Drive letter
     24
     25    call    RamVars_IsDriveHandledByThisBIOS               
     26    jnc     .notOurs
     27
     28    call    FindDPT_ForDriveNumber                  ; if it is one of ours, print the string in bootnfo
     29    call    BootInfo_ConvertDPTtoBX
     30    mov     si, g_szDriveNumBOOTNFO                 ; special g_szDriveNum that prints from BDA
     31    jmp     .go
     32       
     33.notOurs:
     34    mov     si,g_szDriveNum                                 
     35    mov     bx,g_szForeignHD                        ; assume a hard disk for the moment
     36       
     37    test    dl,80h                                         
     38    js      .go
     39    mov     bl,((g_szFloppyDrv)-$$ & 0xff)          ; and revisit the earlier assumption...
     40       
     41.go:
     42    mov     ax, dx                                  ; preserve DL for the floppy drive letter addition
     43    call    DriveXlate_ToOrBack
     44    push    dx                                      ; translated drive number
     45    push    bx                                      ; sub string
     46    add     al, 'A'                                 ; floppy drive letter (we always push this although
     47    push    ax                                      ; the hard disks don't ever use it, but it does no harm)
     48       
    3249    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
    33 
    34 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    35 %if BootMenuPrint_FloppyMenuitem <> BootMenuEvent_FallThroughToFloppyMenuitem
    36 %error "BootMenuPrint.asm must follow BootMenuEvent.asm, and BootMenuPrint_FloppyMenuitem must be the first routine in BootMenuPrint.asm"
    37 %endif
    38 %endif
    39        
    40 ;--------------------------------------------------------------------
    41 ; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    42 ;   Parameters:
    43 ;       BX:DX:AX:   Sector count
    44 ;   Returns:
    45 ;       Size in stack
    46 ;   Corrupts registers:
    47 ;       AX, BX, CX, DX, SI
    48 ;--------------------------------------------------------------------
    49 ALIGN JUMP_ALIGN
    50 ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
    51     pop     si      ; Pop return address
    52     call    Size_ConvertSectorCountInBXDXAXtoKiB
    53     mov     cx, BYTE_MULTIPLES.kiB
    54     call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
    55     push    ax      ; Size in magnitude
    56     push    cx      ; Tenths
    57     push    dx      ; Magnitude character
    58     jmp     si
    59 
    6050
    6151;--------------------------------------------------------------------
     
    7767    mov     si, ROMVARS.szVersion
    7868    ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
    79 
    8069
    8170;--------------------------------------------------------------------
     
    10291       
    10392;--------------------------------------------------------------------
    104 ; BootMenuPrint_HardDiskMenuitem
    105 ;   Parameters:
    106 ;       DL:     Untranslated Hard Disk number
    107 ;       DS:     RAMVARS segment
    108 ;       SF:     set for Information, clear for Item     
    109 ;   Returns:
    110 ;       CF:     Set since menu event handled
    111 ;   Corrupts registers:
    112 ;       AX, BX, SI, DI
    113 ;--------------------------------------------------------------------
    114 ALIGN JUMP_ALIGN
    115 BootMenuPrint_HardDiskMenuitem:
    116     js      short BootMenuPrint_HardDiskMenuitemInformation
    117     call    PrintDriveNumberAfterTranslationFromDL
    118     call    RamVars_IsDriveHandledByThisBIOS
    119     jnc     SHORT .HardDiskMenuitemForForeignDrive
    120     ; Fall to .HardDiskMenuitemForOurDrive
    121 
    122 ;--------------------------------------------------------------------
    123 ; .HardDiskMenuitemForOurDrive
    124 ;   Parameters:
    125 ;       DL:     Untranslated Hard Disk number
    126 ;       DS:     RAMVARS segment
    127 ;   Returns:
    128 ;       CF:     Set since menu event handled
    129 ;   Corrupts registers:
    130 ;       AX, BX, SI, DI
    131 ;--------------------------------------------------------------------
    132 .HardDiskMenuitemForOurDrive:
    133     call    BootInfo_GetOffsetToBX
    134     lea     si, [bx+BOOTNFO.szDrvName]
    135     xor     bx, bx          ; BDA segment
    136     CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
    137     stc
    138     ret
    139 
    140 ;--------------------------------------------------------------------
    141 ; BootMenuPrint_HardDiskMenuitemForForeignDrive
    142 ;   Parameters:
    143 ;       DL:     Untranslated Hard Disk number
    144 ;       DS:     RAMVARS segment
    145 ;   Returns:
    146 ;       CF:     Set since menu event handled
    147 ;   Corrupts registers:
    148 ;       AX, SI, DI
    149 ;--------------------------------------------------------------------
    150 ALIGN JUMP_ALIGN
    151 .HardDiskMenuitemForForeignDrive:
    152     mov     si, g_szforeignHD
    153     jmp     SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
    154 
    155 
    156 ;--------------------------------------------------------------------
    15793; BootMenuPrint_FloppyMenuitemInformation
    15894;   Parameters:
     
    165101;--------------------------------------------------------------------
    166102
    167 FloppyTypes:
    168 .rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
    169 .rgbCapacity:
    170     db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
    171     db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
    172     db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
    173     db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
    174     db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
    175     db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
    176 
    177 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    178 %if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
    179 %error "FddThreeFive_Displacement incorrect"
    180 %endif
    181 %endif
    182        
    183 ALIGN JUMP_ALIGN
    184 BootMenuPrint_FloppyMenuitemInformation:
    185     call    BootMenuPrint_ClearInformationArea
    186     call    FloppyDrive_GetType         ; Get Floppy Drive type to BX
     103ALIGN JUMP_ALIGN
     104BootMenuPrint_RefreshInformation:
     105    CALL_MENU_LIBRARY ClearInformationArea     
     106       
     107    call    BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
     108    jnc     BootMenuEvent_EventCompleted                ; if no menu selection, abort
    187109
    188110    push    bp
    189111    mov     bp, sp
    190     ePUSH_T ax, g_szCapacity
    191        
    192     mov     si, g_szFddSizeOr           ; .PrintXTFloppyType
    193     test    bx, bx                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
    194     jz      SHORT .output
    195 
    196     mov     si, g_szFddUnknown          ; .PrintUnknownFloppyType
     112
     113    test    dl, dl                                      ; are we a hard disk?
     114    js      BootMenuPrint_HardDiskRefreshInformation       
     115       
     116    call    FloppyDrive_GetType                         ; Get Floppy Drive type to BX
     117
     118    mov     cx, g_szFddSizeOr                           ; .PrintXTFloppyType
     119    test    bx, bx                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
     120    jz      SHORT BootMenuPrint_HardDiskRefreshInformation.output
     121
     122    mov     cl, (g_szFddUnknown - $$) & 0xff            ; .PrintUnknownFloppyType
    197123    cmp     bl, FLOPPY_TYPE_35_ED
    198     ja      SHORT .output
     124    ja      SHORT BootMenuPrint_HardDiskRefreshInformation.output
    199125       
    200126    ; Fall to .PrintKnownFloppyType
    201 
    202127
    203128;--------------------------------------------------------------------
     
    223148;--------------------------------------------------------------------
    224149.PrintKnownFloppyType:
    225     mov     si, g_szFddSize
    226        
    227     mov     ax, g_szFddThreeHalf
     150    mov     cl, (g_szFddSize - $$) & 0xff
     151    push    cx
     152       
     153    mov     cl, (g_szFddThreeHalf - $$) & 0xff
    228154    cmp     bl, FLOPPY_TYPE_525_HD
    229155    ja      .ThreeHalf
    230 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
    231 %if g_szFddThreeFive_Displacement = 2       
    232     inc     ax                      ; compressed string case
    233     inc     ax
    234 %else
    235     add     ax, g_szFddThreeFive_Displacement
    236 %endif
    237 %endif
     156    mov     cl, (g_szFddFiveQuarter - $$) & 0xff
    238157.ThreeHalf:     
    239     push    ax                      ; "5 1/4" or "3 1/2"
     158    push    cx                                          ; "5 1/4" or "3 1/2"
    240159
    241160    mov     al,FloppyTypes.rgbCapacityMultiplier
     
    243162    push    ax
    244163
     164    jmp     short BootMenuPrint_HardDiskRefreshInformation.output
     165
     166
     167;--------------------------------------------------------------------
     168; Prints Hard Disk Menuitem information strings.
     169;
     170; BootMenuPrint_HardDiskMenuitemInformation
     171;   Parameters:
     172;       DL:     Untranslated Hard Disk number
     173;       DS:     RAMVARS segment
     174;   Returns:
     175;       CF:     Set since menu event was handled successfully
     176;   Corrupts registers:
     177;       BX, CX, DX, SI, DI, ES
     178;--------------------------------------------------------------------
     179ALIGN JUMP_ALIGN
     180BootMenuPrint_HardDiskRefreshInformation:       
     181    call    RamVars_IsDriveHandledByThisBIOS
     182    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
     183    call    FindDPT_ForDriveNumber                      ; DS:DI to point DPT
     184    ; Fall to .HardDiskMenuitemInfoForOurDrive
     185
     186;--------------------------------------------------------------------
     187; .HardDiskMenuitemInfoForOurDrive
     188;   Parameters:
     189;       DL:     Untranslated Hard Disk number
     190;       DS:DI:  Ptr to DPT
     191;   Returns:
     192;       Nothing
     193;   Corrupts registers:
     194;       AX, BX, CX, DX, SI, DI, ES
     195;--------------------------------------------------------------------
     196.HardDiskMenuitemInfoForOurDrive:
     197    ePUSH_T ax, g_szSizeDual
     198       
     199    ; Get and push L-CHS size
     200    call    AH15h_GetSectorCountToDXAX
     201    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     202
     203    ; Get and push total LBA size
     204    call    BootInfo_GetTotalSectorCount
     205    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat       
     206    jmp     BootMenuPrintCfg_ForOurDrive
     207               
     208;--------------------------------------------------------------------
     209; .HardDiskMenuitemInfoForForeignDrive
     210;   Parameters:
     211;       DL:     Untranslated Hard Disk number
     212;       DS:     RAMVARS segment
     213;   Returns:
     214;       CF:     Set since menu event was handled successfully
     215;   Corrupts registers:
     216;       AX, BX, CX, DX, SI, DI
     217;--------------------------------------------------------------------
     218ALIGN JUMP_ALIGN
     219.HardDiskMenuitemInfoForForeignDrive:
     220    call    DriveXlate_ToOrBack
     221    call    AH15h_GetSectorCountFromForeignDriveToDXAX
     222    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     223
    245224ALIGN JUMP_ALIGN       
    246225.output:
     226    mov     si, g_szCapacity
    247227;;; fall-through
    248228
     
    263243    stc             ; Successfull return from menu event
    264244    pop     bp
    265     ret     
    266 
    267        
    268 ;--------------------------------------------------------------------
    269 ; Prints Hard Disk Menuitem information strings.
    270 ;
    271 ; BootMenuPrint_HardDiskMenuitemInformation
    272 ;   Parameters:
    273 ;       DL:     Untranslated Hard Disk number
    274 ;       DS:     RAMVARS segment
    275 ;   Returns:
    276 ;       CF:     Set since menu event was handled successfully
    277 ;   Corrupts registers:
    278 ;       BX, CX, DX, SI, DI, ES
    279 ;--------------------------------------------------------------------
    280 ALIGN JUMP_ALIGN
    281 BootMenuPrint_HardDiskMenuitemInformation:
    282     call    RamVars_IsDriveHandledByThisBIOS
    283     jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
    284     call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
    285     ; Fall to .HardDiskMenuitemInfoForOurDrive
    286 
    287 ;--------------------------------------------------------------------
    288 ; .HardDiskMenuitemInfoForOurDrive
    289 ;   Parameters:
    290 ;       DL:     Untranslated Hard Disk number
    291 ;       DS:DI:  Ptr to DPT
    292 ;   Returns:
    293 ;       Nothing
    294 ;   Corrupts registers:
    295 ;       AX, BX, CX, DX, SI, DI, ES
    296 ;--------------------------------------------------------------------
    297 .HardDiskMenuitemInfoForOurDrive:
    298     push    di
    299     ePUSH_T ax, BootMenuPrintCfg_ForOurDrive    ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
    300     push    bp
    301     mov     bp, sp
    302     ePUSH_T ax, g_szCapacity
    303 
    304     ; Get and push L-CHS size
    305     mov     [RAMVARS.bTimeoutTicksLeft], dl     ; Store drive number
    306     call    AH15h_GetSectorCountToDXAX
    307     call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    308 
    309     ; Get and push total LBA size
    310     mov     dl, [RAMVARS.bTimeoutTicksLeft]     ; Restore drive number
    311     call    BootInfo_GetTotalSectorCount
    312     call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    313 
    314     mov     si, g_szSizeDual
    315     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    316 
    317 
    318 ;--------------------------------------------------------------------
    319 ; .HardDiskMenuitemInfoForForeignDrive
    320 ;   Parameters:
    321 ;       DL:     Untranslated Hard Disk number
    322 ;       DS:     RAMVARS segment
    323 ;   Returns:
    324 ;       CF:     Set since menu event was handled successfully
    325 ;   Corrupts registers:
    326 ;       AX, BX, CX, DX, SI, DI
    327 ;--------------------------------------------------------------------
    328 ALIGN JUMP_ALIGN
    329 .HardDiskMenuitemInfoForForeignDrive:
    330     push    bp
    331     mov     bp, sp
    332     ePUSH_T ax, g_szCapacity
    333 
    334     call    DriveXlate_ToOrBack
    335     call    AH15h_GetSectorCountFromForeignDriveToDXAX
    336     call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    337 
    338     mov     si, g_szSizeSingle
    339     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    340 
    341        
    342 ;--------------------------------------------------------------------
    343 ; BootMenuPrint_ClearInformationArea
    344 ;   Parameters:
    345 ;       Nothing
    346 ;   Returns:
    347 ;       CF:     Set
    348 ;   Corrupts registers:
    349 ;       AX, DI
    350 ;--------------------------------------------------------------------
    351 ALIGN JUMP_ALIGN
    352 BootMenuPrint_ClearInformationArea:
    353     CALL_MENU_LIBRARY ClearInformationArea
    354     stc
    355245    ret
    356 
     246       
    357247       
    358248;--------------------------------------------------------------------
     
    373263    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
    374264    ret
    375 
    376        
    377 ;--------------------------------------------------------------------
    378 ; PrintDriveNumberAfterTranslationFromDL
    379 ;   Parameters:
    380 ;       DL:     Untranslated Floppy Drive number
    381 ;       DS:     RAMVARS segment
    382 ;   Returns:
    383 ;       Nothing
    384 ;   Corrupts registers:
    385 ;       AX, DI
    386 ;--------------------------------------------------------------------
    387 ALIGN JUMP_ALIGN
    388 PrintDriveNumberAfterTranslationFromDL:
    389     mov     ax, dx
    390     call    DriveXlate_ToOrBack
    391     xchg    dx, ax              ; Restore DX, WORD to print in AL
    392     xor     ah, ah
    393     push    bp
    394     mov     bp, sp
    395     mov     si, g_szDriveNum
    396     push    ax
    397        
    398 BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
    399     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    400265
    401266
     
    510375    push    cx          ; Key attribute for last space
    511376    mov     si, g_szHotkey
    512     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
     377       
     378BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
     379    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    513380
    514381
     
    528395
    529396
    530        
    531 
    532 
    533        
     397;--------------------------------------------------------------------
     398; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     399;   Parameters:
     400;       BX:DX:AX:   Sector count
     401;   Returns:
     402;       Size in stack
     403;   Corrupts registers:
     404;       AX, BX, CX, DX, SI
     405;--------------------------------------------------------------------
     406ALIGN JUMP_ALIGN
     407ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
     408    pop     si                      ; Pop return address
     409    ePUSH_T cx, g_szCapacityNum     ; Push format substring
     410    call    Size_ConvertSectorCountInBXDXAXtoKiB
     411    mov     cx, BYTE_MULTIPLES.kiB
     412    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
     413    push    ax                      ; Size in magnitude
     414    push    cx                      ; Tenths
     415    push    dx                      ; Magnitude character
     416    jmp     si
     417
     418
     419FloppyTypes:
     420.rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
     421.rgbCapacity:
     422    db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
     423    db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
     424    db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
     425    db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
     426    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
     427    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
     428
     429
     430
     431
     432       
     433
     434
     435       
Note: See TracChangeset for help on using the changeset viewer.