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/AH8h_HParams.asm

    r227 r258  
    1414;       SS:BP:  Ptr to IDEPACK
    1515;   Returns with INTPACK:
     16;       BL:     Drive Type (for floppies only)
    1617;       CH:     Maximum cylinder number, bits 7...0
    1718;       CL:     Bits 7...6: Cylinder number bits 9...8
     
    1920;       DH:     Maximum head number (0...255)
    2021;       DL:     Number of drives
     22;       ES:DI:  Floppy DPT (for floppies only)
    2123;       AH:     Int 13h/40h floppy return status
    2224;       CF:     0 if successfull, 1 if error
    2325;--------------------------------------------------------------------
    2426AH8h_HandlerForReadDiskDriveParameters:
     27
    2528    call    RamVars_IsDriveHandledByThisBIOS
    26     jnc     SHORT .GetDriveParametersForForeignHardDiskInDL
     29    jnc     SHORT .OurDrive
     30
     31    call    Int13h_CallPreviousInt13hHandler
     32    jnc     SHORT .MidGame
     33    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     34       
     35.OurDrive:     
    2736    call    AH8h_GetDriveParameters
    28     jmp     SHORT .ReturnAfterStoringValuesToIntpack
    2937
    30 .GetDriveParametersForForeignHardDiskInDL:
    31     call    Int13h_CallPreviousInt13hHandler
    32     jc      SHORT .ReturnErrorFromPreviousInt13hHandler
    33     call    RamVars_GetCountOfKnownDrivesToDL
    34 .ReturnAfterStoringValuesToIntpack:
     38%ifdef MODULE_SERIAL_FLOPPY
     39    push    cs                          ; setup registers if we are a floppy drive, in all cases
     40    pop     es                          ; if it is not a floppy drive, these values will not be put in INTPACK
     41    mov     di, AH8h_FloppyDPT
     42%endif
     43    ;; fall-through
     44       
     45.MidGame:       
     46    call    RamVars_GetCountOfKnownDrivesToAX       ; assume hard disk for now, will discard if for floppies
     47
     48    test    byte [bp+IDEPACK.intpack+INTPACK.dl], 080h
     49    jnz     .Done
     50       
     51    mov     [bp+IDEPACK.intpack+INTPACK.bl], bl
     52
     53    mov     [bp+IDEPACK.intpack+INTPACK.es], es
     54    mov     [bp+IDEPACK.intpack+INTPACK.di], di     
     55
     56    call    FloppyDrive_GetCountToAX
     57
     58.Done: 
     59    mov     ah, dh
     60       
    3561    mov     [bp+IDEPACK.intpack+INTPACK.cx], cx
    36     mov     [bp+IDEPACK.intpack+INTPACK.dx], dx
     62    xchg    [bp+IDEPACK.intpack+INTPACK.dx], ax     ; recover DL for BDA last status byte determination
     63
    3764    xor     ah, ah
    38 .ReturnErrorFromPreviousInt13hHandler:
     65%ifdef MODULE_SERIAL_FLOPPY
     66    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber           
     67%else
    3968    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     69%endif
    4070
    4171
     
    5181;               Bits 5...0: Maximum sector number (1...63)
    5282;       DH:     Maximum head number (0...255)
    53 ;       DL:     Number of drives
    5483;   Corrupts registers:
    5584;       AX, BX
     
    73102;               Bits 5...0: Maximum sector number (1...63)
    74103;       DH:     Maximum head number (0...255)
    75 ;       DL:     Number of drives
    76104;   Corrupts registers:
    77105;       AX, BX
     
    85113    or      cl, bh                  ; CL bits 0...5 = Sectors per track
    86114    mov     dh, bl                  ; DH = Maximum head number
    87     jmp     RamVars_GetCountOfKnownDrivesToDL
     115       
     116%ifdef MODULE_SERIAL_FLOPPY
     117    mov     bl,[di+DPT.bFlagsHigh]
     118    eSHR_IM bl,FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION
     119%endif     
     120    ret
     121
     122%ifdef MODULE_SERIAL_FLOPPY
     123;
     124; Floppy Disk Parameter Table.  There is no way to specify more than one of these
     125; for any given system, so no way to make this drive or media specific.
     126; So we return fixed values out of the ROM for callers might be expecting this information.
     127;
     128; On AT systems, we return the information for a 1.44 MB disk,
     129; and on XT systems, we return the information for a 360 KB disk.
     130;
     131AH8h_FloppyDPT:
     132%ifdef USE_AT
     133    db      0ah << 4 | 0fh          ; Offset 0: Drive timings, 1.44MB values
     134%else
     135    db      0dh << 4 | 0fh          ; Offset 0: Drive timings, 360KB values
     136%endif
     137
     138    db      1h << 1 | 0             ; Offset 1: Typical values of 1 for head load time
     139                                    ;           DMA used (although it actually is not, but is more restrctive)
     140    db      25h                     ; Offset 2: Inactiviy motor turn-off delay,
     141                                    ;           Typical value of 25h for 2 second delay
     142    db      02h                     ; Offset 3: Sector size, always 512
     143
     144%ifdef USE_AT
     145    db      12h                     ; Offset 4: Sectors per track, 1.44MB value
     146    db      1bh                     ; Offset 5: Sector gap, 1.44MB value
     147%else
     148    db      09h                     ; Offset 4: Sectors per track, 360KB value
     149    db      2ah                     ; Offset 5: Sector gap, 360KB value
     150%endif
     151
     152    db      0ffh                    ; Offset 6: Data length
     153
     154%ifdef USE_AT
     155    db      6ch                     ; Offset 7: Format gap length, 1.44MB value
     156%else
     157    db      50h                     ; Offset 7: Format gap length, 360KB value
     158%endif
     159
     160    db      0f6h                    ; Offset 8: Fill byte for format
     161    db      0fh                     ; Offset 9: Head setting time
     162    db      08h                     ; Offset A: Wait for motor startpu time
     163
     164%ifdef USE_AT
     165    db      79                      ; Offset B: Maximum track number, 1.44MB value
     166    db      0                       ; Offset C: Data transfer rate, 1.44MB value
     167    db      4                       ; Offset D: Diskette CMOS drive type, 1.44MB value
     168%else
     169    db      39                      ; Offset B: Maximum track number, 360KB value
     170    db      80h                     ; Offset C: Data transfer rate, 360KB value
     171    db      1                       ; Offset D: Diskette CMOS drive type, 360KB value
     172%endif
     173%endif
Note: See TracChangeset for help on using the changeset viewer.