Changeset 88 in xtideuniversalbios


Ignore:
Timestamp:
Jan 27, 2011, 8:14:13 AM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • Now uses new libraries (untested)
  • Non-working since code size is too large
Location:
trunk/XTIDE_Universal_BIOS
Files:
3 deleted
21 edited

Legend:

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

    r3 r88  
    1 ; File name     :   BootMenu.inc
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   26.3.2010
    4 ; Last update   :   26.3.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Equates used in Boot Menu.
    73%ifndef BOOTMENU_INC
     
    95
    106; Boot menu sizes
    11 MENU_TITLE_LINE_CNT     EQU 3       ; Number of title lines
    12 MENU_INFO_LINE_CNT      EQU 3       ; Number of info lines
    13 MENU_WIDTH_IN_CHARS     EQU 38      ; Menu width in characters
    14 MENU_HEIGHT_IN_CHARS_WITH_INFO      EQU (MENU_TITLE_LINE_CNT + MENU_INFO_LINE_CNT + 4)
    15 MENU_HEIGHT_IN_CHARS_WITHOUT_INFO   EQU (MENU_TITLE_LINE_CNT + 3)
     7BOOT_MENU_TITLE_LINES           EQU 2   ; Number of title lines
     8BOOT_MENU_INFO_LINES            EQU 3   ; Number of info lines
     9BOOT_MENU_TITLE_AND_INFO_LINES  EQU (BOOT_MENU_TITLE_LINES | (BOOT_MENU_INFO_LINES<<8))
     10BOOT_MENU_WIDTH                 EQU 40  ; Menu width in characters
     11BOOT_MENU_HEIGHT_WITHOUT_ITEMS  EQU (BOOT_MENU_TITLE_LINES + BOOT_MENU_INFO_LINES + 4)
    1612
    1713; Function IDs
    18 ID_BOOTFUNC_ROMBOOT     EQU 0       ; ROM boot
     14ID_BOOTFUNC_ROMBOOT             EQU 0   ; ROM boot
    1915
    2016
  • trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc

    r3 r88  
    1 ; File name     :   BootVars.inc
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   23.3.2010
    4 ; Last update   :   9.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Defines for BOOTVARS struct used by boot menu
    73;                   and drive initialization.
     
    2622    .dwSys18h       resb    4       ;  800h, System INT 18h handler (Diskless boot, Boot failure)
    2723    .dwPostStack    resb    4       ;  804h, POST stack when entering INT 19h
    28     .bMenuHotkey    resb    1       ;  808h, Boot Menu hotkey, zero if none pressed
    29                     resb    3
     24                    resb    4
    3025    .rgBootNfo      resb    73F4h   ;  80Ch, Array containing BOOTNFO structs
    3126    .rgbMnuStack:                   ; 7C00h and below, Boot Menu stack
  • trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc

    r3 r88  
    1 ; File name     :   RamVars.inc
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   23.3.2010
    4 ; Last update   :   8.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   RAMVARS struct containing BIOS variables stored in RAM.
    73%ifndef RAMVARS_INC
     
    3127
    3228    .wI13hDS:
    33     .bEndTime       resb    1   ; Timeout ending time
    34                     resb    1   ; Alignment
     29    .wTimeoutCounter    resb    2
    3530
    3631    .wDrvCntAndFirst:
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r3 r88  
    2424    .bIdeCnt        resb    1   ; Number of supported IDE controllers
    2525    .bBootDrv       resb    1   ; Boot Menu default drive
    26     .bBootMnuH      resb    1   ; Boot Menu maximum height
     26                    resb    1   ; (Was boot menu maximum height)
    2727    .bBootDelay     resb    1   ; Boot Menu selection delay in seconds
    2828    .bBootLdrType   resb    1   ; Boot Loader type
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm

    r83 r88  
    11; File name     :   BootInfo.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   16.3.2010
    4 ; Last update   :   6.1.2011
    5 ; Author        :   Tomi Tilli,
    6 ;               :   Krister Nordvall (optimizations)
     2; Project name  :   XTIDE Universal BIOS
    73; Description   :   Functions for generating and accessing drive
    84;                   information to be displayed on boot menu.
     
    145141    loop    BootInfo_StoreAtaString ; Loop while words left
    146142.Return:
    147     mov     al, STOP                ; End string with STOP
     143    xor     ax, ax                  ; Terminate string with NULL
    148144    stosb
    149145    ret
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm

    r84 r88  
    1 ; File name     :   BootMenu.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   25.3.2010
    4 ; Last update   :   14.1.2011
    5 ; Author        :   Tomi Tilli,
    6 ;               :   Krister Nordvall (optimizations)
     1; Project name  :   XTIDE Universal BIOS
    72; Description   :   Displays Boot Menu.
    83
     
    2823    call    DriveXlate_Reset
    2924    call    BootMenuPrint_TheBottomOfScreen
    30     call    BootMenu_GetMenuitemCount
    31     mov     di, BootMenuEvent_Handler
    3225    call    BootMenu_Enter          ; Get selected menuitem index to CX
    3326    call    BootMenuPrint_ClearScreen
    34     test    cx, cx                  ; -1 if nothing selected (ESC pressed)
    35     js      SHORT BootMenu_DisplayAndReturnSelection
    36     call    BootMenu_CheckAndConvertHotkeyToMenuitem
    37     jc      SHORT .SetDriveTranslationForHotkey
     27    cmp     cx, BYTE NO_ITEM_SELECTED
     28    je      SHORT BootMenu_DisplayAndReturnSelection
    3829    jmp     BootMenu_ConvertMenuitemToDriveOrFunction
    39 ALIGN JUMP_ALIGN
    40 .SetDriveTranslationForHotkey:
    41     call    BootMenu_ConvertMenuitemToDriveOrFunction
    42     call    DriveXlate_SetDriveToSwap
    43     clc
     30
     31
     32;--------------------------------------------------------------------
     33; Enters Boot Menu or submenu.
     34;
     35; BootMenu_Enter
     36;   Parameters:
     37;       Nothing
     38;   Returns:
     39;       CX:     Index of selected item or NO_ITEM_SELECTED
     40;   Corrupts registers:
     41;       BX, DI
     42;--------------------------------------------------------------------
     43ALIGN JUMP_ALIGN
     44BootMenu_Enter:
     45    mov     bx, BootMenuEvent_Handler
     46    CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
     47    xchg    cx, ax
    4448    ret
    4549
     
    4852; Returns number of menuitems in Boot Menu.
    4953;
    50 ; BootMenu_GetMenuitemCount
     54; BootMenu_GetMenuitemCountToCX
    5155;   Parameters:
    5256;       DS:     RAMVARS segment
     
    5761;--------------------------------------------------------------------
    5862ALIGN JUMP_ALIGN
    59 BootMenu_GetMenuitemCount:
     63BootMenu_GetMenuitemCountToCX:
    6064    call    RamVars_GetHardDiskCountFromBDAtoCX
    6165    xchg    ax, cx
     
    8993
    9094;--------------------------------------------------------------------
    91 ; Enters Boot Menu or submenu.
    92 ;
    93 ; BootMenu_Enter
    94 ;   Parameters:
    95 ;       CX:     Number of menuitems in menu
    96 ;       DS:SI:  User specific far pointer
    97 ;       CS:DI:  Pointer to menu event handler function
    98 ;   Returns:
    99 ;       CX:     Index of last pointed Menuitem (not necessary selected with ENTER)
    100 ;               FFFFh if cancelled with ESC
    101 ;   Corrupts registers:
    102 ;       AX, BX, DX
    103 ;--------------------------------------------------------------------
    104 ALIGN JUMP_ALIGN
    105 BootMenu_Enter:
    106     call    BootMenu_GetSelectionTimeout
    107     call    BootMenu_GetSize
    108     MIN_U   ah, [cs:ROMVARS.bBootMnuH]      ; Limit to max height
    109     jmp     Menu_Enter
    110 
    111 ;--------------------------------------------------------------------
    112 ; Returns Boot Menu selection timeout in milliseconds.
    113 ;
    114 ; BootMenu_GetSelectionTimeout
    115 ;   Parameters:
    116 ;       Nothing
    117 ;   Returns:
    118 ;       DX:     Selection timeout in millisecs
    119 ;   Corrupts registers:
    120 ;       AX
    121 ;--------------------------------------------------------------------
    122 ALIGN JUMP_ALIGN
    123 BootMenu_GetSelectionTimeout:
    124     mov     ax, 1000            ; Seconds to milliseconds
    125     eMOVZX  dx, BYTE [cs:ROMVARS.bBootDelay]
    126     mul     dx                  ; AX = seconds * milliseconds_per_second
    127     xchg    ax, dx              ; DX = Timeout in millisecs
    128     ret
    129 
    130 ;--------------------------------------------------------------------
    131 ; Returns Boot Menu size.
    132 ;
    133 ; BootMenu_GetSize
    134 ;   Parameters:
    135 ;       Nothing
    136 ;   Returns:
    137 ;       AL:     Menu width with borders included (characters)
    138 ;       AH:     Menu height with borders included (characters)
    139 ;       BL:     Title line count
    140 ;       BH:     Info line count
    141 ;   Corrupts registers:
    142 ;       Nothing
    143 ;--------------------------------------------------------------------
    144 ALIGN JUMP_ALIGN
    145 BootMenu_GetSize:
    146     mov     al, MENU_WIDTH_IN_CHARS
    147     mov     ah, cl                      ; Copy menuitem count to AH
    148     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVNFO
    149     jz      SHORT .GetHeightWithoutInfoArea
    150 ;.GetHeightWithInfoArea:
    151     add     ah, MENU_HEIGHT_IN_CHARS_WITH_INFO
    152     mov     bx, (MENU_INFO_LINE_CNT<<8) | MENU_TITLE_LINE_CNT
    153     ret
    154 ALIGN JUMP_ALIGN
    155 .GetHeightWithoutInfoArea:
    156     add     ah, MENU_HEIGHT_IN_CHARS_WITHOUT_INFO
    157     mov     bx, MENU_TITLE_LINE_CNT
    158     ret
    159 
    160 
    161 ;--------------------------------------------------------------------
    162 ; Checks if hotkey has been pressed on Boot Menu.
    163 ; If it has been, it will be converted to menuitem index.
    164 ;
    165 ; BootMenu_CheckAndConvertHotkeyToMenuitem
    166 ;   Parameters:
    167 ;       CX:     Menuitem index (if no hotkey)
    168 ;   Returns:
    169 ;       CX:     Menuitem index
    170 ;       CF:     Set if hotkey has been pressed
    171 ;               Cleared if no hotkey selection
    172 ;   Corrupts registers:
    173 ;       AX
    174 ;--------------------------------------------------------------------
    175 ALIGN JUMP_ALIGN
    176 BootMenu_CheckAndConvertHotkeyToMenuitem:
    177     push    es
    178     LOAD_BDA_SEGMENT_TO es, ax              ; Zero AX
    179     xchg    al, [es:BOOTVARS.bMenuHotkey]   ; Load and clear hotkey
    180     test    al, al                          ; No hotkey? (clears CF)
    181     jz      SHORT .Return
    182     call    BootMenu_ConvertHotkeyToMenuitem
    183     stc
    184 ALIGN JUMP_ALIGN
    185 .Return:
    186     pop     es
    187     ret
     95; BootMenu_GetHeightToALwithItemCountInCL
     96;   Parameters:
     97;       CL:     Number of menuitems
     98;   Returns:
     99;       AH:     Boot menu height
     100;   Corrupts registers:
     101;       AL, CL, DI
     102;--------------------------------------------------------------------
     103ALIGN JUMP_ALIGN
     104BootMenu_GetHeightToAHwithItemCountInCL:
     105    add     cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
     106    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
     107    MIN_U   ah, cl
     108    ret
     109
    188110
    189111;--------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm

    r28 r88  
    1 ; File name     :   BootMenuEvent.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   26.3.2010
    4 ; Last update   :   1.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Boot Menu event handler for menu library callbacks.
    73
     
    95SECTION .text
    106
     7struc ITEM_TYPE_REFRESH
     8    .HardDisk           resb    2
     9    .FloppyDrive        resb    2
     10    .SpecialFunction    resb    2
     11endstruc
     12
     13
    1114;--------------------------------------------------------------------
    12 ; Boot Menu event handler.
    13 ;
    1415; BootMenuEvent_Handler
    15 ;   Parameters:
    16 ;       BX:     Callback event
    17 ;       CX:     Menuitem index (usually index of selected Menuitem)
    18 ;       DX:     Event parameter (event specific)
    19 ;       SS:BP:  Ptr to MENUVARS
    20 ;   Returns:
    21 ;       AH:     Event specific or unused. Set to 0 if unused.
    22 ;       AL:     1=Event processed
    23 ;               0=Event not processed (default action if any)
     16;   Common parameters for all events:
     17;       BX:         Menu event (anything from MENUEVENT struct)
     18;       SS:BP:      Menu library handle
     19;   Common return values for all events:
     20;       CF:         Set if event processed
     21;                   Cleared if event not processed
    2422;   Corrupts registers:
    25 ;       BX, CX, DX
     23;       All
    2624;--------------------------------------------------------------------
    2725ALIGN JUMP_ALIGN
    2826BootMenuEvent_Handler:
    29     push    es
    30     push    ds
    31     push    di
    32     push    si
     27    cmp     bx, MENUEVENT.RefreshItemFromCX ; Above last supported item?
     28    ja      SHORT .EventNotHandled
     29    jmp     [bx+.rgfnEventSpecificHandlers]
     30.EventNotHandled:
     31.IdleProcessing:
     32    clc
     33    ret
    3334
    34     xor     ax, ax                                  ; Event not processed
    35     cmp     bx, BYTE EVNT_MNU_GETDEF                ; Event in jump table?
    36     ja      SHORT .Return
    37     shl     bx, 1
    38     call    [cs:bx+.rgwEventJmp]
    39 .Return:
    40     pop     si
    41     pop     di
    42     pop     ds
    43     pop     es
    44     ret
    4535ALIGN WORD_ALIGN
    46 .rgwEventJmp:
    47     dw      BootMenuEvent_Exit                      ; 0, EVNT_MNU_EXIT (Menu will quit)
    48     dw      BootMenuEvent_EventItemSelectionChanged ; 1, EVNT_MMU_SELCHG (Menuitem selection changed (with arrows))
    49     dw      BootMenuEvent_EventItemSelected         ; 2, EVNT_MNU_SELSET (Menuitem selected (with Enter))
    50     dw      BootMenuEvent_EventKeyPressed           ; 3, EVNT_MNU_KEY (Keyboard key pressed)
    51     dw      BootMenuEvent_EventMenuDraw             ; 4, EVNT_MNU_UPD (Menu needs to be updated)
    52     dw      BootMenuEvent_EventGetDefaultMenuitem   ; 5, EVNT_MNU_GETDEF (Request menuitem to be selected by default)
     36.rgfnEventSpecificHandlers:
     37    dw      .InitializeMenuinitFromDSSI
     38    dw      .EventCompleted
     39    dw      .IdleProcessing
     40    dw      .ItemHighlightedFromCX
     41    dw      .ItemSelectedFromCX
     42    dw      .KeyStrokeInAX
     43    dw      BootMenuPrint_TitleStrings
     44    dw      .RefreshInformation
     45    dw      .RefreshItemFromCX
    5346
    5447
    55 ;--------------------------------------------------------------------
    56 ; Boot Menu event handler.
    57 ; Handles Menu Exit notification (EVNT_MNU_EXIT).
    58 ;
    59 ; BootMenuEvent_Exit
    60 ;   Parameters:
    61 ;       SS:BP:  Ptr to MENUVARS
    62 ;   Returns:
    63 ;       AH:     1 to cancel exit
    64 ;               0 to allow menu exit
    65 ;       AL:     1 = Event processed
    66 ;   Corrupts registers:
    67 ;       Nothing
    68 ;--------------------------------------------------------------------
     48; Parameters:
     49;   DS:SI:      Ptr to MENUINIT struct to initialize
     50; Returns:
     51;   DS:SI:      Ptr to initialized MENUINIT struct
    6952ALIGN JUMP_ALIGN
    70 BootMenuEvent_Exit:
    71     mov     ax, 1                   ; Event handled
     53.InitializeMenuinitFromDSSI:
     54    push    ds
     55    call    RamVars_GetSegmentToDS
     56    call    .GetDefaultMenuitemToDX
     57    call    BootMenu_GetMenuitemCountToCX
     58    pop     ds
     59    mov     [si+MENUINIT.wItems], cx
     60    mov     [si+MENUINIT.wHighlightedItem], dx
     61    mov     WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
     62    mov     BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
     63    call    BootMenu_GetHeightToAHwithItemCountInCL
     64    mov     [si+MENUINIT.bHeight], ah
     65    stc
    7266    ret
    7367
    74 
    75 ;--------------------------------------------------------------------
    76 ; Boot Menu event handler.
    77 ; Handles Menuitem Selection Changed notification (EVNT_MMU_SELCHG).
    78 ;
    79 ; BootMenuEvent_EventItemSelectionChanged
    80 ;   Parameters:
    81 ;       CX:     Index of selected Menuitem
    82 ;       SS:BP:  Ptr to MENUVARS
    83 ;   Returns:
    84 ;       AX:     1 = Event processed
    85 ;   Corrupts registers:
    86 ;       BX, CX, DX, DI
    87 ;--------------------------------------------------------------------
    8868ALIGN JUMP_ALIGN
    89 BootMenuEvent_EventItemSelectionChanged:
    90     call    RamVars_GetSegmentToDS
    91     call    DriveXlate_Reset
    92     call    BootMenu_ConvertMenuitemToDriveOrFunction
    93     jc      SHORT BootMenuEvent_UpdateAllMenuitems  ; Selection changed to a function
    94     call    DriveXlate_SetDriveToSwap
    95     ; Fall to BootMenuEvent_UpdateAllMenuitems
    96 
    97 ;--------------------------------------------------------------------
    98 ; Redraws all menuitems.
    99 ;
    100 ; BootMenuEvent_UpdateAllMenuitems
    101 ;   Parameters:
    102 ;       SS:BP:  Ptr to MENUVARS
    103 ;   Returns:
    104 ;       AX:     1 = Event processed
    105 ;   Corrupts registers:
    106 ;       BX, CX, DX
    107 ;--------------------------------------------------------------------
    108 ALIGN JUMP_ALIGN
    109 BootMenuEvent_UpdateAllMenuitems:
    110     mov     cx, -1                  ; Update all items
    111     mov     dl, MFL_UPD_ITEM | MFL_UPD_NFO | MFL_UPD_NOCLEAR
    112     call    Menu_Invalidate
    113     mov     ax, 1                   ; Event handled
    114     ret
    115 
    116 
    117 ;--------------------------------------------------------------------
    118 ; Boot Menu event handler.
    119 ; Handles Menuitem Selected notification (EVNT_MNU_SELSET).
    120 ;
    121 ; BootMenuEvent_EventItemSelected
    122 ;   Parameters:
    123 ;       CX:     Index of selected Menuitem
    124 ;       SS:BP:  Ptr to MENUVARS
    125 ;   Returns:
    126 ;       AX:     1 = Event processed
    127 ;   Corrupts registers:
    128 ;       BX, CX, DX
    129 ;--------------------------------------------------------------------
    130 ALIGN JUMP_ALIGN
    131 BootMenuEvent_EventItemSelected:
    132     call    Menu_Exit               ; Exit from menu
    133     mov     ax, 1                   ; Event handled
    134     ret
    135 
    136 
    137 ;--------------------------------------------------------------------
    138 ; Boot Menu event handler.
    139 ; Handles Key pressed notification (EVNT_MNU_KEY).
    140 ;
    141 ; BootMenuEvent_EventKeyPressed
    142 ;   Parameters:
    143 ;       CX:     Index of currently selected Menuitem
    144 ;       DL:     ASCII character
    145 ;       DH:     BIOS Scan Code
    146 ;       SS:BP:  Ptr to MENUVARS
    147 ;   Returns:
    148 ;       AX:     1 = Event processed
    149 ;   Corrupts registers:
    150 ;       BX, CX, DX, DS
    151 ;--------------------------------------------------------------------
    152 ALIGN JUMP_ALIGN
    153 BootMenuEvent_EventKeyPressed:
    154     mov     al, dl                  ; Copy ASCII char to AL
    155     sub     al, 'a'-'A'             ; To upper case character
    156     cmp     al, 'A'                 ; First possible drive letter?
    157     jb      SHORT .Return           ;  If below, return
    158     cmp     al, 'Z'                 ; Last possible drive letter?
    159     ja      SHORT .Return           ;  If above, return
    160     LOAD_BDA_SEGMENT_TO ds, dx
    161     mov     [BOOTVARS.bMenuHotkey], al
    162     jmp     SHORT BootMenuEvent_EventItemSelected
    163 .Return:
    164     mov     ax, 1
    165     ret
    166 
    167 
    168 ;--------------------------------------------------------------------
    169 ; Boot Menu event handler.
    170 ; Handles Menu Update notification (EVNT_MNU_UPD).
    171 ;
    172 ; BootMenuEvent_EventMenuDraw
    173 ;   Parameters:
    174 ;       CX:     Index of Menuitem to update (if MFL_UPD_ITEM set)
    175 ;       DL:     Update flag (only one):
    176 ;                   MFL_UPD_TITLE   Update Menu Title string(s)
    177 ;                   MFL_UPD_NFO     Update Menu Info string(s)
    178 ;                   MFL_UPD_ITEM    Update Menuitem string
    179 ;       SS:BP:  Ptr to MENUVARS
    180 ;   Returns:
    181 ;       AX:     Was event processed
    182 ;   Corrupts registers:
    183 ;       BX, CX, DX, SI, DI, DS
    184 ;--------------------------------------------------------------------
    185 ALIGN JUMP_ALIGN
    186 BootMenuEvent_EventMenuDraw:
    187     test    dl, MFL_UPD_ITEM        ; Need to update Menuitem?
    188     jnz     SHORT BootMenuEvent_DrawMenuitem
    189     test    dl, MFL_UPD_NFO         ; Need to update Info String(s)?
    190     jnz     SHORT BootMenuEvent_DrawInfo
    191     test    dl, MFL_UPD_TITLE       ; Need to update Title String(s)?
    192     jnz     SHORT BootMenuEvent_DrawTitle
    193     xor     ax, ax
    194     ret
    195 
    196 ;--------------------------------------------------------------------
    197 ; Draws Menuitem string. Cursor is set to a menuitem location.
    198 ;
    199 ; BootMenuEvent_DrawMenuitem
    200 ;   Parameters:
    201 ;       CX:     Index of Menuitem to draw
    202 ;       SS:BP:  Ptr to MENUVARS
    203 ;   Returns:
    204 ;       AX:     Was event processed
    205 ;   Corrupts registers:
    206 ;       BX, CX, DX, SI, DI, DS, ES
    207 ;--------------------------------------------------------------------
    208 ALIGN JUMP_ALIGN
    209 BootMenuEvent_DrawMenuitem:
    210     call    RamVars_GetSegmentToDS
    211     call    BootMenu_ConvertMenuitemToDriveOrFunction
    212     jc      SHORT .DrawFunctionItem
    213     call    BootMenuPrint_TranslatedDriveNumber
    214     test    dl, 80h                 ; Floppy drive?
    215     jz      SHORT .DrawFloppyDriveItem
    216     jmp     BootMenuPrint_HardDiskMenuitem
    217 ALIGN JUMP_ALIGN
    218 .DrawFunctionItem:
    219     jmp     BootMenuPrint_FunctionMenuitem
    220 ALIGN JUMP_ALIGN
    221 .DrawFloppyDriveItem:
    222     jmp     BootMenuPrint_FloppyMenuitem
    223 
    224 ;--------------------------------------------------------------------
    225 ; Draws information strings. Cursor is set to a first information line.
    226 ;
    227 ; BootMenuEvent_DrawInfo
    228 ;   Parameters:
    229 ;       CX:     Index of selected menuitem
    230 ;       SS:BP:  Ptr to MENUVARS
    231 ;   Returns:
    232 ;       AX:     Was event processed
    233 ;   Corrupts registers:
    234 ;       BX, CX, DX, SI, DI, DS, ES
    235 ;--------------------------------------------------------------------
    236 ALIGN JUMP_ALIGN
    237 BootMenuEvent_DrawInfo:
    238     call    RamVars_GetSegmentToDS
    239     call    BootMenu_ConvertMenuitemToDriveOrFunction
    240     jc      SHORT .DrawFunctionInfo
    241     test    dl, 80h                 ; Floppy drive?
    242     jz      SHORT .DrawFloppyDriveInfo
    243     jmp     BootMenuPrint_HardDiskMenuitemInformation
    244 ALIGN JUMP_ALIGN
    245 .DrawFunctionInfo:
    246     jmp     BootMenuPrint_FunctionMenuitemInformation
    247 ALIGN JUMP_ALIGN
    248 .DrawFloppyDriveInfo:
    249     jmp     BootMenuPrint_FloppyMenuitemInformation
    250 
    251 ;--------------------------------------------------------------------
    252 ; Draws title strings. Cursor is set to a first title line.
    253 ;
    254 ; BootMenuEvent_DrawTitle
    255 ;   Parameters:
    256 ;       SS:BP:  Ptr to MENUVARS
    257 ;   Returns:
    258 ;       AX:     Was event processed
    259 ;   Corrupts registers:
    260 ;       CX, DX, SI
    261 ;--------------------------------------------------------------------
    262 ALIGN JUMP_ALIGN
    263 BootMenuEvent_DrawTitle:
    264     jmp     BootMenuPrint_TitleStrings
    265 
    266 
    267 ;--------------------------------------------------------------------
    268 ; Boot Menu event handler.
    269 ; Handles Get Default Menuitem notification (EVNT_MNU_GETDEF).
    270 ;
    271 ; BootMenuEvent_EventGetDefaultMenuitem
    272 ;   Parameters:
    273 ;       SS:BP:  Ptr to MENUVARS
    274 ;   Returns:
    275 ;       AX:     Was event processed
    276 ;       CX:     Index of menuitem to set selected
    277 ;   Corrupts registers:
    278 ;       BX, CX, DX, DI, DS
    279 ;--------------------------------------------------------------------
    280 ALIGN JUMP_ALIGN
    281 BootMenuEvent_EventGetDefaultMenuitem:
    282     call    RamVars_GetSegmentToDS
     69.GetDefaultMenuitemToDX:
    28370    mov     dl, [cs:ROMVARS.bBootDrv]   ; Default boot drive
    28471    call    BootMenu_IsDriveInSystem
     
    28673    call    DriveXlate_SetDriveToSwap
    28774    call    BootMenu_ConvertDriveToMenuitem
    288     mov     ax, 1
     75    mov     dx, cx
    28976    ret
    29077ALIGN JUMP_ALIGN
    29178.DoNotSetDefaultMenuitem:
    292     xor     ax, ax
     79    xor     dx, dx                      ; Whatever appears first on boot menu
    29380    ret
     81
     82
     83; Parameters:
     84;   CX:         Index of new highlighted item
     85;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
     86ALIGN JUMP_ALIGN
     87.ItemHighlightedFromCX:
     88    push    cx
     89    push    dx
     90    call    RamVars_GetSegmentToDS
     91    call    DriveXlate_Reset
     92    call    BootMenu_ConvertMenuitemToDriveOrFunction
     93    jc      SHORT .UpdatePreviousAndNewMenuitem ; Selection changed to a function
     94    call    DriveXlate_SetDriveToSwap
     95
     96.UpdatePreviousAndNewMenuitem:
     97    pop     ax      ; Update previous item
     98    CALL_MENU_LIBRARY RefreshItemFromAX
     99    pop     ax      ; Update new item
     100    CALL_MENU_LIBRARY RefreshItemFromAX
     101    CALL_MENU_LIBRARY RefreshInformation
     102    stc
     103    ret
     104
     105
     106; Parameters:
     107;   AL:         ASCII character for the key
     108;   AH:         Keyboard library scan code for the key
     109ALIGN JUMP_ALIGN
     110.KeyStrokeInAX:
     111    xor     ah, ah                  ; ASCII drive letter now in AX
     112    call    BootMenu_ConvertHotkeyToMenuitem
     113    cmp     cx, [bp+MENUINIT.wItems]
     114    jae     SHORT .EventNotHandled  ; Invalid key
     115    xchg    ax, cx
     116    CALL_MENU_LIBRARY HighlightItemFromAX
     117    ; Fall to .ItemSelectedFromCX
     118
     119
     120; Parameters:
     121;   CX:         Index of selected item
     122ALIGN JUMP_ALIGN
     123.ItemSelectedFromCX:
     124    CALL_MENU_LIBRARY Close
     125.EventCompleted:
     126    stc
     127    ret
     128
     129
     130; Parameters:
     131;   CX:         Index of item to refresh
     132;   Cursor has been positioned to the beginning of item line
     133ALIGN JUMP_ALIGN
     134.RefreshItemFromCX:
     135    mov     bx, .rgwItemTypeRefresh
     136    jmp     SHORT .RefreshItemOrInformationWithJumpTableInCSBX
     137
     138
     139; Parameters:
     140;   CX:         Index of highlighted item
     141;   Cursor has been positioned to the beginning of first line
     142ALIGN JUMP_ALIGN
     143.RefreshInformation:
     144    mov     bx, .rgwInformationItemTypeRefresh
     145    ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
     146
     147;--------------------------------------------------------------------
     148; RefreshItemOrInformationWithJumpTableInCSBX
     149;   Parameters:
     150;       CX:     Index of selected menuitem
     151;       CS:BX:  Ptr to ITEM_TYPE_REFRESH jump table
     152;   Returns:
     153;       CF:     set since event processed
     154;--------------------------------------------------------------------
     155ALIGN JUMP_ALIGN
     156.RefreshItemOrInformationWithJumpTableInCSBX:
     157    cmp     cl, NO_ITEM_HIGHLIGHTED
     158    je      SHORT .EventCompleted
     159
     160    call    RamVars_GetSegmentToDS
     161    call    BootMenu_ConvertMenuitemToDriveOrFunction
     162    jc      SHORT .DrawFunction
     163    test    dl, 80h                 ; Floppy drive?
     164    jz      SHORT .DrawFloppyDrive
     165    jmp     [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
     166ALIGN JUMP_ALIGN
     167.DrawFunction:
     168    jmp     [cs:bx+ITEM_TYPE_REFRESH.SpecialFunction]
     169ALIGN JUMP_ALIGN
     170.DrawFloppyDrive:
     171    jmp     [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
     172
     173; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
     174ALIGN WORD_ALIGN
     175.rgwItemTypeRefresh:
     176istruc ITEM_TYPE_REFRESH
     177    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitem
     178    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitem
     179    at  ITEM_TYPE_REFRESH.SpecialFunction,  dw  BootMenuPrint_FunctionMenuitem
     180iend
     181.rgwInformationItemTypeRefresh:
     182istruc ITEM_TYPE_REFRESH
     183    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitemInformation
     184    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitemInformation
     185    at  ITEM_TYPE_REFRESH.SpecialFunction,  dw  BootMenuPrint_ClearInformationArea
     186iend
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r84 r88  
    1 ; File name     :   BootMenuPrint.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   26.3.2010
    4 ; Last update   :   14.1.2011
    5 ; Author        :   Tomi Tilli,
    6 ;               :   Krister Nordvall (optimizations)
     1; Project name  :   XTIDE Universal BIOS
    72; Description   :   Functions for printing boot menu strings.
    83
    94; Section containing code
    105SECTION .text
     6
     7;--------------------------------------------------------------------
     8; Prints Boot Menu title strings.
     9;
     10; BootMenuPrint_TitleStrings
     11;   Parameters:
     12;       Nothing
     13;   Returns:
     14;       CF:     Set since menu event handled
     15;   Corrupts registers:
     16;       AX, SI, DI
     17;--------------------------------------------------------------------
     18ALIGN JUMP_ALIGN
     19BootMenuPrint_TitleStrings:
     20    mov     si, ROMVARS.szTitle
     21    call    PrintNullTerminatedStringFromCSSIandSetCF
     22    call    BootMenuPrint_Newline
     23    mov     si, ROMVARS.szVersion
     24    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     25
     26
     27;--------------------------------------------------------------------
     28; BootMenuPrint_Newline
     29;   Parameters:
     30;       Nothing
     31;   Returns:
     32;       Nothing
     33;   Corrupts registers:
     34;       AX, DI
     35;--------------------------------------------------------------------
     36ALIGN JUMP_ALIGN
     37BootMenuPrint_Newline:
     38    CALL_DISPLAY_LIBRARY PrintNewlineCharacters
     39    ret
     40
     41
     42;--------------------------------------------------------------------
     43; Prints Floppy Drive hotkey string.
     44;
     45; BootMenuPrint_FloppyHotkeyString
     46;   Parameters:
     47;       BL:     Number of floppy drives in system
     48;   Returns:
     49;       Nothing
     50;   Corrupts registers:
     51;       AX, SI
     52;--------------------------------------------------------------------
     53ALIGN JUMP_ALIGN
     54BootMenuPrint_FloppyHotkeyString:
     55    test    bl, bl                  ; Any floppy drives?
     56    jz      SHORT NoFloppyDrivesOrHardDisksToPrint
     57    push    bp
     58
     59    mov     bp, sp
     60    mov     al, 'A'
     61    push    ax                      ; 'A'
     62    dec     ax
     63    add     al, bl
     64    push    ax                      ; Last floppy drive letter
     65    ePUSH_T ax, g_szFDD
     66    ePUSH_T ax, g_szHDD
     67    jmp     SHORT PrintHotkeyString
     68
     69;--------------------------------------------------------------------
     70; Prints Hard Disk hotkey string.
     71;
     72; BootMenuPrint_FloppyHotkeyString
     73;   Parameters:
     74;       BH:     Number of hard disks in system
     75;   Returns:
     76;       Nothing
     77;   Corrupts registers:
     78;       AX, CX, SI
     79;--------------------------------------------------------------------
     80ALIGN JUMP_ALIGN
     81BootMenuPrint_HardDiskHotkeyString:
     82    test    bh, bh                  ; Any hard disks?
     83    jz      SHORT NoFloppyDrivesOrHardDisksToPrint
     84    push    bp
     85
     86    mov     bp, sp
     87    call    BootMenu_GetLetterForFirstHardDisk
     88    push    cx                      ; First hard disk letter
     89    dec     cx
     90    add     cl, bh
     91    push    cx                      ; Last hard disk letter
     92    ePUSH_T ax, g_szHDD
     93    ePUSH_T ax, g_szFDD
     94    ; Fall to PrintHotkeyString
     95
     96ALIGN JUMP_ALIGN
     97PrintHotkeyString:
     98    mov     si, g_szBottomScrn
     99    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     100NoFloppyDrivesOrHardDisksToPrint:
     101    ret
     102
     103;--------------------------------------------------------------------
     104; BootMenuPrint_ClearScreen
     105;   Parameters:
     106;       Nothing
     107;   Returns:
     108;       Nothing
     109;   Corrupts registers:
     110;       AX
     111;--------------------------------------------------------------------
     112ALIGN JUMP_ALIGN
     113BootMenuPrint_ClearScreen:
     114    push    di
     115    mov     ax, ' ' | (MONO_NORMAL<<8)
     116    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
     117    pop     di
     118    ret
     119
     120
     121;--------------------------------------------------------------------
     122; Translates and prints drive number.
     123;
     124; BootMenuPrint_TranslatedDriveNumber
     125;   Parameters:
     126;       DL:     Untranslated drive number
     127;       DS:     RAMVARS segment
     128;   Returns:
     129;       Nothing
     130;   Corrupts registers:
     131;       AX, DI
     132;--------------------------------------------------------------------
     133ALIGN JUMP_ALIGN
     134BootMenuPrint_TranslatedDriveNumber:
     135    push    dx
     136    push    bx
     137
     138    call    DriveXlate_ToOrBack
     139    eMOVZX  ax, dl      ; Drive number to AL
     140    CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
     141    mov     al, ' '     ; Print space
     142    CALL_DISPLAY_LIBRARY PrintCharacterFromAL
     143
     144    pop     bx
     145    pop     dx
     146    ret
     147
     148
     149;--------------------------------------------------------------------
     150; BootMenuPrint_FloppyMenuitem
     151;   Parameters:
     152;       DL:     Untranslated Floppy Drive number
     153;   Returns:
     154;       Nothing
     155;   Corrupts registers:
     156;       AX, DX, SI
     157;--------------------------------------------------------------------
     158ALIGN JUMP_ALIGN
     159BootMenuPrint_FloppyMenuitem:
     160    push    bp
     161
     162    mov     bp, sp
     163    mov     si, g_szFDLetter
     164    ePUSH_T ax, g_szFloppyDrv
     165    add     dl, 'A'
     166    push    dx                  ; Drive letter
     167    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     168
     169
     170;--------------------------------------------------------------------
     171; BootMenuPrint_HardDiskMenuitem
     172;   Parameters:
     173;       DL:     Untranslated Hard Disk number
     174;       DS:     RAMVARS segment
     175;   Returns:
     176;       CF:     Set since menu event handled
     177;   Corrupts registers:
     178;       AX, BX, SI, DI
     179;--------------------------------------------------------------------
     180ALIGN JUMP_ALIGN
     181BootMenuPrint_HardDiskMenuitem:
     182    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
     183    jnc     SHORT .HardDiskMenuitemForForeignDrive
     184    ; Fall to .HardDiskMenuitemForOurDrive
     185
     186;--------------------------------------------------------------------
     187; .HardDiskMenuitemForOurDrive
     188;   Parameters:
     189;       DL:     Untranslated Hard Disk number
     190;       DS:     RAMVARS segment
     191;   Returns:
     192;       CF:     Set since menu event handled
     193;   Corrupts registers:
     194;       AX, BX, SI, DI
     195;--------------------------------------------------------------------
     196;ALIGN JUMP_ALIGN
     197.HardDiskMenuitemForOurDrive:
     198    call    BootInfo_GetOffsetToBX
     199    lea     si, [bx+BOOTNFO.szDrvName]
     200    xor     bx, bx          ; BDA segment
     201    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
     202    stc
     203    ret
     204
     205;--------------------------------------------------------------------
     206; BootMenuPrint_HardDiskMenuitemForForeignDrive
     207;   Parameters:
     208;       DL:     Untranslated Hard Disk number
     209;       DS:     RAMVARS segment
     210;   Returns:
     211;       CF:     Set since menu event handled
     212;   Corrupts registers:
     213;       AX, SI, DI
     214;--------------------------------------------------------------------
     215ALIGN JUMP_ALIGN
     216.HardDiskMenuitemForForeignDrive:
     217    mov     si, g_szforeignHD
     218    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     219
     220
     221;--------------------------------------------------------------------
     222; BootMenuPrint_FunctionMenuitem
     223;   Parameters:
     224;       DX:     Function ID
     225;   Returns:
     226;       CF:     Set if menu event was handled successfully
     227;   Corrupts registers:
     228;       AX, DX, SI, DI
     229;--------------------------------------------------------------------
     230ALIGN JUMP_ALIGN
     231BootMenuPrint_FunctionMenuitem:
     232    test    dx, dx                  ; ID_BOOTFUNC_ROMBOOT
     233    jz      SHORT .PrintRomBootMenuitem
     234    ret
     235
     236ALIGN JUMP_ALIGN
     237.PrintRomBootMenuitem:
     238    mov     si, g_szRomBoot
     239    jmp     PrintNullTerminatedStringFromCSSIandSetCF
     240
     241
     242;--------------------------------------------------------------------
     243; BootMenuPrint_FloppyMenuitemInformation
     244;   Parameters:
     245;       DL:     Untranslated Floppy Drive number
     246;       DS:     RAMVARS segment
     247;   Returns:
     248;       CF:     Set since menu event was handled successfully
     249;   Corrupts registers:
     250;       AX, BX, CX, DX, SI, DI, ES
     251;--------------------------------------------------------------------
     252ALIGN JUMP_ALIGN
     253BootMenuPrint_FloppyMenuitemInformation:
     254    call    BootMenuPrint_ClearInformationArea
     255    call    FloppyDrive_GetType         ; Get Floppy Drive type to BX
     256    test    bx, bx                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
     257    jz      SHORT .PrintXTFloppyType
     258    cmp     bl, FLOPPY_TYPE_35_ED
     259    ja      SHORT .PrintUnknownFloppyType
     260    jmp     SHORT .PrintKnownFloppyType
     261
     262;--------------------------------------------------------------------
     263; .PrintXTFloppyType
     264;   Parameters:
     265;       Nothing
     266;   Returns:
     267;       CF:     Set since menu event was handled successfully
     268;   Corrupts registers:
     269;       AX, SI, DI
     270;--------------------------------------------------------------------
     271ALIGN JUMP_ALIGN
     272.PrintXTFloppyType:
     273    push    bp
     274    mov     si, g_szFddSizeOr
     275    jmp     SHORT .FormatXTorUnknownTypeFloppyDrive
     276
     277;--------------------------------------------------------------------
     278; .PrintUnknownFloppyType
     279;   Parameters:
     280;       Nothing
     281;   Returns:
     282;       CF:     Set since menu event was handled successfully
     283;   Corrupts registers:
     284;       AX, SI, DI
     285;--------------------------------------------------------------------
     286ALIGN JUMP_ALIGN
     287.PrintUnknownFloppyType:
     288    push    bp
     289    mov     si, g_szFddUnknown
     290.FormatXTorUnknownTypeFloppyDrive:
     291    mov     bp, sp
     292    ePUSH_T ax, g_szCapacity
     293    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     294
     295;--------------------------------------------------------------------
     296; .PrintKnownFloppyType
     297;   Parameters:
     298;       BX:     Floppy drive type
     299;   Returns:
     300;       CF:     Set since menu event was handled successfully
     301;   Corrupts registers:
     302;       AX, BX, SI, DI
     303;--------------------------------------------------------------------
     304ALIGN JUMP_ALIGN
     305.PrintKnownFloppyType:
     306    push    bp
     307
     308    mov     bp, sp
     309    mov     si, g_szFddSize
     310    ePUSH_T ax, g_szCapacity
     311    dec     bx                      ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
     312    shl     bx, 1                   ; Shift for WORD lookup
     313    mov     ax, [cs:bx+.rgwPhysicalSize]
     314    push    ax                      ; '5' or '3'
     315    mov     al, ah
     316    push    ax                      ; '1/4' or '1/2'
     317    push    WORD [cs:bx+.rgwCapacity]
     318    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
     319
     320ALIGN WORD_ALIGN
     321.rgwCapacity:
     322    dw      360
     323    dw      1200
     324    dw      720
     325    dw      1440
     326    dw      2880
     327    dw      2880
     328.rgwPhysicalSize:
     329    db      '5', 172    ; 1, FLOPPY_TYPE_525_DD
     330    db      '5', 172    ; 2, FLOPPY_TYPE_525_HD
     331    db      '3', 171    ; 3, FLOPPY_TYPE_35_DD
     332    db      '3', 171    ; 4, FLOPPY_TYPE_35_HD
     333    db      '3', 171    ; 5, 3.5" ED on some BIOSes
     334    db      '3', 171    ; 6, FLOPPY_TYPE_35_ED
     335
     336
     337;--------------------------------------------------------------------
     338; Prints Hard Disk Menuitem information strings.
     339;
     340; BootMenuPrint_HardDiskMenuitemInformation
     341;   Parameters:
     342;       DL:     Untranslated Hard Disk number
     343;       DS:     RAMVARS segment
     344;   Returns:
     345;       CF:     Set since menu event was handled successfully
     346;   Corrupts registers:
     347;       BX, CX, DX, SI, DI, ES
     348;--------------------------------------------------------------------
     349ALIGN JUMP_ALIGN
     350BootMenuPrint_HardDiskMenuitemInformation:
     351    call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
     352    jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
     353    call    .HardDiskMenuitemInfoSizeForOurDrive
     354    jmp     BootMenuPrintCfg_ForOurDrive
     355
     356;--------------------------------------------------------------------
     357; .HardDiskMenuitemInfoForForeignDrive
     358;   Parameters:
     359;       DL:     Untranslated Hard Disk number
     360;       DS:     RAMVARS segment
     361;   Returns:
     362;       CF:     Set since menu event was handled successfully
     363;   Corrupts registers:
     364;       AX, BX, CX, DX, SI, DI
     365;--------------------------------------------------------------------
     366ALIGN JUMP_ALIGN
     367.HardDiskMenuitemInfoForForeignDrive:
     368    push    bp
     369    mov     bp, sp
     370    ePUSH_T ax, g_szCapacity
     371
     372    call    DriveXlate_ToOrBack
     373    call    HCapacity_GetSectorCountFromForeignAH08h
     374    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     375
     376    mov     si, g_szSizeSingle
     377    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
     378
     379;--------------------------------------------------------------------
     380; .HardDiskMenuitemInfoSizeForOurDrive
     381;   Parameters:
     382;       DL:     Untranslated Hard Disk number
     383;       DS:DI:  Ptr to DPT
     384;   Returns:
     385;       Nothing
     386;   Corrupts registers:
     387;       AX, BX, CX, DX, SI, ES
     388;--------------------------------------------------------------------
     389ALIGN JUMP_ALIGN
     390.HardDiskMenuitemInfoSizeForOurDrive:
     391    push    bp
     392    mov     bp, sp
     393    ePUSH_T ax, g_szCapacity
     394
     395    ; Get and push L-CHS size
     396    call    HCapacity_GetSectorCountFromOurAH08h
     397    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     398
     399    ; Get and push total LBA size
     400    call    BootInfo_GetTotalSectorCount
     401    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     402
     403    mov     si, g_szSizeDual
     404    ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
     405
     406
     407;--------------------------------------------------------------------
     408; BootMenuPrint_FormatCSSIfromParamsInSSBP
     409;   Parameters:
     410;       CS:SI:  Ptr to string to format
     411;       SS:BP:  Ptr to format parameters
     412;   Returns:
     413;       BP:     Popped from stack
     414;   Corrupts registers:
     415;       AX
     416;--------------------------------------------------------------------
     417ALIGN JUMP_ALIGN
     418BootMenuPrint_FormatCSSIfromParamsInSSBP:
     419    push    di
     420    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
     421    stc             ; Successfull return from menu event
     422    pop     di
     423    pop     bp
     424    ret
     425
     426
     427;--------------------------------------------------------------------
     428; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     429;   Parameters:
     430;       BX:DX:AX:   Sector count
     431;   Returns:
     432;       Size in stack
     433;   Corrupts registers:
     434;       AX, BX, CX, DX, SI
     435;--------------------------------------------------------------------
     436ALIGN JUMP_ALIGN
     437ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
     438    pop     si      ; Pop return address
     439    call    Size_ConvertSectorCountInBXDXAXtoKiB
     440    mov     cx, BYTE_MULTIPLES.kiB
     441    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
     442    push    ax      ; Size in magnitude
     443    push    cx      ; Tenths
     444    push    dx      ; Magnitude character
     445    jmp     si
     446
     447
     448;--------------------------------------------------------------------
     449; PrintNullTerminatedStringFromCSSIandSetCF
     450;   Parameters:
     451;       CS:SI:  Ptr to NULL terminated string to print
     452;   Returns:
     453;       CF:     Set since menu event was handled successfully
     454;   Corrupts registers:
     455;       AX, DI
     456;--------------------------------------------------------------------
     457ALIGN JUMP_ALIGN
     458PrintNullTerminatedStringFromCSSIandSetCF:
     459    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
     460    stc
     461    ret
     462
     463
     464;--------------------------------------------------------------------
     465; BootMenuPrint_ClearInformationArea
     466;   Parameters:
     467;       Nothing
     468;   Returns:
     469;       CF:     Set
     470;   Corrupts registers:
     471;       AX, DI
     472;--------------------------------------------------------------------
     473ALIGN JUMP_ALIGN
     474BootMenuPrint_ClearInformationArea:
     475    CALL_MENU_LIBRARY ClearInformationArea
     476    stc
     477    ret
     478
    11479
    12480;--------------------------------------------------------------------
     
    70538ALIGN JUMP_ALIGN
    71539BootMenuPrint_SetCursorPosition:
    72     push    bx
    73     call    MenuCrsr_SetCursor
    74     pop     bx
    75     ret
    76 
    77 
    78 ;--------------------------------------------------------------------
    79 ; Prints Floppy Drive hotkey string.
    80 ;
    81 ; BootMenuPrint_FloppyHotkeyString
    82 ;   Parameters:
    83 ;       BL:     Number of floppy drives in system
    84 ;   Returns:
    85 ;       Nothing
    86 ;   Corrupts registers:
    87 ;       AX, CX, DX, SI
    88 ;--------------------------------------------------------------------
    89 ALIGN JUMP_ALIGN
    90 BootMenuPrint_FloppyHotkeyString:
    91     test    bl, bl                  ; Any floppy drives?
    92     jz      .Return
    93     ePUSH_T ax, g_szHDD
    94     ePUSH_T ax, g_szFDD
    95     mov     ax, 'A'-1
    96     add     al, bl                  ; Last Floppy Drive letter
    97     push    ax
    98     ePUSH_T ax, 'A'
    99     jmp     SHORT BootMenuPrint_HotkeyString
    100 .Return:
    101     ret
    102 
    103 ;--------------------------------------------------------------------
    104 ; Prints Floppy Drive or Hard Disk hotkey string when
    105 ; parameters are pushed to stack.
    106 ;
    107 ; BootMenuPrint_HotkeyString
    108 ;   Parameters:
    109 ;       Stack:  String formatting parameters
    110 ;   Returns:
    111 ;       Nothing
    112 ;   Corrupts registers:
    113 ;       AX, CX, DX, SI
    114 ;--------------------------------------------------------------------
    115 ALIGN JUMP_ALIGN
    116 BootMenuPrint_HotkeyString:
    117     mov     si, g_szBottomScrn
    118     mov     dh, 8                   ; 8 bytes pushed to stack
    119     jmp     PrintString_JumpToFormat
    120 
    121 
    122 ;--------------------------------------------------------------------
    123 ; Prints Hard Disk hotkey string.
    124 ;
    125 ; BootMenuPrint_FloppyHotkeyString
    126 ;   Parameters:
    127 ;       BH:     Number of hard disks in system
    128 ;   Returns:
    129 ;       Nothing
    130 ;   Corrupts registers:
    131 ;       AX, CX, DX, SI
    132 ;--------------------------------------------------------------------
    133 ALIGN JUMP_ALIGN
    134 BootMenuPrint_HardDiskHotkeyString:
    135     test    bh, bh                  ; Any hard disks?
    136     jz      .Return
    137     ePUSH_T ax, g_szFDD
    138     ePUSH_T ax, g_szHDD
    139     call    BootMenu_GetLetterForFirstHardDisk
    140     eMOVZX  ax, bh                  ; Hard disk count to AX
    141     add     ax, cx                  ; One past last hard disk letter
    142     dec     ax                      ; Last hard disk letter
    143     push    ax
    144     push    cx
    145     jmp     SHORT BootMenuPrint_HotkeyString
    146 .Return:
    147     ret
    148 
    149 
    150 ;--------------------------------------------------------------------
    151 ; Clears screen.
    152 ;
    153 ; BootMenuPrint_ClearScreen
    154 ;   Parameters:
    155 ;       Nothing
    156 ;   Returns:
    157 ;       Nothing
    158 ;   Corrupts registers:
    159 ;       AX, BX, DX
    160 ;--------------------------------------------------------------------
    161 ALIGN JUMP_ALIGN
    162 BootMenuPrint_ClearScreen:
    163     push    cx
    164     call    MenuDraw_ClrScr
    165     pop     cx
    166     ret
    167 
    168 
    169 ;--------------------------------------------------------------------
    170 ; Translates and prints drive number.
    171 ;
    172 ; BootMenuPrint_TranslatedDriveNumber
    173 ;   Parameters:
    174 ;       DL:     Untranslated drive number
    175 ;       DS:     RAMVARS segment
    176 ;   Returns:
    177 ;       Nothing
    178 ;   Corrupts registers:
    179 ;       AX, DI
    180 ;--------------------------------------------------------------------
    181 ALIGN JUMP_ALIGN
    182 BootMenuPrint_TranslatedDriveNumber:
    183     push    dx
    184     call    DriveXlate_ToOrBack
    185     mov     al, dl                      ; Drive number to AL
    186     call    Print_IntHexB
    187     mov     dl, ' '
    188     PRINT_CHAR                          ; Print space
    189     pop     dx
    190     ret
    191 
    192 
    193 ;--------------------------------------------------------------------
    194 ; Prints Floppy Drive Menuitem string.
    195 ;
    196 ; BootMenuPrint_FloppyMenuitem
    197 ;   Parameters:
    198 ;       DL:     Untranslated Floppy Drive number
    199 ;   Returns:
    200 ;       AX:     1 if drive number was valid
    201 ;               0 if drive number was invalid
    202 ;   Corrupts registers:
    203 ;       CX, DX, SI
    204 ;--------------------------------------------------------------------
    205 ALIGN JUMP_ALIGN
    206 BootMenuPrint_FloppyMenuitem:
    207     ePUSH_T ax, BootMenuPrint_HardDiskPrinted   ; Return address
    208     add     dl, 'A'             ; Number to letter
    209     push    dx
    210     ePUSH_T ax, g_szFloppyDrv
    211     mov     si, g_szFDLetter
    212     mov     dh, 4               ; 4 bytes pushed to stack
    213     jmp     PrintString_JumpToFormat
    214 
    215 
    216 ;--------------------------------------------------------------------
    217 ; Prints Hard Disk Menuitem string.
    218 ;
    219 ; BootMenuPrint_HardDiskMenuitem
    220 ;   Parameters:
    221 ;       DL:     Untranslated Hard Disk number
    222 ;       DS:     RAMVARS segment
    223 ;   Returns:
    224 ;       AX:     1 if drive number was valid
    225 ;               0 if drive number was invalid
    226 ;   Corrupts registers:
    227 ;       CX, DX, SI, ES
    228 ;--------------------------------------------------------------------
    229 ALIGN JUMP_ALIGN
    230 BootMenuPrint_HardDiskMenuitem:
    231     ePUSH_T ax, BootMenuPrint_HardDiskPrinted
    232     call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
    233     jnc     SHORT BootMenuPrint_HardDiskMenuitemForForeignDrive
    234     jmp     SHORT BootMenuPrint_HardDiskMenuitemForOurDrive
    235 ALIGN JUMP_ALIGN
    236 BootMenuPrint_HardDiskPrinted:
    237     mov     ax, 1
    238     ret
    239 
    240 ;--------------------------------------------------------------------
    241 ; Prints Hard Disk Menuitem string for drive that is handled by
    242 ; some another BIOS.
    243 ;
    244 ; BootMenuPrint_HardDiskMenuitemForForeignDrive
    245 ;   Parameters:
    246 ;       DL:     Untranslated Hard Disk number
    247 ;       DS:     RAMVARS segment
    248 ;   Returns:
    249 ;       AX:     1 if drive number was valid
    250 ;               0 if drive number was invalid
    251 ;   Corrupts registers:
    252 ;       CX, DX, SI
    253 ;--------------------------------------------------------------------
    254 ALIGN JUMP_ALIGN
    255 BootMenuPrint_HardDiskMenuitemForForeignDrive:
    256     mov     si, g_szforeignHD
    257     jmp     PrintString_FromCS
    258 
    259 ;--------------------------------------------------------------------
    260 ; Prints Hard Disk Menuitem string for drive that is handled by our BIOS.
    261 ;
    262 ; BootMenuPrint_HardDiskMenuitemForOurDrive
    263 ;   Parameters:
    264 ;       DL:     Untranslated Hard Disk number
    265 ;       DS:     RAMVARS segment
    266 ;   Returns:
    267 ;       AX:     1 if drive number was valid
    268 ;               0 if drive number was invalid
    269 ;   Corrupts registers:
    270 ;       CX, DX, SI, ES
    271 ;--------------------------------------------------------------------
    272 ALIGN JUMP_ALIGN
    273 BootMenuPrint_HardDiskMenuitemForOurDrive:
    274     call    BootInfo_GetOffsetToBX
    275     LOAD_BDA_SEGMENT_TO es, ax
    276     lea     si, [bx+BOOTNFO.szDrvName]
    277     jmp     PrintString_FromES
    278 
    279 
    280 ;--------------------------------------------------------------------
    281 ; Prints Function Menuitem string.
    282 ;
    283 ; BootMenuPrint_FunctionMenuitem
    284 ;   Parameters:
    285 ;       DX:     Function ID
    286 ;   Returns:
    287 ;       AX:     1 if function ID was valid
    288 ;               0 if function ID was invalid
    289 ;   Corrupts registers:
    290 ;       DX, SI
    291 ;--------------------------------------------------------------------
    292 ALIGN JUMP_ALIGN
    293 BootMenuPrint_FunctionMenuitem:
    294     test    dx, dx                  ; ID_BOOTFUNC_ROMBOOT
    295     jz      SHORT .PrintRomBootMenuitem
    296     xor     ax, ax                  ; Event not processed
    297     ret
    298 
    299 ALIGN JUMP_ALIGN
    300 .PrintRomBootMenuitem:
    301     mov     si, g_szRomBoot
    302     ; Fall to .PrintAndReturn
    303 
    304 ALIGN JUMP_ALIGN
    305 .PrintAndReturn:
    306     call    PrintString_FromCS
    307     mov     ax, 1                   ; Event processed
    308     ret
    309 
    310 
    311 ;--------------------------------------------------------------------
    312 ; Prints Floppy Drive Menuitem information strings.
    313 ;
    314 ; BootMenuPrint_FloppyMenuitemInformation
    315 ;   Parameters:
    316 ;       DL:     Untranslated Floppy Drive number
    317 ;       DS:     RAMVARS segment
    318 ;   Returns:
    319 ;       AX:     1 if drive number was valid
    320 ;               0 if drive number was invalid
    321 ;   Corrupts registers:
    322 ;       BX, CX, DX, SI, DI, ES
    323 ;--------------------------------------------------------------------
    324 ALIGN JUMP_ALIGN
    325 BootMenuPrint_FloppyMenuitemInformation:
    326     call    FloppyDrive_GetType                     ; Get Floppy Drive type to BX
    327     ePUSH_T ax, BootMenuPrint_ClearThreeInfoLines   ; New return address
    328     test    bx, bx                                  ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
    329     jz      SHORT BootMenuPrint_PrintXTFloppyType
    330     cmp     bl, FLOPPY_TYPE_35_ED
    331     ja      SHORT BootMenuPrint_PrintUnknownFloppyType
    332     jmp     SHORT BootMenuPrint_PrintKnownFloppyType
    333 
    334 ;--------------------------------------------------------------------
    335 ; Prints Menuitem information string for two possible XT floppy drives.
    336 ;
    337 ; BootMenuPrint_PrintXTFloppyType
    338 ;   Parameters:
    339 ;       Nothing
    340 ;   Returns:
    341 ;       Nothing
    342 ;   Corrupts registers:
    343 ;       CX, DX, SI
    344 ;--------------------------------------------------------------------
    345 ALIGN JUMP_ALIGN
    346 BootMenuPrint_PrintXTFloppyType:
    347     mov     si, g_szFddSizeOr
    348     jmp     SHORT BootMenuPrint_FormatUnknownFloppyType
    349 
    350 ;--------------------------------------------------------------------
    351 ; Prints Menuitem information string for unknown floppy drive type.
    352 ;
    353 ; BootMenuPrint_PrintUnknownFloppyType
    354 ;   Parameters:
    355 ;       Nothing
    356 ;   Returns:
    357 ;       Nothing
    358 ;   Corrupts registers:
    359 ;       CX, DX, SI
    360 ;--------------------------------------------------------------------
    361 ALIGN JUMP_ALIGN
    362 BootMenuPrint_PrintUnknownFloppyType:
    363     mov     si, g_szFddUnknown
    364 BootMenuPrint_FormatUnknownFloppyType:
    365     ePUSH_T ax, g_szCapacity
    366     mov     dh, 2                   ; 2 bytes pushed to stack
    367     jmp     PrintString_JumpToFormat
    368 
    369 ;--------------------------------------------------------------------
    370 ; Prints Menuitem information string for known floppy drive type.
    371 ;
    372 ; BootMenuPrint_PrintKnownFloppyType
    373 ;   Parameters:
    374 ;       BX:     Floppy drive type
    375 ;   Returns:
    376 ;       Nothing
    377 ;   Corrupts registers:
    378 ;       CX, DX, SI
    379 ;--------------------------------------------------------------------
    380 ALIGN JUMP_ALIGN
    381 BootMenuPrint_PrintKnownFloppyType:
    382     dec     bx                      ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
    383     shl     bx, 1                   ; Shift for WORD lookup
    384     push    WORD [cs:bx+.rgwCapacity]
    385     mov     ax, [cs:bx+.rgwPhysicalSize]
    386     push    ax                      ; '1/4' or '1/2'
    387     mov     al, ah
    388     push    ax                      ; '5' or '3'
    389     ePUSH_T ax, g_szCapacity
    390     mov     si, g_szFddSize
    391     mov     dh, 8                   ; 8 bytes pushed to stack
    392     jmp     PrintString_JumpToFormat
    393 ALIGN WORD_ALIGN
    394 .rgwCapacity:
    395     dw      360
    396     dw      1200
    397     dw      720
    398     dw      1440
    399     dw      2880
    400     dw      2880
    401 .rgwPhysicalSize:
    402     db      172, '5'    ; 1, FLOPPY_TYPE_525_DD
    403     db      172, '5'    ; 2, FLOPPY_TYPE_525_HD
    404     db      171, '3'    ; 3, FLOPPY_TYPE_35_DD
    405     db      171, '3'    ; 4, FLOPPY_TYPE_35_HD
    406     db      171, '3'    ; 5, 3.5" ED on some BIOSes
    407     db      171, '3'    ; 6, FLOPPY_TYPE_35_ED
    408 
    409 
    410 ;--------------------------------------------------------------------
    411 ; Clears remaining characters from current information line
    412 ; and clears following lines.
    413 ;
    414 ; BootMenuPrint_ClearThreeInfoLines
    415 ; BootMenuPrint_ClearTwoInfoLines
    416 ; BootMenuPrint_ClearOneInfoLine
    417 ;   Parameters:
    418 ;       Nothing
    419 ;   Returns:
    420 ;       AX:     1
    421 ;   Corrupts registers:
    422 ;       BX, DX
    423 ;--------------------------------------------------------------------
    424 ALIGN JUMP_ALIGN
    425 BootMenuPrint_ClearThreeInfoLines:
    426     call    MenuDraw_NewlineStrClrLn
    427 ALIGN JUMP_ALIGN
    428 BootMenuPrint_ClearTwoInfoLines:
    429     call    MenuDraw_NewlineStrClrLn
    430 ALIGN JUMP_ALIGN
    431 BootMenuPrint_ClearOneInfoLine:
    432     call    MenuDraw_NewlineStrClrLn
    433     mov     ax, 1
    434     ret
    435 
    436 
    437 ;--------------------------------------------------------------------
    438 ; Prints Hard Disk Menuitem information strings.
    439 ;
    440 ; BootMenuPrint_HardDiskMenuitemInformation
    441 ;   Parameters:
    442 ;       DL:     Untranslated Hard Disk number
    443 ;       DS:     RAMVARS segment
    444 ;   Returns:
    445 ;       AX:     1 if drive number was valid
    446 ;               0 if drive number was invalid
    447 ;   Corrupts registers:
    448 ;       BX, CX, DX, SI, DI, ES
    449 ;--------------------------------------------------------------------
    450 ALIGN JUMP_ALIGN
    451 BootMenuPrint_HardDiskMenuitemInformation:
    452     ePUSH_T ax, BootMenuPrint_HardDiskPrinted
    453     call    FindDPT_ForDriveNumber      ; DS:DI to point DPT
    454     jnc     SHORT BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
    455     call    BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
    456     jmp     BootMenuPrintCfg_ForOurDrive
    457 
    458 ;--------------------------------------------------------------------
    459 ; Prints Hard Disk Menuitem information strings for drive that
    460 ; is handled by some other BIOS.
    461 ;
    462 ; BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
    463 ;   Parameters:
    464 ;       DL:     Untranslated Hard Disk number
    465 ;       DS:     RAMVARS segment
    466 ;   Returns:
    467 ;       Nothing
    468 ;   Corrupts registers:
    469 ;       AX, BX, CX, DX, SI, DI
    470 ;--------------------------------------------------------------------
    471 ALIGN JUMP_ALIGN
    472 BootMenuPrint_HardDiskMenuitemInfoForForeignDrive:
    473     call    DriveXlate_ToOrBack
    474     call    HCapacity_GetSectorCountFromForeignAH08h
    475     call    HCapacity_ConvertSectorCountToSize
    476     ePUSH_T dx, BootMenuPrint_ClearThreeInfoLines   ; Return address
    477     push    cx                          ; Magnitude character
    478     push    si                          ; Tenths
    479     push    ax                          ; Size in magnitude
    480     ePUSH_T ax, g_szCapacity            ; "Capacity"
    481     mov     si, g_szSizeSingle
    482     mov     dh, 8                       ; 8 bytes pushed to stack
    483     jmp     PrintString_JumpToFormat
    484 
    485 ;--------------------------------------------------------------------
    486 ; Prints Hard Disk Menuitem information size string for drive that
    487 ; is handled by our BIOS.
    488 ;
    489 ; BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
    490 ;   Parameters:
    491 ;       DL:     Untranslated Hard Disk number
    492 ;       DS:DI:  Ptr to DPT
    493 ;   Returns:
    494 ;       Nothing
    495 ;   Corrupts registers:
    496 ;       AX, BX, CX, DX, SI, ES
    497 ;--------------------------------------------------------------------
    498 ALIGN JUMP_ALIGN
    499 BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive:
    500     ePUSH_T ax, BootMenuPrint_ClearOneInfoLine  ; Return address
    501 
    502     ; Get and push total LBA size
    503     call    BootInfo_GetTotalSectorCount
    504     call    HCapacity_ConvertSectorCountToSize
    505     push    cx                              ; Magnitude character
    506     push    si                              ; Tenths
    507     push    ax                              ; Size in magnitude
    508 
    509     ; Get and push L-CHS size
    510     mov     dl, [di+DPT.bDrvNum]            ; Restore drive number
    511     call    HCapacity_GetSectorCountFromOurAH08h
    512     call    HCapacity_ConvertSectorCountToSize
    513     push    cx                              ; Magnitude character
    514     push    si                              ; Tenths
    515     push    ax                              ; Size in magnitude
    516 
    517     ePUSH_T ax, g_szCapacity                ; "Capacity"
    518     mov     si, g_szSizeDual
    519     mov     dh, 14                          ; 14 bytes pushed to stack
    520     jmp     PrintString_JumpToFormat
    521 
    522 
    523 ;--------------------------------------------------------------------
    524 ; Prints Function Menuitem information strings.
    525 ;
    526 ; BootMenuPrint_HardDiskMenuitemInformation
    527 ;   Parameters:
    528 ;       DX:     Function ID
    529 ;       DS:     RAMVARS segment
    530 ;   Returns:
    531 ;       AX:     1 if function ID was valid
    532 ;               0 if function ID was valid
    533 ;   Corrupts registers:
    534 ;       BX, DX
    535 ;--------------------------------------------------------------------
    536 ALIGN JUMP_ALIGN
    537 BootMenuPrint_FunctionMenuitemInformation:
    538     jmp     SHORT BootMenuPrint_ClearThreeInfoLines
    539 
    540 
    541 ;--------------------------------------------------------------------
    542 ; Prints Boot Menu title strings.
    543 ;
    544 ; BootMenuPrint_TitleStrings
    545 ;   Parameters:
    546 ;       Nothing
    547 ;   Returns:
    548 ;       AX:     Was printing successfull
    549 ;   Corrupts registers:
    550 ;       BX, DX, SI
    551 ;--------------------------------------------------------------------
    552 ALIGN JUMP_ALIGN
    553 BootMenuPrint_TitleStrings:
    554     mov     si, ROMVARS.szTitle
    555     call    PrintString_FromCS
    556     call    BootMenuPrint_ClearOneInfoLine
    557     mov     si, ROMVARS.szVersion
    558     call    PrintString_FromCS
    559     call    BootMenuPrint_ClearOneInfoLine
    560     mov     si, g_szTitleLn3
    561     call    PrintString_FromCS
    562     jmp     SHORT BootMenuPrint_ClearOneInfoLine
     540    push    di
     541    mov     ax, dx
     542    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
     543    pop     di
     544    ret
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm

    r3 r88  
    1 ; File name     :   BootMenuPrintCfg.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   28.3.2010
    4 ; Last update   :   9.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for printing drive configuration
    73;                   information on Boot Menu.
     
    2016;       Nothing
    2117;   Corrupts registers:
    22 ;       AX, BX, CX, DX, SI, ES
     18;       AX, BX, CX, DX, SI, DI, ES
    2319;--------------------------------------------------------------------
    2420ALIGN JUMP_ALIGN
     
    2723    call    BootMenuPrintCfg_GetPointers
    2824    call    BootMenuPrintCfg_PushAndFormatCfgString
    29     jmp     BootMenuPrint_ClearOneInfoLine
     25    jmp     BootMenuPrint_Newline
    3026
    3127
     
    3935;       Nothing
    4036;   Corrupts registers:
    41 ;       AX, BX, DX
     37;       AX, SI, DI
    4238;--------------------------------------------------------------------
    4339ALIGN JUMP_ALIGN
    4440BootMenuPrintCfg_HeaderAndChangeLine:
    4541    mov     si, g_szCfgHeader
    46     call    PrintString_FromCS
    47     jmp     BootMenuPrint_ClearOneInfoLine
     42    call    PrintNullTerminatedStringFromCSSIandSetCF
     43    jmp     BootMenuPrint_Newline
    4844
    4945
     
    8379;       Nothing
    8480;   Corrupts registers:
    85 ;       AX, CX, DX, SI
     81;       AX, DX, SI, DI
    8682;--------------------------------------------------------------------
    8783ALIGN JUMP_ALIGN
    8884BootMenuPrintCfg_PushAndFormatCfgString:
     85    push    bp
     86
     87    mov     bp, sp
    8988    ; Fall to first push below
    9089
    9190;--------------------------------------------------------------------
    92 ; BootMenuPrintCfg_PushResetStatus
     91; PushAddressingMode
     92;   Parameters:
     93;       DS:DI:  Ptr to DPT
     94;       ES:BX:  Ptr to BOOTNFO
     95;       CS:SI:  Ptr to IDEVARS
     96;   Returns:
     97;       Nothing (jumps to next push below)
     98;   Corrupts registers:
     99;       AX, DX
     100;--------------------------------------------------------------------
     101PushAddressingMode:
     102    mov     dx, bx              ; Backup BX to DX
     103    mov     bx, MASK_DPT_ADDR   ; Load addressing mode mask
     104    and     bl, [di+DPT.bFlags] ; Addressing mode now in BX
     105    push    WORD [cs:bx+.rgszAddressingModeString]
     106    mov     bx, dx
     107    jmp     SHORT .NextPush
     108ALIGN WORD_ALIGN
     109.rgszAddressingModeString:
     110    dw      g_szLCHS
     111    dw      g_szPCHS
     112    dw      g_szLBA28
     113    dw      g_szLBA48
     114ALIGN JUMP_ALIGN
     115.NextPush:
     116
     117;--------------------------------------------------------------------
     118; PushBlockMode
    93119;   Parameters:
    94120;       DS:DI:  Ptr to DPT
     
    100126;       AX
    101127;--------------------------------------------------------------------
    102 BootMenuPrintCfg_PushResetStatus:
    103     eMOVZX  ax, BYTE [di+DPT.bReset]
     128PushBlockMode:
     129    eMOVZX  ax, BYTE [di+DPT.bSetBlock]
    104130    push    ax
    105131
    106132;--------------------------------------------------------------------
    107 ; BootMenuPrintCfg_PushIRQ
    108 ;   Parameters:
    109 ;       DS:DI:  Ptr to DPT
    110 ;       ES:BX:  Ptr to BOOTNFO
    111 ;       CS:SI:  Ptr to IDEVARS
    112 ;   Returns:
    113 ;       Nothing (falls to next push below)
     133; PushBusType
     134;   Parameters:
     135;       DS:DI:  Ptr to DPT
     136;       ES:BX:  Ptr to BOOTNFO
     137;       CS:SI:  Ptr to IDEVARS
     138;   Returns:
     139;       Nothing (jumps to next push below)
    114140;   Corrupts registers:
    115141;       AX, DX
    116142;--------------------------------------------------------------------
    117 BootMenuPrintCfg_PushIRQ:
    118     mov     dl, ' '                     ; Load space to DL
    119     mov     al, [cs:si+IDEVARS.bIRQ]
    120     test    al, al                      ; Interrupts disabled?
    121     jz      SHORT .PushIrqDisabled
    122     add     al, '0'                     ; Digit to ASCII
    123     cmp     al, '9'                     ; Only one digit needed?
    124     jbe     SHORT .PushCharacters
    125 
    126     ; Two digits needed
    127     sub     al, 10                      ; Limit to single digit ASCII
    128     mov     dl, '1'                     ; Load '1 to DX
    129     jmp     SHORT .PushCharacters
    130 ALIGN JUMP_ALIGN
    131 .PushIrqDisabled:
    132     mov     al, '-'                     ; Load line to AL
    133     xchg    ax, dx                      ; Space to AL, line to DL
    134 ALIGN JUMP_ALIGN
    135 .PushCharacters:
    136     push    ax
    137     push    dx
    138 
    139 ;--------------------------------------------------------------------
    140 ; BootMenuPrintCfg_PushBusType
    141 ;   Parameters:
    142 ;       DS:DI:  Ptr to DPT
    143 ;       ES:BX:  Ptr to BOOTNFO
    144 ;       CS:SI:  Ptr to IDEVARS
    145 ;   Returns:
    146 ;       Nothing (jumps to next push below)
    147 ;   Corrupts registers:
    148 ;       AX, DX
    149 ;--------------------------------------------------------------------
    150 BootMenuPrintCfg_PushBusType:
     143PushBusType:
    151144    xchg    ax, bx      ; Store BX to AX
    152145    eMOVZX  bx, BYTE [cs:si+IDEVARS.bBusType]
    153146    mov     bx, [cs:bx+.rgwBusTypeValues]   ; Char to BL, Int to BH
    154147    eMOVZX  dx, bh
     148    push    bx          ; Push character
    155149    push    dx          ; Push 8, 16 or 32
    156     push    bx          ; Push character
    157150    xchg    bx, ax      ; Restore BX
    158151    jmp     SHORT .NextPush
     
    167160
    168161;--------------------------------------------------------------------
    169 ; BootMenuPrintCfg_PushBlockMode
     162; PushIRQ
    170163;   Parameters:
    171164;       DS:DI:  Ptr to DPT
     
    175168;       Nothing (falls to next push below)
    176169;   Corrupts registers:
     170;       AX, DX
     171;--------------------------------------------------------------------
     172PushIRQ:
     173    mov     dl, ' '                     ; Load space to DL
     174    mov     al, [cs:si+IDEVARS.bIRQ]
     175    test    al, al                      ; Interrupts disabled?
     176    jz      SHORT .PushIrqDisabled
     177    add     al, '0'                     ; Digit to ASCII
     178    cmp     al, '9'                     ; Only one digit needed?
     179    jbe     SHORT .PushCharacters
     180
     181    ; Two digits needed
     182    sub     al, 10                      ; Limit to single digit ASCII
     183    mov     dl, '1'                     ; Load '1 to DX
     184    jmp     SHORT .PushCharacters
     185ALIGN JUMP_ALIGN
     186.PushIrqDisabled:
     187    mov     al, '-'                     ; Load line to AL
     188    xchg    ax, dx                      ; Space to AL, line to DL
     189ALIGN JUMP_ALIGN
     190.PushCharacters:
     191    push    dx
     192    push    ax
     193
     194;--------------------------------------------------------------------
     195; PushResetStatus
     196;   Parameters:
     197;       DS:DI:  Ptr to DPT
     198;       ES:BX:  Ptr to BOOTNFO
     199;       CS:SI:  Ptr to IDEVARS
     200;   Returns:
     201;       Nothing (falls to next push below)
     202;   Corrupts registers:
    177203;       AX
    178204;--------------------------------------------------------------------
    179 BootMenuPrintCfg_PushBlockMode:
    180     eMOVZX  ax, BYTE [di+DPT.bSetBlock]
     205PushResetStatus:
     206    eMOVZX  ax, BYTE [di+DPT.bReset]
    181207    push    ax
    182208
    183209;--------------------------------------------------------------------
    184 ; BootMenuPrintCfg_PushAddressingMode
    185 ;   Parameters:
    186 ;       DS:DI:  Ptr to DPT
    187 ;       ES:BX:  Ptr to BOOTNFO
    188 ;       CS:SI:  Ptr to IDEVARS
    189 ;   Returns:
    190 ;       Nothing (jumps to next push below)
    191 ;   Corrupts registers:
    192 ;       AX, DX
    193 ;--------------------------------------------------------------------
    194 BootMenuPrintCfg_PushAddressingMode:
    195     mov     dx, bx              ; Backup BX to DX
    196     mov     bx, MASK_DPT_ADDR   ; Load addressing mode mask
    197     and     bl, [di+DPT.bFlags] ; Addressing mode now in BX
    198     push    WORD [cs:bx+.rgszAddressingModeString]
    199     mov     bx, dx
    200     jmp     SHORT .NextPush
    201 ALIGN WORD_ALIGN
    202 .rgszAddressingModeString:
    203     dw  g_szLCHS
    204     dw  g_szPCHS
    205     dw  g_szLBA28
    206     dw  g_szLBA48
    207 ALIGN JUMP_ALIGN
    208 .NextPush:
    209 
    210 ;--------------------------------------------------------------------
    211210; Prints formatted configuration string from parameters pushed to stack.
    212211;
     
    217216;       Nothing
    218217;   Corrupts registers:
    219 ;       AX, CX, DX, SI
     218;       AX, SI, DI
    220219;--------------------------------------------------------------------
    221220BootMenuPrintCfg_ValuesFromStack:
    222221    mov     si, g_szCfgFormat
    223     mov     dh, 14                      ; 14 bytes pushed to stack
    224     jmp     PrintString_JumpToFormat
     222    jmp     PrintNullTerminatedStringFromCSSIandSetCF
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootPrint.asm

    r87 r88  
    1 ; Project name  :   IDE BIOS
     1; Project name  :   XTIDE Universal BIOS
    22; Description   :   Functions for printing boot related strings.
    33
     
    66
    77;--------------------------------------------------------------------
    8 ; Prints trying to boot string.
    9 ;
    108; BootPrint_TryToBootFromDL
    119;   Parameters:
     
    1513;       Nothing
    1614;   Corrupts registers:
    17 ;       AX, CX, SI, DI
     15;       AX, SI
    1816;--------------------------------------------------------------------
    1917ALIGN JUMP_ALIGN
    2018BootPrint_TryToBootFromDL:
    21     push    dx
    22     ePUSH_T ax, BootPrint_PopDxAndReturn    ; Return address
     19    push    bp
     20    mov     bp, sp
    2321
    24     xor     dh, dh              ; Translated drive number to DX
    25     push    dx                  ; Push translated drive number
     22    mov     ax, g_szHardDrv
     23    test    dl, 80h
     24    eCMOVZ  ax, g_szFloppyDrv
     25    push    ax                  ; "Hard Drive" or "Floppy Drive"
     26
    2627    call    DriveXlate_ToOrBack
    2728    push    dx                  ; Push untranslated drive number
    28 
    29     mov     ax, g_szFloppyDrv   ; Assume "Floppy Drive"
    30     test    dl, 80h             ; Hard Disk?
    31     jz      SHORT .PushHardOrFloppy
    32     add     ax, BYTE g_szHardDrv - g_szFloppyDrv
    33 .PushHardOrFloppy:
    34     push    ax
     29    call    DriveXlate_ToOrBack
     30    push    dx                  ; Push translated drive number
    3531
    3632    mov     si, g_szTryToBoot
    37     mov     dh, 6               ; 6 bytes pushed to stack
    38     jmp     PrintString_JumpToFormat
    39 
    40 ALIGN JUMP_ALIGN
    41 BootPrint_PopDxAndReturn:
    42     pop     dx
    43     ret
     33    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    4434
    4535
    4636;--------------------------------------------------------------------
    47 ; Prints message that valid boot sector has been found.
    48 ;
    4937; BootPrint_BootSectorLoaded
    5038;   Parameters:
     
    5341;       Nothing
    5442;   Corrupts registers:
    55 ;       AX, CX, SI
     43;       AX, SI
    5644;--------------------------------------------------------------------
    5745ALIGN JUMP_ALIGN
    5846BootPrint_BootSectorLoaded:
    59     push    dx
    60     ePUSH_T ax, BootPrint_PopDxAndReturn    ; Return address
    61 
     47    push    bp
     48    mov     bp, sp
     49    ePUSH_T ax, g_szBootSector
    6250    ePUSH_T ax, g_szFound
    63     jmp     SHORT BootPrint_MsgCodeShared
    64 
     51    jmp     SHORT PrintBootSectorResult
    6552
    6653;--------------------------------------------------------------------
    67 ; Prints message that first sector is not boot sector.
    68 ;
    6954; BootPrint_FirstSectorNotBootable
    7055;   Parameters:
     
    7358;       Nothing
    7459;   Corrupts registers:
    75 ;       AX, CX, DX, SI
     60;       AX, SI
    7661;--------------------------------------------------------------------
    7762ALIGN JUMP_ALIGN
    7863BootPrint_FirstSectorNotBootable:
     64    push    bp
     65    mov     bp, sp
     66    ePUSH_T ax, g_szBootSector
    7967    ePUSH_T ax, g_szNotFound
    80 BootPrint_MsgCodeShared:
    81     ePUSH_T ax, g_szBootSector
     68PrintBootSectorResult:
    8269    mov     si, g_szSectRead
    83     mov     dh, 4               ; 4 bytes pushed to stack
    84     jmp     PrintString_JumpToFormat
     70    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    8571
    8672
    8773;--------------------------------------------------------------------
    88 ; Prints error code for failed first sector read attempt.
    89 ;
    9074; BootPrint_FailedToLoadFirstSector
    9175;   Parameters:
     
    9478;       Nothing
    9579;   Corrupts registers:
    96 ;       AX, CX, DX, SI
     80;       AX, CX, SI
    9781;--------------------------------------------------------------------
    9882ALIGN JUMP_ALIGN
    9983BootPrint_FailedToLoadFirstSector:
     84    push    bp
     85    mov     bp, sp
    10086    eMOVZX  cx, ah              ; Error code to CX
    10187    push    cx                  ; Push INT 13h error code
    10288    mov     si, g_szReadError
    103     mov     dh, 2               ; 2 bytes pushed to stack
    104     jmp     PrintString_JumpToFormat
     89    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm

    r3 r88  
    1 ; File name     :   AH25h_HDrvID.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   24.10.2009
    4 ; Last update   :   14.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Int 13h function AH=25h, Get Drive Information.
    73
     
    9187    mov     al, HCMD_ID_DEV             ; Load Identify Device command to AL
    9288    out     dx, al                      ; Output command
    93     call    SoftDelay_BeforePollingStatusRegister
    9489    call    HStatus_WaitDrqDefTime      ; Wait until ready to transfer (no IRQ!)
    9590    jc      SHORT .Return               ; Return if error
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r84 r88  
    1 ; File name     :   AHDh_HReset.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   9.12.2007
    4 ; Last update   :   14.1.2011
    5 ; Author        :   Tomi Tilli,
    6 ;               :   Krister Nordvall (optimizations)
     1; Project name  :   XTIDE Universal BIOS
    72; Description   :   Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
    83
     
    9489    or      al, FLG_IDE_CTRL_SRST       ; Set Reset bit
    9590    call    HDrvSel_OutputDeviceControlByte
    96     mov     cx, 5                       ; Delay at least 5us
    97     call    SoftDelay_us
     91    mov     ax, 5                       ; Delay at least 5us
     92    call    Delay_MicrosecondsFromAX
    9893
    9994    ; HSR1: Clear_wait
    100     and     al, ~FLG_IDE_CTRL_SRST      ; Clear Reset bit
     95    mov     al, [di+DPT.bDrvCtrl]       ; Load value for ACR
    10196    out     dx, al                      ; End Reset
    102     mov     cx, 2000                    ; Delay at least 2ms
    103     call    SoftDelay_us
     97    mov     ax, 2000                    ; Delay at least 2ms
     98    call    Delay_MicrosecondsFromAX
    10499
    105100    ; HSR2: Check_status
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm

    r32 r88  
    1 ; File name     :   HCapacity.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   16.3.2010
    4 ; Last update   :   3.8.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for hard disk capacity calculations.
    73
     
    4743    xor     bx, bx          ; Zero BX for 48-bit sector count
    4844    ret
    49 
    50 
    51 ;--------------------------------------------------------------------
    52 ; Converts sector count to hard disk size.
    53 ;
    54 ; HCapacity_ConvertSectorCountToSize:
    55 ;   Parameters:
    56 ;       BX:DX:AX:   Total sector count
    57 ;   Returns:
    58 ;       AX:         Size in magnitude
    59 ;       SI:         Tenths
    60 ;       CX:         Magnitude character:
    61 ;                       'k' = *1024   B = kiB
    62 ;                       'M' = *1024 kiB = MiB
    63 ;                       'G' = *1024 MiB = GiB
    64 ;                       'T' = *1024 GiB = TiB
    65 ;                       'P' = *1024 TiB = PiB
    66 ;   Corrupts registers:
    67 ;       BX, DX
    68 ;--------------------------------------------------------------------
    69 ALIGN JUMP_ALIGN
    70 HCapacity_ConvertSectorCountToSize:
    71     call    HCapacity_ConvertSectorCountToKiB
    72     mov     cx, 1                   ; Magnitude is 1 for kiB
    73 ALIGN JUMP_ALIGN
    74 .MagnitudeLoop:
    75     test    bx, bx                  ; Bits 32...47 in use?
    76     jnz     SHORT .ShiftByMagnitude ;  If so, jump to shift
    77     test    dx, dx                  ; Bits 16...31 in use?
    78     jnz     SHORT .ShiftByMagnitude ;  If so, jump to shift
    79     cmp     ax, 10000               ; 5 digits needed?
    80     jb      SHORT .ShiftComplete    ;  If less, all done
    81 ALIGN JUMP_ALIGN
    82 .ShiftByMagnitude:
    83     call    HCapacity_ShiftForNextMagnitude
    84     jmp     SHORT .MagnitudeLoop
    85 ALIGN JUMP_ALIGN
    86 .ShiftComplete:
    87     mov     bx, cx                  ; Copy shift count to BX
    88     mov     cl, [cs:bx+.rgbMagnitudeToChar]
    89     jmp     SHORT HCapacity_ConvertSizeRemainderToTenths
    90 ALIGN WORD_ALIGN
    91 .rgbMagnitudeToChar:    db  " kMGTP"
    92 
    93 ;--------------------------------------------------------------------
    94 ; Converts 48-bit sector count to size in kiB.
    95 ;
    96 ; HCapacity_ConvertSectorCountToKiB:
    97 ;   Parameters:
    98 ;       BX:DX:AX:   Total sector count
    99 ;   Returns:
    100 ;       BX:DX:AX:   Total size in kiB
    101 ;       CF:         Remainder from division
    102 ;   Corrupts registers:
    103 ;       Nothing
    104 ;--------------------------------------------------------------------
    105 ALIGN JUMP_ALIGN
    106 HCapacity_ConvertSectorCountToKiB:
    107 HCapacity_DivideSizeByTwo:
    108     shr     bx, 1                   ; Divide sector count by 2...
    109     rcr     dx, 1                   ; ...to get disk size in...
    110     rcr     ax, 1                   ; ...kiB
    111     ret
    112 
    113 ;--------------------------------------------------------------------
    114 ; Divides size by 1024 and increments magnitude.
    115 ;
    116 ; HCapacity_ShiftForNextMagnitude:
    117 ;   Parameters:
    118 ;       BX:DX:AX:   Size in magnitude
    119 ;       CX:         Magnitude (0=B, 1=kiB, 2=MiB...)
    120 ;   Returns:
    121 ;       BX:DX:AX:   Size in magnitude
    122 ;       SI:         Remainder (0...1023)
    123 ;       CX:         Magnitude (1=kiB, 2=MiB...)
    124 ;   Corrupts registers:
    125 ;       Nothing
    126 ;--------------------------------------------------------------------
    127 ALIGN JUMP_ALIGN
    128 HCapacity_ShiftForNextMagnitude:
    129     push    cx
    130     xor     si, si                  ; Zero remainder
    131     mov     cl, 10                  ; Divide by 1024
    132 ALIGN JUMP_ALIGN
    133 .ShiftLoop:
    134     call    HCapacity_DivideSizeByTwo
    135     rcr     si, 1                   ; Update remainder
    136     loop    .ShiftLoop
    137     eSHR_IM si, 6                   ; Remainder to SI beginning
    138     pop     cx
    139     inc     cx                      ; Increment shift count
    140     ret
    141 
    142 ;--------------------------------------------------------------------
    143 ; Converts remainder from HCapacity_ShiftForNextMagnitude to tenths.
    144 ;
    145 ; HCapacity_ConvertSizeRemainderToTenths:
    146 ;   Parameters:
    147 ;       BX:DX:AX:   Size in magnitude
    148 ;       SI:         Remainder from last magnitude division (0...1023)
    149 ;   Returns:
    150 ;       BX:DX:AX:   Size in magnitude
    151 ;       SI:         Tenths
    152 ;   Corrupts registers:
    153 ;       Nothing
    154 ;--------------------------------------------------------------------
    155 ALIGN JUMP_ALIGN
    156 HCapacity_ConvertSizeRemainderToTenths:
    157     push    dx
    158     push    ax
    159 
    160     mov     ax, 10
    161     mul     si                  ; DX:AX = remainder * 10
    162     eSHR_IM ax, 10              ; Divide AX by 1024
    163     xchg    si, ax              ; SI = tenths
    164 
    165     pop     ax
    166     pop     dx
    167     ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCommand.asm

    r3 r88  
    1 ; File name     :   HCommand.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   28.3.2010
    4 ; Last update   :   16.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for outputting IDE commands and parameters.
    73
     
    113109    out     dx, al
    114110    mov     al, ah                      ; Restore sector count to AL
    115     jmp     SoftDelay_BeforePollingStatusRegister
     111    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm

    r3 r88  
    1 ; File name     :   HDrvSel.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   25.2.2010
    4 ; Last update   :   13.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for selecting Master or Slave drive.
    73
     
    6056
    6157    ; Wait until drive is ready to accept commands
    62     call    SoftDelay_BeforePollingStatusRegister
    6358    call    HStatus_WaitRdyDefTime
    6459    pop     cx
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm

    r34 r88  
    1 ; File name     :   HStatus.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   15.12.2009
    4 ; Last update   :   23.8.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   IDE Status Register polling functions.
    73
     
    176172ALIGN JUMP_ALIGN
    177173HStatus_PollBsyAndFlg:
    178     call    SoftDelay_InitTimeout               ; Initialize timeout counter
     174    call    InitializeTimeoutWithTicksInCL      ; Initialize timeout counter
    179175    in      al, dx                              ; Discard contents for first read
    180176                                                ; (should read Alternate Status Register)
     
    188184ALIGN JUMP_ALIGN
    189185.UpdateTimeout:
    190     call    SoftDelay_UpdTimeout                ; Update timeout counter
     186    call    SetCFifTimeout
    191187    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    192188    jmp     HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
     
    210206ALIGN JUMP_ALIGN
    211207HStatus_PollBsy:
    212     call    SoftDelay_InitTimeout               ; Initialize timeout counter
     208    call    InitializeTimeoutWithTicksInCL      ; Initialize timeout counter
    213209    in      al, dx                              ; Discard contents for first read
    214210                                                ; (should read Alternate Status Register)
     
    218214    test    al, FLG_IDE_ST_BSY                  ; Controller busy?
    219215    jz      SHORT GetErrorCodeFromPollingToAH   ;  If not, jump to check errors
    220     call    SoftDelay_UpdTimeout                ; Update timeout counter
     216    call    SetCFifTimeout                      ; Update timeout counter
    221217    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    222218ALIGN JUMP_ALIGN
    223219GetErrorCodeFromPollingToAH:
    224220    jmp     HError_ProcessErrorsAfterPollingBSY
     221
     222
     223;--------------------------------------------------------------------
     224; InitializeTimeoutWithTicksInCL
     225;   Parameters:
     226;       CL:     Timeout value in system timer ticks
     227;       DS:     Segment to RAMVARS
     228;   Returns:
     229;       Nothing
     230;   Corrupts registers:
     231;       CX
     232;--------------------------------------------------------------------
     233ALIGN JUMP_ALIGN
     234InitializeTimeoutWithTicksInCL:
     235    push    bx
     236    xchg    cx, ax
     237
     238    xor     ah, ah      ; Timeout ticks now in AX
     239    mov     bx, RAMVARS.wTimeoutCounter
     240    call    TimerTicks_InitializeTimeoutFromAX
     241
     242    xchg    ax, cx      ; Restore AX
     243    pop     bx
     244    ret
     245
     246;--------------------------------------------------------------------
     247; SetCFifTimeout
     248;   Parameters:
     249;       DS:     Segment to RAMVARS
     250;   Returns:
     251;       Nothing
     252;   Corrupts registers:
     253;       CX
     254;--------------------------------------------------------------------
     255ALIGN JUMP_ALIGN
     256SetCFifTimeout:
     257    push    bx
     258    xchg    cx, ax
     259
     260    mov     bx, RAMVARS.wTimeoutCounter
     261    call    TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
     262
     263    xchg    ax, cx      ; Restore AX
     264    pop     bx
     265    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int18h.asm

    r3 r88  
    1 ; File name     :   Int18h.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   6.1.2010
    4 ; Last update   :   25.3.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Int 18h BIOS functions (ROM boot and Boot error).
    73
     
    2420Int18h_BootError:
    2521    mov     si, g_sz18hCallback
    26     call    PrintString_FromCS      ; No need to clean stack
     22    call    PrintNullTerminatedStringFromCSSIandSetCF
    2723    jmp     Int19hMenu_Display      ; Return to boot menu
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r86 r88  
    1 ; Project name  :   IDE BIOS
     1; Project name  :   XTIDE Universal BIOS
    22; Description   :   Functions for printing drive detection strings.
    33
     
    1414;       Nothing
    1515;   Corrupts registers:
    16 ;       AX, CX, DX, SI
     16;       AX, SI
    1717;--------------------------------------------------------------------
    1818ALIGN JUMP_ALIGN
    1919DetectPrint_RomFoundAtSegment:
    20     push    cs
    21     ePUSH_T ax, ROMVARS.szTitle
     20    push    bp
     21
    2222    mov     si, g_szRomAt
    23     jmp     SHORT DetectPrint_4BytesPushedToStack
     23    mov     bp, sp
     24    ePUSH_T ax, ROMVARS.szTitle         ; Bios title string
     25    push    cs                          ; BIOS segment
     26    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    2427
    2528
     
    3437;       Nothing
    3538;   Corrupts registers:
    36 ;       AX, CX, DX, SI
     39;       AX, SI
    3740;--------------------------------------------------------------------
    3841ALIGN JUMP_ALIGN
     
    5053; DetectPrint_StartingDriveDetect
    5154;   Parameters:
    52 ;       AX:     Offset to "Master" or "Slave" string
     55;       CS:AX:  Ptr to "Master" or "Slave" string
    5356;       CS:BP:  Ptr to IDEVARS
    5457;   Returns:
    5558;       Nothing
    5659;   Corrupts registers:
    57 ;       AX, CX, DX, SI
     60;       AX, SI
    5861;--------------------------------------------------------------------
    5962ALIGN JUMP_ALIGN
    6063DetectPrint_StartingDriveDetect:
    61     push    WORD [cs:bp+IDEVARS.wPort]
    62     push    ax
     64    push    bp
     65
     66    mov     si, [cs:bp+IDEVARS.wPort]
     67    mov     bp, sp
     68    push    ax                          ; Push "Master" or "Slave"
     69    push    si                          ; Push port number
    6370    mov     si, g_szDetect
    64 DetectPrint_4BytesPushedToStack:
    65     mov     dh, 4                       ; 4 bytes pushed to stack
    66     jmp     PrintString_JumpToFormat
     71    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    6772
    6873
     
    7984;       Nothing
    8085;   Corrupts registers:
    81 ;       AX, DX, SI
     86;       AX, SI
    8287;--------------------------------------------------------------------
    8388ALIGN JUMP_ALIGN
    8489DetectPrint_DriveNameOrNotFound:
     90    push    di
    8591    jc      SHORT .PrintDriveNotFound
     92    push    bx
     93
    8694    lea     si, [bx+BOOTNFO.szDrvName]
    87     call    PrintString_FromES
    88     jmp     Print_Newline
     95    mov     bx, es
     96    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
     97    CALL_DISPLAY_LIBRARY PrintNewlineCharacters
     98
     99    pop     bx
     100    pop     di
     101    ret
     102
    89103ALIGN JUMP_ALIGN
    90104.PrintDriveNotFound:
    91105    mov     si, g_szNotFound
    92     jmp     PrintString_FromCS
     106    call    PrintNullTerminatedStringFromCSSIandSetCF
     107    pop     di
     108    ret
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r86 r88  
    1313
    1414; Included .inc files
    15 %include "emulate.inc"          ; Must be included first!
    16 %include "macros.inc"           ; For generic macros
     15%include "AssemblyLibrary.inc"  ; Assembly Library. Must be included first!
     16%include "macros.inc"           ; General purpose macros
    1717%include "BiosData.inc"         ; For BIOS Data area equates
    1818%include "Interrupts.inc"       ; For interrupt equates
     
    3838    at  ROMVARS.bRomSize,   db  CNT_ROM_BLOCKS  ; ROM size in 512B blocks
    3939    at  ROMVARS.rgbJump,    jmp Initialize_FromMainBiosRomSearch
    40     at  ROMVARS.rgbDate,    db  "11/28/10"      ; Build data (mm/dd/yy)
    41     at  ROMVARS.rgbSign,    db  "XTIDE110"      ; Signature for flash program
     40    at  ROMVARS.rgbDate,    db  "01/27/11"      ; Build data (mm/dd/yy)
     41    at  ROMVARS.rgbSign,    db  "XTIDE120"      ; Signature for flash program
    4242    at  ROMVARS.szTitle
    4343        db  "-=XTIDE Universal BIOS"
    4444%ifdef USE_AT
    45         db  " (AT)=-",STOP
     45        db  " (AT)=-",NULL
    4646%elifdef USE_186
    47         db  " (XT+)=-",STOP
     47        db  " (XT+)=-",NULL
    4848%else
    49         db  " (XT)=-",STOP
     49        db  " (XT)=-",NULL
    5050%endif
    51     at  ROMVARS.szVersion,  db  "v1.1.5 (11/28/10)",STOP
     51    at  ROMVARS.szVersion,  db  "v1.2.0_wip (01/27/11)",NULL
    5252
    5353;---------------------------;
     
    5858    at  ROMVARS.bIdeCnt,        db  3                       ; Number of supported controllers
    5959    at  ROMVARS.bBootDrv,       db  80h                     ; Boot Menu default drive
    60     at  ROMVARS.bBootMnuH,      db  20                      ; Boot Menu maximum height
    6160    at  ROMVARS.bBootDelay,     db  30                      ; Boot Menu selection delay (secs)
    6261    at  ROMVARS.bBootLdrType,   db  BOOTLOADER_TYPE_MENU    ; Boot loader type
     
    9190    at  ROMVARS.bIdeCnt,        db  1                       ; Number of supported controllers
    9291    at  ROMVARS.bBootDrv,       db  80h                     ; Boot Menu default drive
    93     at  ROMVARS.bBootMnuH,      db  20                      ; Boot Menu maximum height
    9492    at  ROMVARS.bBootDelay,     db  30                      ; Boot Menu selection delay (secs)
    9593    at  ROMVARS.bBootLdrType,   db  BOOTLOADER_TYPE_MENU    ; Boot loader type
     
    108106
    109107; Include .asm files (static data and libraries)
     108%include "AssemblyLibrary.asm"
    110109%include "Strings.asm"          ; For BIOS message strings
    111 %include "math.asm"             ; For Math library
    112 %include "string.asm"           ; For String library
    113 %include "print.asm"            ; For Print library
    114 %include "keys.asm"             ; For keyboard library (required by menu library)
    115 %include "menu.asm"             ; For menu library
    116 %include "PrintString.asm"      ; Customized printing for this BIOS
    117 %include "SoftDelay.asm"        ; For software delay loops
    118110
    119111; Include .asm files (Initialization and drive detection)
     
    178170
    179171; Fill with zeroes until size is what we want
    180 times (CNT_ROM_BLOCKS*512)-($-$$) db 0
     172;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
  • trunk/XTIDE_Universal_BIOS/Src/Strings.asm

    r3 r88  
    1 ; File name     :   Strings.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   4.12.2007
    4 ; Last update   :   9.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Strings and equates for BIOS messages.
    73
     
    106
    117; POST drive detection strings
    12 g_szRomAt:      db  "%s @ %x",CR,LF,STOP
    13 g_szMaster:     db  "Master",STOP
    14 g_szSlave:      db  "Slave ",STOP
    15 g_szDetect:     db  "IDE %s at %x: ",STOP           ; IDE Master at 1F0h:
    16 g_szNotFound:   db  "not found",CR,LF,STOP
     8g_szRomAt:      db  "%s @ %x",CR,LF,NULL
     9g_szMaster:     db  "Master",NULL
     10g_szSlave:      db  "Slave ",NULL
     11g_szDetect:     db  "IDE %s at %x: ",NULL           ; IDE Master at 1F0h:
     12g_szNotFound:   db  "not found",CR,LF,NULL
    1713
    1814; Boot loader strings
    19 g_szFloppyDrv:  db  "Floppy Drive",STOP
    20 g_szHardDrv:    db  " Hard Drive ",STOP
    21 g_szTryToBoot:  db  "Booting from %s %x",175,"%x ... ",STOP
    22 g_szBootSector: db  "Boot Sector",STOP
    23 g_szFound:      db  "found",STOP
    24 g_szSectRead:   db  "%s %s!",CR,LF,STOP
    25 g_szReadError:  db  "Error %x!",CR,LF,STOP
    26 g_sz18hCallback:db  "Boot menu callback via INT 18h",STOP
     15g_szFloppyDrv:  db  "Floppy Drive",NULL
     16g_szHardDrv:    db  " Hard Drive ",NULL
     17g_szTryToBoot:  db  "Booting from %s %x",175,"%x ... ",NULL
     18g_szBootSector: db  "Boot Sector",NULL
     19g_szFound:      db  "found",NULL
     20g_szSectRead:   db  "%s %s!",CR,LF,NULL
     21g_szReadError:  db  "Error %x!",CR,LF,NULL
     22g_sz18hCallback:db  "Boot menu callback via INT 18h",NULL
    2723
    2824; Boot menu bottom of screen strings
    29 g_szFDD:        db  "FDD",STOP
    30 g_szHDD:        db  "HDD",STOP
    31 g_szBottomScrn: db  "%c to %c boots from %s with %s mappings",CR,LF,STOP
    32 
    33 ; Boot Menu title strings
    34 g_szTitleLn3:   db  "Copyright 2009-2010 by Tomi Tilli",STOP
     25g_szFDD:        db  "FDD",NULL
     26g_szHDD:        db  "HDD",NULL
     27g_szBottomScrn: db  "%c to %c boots from %s with %s mappings",CR,LF,NULL
    3528
    3629; Boot Menu menuitem strings
    37 g_szFDLetter:   db  "%s %c",STOP
    38 g_szforeignHD:  db  "Foreign Hard Disk",STOP
    39 g_szRomBoot:    db  "ROM Boot",STOP
     30g_szFDLetter:   db  "%s %c",NULL
     31g_szforeignHD:  db  "Foreign Hard Disk",NULL
     32g_szRomBoot:    db  "ROM Boot",NULL
    4033
    4134; Boot Menu information strings
    42 g_szCapacity:   db  "Capacity : ",STOP
    43 g_szSizeSingle: db  "%s%u.%u %ciB",STOP
    44 g_szSizeDual:   db  "%s%u.%u %ciB / %u.%u %ciB",STOP
    45 g_szCfgHeader:  db  "Addr.", T_V, "Block", T_V, "Bus",   T_V, "IRQ",   T_V, "Reset", STOP
    46 g_szCfgFormat:  db  "%s"   , T_V, "%5u",   T_V, "%c%2u", T_V, " %c%c", T_V, "%5x",   STOP
    47 g_szLCHS:       db  "L-CHS",STOP
    48 g_szPCHS:       db  "P-CHS",STOP
    49 g_szLBA28:      db  "LBA28",STOP
    50 g_szLBA48:      db  "LBA48",STOP
    51 g_szFddUnknown: db  "%sUnknown",STOP
    52 g_szFddSizeOr:  db  "%s5",172,22h," or 3",171,22h," DD",STOP
    53 g_szFddSize:    db  "%s%c%c",22h,", %u kiB",STOP    ; 3½", 1440 kiB
     35g_szCapacity:   db  "Capacity : ",NULL
     36g_szSizeSingle: db  "%s%u.%u %ciB",NULL
     37g_szSizeDual:   db  "%s%u.%u %ciB / %u.%u %ciB",NULL
     38g_szCfgHeader:  db  "Addr.",SINGLE_VERTICAL,"Block",SINGLE_VERTICAL,"Bus",  SINGLE_VERTICAL,"IRQ",  SINGLE_VERTICAL,"Reset",NULL
     39g_szCfgFormat:  db  "%s"   ,SINGLE_VERTICAL,"%5u",  SINGLE_VERTICAL,"%c%2u",SINGLE_VERTICAL," %c%c",SINGLE_VERTICAL,"%5x",  NULL
     40g_szLCHS:       db  "L-CHS",NULL
     41g_szPCHS:       db  "P-CHS",NULL
     42g_szLBA28:      db  "LBA28",NULL
     43g_szLBA48:      db  "LBA48",NULL
     44g_szFddUnknown: db  "%sUnknown",NULL
     45g_szFddSizeOr:  db  "%s5",172,22h," or 3",171,22h," DD",NULL
     46g_szFddSize:    db  "%s%c%c",22h,", %u kiB",NULL    ; 3½", 1440 kiB
  • trunk/XTIDE_Universal_BIOS/makefile

    r80 r88  
    4141HEADERS += Src/Initialization/
    4242HEADERS += Src/Libraries/
    43 HEADERS += Src/Libraries/menu/
    4443HEADERS += Src/VariablesAndDPTs/
     44
     45# Subdirectories where library files are:
     46LIBS = ../Assembly_Library/Inc/
     47LIBS += ../Assembly_Library/Src/
     48LIBS += ../Assembly_Library/Src/Display/
     49LIBS += ../Assembly_Library/Src/File/
     50LIBS += ../Assembly_Library/Src/Keyboard/
     51LIBS += ../Assembly_Library/Src/Menu/
     52LIBS += ../Assembly_Library/Src/Menu/Dialog/
     53LIBS += ../Assembly_Library/Src/String/
     54LIBS += ../Assembly_Library/Src/Time/
     55LIBS += ../Assembly_Library/Src/Util/
     56LIBS += ../XTIDE_Universal_BIOS/Inc/
     57HEADERS += $(LIBS)
    4558
    4659
     
    4861# Assembler preprocessor defines.                               #
    4962#################################################################
    50 DEFINES =
    51 DEFINES_XT =
    52 DEFINES_XTPLUS = USE_186
     63DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_BIT_UTILS EXCLUDE_SORT_UTILS
     64DEFINES_XT = ELIMINATE_CGA_SNOW
     65DEFINES_XTPLUS = ELIMINATE_CGA_SNOW USE_186
    5366DEFINES_AT = USE_186 USE_286 USE_AT
    5467
Note: See TracChangeset for help on using the changeset viewer.