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


Ignore:
Timestamp:
Feb 22, 2012, 7:01:53 PM (12 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/Initialization
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm

    r254 r258  
    4343
    4444%ifdef MODULE_SERIAL
     45;----------------------------------------------------------------------
    4546;
    4647; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
     
    5758%endif
    5859
    59 .done:
     60.done: 
     61%ifdef MODULE_SERIAL_FLOPPY
     62;----------------------------------------------------------------------
     63;
     64; Add in any emulated serial floppy drives.
     65;
     66    mov     al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt]
     67    dec     al
     68    mov     cl, al
     69    js      .NoFloppies                     ; if no drives are present, we store 0ffh
     70
     71    call    FloppyDrive_GetCountFromBIOS_or_BDA
     72
     73    push    ax
     74
     75    add     al, cl                          ; Add our drives to existing drive count
     76    cmp     al, 3                           ; For BDA, max out at 4 drives (ours is zero based)
     77    jl      .MaxBDAFloppiesExceeded
     78    mov     al, 3                           
     79.MaxBDAFloppiesExceeded:
     80    eROR_IM al, 2                           ; move to bits 6-7
     81    inc     ax                              ; low order bit, indicating floppy drive exists
     82
     83    mov     ah, [es:BDA.wEquipment]         ; Load Equipment WORD low byte 
     84    and     ah, 03eh                        ; Mask off drive number and drives present bit
     85    or      al, ah                          ; Or in new values
     86    mov     [es:BDA.wEquipment], al         ; and store
     87
     88    mov     al, 1eh                         ; BDA pointer to Floppy DPT
     89    mov     si, AH8h_FloppyDPT
     90    call    Interrupts_InstallHandlerToVectorInALFromCSSI
     91
     92    pop     ax
     93
     94    shr     cl, 1                           ; number of drives, 1 or 2 only, to CF flag (clear=1, set=2)
     95    rcl     al, 1                           ; starting drive number in upper 7 bits, number of drives in low bit
     96.NoFloppies:   
     97    mov     [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], al
     98%endif
     99       
    60100    ret
    61101
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm

    r181 r258  
    120120; Returns number of Floppy Drives in system.
    121121;
    122 ; FloppyDrive_GetCountToCX
    123 ;   Parameters:
    124 ;       Nothing
    125 ;   Returns:
    126 ;       CX:     Number of Floppy Drives
    127 ;   Corrupts registers:
    128 ;       Nothing
    129 ;--------------------------------------------------------------------
    130 ALIGN JUMP_ALIGN
    131 FloppyDrive_GetCountToCX:
     122; FloppyDrive_GetCountToAX
     123;   Parameters:
     124;       DS:     RAMVARS Segment
     125;   Returns:
     126;       AX:     Number of Floppy Drives
     127;--------------------------------------------------------------------
     128ALIGN JUMP_ALIGN
     129FloppyDrive_GetCountToAX:       
     130%ifdef MODULE_SERIAL_FLOPPY
     131    call    RamVars_UnpackFlopCntAndFirstToAL
     132    adc     al,1                        ; adds in the drive count bit, and adds 1 for count vs. 0-index,
     133                                        ; but still won't impact SF
     134    jns     .UseInternalNumber          ; need to clear CH on the way out, and add in additional drive numbers
     135
     136%endif
     137    call    FloppyDrive_GetCountFromBIOS_or_BDA
     138       
     139.UseInternalNumber:
     140    mov     ah, [cs:ROMVARS.bMinFddCnt]
     141    MAX_U   al, ah
     142    cbw
     143       
     144    ret
     145
     146ALIGN JUMP_ALIGN       
     147FloppyDrive_GetCountFromBIOS_or_BDA:
    132148    push    es
    133 %ifdef USE_AT
    134     call    GetCountFromBIOS
    135 %else
    136     call    GetCountFromBDA
    137 %endif
    138     mov     ch, [cs:ROMVARS.bMinFddCnt]
    139     MAX_U   cl, ch
    140     pop     es
    141     xor     ch, ch
    142     ret
    143 
    144149
    145150;--------------------------------------------------------------------
     
    160165%ifdef USE_AT
    161166ALIGN JUMP_ALIGN
    162 GetCountFromBIOS:
     167.GetCountFromBIOS:
    163168    push    di
    164169    push    dx
    165170    push    bx
    166     push    ax
    167171
    168172    mov     ah, 08h                 ; Get Drive Parameters
    169173    cwd                             ; Floppy Drive 00h
    170174    int     BIOS_DISKETTE_INTERRUPT_40h
    171     mov     cl, dl                  ; Number of Floppy Drives to CL
    172 
    173     pop     ax
     175    mov     al, dl                  ; Number of Floppy Drives to AL
     176
    174177    pop     bx
    175178    pop     dx
    176179    pop     di
    177     ret
    178 %endif
    179 
     180%endif
    180181
    181182;--------------------------------------------------------------------
     
    193194%ifndef USE_AT
    194195ALIGN JUMP_ALIGN
    195 GetCountFromBDA:
    196     LOAD_BDA_SEGMENT_TO es, cx
    197     mov     cl, [es:BDA.wEquipment]         ; Load Equipment WORD low byte
    198     mov     ch, cl                          ; Copy it to CH
    199     and     cx, 0C001h                      ; Leave bits 15..14 and 0
    200     eROL_IM ch, 2                           ; EW low byte bits 7..6 to 1..0
    201     add     cl, ch                          ; CL = Floppy Drive count
    202     ret
    203 %endif
     196.GetCountFromBDA:
     197    LOAD_BDA_SEGMENT_TO es, ax
     198    mov     al, [es:BDA.wEquipment]         ; Load Equipment WORD low byte
     199    mov     ah, al                          ; Copy it to CH
     200    and     ax, 0C001h                      ; Leave bits 15..14 and 0
     201    eROL_IM ah, 2                           ; EW low byte bits 7..6 to 1..0
     202    add     al, ah                          ; CL = Floppy Drive count
     203%endif
     204
     205    pop     es
     206    ret
     207       
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r243 r258  
    2929
    3030    ; Install INT 19h handler (boot loader) where drives are detected
    31     mov     bx, BIOS_BOOT_LOADER_INTERRUPT_19h
     31    mov     al, BIOS_BOOT_LOADER_INTERRUPT_19h
    3232    mov     si, Int19h_BootLoaderHandler
    33     call    Interrupts_InstallHandlerToVectorInBXFromCSSI
     33    call    Interrupts_InstallHandlerToVectorInALFromCSSI
    3434
    3535.SkipRomInitialization:
     
    7373    mov     dl, 80h
    7474    call    RamVars_IsDriveHandledByThisBIOS
    75     jnc     SHORT .FindForDrive81h  ; Store nothing if not our drive
     75    jc      SHORT .FindForDrive81h  ; Store nothing if not our drive
    7676    call    FindDPT_ForDriveNumber  ; DPT to DS:DI
    7777    mov     [es:HD0_DPT_POINTER_41h*4], di
     
    8080    inc     dx
    8181    call    RamVars_IsDriveHandledByThisBIOS
    82     jnc     SHORT .ResetDetectedDrives
     82    jc      SHORT .ResetDetectedDrives
    8383    call    FindDPT_ForDriveNumber
    8484    mov     [es:HD1_DPT_POINTER_46h*4], di
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm

    r243 r258  
    3434    mov     ax, [es:BIOS_DISK_INTERRUPT_13h*4]  ; Load old INT 13h offset
    3535    mov     [RAMVARS.fpOldI13h], ax             ; Store old INT 13h offset
    36 
    37     mov     bx, BIOS_DISK_INTERRUPT_13h         ; INT 13h interrupt vector offset
    38     mov     si, Int13h_DiskFunctionsHandler     ; Interrupt handler offset
    39     call    Interrupts_InstallHandlerToVectorInBXFromCSSI
    4036
    4137    ; Only store INT 13h handler to 40h if 40h is not already installed.
     
    4743    mov     [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx    ; Store old INT 13h segment
    4844.Int40hAlreadyInstalled:
     45
     46    mov     al, BIOS_DISK_INTERRUPT_13h         ; INT 13h interrupt vector offset
     47    mov     si, Int13h_DiskFunctionsHandler     ; Interrupt handler offset
     48    call    Interrupts_InstallHandlerToVectorInALFromCSSI
    4949    ; Fall to .InitializeHardwareIrqHandlers
    5050
     
    5656;       Nothing
    5757;   Corrupts registers:
    58 ;       BX, CX, DX, SI, DI
     58;       BX, CX, DX, SI, DI, AX
    5959;--------------------------------------------------------------------
    6060.InitializeHardwareIrqHandlers:
     
    6262    mov     di, ROMVARS.ideVars0            ; CS:SI points to first IDEVARS
    6363.IdeControllerLoop:
    64     eMOVZX  bx, BYTE [cs:di+IDEVARS.bIRQ]
     64    mov     al, BYTE [cs:di+IDEVARS.bIRQ]
    6565    add     di, BYTE IDEVARS_size           ; Increment to next controller
    6666    call    .InstallLowOrHighIrqHandler
     
    7272; .InstallLowOrHighIrqHandler
    7373;   Parameters:
    74 ;       BX:     IRQ number, 0 if IRQ disabled
     74;       AL:     IRQ number, 0 if IRQ disabled
    7575;       ES:     BDA and Interrupt Vector segment (zero)
    7676;   Returns:
     
    8080;--------------------------------------------------------------------
    8181.InstallLowOrHighIrqHandler:
    82     test    bl, bl
     82    test    al, al
    8383    jz      SHORT .Return   ; IRQ not used
    84     cmp     bl, 8
     84    cmp     al, 8
    8585    jb      SHORT .InstallLowIrqHandler
    8686    ; Fall to .InstallHighIrqHandler
     
    9494;       Nothing
    9595;   Corrupts registers:
    96 ;       BX, SI
     96;       AL, BX, SI
    9797;--------------------------------------------------------------------
    9898.InstallHighIrqHandler:
    99     add     bx, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8   ; Interrupt vector number
     99    add     al, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8   ; Interrupt vector number
    100100    mov     si, IdeIrq_InterruptServiceRoutineForIrqs8to15
    101     jmp     SHORT Interrupts_InstallHandlerToVectorInBXFromCSSI
     101    jmp     SHORT Interrupts_InstallHandlerToVectorInALFromCSSI
    102102
    103103;--------------------------------------------------------------------
    104104; .InstallLowIrqHandler
    105105;   Parameters:
    106 ;       BX:     IRQ number (0...7)
    107 ;       ES:     BDA and Interrupt Vector segment (zero)
    108 ;   Returns:
    109 ;       Nothing
    110 ;   Corrupts registers:
    111 ;       BX, SI
     106;       AL:     IRQ number (0...7)
     107;       ES:     BDA and Interrupt Vector segment (zero)
     108;   Returns:
     109;       Nothing
     110;   Corrupts registers:
     111;       AL, BX, SI
    112112;--------------------------------------------------------------------
    113113.InstallLowIrqHandler:
    114     add     bx, BYTE HARDWARE_IRQ_0_INTERRUPT_08h       ; Interrupt vector number
     114    add     al, BYTE HARDWARE_IRQ_0_INTERRUPT_08h       ; Interrupt vector number
    115115    mov     si, IdeIrq_InterruptServiceRoutineForIrqs2to7
    116     ; Fall to Interrupts_InstallHandlerToVectorInBXFromCSSI
    117 
    118 
    119 ;--------------------------------------------------------------------
    120 ; Interrupts_InstallHandlerToVectorInBXFromCSSI
    121 ;   Parameters:
    122 ;       BX:     Interrupt vector number (for example 13h)
     116    ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI
     117
     118
     119;--------------------------------------------------------------------
     120; Interrupts_InstallHandlerToVectorInALFromCSSI
     121;   Parameters:
     122;       AL:     Interrupt vector number (for example 13h)
    123123;       ES:     BDA and Interrupt Vector segment (zero)
    124124;       CS:SI:  Ptr to interrupt handler
     
    126126;       Nothing
    127127;   Corrupts registers:
    128 ;       BX
    129 ;--------------------------------------------------------------------
    130 Interrupts_InstallHandlerToVectorInBXFromCSSI:
    131     eSHL_IM bx, 2                   ; Shift for DWORD offset
     128;       AX, BX
     129;--------------------------------------------------------------------
     130Interrupts_InstallHandlerToVectorInALFromCSSI:
     131    mov     bl, 4                   ; Shift for DWORD offset, MUL smaller than other alternatives
     132    mul     bl
     133    xchg    ax, bx
    132134    mov     [es:bx], si             ; Store offset
    133135    mov     [es:bx+2], cs           ; Store segment
Note: See TracChangeset for help on using the changeset viewer.