[93] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Int 13h function AH=8h, Read Disk Drive Parameters. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; Int 13h function AH=8h, Read Disk Drive Parameters. |
---|
| 9 | ; |
---|
| 10 | ; AH8h_HandlerForReadDiskDriveParameters |
---|
| 11 | ; Parameters: |
---|
[148] | 12 | ; DL: Translated Drive number |
---|
| 13 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
[150] | 14 | ; SS:BP: Ptr to IDEPACK |
---|
| 15 | ; Returns with INTPACK: |
---|
[258] | 16 | ; BL: Drive Type (for floppies only) |
---|
[3] | 17 | ; CH: Maximum cylinder number, bits 7...0 |
---|
| 18 | ; CL: Bits 7...6: Cylinder number bits 9...8 |
---|
| 19 | ; Bits 5...0: Maximum sector number (1...63) |
---|
| 20 | ; DH: Maximum head number (0...255) |
---|
| 21 | ; DL: Number of drives |
---|
[258] | 22 | ; ES:DI: Floppy DPT (for floppies only) |
---|
[3] | 23 | ; AH: Int 13h/40h floppy return status |
---|
| 24 | ; CF: 0 if successfull, 1 if error |
---|
| 25 | ;-------------------------------------------------------------------- |
---|
| 26 | AH8h_HandlerForReadDiskDriveParameters: |
---|
[258] | 27 | |
---|
[32] | 28 | call RamVars_IsDriveHandledByThisBIOS |
---|
[258] | 29 | jnc SHORT .OurDrive |
---|
| 30 | |
---|
| 31 | call Int13h_CallPreviousInt13hHandler |
---|
| 32 | jnc SHORT .MidGame |
---|
| 33 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
| 34 | |
---|
| 35 | .OurDrive: |
---|
[3] | 36 | call AH8h_GetDriveParameters |
---|
| 37 | |
---|
[258] | 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 | |
---|
[150] | 61 | mov [bp+IDEPACK.intpack+INTPACK.cx], cx |
---|
[258] | 62 | xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; recover DL for BDA last status byte determination |
---|
| 63 | |
---|
[148] | 64 | xor ah, ah |
---|
[258] | 65 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 66 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber |
---|
| 67 | %else |
---|
[148] | 68 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
[258] | 69 | %endif |
---|
[3] | 70 | |
---|
[32] | 71 | |
---|
[3] | 72 | ;-------------------------------------------------------------------- |
---|
| 73 | ; Returns L-CHS parameters for drive and total hard disk count. |
---|
| 74 | ; |
---|
[28] | 75 | ; AH8h_GetDriveParameters |
---|
[3] | 76 | ; Parameters: |
---|
[148] | 77 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
[3] | 78 | ; Returns: |
---|
| 79 | ; CH: Maximum cylinder number, bits 7...0 |
---|
| 80 | ; CL: Bits 7...6: Cylinder number bits 9...8 |
---|
| 81 | ; Bits 5...0: Maximum sector number (1...63) |
---|
| 82 | ; DH: Maximum head number (0...255) |
---|
| 83 | ; Corrupts registers: |
---|
[148] | 84 | ; AX, BX |
---|
[3] | 85 | ;-------------------------------------------------------------------- |
---|
| 86 | AH8h_GetDriveParameters: |
---|
[227] | 87 | call AccessDPT_GetLCHStoAXBLBH |
---|
[148] | 88 | ; Fall to .PackReturnValues |
---|
[3] | 89 | |
---|
| 90 | ;-------------------------------------------------------------------- |
---|
| 91 | ; Packs L-CHS values to INT 13h, AH=08h return values. |
---|
| 92 | ; |
---|
[148] | 93 | ; .PackReturnValues |
---|
[3] | 94 | ; Parameters: |
---|
[227] | 95 | ; AX: Number of L-CHS cylinders available (1...1024) |
---|
| 96 | ; BL: Number of L-CHS heads (1...256) |
---|
| 97 | ; BH: Number of L-CHS sectors per track (1...63) |
---|
[32] | 98 | ; DS: RAMVARS segment |
---|
[3] | 99 | ; Returns: |
---|
| 100 | ; CH: Maximum cylinder number, bits 7...0 |
---|
| 101 | ; CL: Bits 7...6: Cylinder number bits 9...8 |
---|
| 102 | ; Bits 5...0: Maximum sector number (1...63) |
---|
| 103 | ; DH: Maximum head number (0...255) |
---|
| 104 | ; Corrupts registers: |
---|
| 105 | ; AX, BX |
---|
| 106 | ;-------------------------------------------------------------------- |
---|
[148] | 107 | .PackReturnValues: |
---|
[227] | 108 | dec ax ; AX = Number of last cylinder |
---|
| 109 | dec bx ; BL = Number of last head |
---|
| 110 | xchg cx, ax |
---|
| 111 | xchg cl, ch ; CH = Last cylinder bits 0...7 |
---|
| 112 | eROR_IM cl, 2 ; CL bits 6...7 = Last cylinder bits 8...9 |
---|
| 113 | or cl, bh ; CL bits 0...5 = Sectors per track |
---|
| 114 | mov dh, bl ; DH = Maximum head number |
---|
[258] | 115 | |
---|
| 116 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 117 | mov bl,[di+DPT.bFlagsHigh] |
---|
[261] | 118 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS ; not sure why this is needed for preprocessor-only |
---|
[258] | 119 | eSHR_IM bl,FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION |
---|
[261] | 120 | %endif |
---|
[258] | 121 | %endif |
---|
| 122 | ret |
---|
| 123 | |
---|
| 124 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 125 | ; |
---|
| 126 | ; Floppy Disk Parameter Table. There is no way to specify more than one of these |
---|
| 127 | ; for any given system, so no way to make this drive or media specific. |
---|
[261] | 128 | ; So we return fixed values out of the ROM for callers who might be expecting this information. |
---|
[258] | 129 | ; |
---|
| 130 | ; On AT systems, we return the information for a 1.44 MB disk, |
---|
| 131 | ; and on XT systems, we return the information for a 360 KB disk. |
---|
| 132 | ; |
---|
| 133 | AH8h_FloppyDPT: |
---|
| 134 | %ifdef USE_AT |
---|
| 135 | db 0ah << 4 | 0fh ; Offset 0: Drive timings, 1.44MB values |
---|
| 136 | %else |
---|
| 137 | db 0dh << 4 | 0fh ; Offset 0: Drive timings, 360KB values |
---|
| 138 | %endif |
---|
| 139 | |
---|
| 140 | db 1h << 1 | 0 ; Offset 1: Typical values of 1 for head load time |
---|
| 141 | ; DMA used (although it actually is not, but is more restrctive) |
---|
| 142 | db 25h ; Offset 2: Inactiviy motor turn-off delay, |
---|
| 143 | ; Typical value of 25h for 2 second delay |
---|
| 144 | db 02h ; Offset 3: Sector size, always 512 |
---|
| 145 | |
---|
| 146 | %ifdef USE_AT |
---|
| 147 | db 12h ; Offset 4: Sectors per track, 1.44MB value |
---|
| 148 | db 1bh ; Offset 5: Sector gap, 1.44MB value |
---|
| 149 | %else |
---|
| 150 | db 09h ; Offset 4: Sectors per track, 360KB value |
---|
| 151 | db 2ah ; Offset 5: Sector gap, 360KB value |
---|
| 152 | %endif |
---|
| 153 | |
---|
| 154 | db 0ffh ; Offset 6: Data length |
---|
| 155 | |
---|
| 156 | %ifdef USE_AT |
---|
| 157 | db 6ch ; Offset 7: Format gap length, 1.44MB value |
---|
| 158 | %else |
---|
| 159 | db 50h ; Offset 7: Format gap length, 360KB value |
---|
| 160 | %endif |
---|
| 161 | |
---|
| 162 | db 0f6h ; Offset 8: Fill byte for format |
---|
| 163 | db 0fh ; Offset 9: Head setting time |
---|
| 164 | db 08h ; Offset A: Wait for motor startpu time |
---|
| 165 | |
---|
| 166 | %ifdef USE_AT |
---|
| 167 | db 79 ; Offset B: Maximum track number, 1.44MB value |
---|
| 168 | db 0 ; Offset C: Data transfer rate, 1.44MB value |
---|
| 169 | db 4 ; Offset D: Diskette CMOS drive type, 1.44MB value |
---|
| 170 | %else |
---|
| 171 | db 39 ; Offset B: Maximum track number, 360KB value |
---|
| 172 | db 80h ; Offset C: Data transfer rate, 360KB value |
---|
| 173 | db 1 ; Offset D: Diskette CMOS drive type, 360KB value |
---|
| 174 | %endif |
---|
| 175 | %endif |
---|