[3] | 1 | ; File name : FloppyDrive.asm
|
---|
| 2 | ; Project name : IDE BIOS
|
---|
| 3 | ; Created date : 25.3.2010
|
---|
[27] | 4 | ; Last update : 28.7.2010
|
---|
[3] | 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Various floppy drive related functions that
|
---|
| 7 | ; Boot Menu uses.
|
---|
| 8 |
|
---|
| 9 | ; Section containing code
|
---|
| 10 | SECTION .text
|
---|
| 11 |
|
---|
| 12 | ;--------------------------------------------------------------------
|
---|
| 13 | ; Checks is floppy drive handler installed to interrupt vector 40h.
|
---|
| 14 | ;
|
---|
| 15 | ; FloppyDrive_IsInt40hInstalled
|
---|
| 16 | ; Parameters:
|
---|
| 17 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
| 18 | ; Returns:
|
---|
| 19 | ; CF: Set if INT 40h is installed
|
---|
| 20 | ; Cleared if INT 40h is not installed
|
---|
| 21 | ; Corrupts registers:
|
---|
| 22 | ; BX, CX, DI
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
| 24 | ALIGN JUMP_ALIGN
|
---|
| 25 | FloppyDrive_IsInt40hInstalled:
|
---|
| 26 | cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment?
|
---|
[27] | 27 | cmc
|
---|
[3] | 28 | ret
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | ;--------------------------------------------------------------------
|
---|
| 32 | ; Returns floppy drive type.
|
---|
| 33 | ; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
|
---|
| 34 | ; is still returned for them.
|
---|
| 35 | ;
|
---|
| 36 | ; FloppyDrive_GetType
|
---|
| 37 | ; Parameters:
|
---|
| 38 | ; DL: Floppy Drive number
|
---|
| 39 | ; Returns:
|
---|
| 40 | ; BX: Floppy Drive Type:
|
---|
| 41 | ; FLOPPY_TYPE_525_OR_35_DD
|
---|
| 42 | ; FLOPPY_TYPE_525_DD
|
---|
| 43 | ; FLOPPY_TYPE_525_HD
|
---|
| 44 | ; FLOPPY_TYPE_35_DD
|
---|
| 45 | ; FLOPPY_TYPE_35_HD
|
---|
| 46 | ; FLOPPY_TYPE_35_ED
|
---|
| 47 | ; CF: Set if AH=08h not supported (XT systems) or error
|
---|
| 48 | ; Cleared if type read correctly (AT systems)
|
---|
| 49 | ; Corrupts registers:
|
---|
| 50 | ; AX, CX, DX, DI, ES
|
---|
| 51 | ;--------------------------------------------------------------------
|
---|
| 52 | ALIGN JUMP_ALIGN
|
---|
| 53 | FloppyDrive_GetType:
|
---|
| 54 | mov ah, 08h ; Get Drive Parameters
|
---|
| 55 | xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
|
---|
| 56 | int INTV_FLOPPY_FUNC
|
---|
| 57 | ret
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | ;--------------------------------------------------------------------
|
---|
| 61 | ; Returns number of Floppy Drives in system.
|
---|
| 62 | ;
|
---|
| 63 | ; FloppyDrive_GetCount
|
---|
| 64 | ; Parameters:
|
---|
| 65 | ; Nothing
|
---|
| 66 | ; Returns:
|
---|
| 67 | ; CX: Number of Floppy Drives
|
---|
| 68 | ; Corrupts registers:
|
---|
| 69 | ; Nothing
|
---|
| 70 | ;--------------------------------------------------------------------
|
---|
| 71 | ALIGN JUMP_ALIGN
|
---|
| 72 | FloppyDrive_GetCount:
|
---|
| 73 | push es
|
---|
| 74 | call FloppyDrive_GetCountFromBIOS
|
---|
| 75 | jnc SHORT .CompareToUserMinimum
|
---|
| 76 | call FloppyDrive_GetCountFromBDA
|
---|
| 77 | ALIGN JUMP_ALIGN
|
---|
| 78 | .CompareToUserMinimum:
|
---|
| 79 | MAX_U cl, [cs:ROMVARS.bMinFddCnt]
|
---|
| 80 | xor ch, ch
|
---|
| 81 | pop es
|
---|
| 82 | ret
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | ;--------------------------------------------------------------------
|
---|
| 86 | ; Reads Floppy Drive Count from BIOS.
|
---|
| 87 | ; Does not work on most XT systems. Call FloppyDrive_GetCountFromBDA
|
---|
| 88 | ; if this function fails.
|
---|
| 89 | ;
|
---|
| 90 | ; FloppyDrive_GetCountFromBIOS
|
---|
| 91 | ; Parameters:
|
---|
| 92 | ; Nothing
|
---|
| 93 | ; Returns:
|
---|
| 94 | ; CL: Number of Floppy Drives
|
---|
| 95 | ; CF: Cleared if successfull
|
---|
| 96 | ; Set if BIOS function not supported
|
---|
| 97 | ; Corrupts registers:
|
---|
| 98 | ; CH, ES
|
---|
| 99 | ;--------------------------------------------------------------------
|
---|
| 100 | ALIGN JUMP_ALIGN
|
---|
| 101 | FloppyDrive_GetCountFromBIOS:
|
---|
| 102 | push di
|
---|
| 103 | push dx
|
---|
| 104 | push bx
|
---|
| 105 | push ax
|
---|
| 106 |
|
---|
| 107 | mov ah, 08h ; Get Drive Parameters
|
---|
| 108 | xor dx, dx ; Floppy Drive 00h
|
---|
| 109 | int INTV_FLOPPY_FUNC
|
---|
| 110 | mov cl, dl ; Number of Floppy Drives to CL
|
---|
| 111 |
|
---|
| 112 | pop ax
|
---|
| 113 | pop bx
|
---|
| 114 | pop dx
|
---|
| 115 | pop di
|
---|
| 116 | ret
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | ;--------------------------------------------------------------------
|
---|
| 120 | ; Reads Floppy Drive Count (0...4) from BIOS Data Area.
|
---|
| 121 | ; This function should be used only if FloppyDrive_GetCountFromBIOS fails.
|
---|
| 122 | ;
|
---|
| 123 | ; FloppyDrive_GetCountFromBDA
|
---|
| 124 | ; Parameters:
|
---|
| 125 | ; Nothing
|
---|
| 126 | ; Returns:
|
---|
| 127 | ; CL: Number of Floppy Drives
|
---|
| 128 | ; Corrupts registers:
|
---|
| 129 | ; CH, ES
|
---|
| 130 | ;--------------------------------------------------------------------
|
---|
| 131 | ALIGN JUMP_ALIGN
|
---|
| 132 | FloppyDrive_GetCountFromBDA:
|
---|
| 133 | LOAD_BDA_SEGMENT_TO es, cx
|
---|
| 134 | mov cl, [es:BDA.wEquipment] ; Load Equipment WORD low byte
|
---|
| 135 | mov ch, cl ; Copy it to CH
|
---|
| 136 | and cx, 0C001h ; Leave bits 15..14 and 0
|
---|
| 137 | eROL_IM ch, 2 ; EW low byte bits 7..6 to 1..0
|
---|
| 138 | add cl, ch ; CL = Floppy Drive count
|
---|
| 139 | ret
|
---|