[99] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for accessing DPT data.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
[150] | 8 | ; AccessDPT_GetDriveSelectByteToAL
|
---|
| 9 | ; Parameters:
|
---|
| 10 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 11 | ; Returns:
|
---|
| 12 | ; AL: Drive Select Byte
|
---|
| 13 | ; Corrupts registers:
|
---|
| 14 | ; Nothing
|
---|
| 15 | ;--------------------------------------------------------------------
|
---|
| 16 | ALIGN JUMP_ALIGN
|
---|
| 17 | AccessDPT_GetDriveSelectByteToAL:
|
---|
| 18 | mov al, [di+DPT.wFlags]
|
---|
| 19 | and al, FLG_DRVNHEAD_LBA | FLG_DRVNHEAD_DRV
|
---|
| 20 | or al, MASK_DRVNHEAD_SET ; Bits set to 1 for old drives
|
---|
| 21 | ret
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
| 25 | ; AccessDPT_GetDeviceControlByteToAL
|
---|
| 26 | ; Parameters:
|
---|
| 27 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 28 | ; Returns:
|
---|
| 29 | ; AL: Device Control Byte
|
---|
| 30 | ; Corrupts registers:
|
---|
| 31 | ; Nothing
|
---|
| 32 | ;--------------------------------------------------------------------
|
---|
| 33 | ALIGN JUMP_ALIGN
|
---|
| 34 | AccessDPT_GetDeviceControlByteToAL:
|
---|
| 35 | xor al, al
|
---|
[158] | 36 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
|
---|
[150] | 37 | jnz SHORT .EnableDeviceIrq
|
---|
| 38 | or al, FLG_DEVCONTROL_nIEN ; Disable IRQ
|
---|
| 39 | .EnableDeviceIrq:
|
---|
| 40 | ret
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | ;--------------------------------------------------------------------
|
---|
| 44 | ; AccessDPT_GetAddressingModeForWordLookToBX
|
---|
| 45 | ; Parameters:
|
---|
| 46 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 47 | ; Returns:
|
---|
| 48 | ; BX: Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) shifted for WORD lookup
|
---|
| 49 | ; Corrupts registers:
|
---|
| 50 | ; Nothing
|
---|
| 51 | ;--------------------------------------------------------------------
|
---|
| 52 | ALIGN JUMP_ALIGN
|
---|
| 53 | AccessDPT_GetAddressingModeForWordLookToBX:
|
---|
[158] | 54 | mov bl, [di+DPT.bFlagsLow]
|
---|
| 55 | and bx, BYTE MASKL_DPT_ADDRESSING_MODE
|
---|
[150] | 56 | eSHR_IM bx, ADDRESSING_MODE_FIELD_POSITION-1
|
---|
| 57 | ret
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | ;--------------------------------------------------------------------
|
---|
[173] | 61 | ; AccessDPT_GetLCHS
|
---|
[3] | 62 | ; Parameters:
|
---|
| 63 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 64 | ; Returns:
|
---|
| 65 | ; AX: Number of L-CHS sectors per track
|
---|
| 66 | ; BX: Number of L-CHS cylinders
|
---|
| 67 | ; DX: Number of L-CHS heads
|
---|
| 68 | ; Corrupts registers:
|
---|
[173] | 69 | ; CX
|
---|
[3] | 70 | ;--------------------------------------------------------------------
|
---|
[173] | 71 | AccessDPT_GetLCHS:
|
---|
| 72 | ; Load CHS from DPT
|
---|
| 73 | eMOVZX ax, BYTE [di+DPT.bSectors]
|
---|
| 74 | mov bx, [di+DPT.dwCylinders]
|
---|
[161] | 75 | cwd
|
---|
[173] | 76 | mov dl, [di+DPT.bHeads]
|
---|
| 77 |
|
---|
| 78 | ; Only need to limit sectors for LBA assist
|
---|
| 79 | test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
|
---|
[181] | 80 | jz SHORT AccessDPT_ShiftPCHinBXDXtoLCH
|
---|
[173] | 81 |
|
---|
[181] | 82 | cmp WORD [di+DPT.dwCylinders+2], BYTE 0
|
---|
| 83 | jnz SHORT .Return_MAX_LCHS_CYLINDERS
|
---|
[173] | 84 |
|
---|
[181] | 85 | ; Limit cylinders to 1024
|
---|
| 86 | cmp bx, MAX_LCHS_CYLINDERS
|
---|
| 87 | jb SHORT .Return
|
---|
| 88 | ALIGN JUMP_ALIGN
|
---|
| 89 | .Return_MAX_LCHS_CYLINDERS:
|
---|
[173] | 90 | mov bx, MAX_LCHS_CYLINDERS
|
---|
[181] | 91 | ALIGN JUMP_ALIGN, ret
|
---|
| 92 | .Return:
|
---|
[3] | 93 | ret
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | ;--------------------------------------------------------------------
|
---|
[173] | 97 | ; AccessDPT_ShiftPCHinBXDXtoLCH
|
---|
| 98 | ; Parameters:
|
---|
| 99 | ; BX: P-CHS cylinders (1...16383)
|
---|
| 100 | ; DX: P-CHS heads (1...16)
|
---|
| 101 | ; Returns:
|
---|
| 102 | ; BX: Number of L-CHS cylinders (1...1024)
|
---|
| 103 | ; DX: Number of L-CHS heads (1...255)
|
---|
| 104 | ; CX: Number of bits shifted
|
---|
| 105 | ; Corrupts registers:
|
---|
| 106 | ; Nothing
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | AccessDPT_ShiftPCHinBXDXtoLCH:
|
---|
| 109 | xor cx, cx
|
---|
| 110 | .ShiftLoop:
|
---|
| 111 | cmp bx, MAX_LCHS_CYLINDERS ; Need to shift?
|
---|
| 112 | jbe SHORT .LimitHeadsTo255 ; If not, return
|
---|
| 113 | inc cx ; Increment shift count
|
---|
| 114 | shr bx, 1 ; Halve cylinders
|
---|
| 115 | shl dx, 1 ; Double heads
|
---|
| 116 | jmp SHORT .ShiftLoop
|
---|
| 117 | .LimitHeadsTo255: ; DOS does not support drives with 256 heads
|
---|
[181] | 118 | sub dl, dh ; DH set only when 256 logical heads
|
---|
[173] | 119 | xor dh, dh
|
---|
| 120 | ret
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | ;--------------------------------------------------------------------
|
---|
[3] | 124 | ; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
|
---|
| 125 | ; Parameters:
|
---|
| 126 | ; AX: Bitmask to test DRVPARAMS.wFlags
|
---|
| 127 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 128 | ; Returns:
|
---|
| 129 | ; ZF: Set if tested bit was zero
|
---|
| 130 | ; Cleared if tested bit was non-zero
|
---|
| 131 | ; CF: 0
|
---|
| 132 | ; Corrupts registers:
|
---|
| 133 | ; BX
|
---|
| 134 | ;--------------------------------------------------------------------
|
---|
| 135 | ALIGN JUMP_ALIGN
|
---|
| 136 | AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive:
|
---|
| 137 | call AccessDPT_GetPointerToDRVPARAMStoCSBX
|
---|
| 138 | test [cs:bx+DRVPARAMS.wFlags], ax
|
---|
| 139 | ret
|
---|
| 140 |
|
---|
| 141 | ;--------------------------------------------------------------------
|
---|
| 142 | ; Returns pointer to DRVPARAMS for master or slave drive.
|
---|
| 143 | ;
|
---|
| 144 | ; AccessDPT_GetPointerToDRVPARAMStoCSBX
|
---|
| 145 | ; Parameters:
|
---|
| 146 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 147 | ; Returns:
|
---|
| 148 | ; CS:BX: Ptr to DRVPARAMS
|
---|
| 149 | ; Corrupts registers:
|
---|
| 150 | ; Nothing
|
---|
| 151 | ;--------------------------------------------------------------------
|
---|
| 152 | ALIGN JUMP_ALIGN
|
---|
| 153 | AccessDPT_GetPointerToDRVPARAMStoCSBX:
|
---|
[150] | 154 | eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
|
---|
| 155 | add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
|
---|
[158] | 156 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
|
---|
[150] | 157 | jz SHORT .ReturnPointerToDRVPARAMS
|
---|
| 158 | add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
|
---|
| 159 | .ReturnPointerToDRVPARAMS:
|
---|
[3] | 160 | ret
|
---|