Changeset 258 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Boot


Ignore:
Timestamp:
Feb 22, 2012, 7:01:53 PM (13 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Added floppy drive emulation over the serial connection (MODULE_SERIAL_FLOPPY). Along the way, various optimizations were made to stay within the 8K ROM size target. Also, serial code now returns the number of sectors transferred.

Location:
trunk/XTIDE_Universal_BIOS/Src/Boot
Files:
4 edited

Legend:

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

    r248 r258  
    3737;               Clear: There is no selected menu item, DL is not valid
    3838;   Corrupts registers:
    39 ;       CX, DI
     39;       AX, DI
    4040;--------------------------------------------------------------------
    4141ALIGN JUMP_ALIGN
     
    5050
    5151    mov     dl, cl                          ; Copy menuitem index to DX
    52     call    FloppyDrive_GetCountToCX
    53     cmp     dl, cl                          ; Floppy drive?
     52    call    FloppyDrive_GetCountToAX
     53    cmp     dl, al                          ; Floppy drive?
    5454    jb      SHORT .ReturnFloppyDriveInDX    ; Set CF if branch taken
    55     or      cl, 80h                         ; Or 80h into CL before the sub
     55    or      al, 80h                         ; Or 80h into AL before the sub
    5656                                            ; to cause CF to be set after
    5757                                            ; and result has high order bit set
    58     sub     dl, cl                          ; Remove floppy drives from index
     58    sub     dl, al                          ; Remove floppy drives from index
    5959
    6060.ReturnFloppyDriveInDX:
     
    9494ALIGN JUMP_ALIGN
    9595BootMenu_GetMenuitemCountToAX:
    96     call    RamVars_GetHardDiskCountFromBDAtoCX
     96    call    RamVars_GetHardDiskCountFromBDAtoAX
    9797    xchg    ax, cx
    98     call    FloppyDrive_GetCountToCX
     98    call    FloppyDrive_GetCountToAX
    9999    add     ax, cx
    100100    ret
     
    136136BootMenu_GetMenuitemToAXforAsciiHotkeyInAL:
    137137    call    Char_ALtoUpperCaseLetter
    138     call    BootMenu_GetLetterForFirstHardDiskToCL
    139138    xor     ah, ah
    140     cmp     al, cl                      ; Letter is for Hard Disk?
     139    xchg    ax, cx
     140    call    BootMenu_GetLetterForFirstHardDiskToAL
     141    cmp     cl, al                      ; Letter is for Hard Disk?
    141142    jae     SHORT .StartFromHardDiskLetter
     143    xchg    ax, cx
    142144    sub     al, 'A'                     ; Letter to Floppy Drive menuitem
    143145    ret
    144146ALIGN JUMP_ALIGN
    145147.StartFromHardDiskLetter:
    146     sub     al, cl                      ; Hard Disk index
    147     call    FloppyDrive_GetCountToCX
     148    sub     cl, al                      ; Hard Disk index
     149    call    FloppyDrive_GetCountToAX
    148150    add     ax, cx                      ; Menuitem index
     151                                        ; Note: no need to xchg ax, cx as above, since adding with result to ax
    149152    ret
    150153
     
    160163;       CL:     Upper case letter for first hard disk
    161164;   Corrupts registers:
    162 ;       CH
    163 ;--------------------------------------------------------------------
    164 ALIGN JUMP_ALIGN
    165 BootMenu_GetLetterForFirstHardDiskToCL:
    166     call    FloppyDrive_GetCountToCX
    167     add     cl, 'A'
    168     cmp     cl, 'C'
     165;       AX
     166;--------------------------------------------------------------------
     167ALIGN JUMP_ALIGN
     168BootMenu_GetLetterForFirstHardDiskToAL:
     169    call    FloppyDrive_GetCountToAX
     170    add     al, 'A'
     171    cmp     al, 'C'
    169172    ja      .Return
    170     mov     cl, 'C'
     173    mov     al, 'C'
    171174ALIGN JUMP_ALIGN, ret
    172175.Return:
     
    181184;       DX:     Menuitem index (assuming drive is available)
    182185;   Corrupts registers:
    183 ;       Nothing
     186;       AX
    184187;--------------------------------------------------------------------
    185188ALIGN JUMP_ALIGN
     
    188191    test    dl, dl
    189192    jns     SHORT .ReturnItemIndexInDX  ; Return if floppy drive (HD bit not set)
    190     call    FloppyDrive_GetCountToCX
     193    call    FloppyDrive_GetCountToAX
    191194    and     dl, ~80h                    ; Clear HD bit
    192     add     dx, cx
     195    add     dx, ax
    193196.ReturnItemIndexInDX:
    194197    ret
     
    212215    test    dl, dl                              ; Floppy drive?
    213216    jns     SHORT .IsFloppyDriveInSystem
    214     call    RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
    215     or      cl, 80h                             ; Set Hard Disk bit to CX
     217    call    RamVars_GetHardDiskCountFromBDAtoAX ; Hard Disk count to AX
     218    or      al, 80h                             ; Set Hard Disk bit to AX
    216219    jmp     SHORT .CompareDriveNumberToDriveCount
    217220.IsFloppyDriveInSystem:
    218     call    FloppyDrive_GetCountToCX
     221    call    FloppyDrive_GetCountToAX
    219222.CompareDriveNumberToDriveCount:
    220     cmp     dl, cl                              ; Set CF when DL is smaller
    221     ret
     223    cmp     dl, al                              ; Set CF when DL is smaller
     224    ret
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm

    r248 r258  
    2121%ifdef MENUEVENT_INLINE_OFFSETS
    2222
    23     add     bx, BootMenuEvent_Handler
     23    add     bx, BootMenuEvent_Handler.FirstEvent
    2424    jmp     bx
    2525
    26 MENUEVENT_InitializeMenuinitFromDSSI equ  (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler)
    27 MENUEVENT_ExitMenu equ  (BootMenuEvent_EventCompleted - BootMenuEvent_Handler)
    28 MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler)
    29 MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler)
    30 MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler)
    31 MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler)
    32 MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler)
    33 MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler)
     26MENUEVENT_InitializeMenuinitFromDSSI equ  (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler.FirstEvent)
     27MENUEVENT_ExitMenu equ  (BootMenuEvent_EventCompleted - BootMenuEvent_Handler.FirstEvent)
     28MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler.FirstEvent)
     29MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler.FirstEvent)
     30MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler.FirstEvent)
     31MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler.FirstEvent)
     32MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler.FirstEvent)
     33MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler.FirstEvent)
    3434;
    3535; Note that there is no entry for MENUEVENT_IdleProcessing.  If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
     
    6767;   DS:SI:      Ptr to initialized MENUINIT struct
    6868ALIGN JUMP_ALIGN
     69.FirstEvent:   
    6970.InitializeMenuinitFromDSSI:
    7071    push    ds
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r255 r258  
    2424
    2525    call    RamVars_IsDriveHandledByThisBIOS               
    26     jnc     .notOurs
     26    jc      .notOurs
    2727
    2828    call    FindDPT_ForDriveNumber                  ; if it is one of ours, print the string in bootnfo
     
    4747    push    ax                                      ; the hard disks don't ever use it, but it does no harm)
    4848       
    49     jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
     49    jmp     short BootMenuPrint_RefreshInformation.FormatRelay
    5050
    5151;--------------------------------------------------------------------
     
    8787    push    bp
    8888    mov     bp,sp
    89     jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
     89    jmp     short BootMenuPrint_RefreshInformation.FormatRelay
    9090
    9191       
     
    110110    mov     bp, sp
    111111
     112    mov     si, g_szCapacity                            ; Setup print string now, carries through to print call
     113
     114    xor     di, di
     115    call    RamVars_IsDriveHandledByThisBIOS
     116    jc      SHORT .notours
     117    call    FindDPT_ForDriveNumber                      ; DS:DI to point DPT
     118.notours:       
     119       
    112120    test    dl, dl                                      ; are we a hard disk?
    113121    js      BootMenuPrint_HardDiskRefreshInformation       
    114        
     122
     123    test    di,di
     124    jnz     .ours
    115125    call    FloppyDrive_GetType                         ; Get Floppy Drive type to BX
     126    jmp     .around
     127.ours:
     128    call    AH8h_GetDriveParameters
     129.around:               
    116130
    117131    mov     ax, g_szFddSizeOr                           ; .PrintXTFloppyType
    118     test    bx, bx                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
     132    test    bl, bl                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
    119133    jz      SHORT .PushAXAndOutput
    120134
     
    158172
    159173    mov     al,FloppyTypes.rgbCapacityMultiplier
     174    mov     bh, 0
    160175    mul     byte [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
    161176
     
    163178    push    ax
    164179
    165     jmp     short BootMenuPrint_HardDiskRefreshInformation.output
     180.FormatRelay:
     181    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
    166182
    167183
     
    180196ALIGN JUMP_ALIGN
    181197BootMenuPrint_HardDiskRefreshInformation:       
    182     call    RamVars_IsDriveHandledByThisBIOS
    183     jnc     SHORT .HardDiskMenuitemInfoForForeignDrive
    184     call    FindDPT_ForDriveNumber                      ; DS:DI to point DPT
    185     ; Fall to .HardDiskMenuitemInfoForOurDrive
    186 
    187 ;--------------------------------------------------------------------
    188 ; .HardDiskMenuitemInfoForOurDrive
    189 ;   Parameters:
    190 ;       DL:     Untranslated Hard Disk number
    191 ;       DS:DI:  Ptr to DPT
    192 ;   Returns:
    193 ;       Nothing
    194 ;   Corrupts registers:
    195 ;       AX, BX, CX, DX, SI, DI, ES
    196 ;--------------------------------------------------------------------
     198    test    di,di
     199    jz      .HardDiskMenuitemInfoForForeignDrive       
     200
    197201.HardDiskMenuitemInfoForOurDrive:
    198202    ePUSH_T ax, g_szInformation
     
    200204    ; Get and push total LBA size
    201205    call    BootMenuInfo_GetTotalSectorCount
    202     call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat       
    203     jmp     BootMenuPrintCfg_ForOurDrive
    204 
    205 ;--------------------------------------------------------------------
    206 ; .HardDiskMenuitemInfoForForeignDrive
    207 ;   Parameters:
    208 ;       DL:     Untranslated Hard Disk number
    209 ;       DS:     RAMVARS segment
    210 ;   Returns:
    211 ;       CF:     Set since menu event was handled successfully
    212 ;   Corrupts registers:
    213 ;       AX, BX, CX, DX, SI, DI
    214 ;--------------------------------------------------------------------
    215 ALIGN JUMP_ALIGN
     206    jmp     .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     207       
    216208.HardDiskMenuitemInfoForForeignDrive:
    217209    call    DriveXlate_ToOrBack
    218210    call    AH15h_GetSectorCountFromForeignDriveToDXAX
    219     call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    220 
    221 ALIGN JUMP_ALIGN       
    222 .output:
    223     mov     si, g_szCapacity
    224 ;;; fall-through
     211
     212.ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
     213    ePUSH_T cx, g_szCapacityNum     ; Push format substring
     214    call    Size_ConvertSectorCountInBXDXAXtoKiB
     215    mov     cx, BYTE_MULTIPLES.kiB
     216    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
     217    push    ax                      ; Size in magnitude
     218    push    cx                      ; Tenths
     219    push    dx                      ; Magnitude character       
     220               
     221    test    di,di
     222    jz      short BootMenuPrint_FormatCSSIfromParamsInSSBP
     223
     224%include "BootMenuPrintCfg.asm"         ; inline of code to fill out remainder of information string
     225
     226;;; fall-through to BootMenuPrint_FormatCSSIfromParamsInSSBP
     227
    225228
    226229;--------------------------------------------------------------------
     
    273276ALIGN JUMP_ALIGN
    274277BootMenuPrint_TheBottomOfScreen:
    275     call    FloppyDrive_GetCountToCX
    276     mov     bl, cl                  ; Floppy Drive count to BL
    277     call    RamVars_GetHardDiskCountFromBDAtoCX
    278     mov     bh, cl                  ; Hard Disk count to BH
     278    call    FloppyDrive_GetCountToAX
     279    xchg    bx, ax                  ; Floppy Drive count to BL
     280    call    RamVars_GetHardDiskCountFromBDAtoAX
     281    mov     bh, al                  ; Hard Disk count to BH
    279282    ; Fall to .MoveCursorToHotkeyStrings
    280283
     
    321324    test    bh, bh      ; Any Hard Drives?
    322325    jz      SHORT .SkipHardDriveHotkeys
    323     xchg    ax, cx      ; Store Key Attribute
    324     call    BootMenu_GetLetterForFirstHardDiskToCL
    325     mov     ch, ANGLE_QUOTE_RIGHT
    326     xchg    ax, cx
     326    call    BootMenu_GetLetterForFirstHardDiskToAL
     327    mov     ah, ANGLE_QUOTE_RIGHT
    327328    mov     si, g_szHDD
    328329    call    PushHotkeyParamsAndFormat
     
    390391    CALL_DISPLAY_LIBRARY InitializeDisplayContext
    391392    ret
    392 
    393 
    394 ;--------------------------------------------------------------------
    395 ; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    396 ;   Parameters:
    397 ;       BX:DX:AX:   Sector count
    398 ;   Returns:
    399 ;       Size in stack
    400 ;   Corrupts registers:
    401 ;       AX, BX, CX, DX, SI
    402 ;--------------------------------------------------------------------
    403 ALIGN JUMP_ALIGN
    404 ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
    405     pop     si                      ; Pop return address
    406     ePUSH_T cx, g_szCapacityNum     ; Push format substring
    407     call    Size_ConvertSectorCountInBXDXAXtoKiB
    408     mov     cx, BYTE_MULTIPLES.kiB
    409     call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
    410     push    ax                      ; Size in magnitude
    411     push    cx                      ; Tenths
    412     push    dx                      ; Magnitude character
    413     jmp     si
    414393
    415394
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm

    r241 r258  
    22; Description   :   Functions for printing drive configuration
    33;                   information on Boot Menu.
    4 
     4;
     5; Included by BootMenuPrint.asm, this routine is to be inserted into
     6; BootMenuPrint_HardDiskRefreshInformation.
     7;
    58; Section containing code
    69SECTION .text
     10
     11;;; fall-into from BootMenuPrint_HardDiskRefreshInformation.
    712
    813;--------------------------------------------------------------------
     
    1621;       Nothing
    1722;   Corrupts registers:
    18 ;       AX, BX, CX, DX, SI, DI
     23;       AX, BX, CX, DX
    1924;--------------------------------------------------------------------
    20 ALIGN JUMP_ALIGN
    21 BootMenuPrintCfg_ForOurDrive:
     25.BootMenuPrintCfg_ForOurDrive:
    2226    eMOVZX  ax, BYTE [di+DPT.bIdevarsOffset]
    23     xchg    si, ax                      ; CS:SI now points to IDEVARS
     27    xchg    bx, ax                      ; CS:BX now points to IDEVARS
    2428    ; Fall to .PushAndFormatCfgString
    2529
     
    2832;   Parameters:
    2933;       DS:DI:  Ptr to DPT
    30 ;       CS:SI:  Ptr to IDEVARS
     34;       CS:BX:  Ptr to IDEVARS
    3135;   Returns:
    3236;       Nothing (jumps to next push below)
    3337;   Corrupts registers:
    34 ;       AX, BX
     38;       AX, CX
    3539;--------------------------------------------------------------------
    3640.PushAddressingMode:
     
    4145    ;; with AL clear, and so we exchange AL and AH after the multiply for the final result.
    4246    ;;
    43     mov     bl,(1<<(8-ADDRESSING_MODE_FIELD_POSITION)) * g_szAddressingModes_Displacement
    44     mul     bl
     47    mov     cl,(1<<(8-ADDRESSING_MODE_FIELD_POSITION)) * g_szAddressingModes_Displacement
     48    mul     cl
    4549    xchg    al,ah
    4650    add     ax,g_szAddressingModes
     
    5155;   Parameters:
    5256;       DS:DI:  Ptr to DPT
    53 ;       CS:SI:  Ptr to IDEVARS
     57;       CS:BX:  Ptr to IDEVARS
    5458;   Returns:
    5559;       Nothing (falls to next push below)
     
    6973;   Parameters:
    7074;       DS:DI:  Ptr to DPT
    71 ;       CS:SI:  Ptr to IDEVARS
     75;       CS:BX:  Ptr to IDEVARS
    7276;   Returns:
    7377;       Nothing (jumps to next push below)
     
    7781.PushBusType:
    7882    mov     al,g_szBusTypeValues_Displacement
    79     mul     BYTE [cs:si+IDEVARS.bDevice]
     83    mul     BYTE [cs:bx+IDEVARS.bDevice]
    8084       
    8185    shr     ax,1            ; divide by 2 since IDEVARS.bDevice is multiplied by 2
     
    8892;   Parameters:
    8993;       DS:DI:  Ptr to DPT
    90 ;       CS:SI:  Ptr to IDEVARS
     94;       CS:BX:  Ptr to IDEVARS
    9195;   Returns:
    9296;       Nothing (falls to next push below)
     
    9599;--------------------------------------------------------------------
    96100.PushIRQ:
    97     mov     al, BYTE [cs:si+IDEVARS.bIRQ]
     101    mov     al, BYTE [cs:bx+IDEVARS.bIRQ]
    98102    cbw
    99103    push    ax
     
    103107;   Parameters:
    104108;       DS:DI:  Ptr to DPT
    105 ;       CS:SI:  Ptr to IDEVARS
     109;       CS:BX:  Ptr to IDEVARS
    106110;   Returns:
    107111;       Nothing (falls to next push below)
     
    114118    push    ax
    115119
    116 ;--------------------------------------------------------------------
    117 ; PrintValuesFromStack
    118 ;   Parameters:
    119 ;       Stack:  All formatting parameters
    120 ;   Returns:
    121 ;       Nothing
    122 ;   Corrupts registers:
    123 ;       AX, SI, DI
    124 ;--------------------------------------------------------------------
    125 .PrintValuesFromStack:
    126     jmp     BootMenuPrint_HardDiskRefreshInformation.output
    127 
     120;;; fall-out to BootMenuPrint_HardDiskRefreshInformation.
Note: See TracChangeset for help on using the changeset viewer.