Changeset 525 in xtideuniversalbios


Ignore:
Timestamp:
Mar 14, 2013, 9:45:07 PM (8 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Made some improvements to the stack switching in Int13h.asm.
  • Added a tail-call optimized variant of the CALL_MENU_LIBRARY macro (JMP_MENU_LIBRARY).
  • Other optimizations and fixes.
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/Menu.inc

    r370 r525  
    55
    66;--------------------------------------------------------------------
    7 ; Menu Library users need to use this macro since it will provide
     7; Menu Library users need to use these macros since it will provide
    88; compatibility with future library versions.
    99;
    1010; CALL_MENU_LIBRARY
     11; JMP_MENU_LIBRARY
    1112;   Parameters:
    1213;       %1:         Function to call (functionName from MENU_LIB)
     
    2122    %ifidn %1, CloseMenuIfExitEventAllows
    2223        call    MenuInit_CloseMenuIfExitEventAllows
    23 
    2424    %elifidn %1, Close
    2525        call    MenuInit_CloseMenuWindow
    26 
    2726    %elifidn %1, SetUserDataFromDSSI
    2827        call    MenuInit_SetUserDataFromDSSI
    29 
    3028    %elifidn %1, GetUserDataToDSSI
    3129        call    MenuInit_GetUserDataToDSSI
    32 
    3330    %elifidn %1, SetTitleHeightFromAL
    3431        call    MenuInit_SetTitleHeightFromAL
    35 
    3632    %elifidn %1, GetHighlightedItemToAX
    3733        call    MenuInit_GetHighlightedItemToAX
    38 
    3934    %elifidn %1, SetTotalItemsFromAX
    4035        call    MenuInit_SetTotalItemsFromAX
    41 
    4236    %elifidn %1, SetInformationHeightFromAL
    4337        call    MenuInit_SetInformationHeightFromAL
    44 
    4538    %elifidn %1, SetTimeoutValueFromAX
    4639        call    MenuTime_SetSelectionTimeoutValueFromAX
    47 
    4840    %else
    4941        mov     di, %1
    5042        call    Menu_FunctionFromDI
     43    %endif
     44%endmacro
     45
     46%macro JMP_MENU_LIBRARY 1
     47    %ifidn %1, CloseMenuIfExitEventAllows
     48        jmp     MenuInit_CloseMenuIfExitEventAllows
     49    %elifidn %1, Close
     50        jmp     MenuInit_CloseMenuWindow
     51    %elifidn %1, SetUserDataFromDSSI
     52        jmp     MenuInit_SetUserDataFromDSSI
     53    %elifidn %1, GetUserDataToDSSI
     54        jmp     MenuInit_GetUserDataToDSSI
     55    %elifidn %1, SetTitleHeightFromAL
     56        jmp     MenuInit_SetTitleHeightFromAL
     57    %elifidn %1, GetHighlightedItemToAX
     58        jmp     MenuInit_GetHighlightedItemToAX
     59    %elifidn %1, SetTotalItemsFromAX
     60        jmp     MenuInit_SetTotalItemsFromAX
     61    %elifidn %1, SetInformationHeightFromAL
     62        jmp     MenuInit_SetInformationHeightFromAL
     63    %elifidn %1, SetTimeoutValueFromAX
     64        jmp     MenuTime_SetSelectionTimeoutValueFromAX
     65    %else
     66        mov     di, %1
     67        jmp     Menu_FunctionFromDI
    5168    %endif
    5269%endmacro
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm

    r505 r525  
    714714    call    InitializeNullStringsToDialogInputInDSSI
    715715    mov     WORD [si+DIALOG_INPUT.fszTitle], g_szSelectNewDrive
    716     CALL_MENU_LIBRARY GetDriveWithIoInDSSI
    717     ret
     716    JMP_MENU_LIBRARY GetDriveWithIoInDSSI
    718717
    719718;--------------------------------------------------------------------
  • trunk/BIOS_Drive_Information_Tool/Src/Print.asm

    r505 r525  
    210210    loop    .ReverseNextWord
    211211    dec     di
    212     xor     ax, ax
     212    xchg    cx, ax
    213213    stosb               ; Terminate with NULL
    214214
  • trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc

    r522 r525  
    3737struc RAMVARS
    3838%ifdef RELOCATE_INT13H_STACK
    39                         resb    256 ; Size of our stack
    40     .rgbTopOfStack:
     39                        resb    252
     40    .dwStackChangeDSDI:
     41    .wStackChangeDI     resb    2   ; Used during stack
     42    .wStackChangeDS     resb    2   ; switching only
     43    .rgbTopOfStack:                 ; 256 bytes of stack
    4144    .fpInt13hEntryStack resb    4
    42     .dwStackChangeDSDI:
    43     .wStackChangeDI     resb    2
    44     .wStackChangeDS     resb    2
    4545%endif
    4646    .wDrvDetectSignature:           ; Signature when BIOS is in drive detection mode
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r522 r525  
    3737ALIGN JUMP_ALIGN
    3838Int13h_DiskFunctionsHandlerWithStackChange:
    39     push    ds
     39    sti         ; Enable interrupts
     40    ; TODO: Maybe we need to save Flags (DF) as well?
     41    push    ds  ; Save DS:DI on the original stack
    4042    push    di
    4143    call    RamVars_GetSegmentToDS
    4244
    4345    ; Store entry registers to RAMVARS
     46%ifdef USE_386
     47    pop     DWORD [RAMVARS.dwStackChangeDSDI]
     48%else
     49    pop     WORD [RAMVARS.wStackChangeDI]   ; Pop DS:DI to the top of what
     50    pop     WORD [RAMVARS.wStackChangeDS]   ; is to become the new stack
     51%endif
    4452    mov     [RAMVARS.fpInt13hEntryStack], sp
    4553    mov     [RAMVARS.fpInt13hEntryStack+2], ss
    46     pop     WORD [RAMVARS.wStackChangeDI]
    47     pop     WORD [RAMVARS.wStackChangeDS]
    4854
    4955    ; Load new stack and restore DS and DI
    50     mov     di, ds      ; We do not want to overwrite DS and DI in stack
    51     mov     ss, di
    52     mov     sp, RAMVARS.rgbTopOfStack
    53     lds     di, [RAMVARS.dwStackChangeDSDI]
     56    mov     di, ds      ; We can save 2 bytes by using PUSH/POP but it's slower
     57    mov     ss, di      ; No need to wrap with CLI/STI since this is for AT only (286+)
     58    mov     sp, RAMVARS.rgbTopOfStack-4
     59    pop     di          ; DI before stack change
     60    pop     ds          ; DS before stack change
    5461
    5562    ; Call INT 13h
     
    5966
    6067    ; Restore stack (we must not corrupt FLAGS!)
    61     cli
    6268%ifdef USE_386
    6369    lss     sp, [ss:RAMVARS.fpInt13hEntryStack]
    6470%else
     71    cli
    6572    mov     sp, [ss:RAMVARS.fpInt13hEntryStack]
    6673    mov     ss, [ss:RAMVARS.fpInt13hEntryStack+2]
    67 %endif
    68     pop     di          ; DI before stack change
    69     pop     ds          ; DS before stack change
     74    sti
     75%endif
    7076    retf    2           ; Skip FLAGS from stack
    7177%endif ; RELOCATE_INT13H_STACK
     
    8894ALIGN JUMP_ALIGN
    8995Int13h_DiskFunctionsHandler:
     96%ifndef RELOCATE_INT13H_STACK
    9097    sti                                 ; Enable interrupts
     98%endif
    9199    cld                                 ; String instructions to increment pointers
    92100    CREATE_FRAME_INTPACK_TO_SSBP    SIZE_OF_IDEPACK_WITHOUT_INTPACK
     
    398406    dw  AH1Eh_HandlerForXTCFfeatures                ; 1Eh, Lo-tech XT-CF features (XTIDE Universal BIOS)
    399407%else
    400     dw  UnsupportedFunction                         ; 1Eh, 
     408    dw  UnsupportedFunction                         ; 1Eh,
    401409%endif
    402410    dw  UnsupportedFunction                         ; 1Fh,
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm

    r505 r525  
    112112    jae     SHORT .SetMemoryMappedMode
    113113
    114 ; We need to limit block size here. Consider this scenario;
    115 ; 1. While in PIO mode or memory mapped mode, the drive is set to do
    116 ;    block transfers larger than XTCF_DMA_MODE_MAX_BLOCK_SIZE.
    117 ; 2. A call is subsequently made to change device mode to DEVICE_8BIT_XTCF_DMA.
    118 ; 3. The call to AH24h_SetBlockSize fails but the change in device mode has been made.
    119 
    120114    ; Set DMA Mode
    121115    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    122116    mov     al, [di+DPT_ATA.bBlockSize]
    123     MIN_U   al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
    124     jmp     SHORT AH24h_SetBlockSize    ; Returns via AH23h_Enable8bitPioMode
     117    cmp     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
     118    jbe     SHORT AH24h_SetBlockSize
     119    mov     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
     120    jmp     SHORT AH24h_SetBlockSize
    125121
    126122.SetMemoryMappedMode:
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm

    r523 r525  
    174174ALIGN JUMP_ALIGN
    175175StoreAndDisplayNumberOfControllers:
    176     mov     ax, 1
    177     MAX_U   al, cl                      ; Cannot store zero
     176    xor     ax, ax
     177    or      al, cl
     178    jnz     SHORT .AtLeastOneController
     179    inc     ax                          ; Cannot store zero
     180.AtLeastOneController:
    178181    test    BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
    179182    jnz     SHORT .FullModeSoNoNeedToLimit
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm

    r376 r525  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    190190    mov     dx, ds
    191191    mov     ax, bx
    192     CALL_MENU_LIBRARY StartProgressTaskWithIoInDSSIandParamInDXAX
    193     ret
     192    JMP_MENU_LIBRARY StartProgressTaskWithIoInDSSIandParamInDXAX
    194193
    195194
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm

    r505 r525  
    1 ; Project name  :   XTIDE Univeral BIOS Configurator v2
     1; Project name  :   XTIDE Universal BIOS Configurator v2
    22; Description   :   Program start and exit.
    33
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm

    r505 r525  
    3333MenuEvents_DisplayMenu:
    3434    mov     bx, MenuEventHandler
    35     CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
    36     ret
     35    JMP_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
    3736
    3837
     
    218217    jnz     SHORT .PrintNameOfLoadedFile
    219218    test    ax, FLG_CFGVARS_ROMLOADED
    220     jnz     SHORT .PrintLoadedEeprom
     219    mov     si, g_szEEPROM
     220    jnz     SHORT .PrintNameOfLoadedFileOrEeprom
    221221    ; Fall to .PrintNothingLoaded
    222222
     
    228228.PrintNameOfLoadedFile:
    229229    mov     si, g_cfgVars+CFGVARS.szOpenedFile
    230     CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
    231     jmp     SHORT .PrintTypeOfLoadedBios
    232 
    233 ALIGN JUMP_ALIGN
    234 .PrintLoadedEeprom:
    235     mov     si, g_szEEPROM
     230    ; Fall to .PrintNameOfLoadedFileOrEeprom
     231
     232ALIGN JUMP_ALIGN
     233.PrintNameOfLoadedFileOrEeprom:
    236234    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
    237235    ; Fall to .PrintTypeOfLoadedBios
    238236
    239 ALIGN JUMP_ALIGN
    240237.PrintTypeOfLoadedBios:
    241238    mov     si, g_szSourceAndTypeSeparator
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm

    r425 r525  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    168168    call    GetConfigurationBufferToESDIforMenuitemInDSSI
    169169    add     di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
    170        
     170
    171171    push    bx
    172172    mov     bx,[si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
     
    176176.NoWriter:
    177177    pop     bx
    178        
     178
    179179    jmp     [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
    180180.InvalidItemType:
     
    295295    CALL_MENU_LIBRARY RefreshTitle
    296296    CALL_MENU_LIBRARY GetHighlightedItemToAX
    297     CALL_MENU_LIBRARY RefreshItemFromAX
    298     ret
     297    JMP_MENU_LIBRARY RefreshItemFromAX
    299298
    300299ALIGN JUMP_ALIGN
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupage.asm

    r376 r525  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    3939    xor     ax, ax
    4040    CALL_MENU_LIBRARY HighlightItemFromAX
    41     CALL_MENU_LIBRARY RefreshWindow
    42     ret
     41    JMP_MENU_LIBRARY RefreshWindow
    4342
    4443
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm

    r376 r525  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing initialized data
     
    2929iend
    3030
    31 g_MenuitemMainMenuLicense:     
     31g_MenuitemMainMenuLicense:
    3232istruc MENUITEM
    3333    at  MENUITEM.fnActivate,        dw  Menuitem_DisplayHelpMessageFromDSSI
     
    3535    at  MENUITEM.szQuickInfo,       dw  g_szNfoMainLicense
    3636    at  MENUITEM.szHelp,            dw  g_szHelpMainLicense
    37     at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE       
    38     at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
    39 iend
    40        
     37    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
     38    at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
     39iend
     40
    4141g_MenuitemMainMenuLoadBiosFromFile:
    4242istruc MENUITEM
     
    8989iend
    9090
    91 g_MenuitemMainMenuSaveFile:     
     91g_MenuitemMainMenuSaveFile:
    9292istruc MENUITEM
    9393    at  MENUITEM.fnActivate,        dw  BiosFile_SaveUnsavedChanges
     
    9797    at  MENUITEM.bFlags,            db  NULL
    9898    at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
    99 iend       
     99iend
    100100
    101101g_MenuitemMainMenuExitToDos:
     
    109109iend
    110110
    111 g_MenuitemMainMenuHomePage:     
     111g_MenuitemMainMenuHomePage:
    112112istruc MENUITEM
    113113    at  MENUITEM.fnActivate,        dw  Menuitem_DisplayHelpMessageFromDSSI
     
    115115    at  MENUITEM.szQuickInfo,       dw  g_szNfoMainHomePage
    116116    at  MENUITEM.szHelp,            dw  g_szNfoMainHomePage
    117     at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE       
    118     at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
    119 iend                       
     117    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
     118    at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
     119iend
    120120
    121121
     
    139139    call    .EnableOrDisableConfigureXtideUniversalBios
    140140    call    .EnableOrDisableFlashEeprom
    141     call    .EnableOrDisableSave           
     141    call    .EnableOrDisableSave
    142142    mov     si, g_MenupageForMainMenu
    143143    jmp     Menupage_ChangeToNewMenupageInDSSI
     
    220220;       Nothing
    221221;--------------------------------------------------------------------
    222 ALIGN JUMP_ALIGN       
    223 .EnableOrDisableSave:   
     222ALIGN JUMP_ALIGN
     223.EnableOrDisableSave:
    224224    test    WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED
    225225    jz      SHORT .DisableSave
     
    227227    ret
    228228
    229 ALIGN JUMP_ALIGN               
     229ALIGN JUMP_ALIGN
    230230.DisableSave:
    231231    and     BYTE [g_MenuitemMainMenuSaveFile+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
    232232    ret
    233                
     233
    234234;--------------------------------------------------------------------
    235235; MENUITEM activation functions (.fnActivate)
     
    243243ALIGN JUMP_ALIGN
    244244ExitToDosSelectedFromMenu:
    245     CALL_MENU_LIBRARY CloseMenuIfExitEventAllows
    246 ExitToDosFromBackButton:
    247     ret
     245    JMP_MENU_LIBRARY CloseMenuIfExitEventAllows
    248246
    249247
     
    262260.CancelFileLoading:
    263261    add     sp, BYTE FILE_DIALOG_IO_size
     262ExitToDosFromBackButton:
    264263    ret
    265264
     
    284283    jmp     Dialogs_DisplayNotificationFromCSDX
    285284
    286 
    287    
Note: See TracChangeset for help on using the changeset viewer.