[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 | ;-------------------------------------------------------------------- |
---|
[191] | 44 | ; AccessDPT_GetAddressingModeToAXZF |
---|
[150] | 45 | ; Parameters: |
---|
| 46 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 47 | ; Returns: |
---|
[191] | 48 | ; AX: Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) |
---|
| 49 | ; ZF: Set if AX=0 |
---|
[150] | 50 | ; Corrupts registers: |
---|
| 51 | ; Nothing |
---|
| 52 | ;-------------------------------------------------------------------- |
---|
| 53 | ALIGN JUMP_ALIGN |
---|
[191] | 54 | AccessDPT_GetAddressingModeToAXZF: |
---|
| 55 | mov al, [di+DPT.bFlagsLow] |
---|
| 56 | and ax, BYTE MASKL_DPT_ADDRESSING_MODE |
---|
| 57 | eSHR_IM ax, ADDRESSING_MODE_FIELD_POSITION |
---|
[150] | 58 | ret |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | ;-------------------------------------------------------------------- |
---|
[173] | 62 | ; AccessDPT_GetLCHS |
---|
[3] | 63 | ; Parameters: |
---|
| 64 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 65 | ; Returns: |
---|
| 66 | ; AX: Number of L-CHS sectors per track |
---|
| 67 | ; BX: Number of L-CHS cylinders |
---|
| 68 | ; DX: Number of L-CHS heads |
---|
| 69 | ; Corrupts registers: |
---|
[173] | 70 | ; CX |
---|
[3] | 71 | ;-------------------------------------------------------------------- |
---|
[173] | 72 | AccessDPT_GetLCHS: |
---|
| 73 | ; Load CHS from DPT |
---|
| 74 | eMOVZX ax, BYTE [di+DPT.bSectors] |
---|
| 75 | mov bx, [di+DPT.dwCylinders] |
---|
[161] | 76 | cwd |
---|
[173] | 77 | mov dl, [di+DPT.bHeads] |
---|
| 78 | |
---|
| 79 | ; Only need to limit sectors for LBA assist |
---|
| 80 | test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA |
---|
[181] | 81 | jz SHORT AccessDPT_ShiftPCHinBXDXtoLCH |
---|
[173] | 82 | |
---|
[181] | 83 | cmp WORD [di+DPT.dwCylinders+2], BYTE 0 |
---|
| 84 | jnz SHORT .Return_MAX_LCHS_CYLINDERS |
---|
[173] | 85 | |
---|
[181] | 86 | ; Limit cylinders to 1024 |
---|
| 87 | cmp bx, MAX_LCHS_CYLINDERS |
---|
| 88 | jb SHORT .Return |
---|
| 89 | ALIGN JUMP_ALIGN |
---|
| 90 | .Return_MAX_LCHS_CYLINDERS: |
---|
[173] | 91 | mov bx, MAX_LCHS_CYLINDERS |
---|
[181] | 92 | ALIGN JUMP_ALIGN, ret |
---|
| 93 | .Return: |
---|
[3] | 94 | ret |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | ;-------------------------------------------------------------------- |
---|
[173] | 98 | ; AccessDPT_ShiftPCHinBXDXtoLCH |
---|
| 99 | ; Parameters: |
---|
| 100 | ; BX: P-CHS cylinders (1...16383) |
---|
| 101 | ; DX: P-CHS heads (1...16) |
---|
| 102 | ; Returns: |
---|
| 103 | ; BX: Number of L-CHS cylinders (1...1024) |
---|
| 104 | ; DX: Number of L-CHS heads (1...255) |
---|
| 105 | ; CX: Number of bits shifted |
---|
| 106 | ; Corrupts registers: |
---|
| 107 | ; Nothing |
---|
| 108 | ;-------------------------------------------------------------------- |
---|
| 109 | AccessDPT_ShiftPCHinBXDXtoLCH: |
---|
| 110 | xor cx, cx |
---|
| 111 | .ShiftLoop: |
---|
| 112 | cmp bx, MAX_LCHS_CYLINDERS ; Need to shift? |
---|
| 113 | jbe SHORT .LimitHeadsTo255 ; If not, return |
---|
| 114 | inc cx ; Increment shift count |
---|
| 115 | shr bx, 1 ; Halve cylinders |
---|
| 116 | shl dx, 1 ; Double heads |
---|
| 117 | jmp SHORT .ShiftLoop |
---|
| 118 | .LimitHeadsTo255: ; DOS does not support drives with 256 heads |
---|
[181] | 119 | sub dl, dh ; DH set only when 256 logical heads |
---|
[173] | 120 | xor dh, dh |
---|
| 121 | ret |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | ;-------------------------------------------------------------------- |
---|
[3] | 125 | ; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive |
---|
| 126 | ; Parameters: |
---|
| 127 | ; AX: Bitmask to test DRVPARAMS.wFlags |
---|
| 128 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 129 | ; Returns: |
---|
| 130 | ; ZF: Set if tested bit was zero |
---|
| 131 | ; Cleared if tested bit was non-zero |
---|
| 132 | ; CF: 0 |
---|
| 133 | ; Corrupts registers: |
---|
| 134 | ; BX |
---|
| 135 | ;-------------------------------------------------------------------- |
---|
| 136 | ALIGN JUMP_ALIGN |
---|
| 137 | AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive: |
---|
| 138 | call AccessDPT_GetPointerToDRVPARAMStoCSBX |
---|
| 139 | test [cs:bx+DRVPARAMS.wFlags], ax |
---|
| 140 | ret |
---|
| 141 | |
---|
| 142 | ;-------------------------------------------------------------------- |
---|
| 143 | ; Returns pointer to DRVPARAMS for master or slave drive. |
---|
| 144 | ; |
---|
| 145 | ; AccessDPT_GetPointerToDRVPARAMStoCSBX |
---|
| 146 | ; Parameters: |
---|
| 147 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 148 | ; Returns: |
---|
| 149 | ; CS:BX: Ptr to DRVPARAMS |
---|
| 150 | ; Corrupts registers: |
---|
| 151 | ; Nothing |
---|
| 152 | ;-------------------------------------------------------------------- |
---|
| 153 | ALIGN JUMP_ALIGN |
---|
| 154 | AccessDPT_GetPointerToDRVPARAMStoCSBX: |
---|
[150] | 155 | eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS |
---|
| 156 | add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS |
---|
[158] | 157 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE |
---|
[150] | 158 | jz SHORT .ReturnPointerToDRVPARAMS |
---|
| 159 | add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS |
---|
| 160 | .ReturnPointerToDRVPARAMS: |
---|
[3] | 161 | ret |
---|