Changeset 258 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r249 r258  
    2929    mov     [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl
    3030    call    RamVars_IsFunctionHandledByThisBIOS
    31     jnc     SHORT Int13h_DirectCallToAnotherBios
     31    jc      SHORT Int13h_DirectCallToAnotherBios
     32
    3233    call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    3334
     
    139140ALIGN JUMP_ALIGN
    140141Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH:
     142%ifdef MODULE_SERIAL_FLOPPY
     143    mov     al, [bp+IDEPACK.intpack+INTPACK.dl]
     144Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber:   
     145    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber
     146%else
    141147    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
     148%endif
    142149Int13h_ReturnFromHandlerWithoutStoringErrorCode:
    143150    or      WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF   ; Return with interrupts enabled
     
    154161;   Returns:
    155162;       Depends on function
     163;       NOTE: ES:DI needs to be returned from the previous interrupt
     164;             handler, for floppy DPT in function 08h
    156165;   Corrupts registers:
    157 ;       BX, DI, ES
     166;       None
    158167;--------------------------------------------------------------------
    159168ALIGN JUMP_ALIGN
    160169Int13h_CallPreviousInt13hHandler:
    161     push    di
    162170    call    ExchangeCurrentInt13hHandlerWithOldInt13hHandler
    163171    int     BIOS_DISK_INTERRUPT_13h
    164     call    ExchangeCurrentInt13hHandlerWithOldInt13hHandler
    165     pop     di
    166     ret
    167 
     172;;;  fall-through to ExchangeCurrentInt13hHandlerWithOldInt13hHandler
    168173
    169174;--------------------------------------------------------------------
     
    174179;       Nothing
    175180;   Corrupts registers:
    176 ;       DI
     181;       Nothing
     182;       Note: Flags are preserved
    177183;--------------------------------------------------------------------
    178184ALIGN JUMP_ALIGN
    179185ExchangeCurrentInt13hHandlerWithOldInt13hHandler:
    180186    push    es
    181     LOAD_BDA_SEGMENT_TO es, di
    182     mov     di, [RAMVARS.fpOldI13h]
     187    push    si
     188    LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO  es, si
     189    mov     si, [RAMVARS.fpOldI13h]
    183190    cli
    184     xchg    di, [es:BIOS_DISK_INTERRUPT_13h*4]
    185     mov     [RAMVARS.fpOldI13h], di
    186     mov     di, [RAMVARS.fpOldI13h+2]
    187     xchg    di, [es:BIOS_DISK_INTERRUPT_13h*4+2]
     191    xchg    si, [es:BIOS_DISK_INTERRUPT_13h*4]
     192    mov     [RAMVARS.fpOldI13h], si
     193    mov     si, [RAMVARS.fpOldI13h+2]
     194    xchg    si, [es:BIOS_DISK_INTERRUPT_13h*4+2]
    188195    sti
    189     mov     [RAMVARS.fpOldI13h+2], di
     196    mov     [RAMVARS.fpOldI13h+2], si
     197    pop     si
    190198    pop     es
    191199    ret
     
    204212;--------------------------------------------------------------------
    205213ALIGN JUMP_ALIGN
     214%ifdef MODULE_SERIAL_FLOPPY
     215Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber:
     216    ; Store error code to BDA
     217    mov     bx, BDA.bHDLastSt
     218    test    al, al
     219    js      .HardDisk
     220    mov     bl, BDA.bFDRetST & 0xff
     221.HardDisk:
     222    LOAD_BDA_SEGMENT_TO ds, di
     223    mov     [bx], ah       
     224%else
    206225Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH:
    207226    ; Store error code to BDA
    208     LOAD_BDA_SEGMENT_TO ds, di
     227    LOAD_BDA_SEGMENT_TO ds, di     
    209228    mov     [BDA.bHDLastSt], ah
     229%endif
    210230
    211231    ; Store error code to INTPACK
Note: See TracChangeset for help on using the changeset viewer.