[3] | 1 | ; File name : CompatibleDPT.asm |
---|
| 2 | ; Project name : IDE BIOS |
---|
| 3 | ; Created date : 6.4.2010 |
---|
| 4 | ; Last update : 6.4.2010 |
---|
| 5 | ; Author : Tomi Tilli |
---|
| 6 | ; Description : Functions for creating Disk Parameter Tables for |
---|
| 7 | ; software compatibility only. These DPTs are not used |
---|
| 8 | ; by our BIOS. |
---|
| 9 | |
---|
| 10 | ; Section containing code |
---|
| 11 | SECTION .text |
---|
| 12 | |
---|
| 13 | ;-------------------------------------------------------------------- |
---|
| 14 | ; Creates compatible for drives 80h and 81h. There will be stored |
---|
| 15 | ; to interrupt vectors 41h and 46h. |
---|
| 16 | ; |
---|
| 17 | ; CompatibleDPT_CreateForDrives80hAnd81h |
---|
| 18 | ; Parameters: |
---|
| 19 | ; DS: RAMVARS segment |
---|
| 20 | ; ES: BDA segment (zero) |
---|
| 21 | ; Returns: |
---|
| 22 | ; Nothing |
---|
| 23 | ; Corrupts registers: |
---|
| 24 | ; All except DS and ES |
---|
| 25 | ;-------------------------------------------------------------------- |
---|
| 26 | ALIGN JUMP_ALIGN |
---|
| 27 | CompatibleDPT_CreateForDrives80hAnd81h: |
---|
| 28 | ; Only create compatible DPTs in full mode |
---|
| 29 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
| 30 | jz SHORT CompatibleDPT_StoreCustomDPTs |
---|
| 31 | |
---|
| 32 | mov dl, 80h |
---|
| 33 | call FindDPT_ForDriveNumber ; DPT to DS:DI |
---|
| 34 | jnc SHORT .CreateForDrive81h |
---|
| 35 | call CompatibleDPT_CreateForDrive80h |
---|
| 36 | ALIGN JUMP_ALIGN |
---|
| 37 | .CreateForDrive81h: |
---|
| 38 | mov dl, 81h |
---|
| 39 | call FindDPT_ForDriveNumber |
---|
| 40 | jnc SHORT .Return |
---|
| 41 | call CompatibleDPT_CreateForDrive81h |
---|
| 42 | ALIGN JUMP_ALIGN |
---|
| 43 | .Return: |
---|
| 44 | ret |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | ;-------------------------------------------------------------------- |
---|
| 48 | ; Stores pointers to our custom DPTs for drives 80h and 81h. |
---|
| 49 | ; |
---|
| 50 | ; CompatibleDPT_StoreCustomDPTs |
---|
| 51 | ; Parameters: |
---|
| 52 | ; ES: BDA and interrupt vector segment (zero) |
---|
| 53 | ; Returns: |
---|
| 54 | ; Nothing |
---|
| 55 | ; Corrupts registers: |
---|
| 56 | ; DX, DI |
---|
| 57 | ;-------------------------------------------------------------------- |
---|
| 58 | ALIGN JUMP_ALIGN |
---|
| 59 | CompatibleDPT_StoreCustomDPTs: |
---|
| 60 | mov dl, 80h |
---|
| 61 | call FindDPT_ForDriveNumber ; DPT to DS:DI |
---|
| 62 | jnc SHORT .FindForDrive81h |
---|
| 63 | mov [es:INTV_HD0DPT*4], di |
---|
| 64 | mov [es:INTV_HD0DPT*4+2], ds |
---|
| 65 | ALIGN JUMP_ALIGN |
---|
| 66 | .FindForDrive81h: |
---|
| 67 | inc dx |
---|
| 68 | call FindDPT_ForDriveNumber |
---|
| 69 | jnc SHORT .Return |
---|
| 70 | mov [es:INTV_HD1DPT*4], di |
---|
| 71 | mov [es:INTV_HD1DPT*4+2], ds |
---|
| 72 | ALIGN JUMP_ALIGN |
---|
| 73 | .Return: |
---|
| 74 | ret |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | ;-------------------------------------------------------------------- |
---|
| 78 | ; Copies parameters from our custom DPT struct to a |
---|
| 79 | ; standard COMPATIBLE_FDPT or COMPATIBLE_EDPT struct. |
---|
| 80 | ; |
---|
| 81 | ; CompatibleDPT_CreateForDrive80h |
---|
| 82 | ; CompatibleDPT_CreateForDrive81h |
---|
| 83 | ; Parameters: |
---|
| 84 | ; DS:DI: Ptr to DPT |
---|
| 85 | ; ES: BDA and interrupt vector segment (zero) |
---|
| 86 | ; Returns: |
---|
| 87 | ; Nothing |
---|
| 88 | ; Corrupts registers: |
---|
| 89 | ; AX, BX, CX, DX, SI |
---|
| 90 | ;-------------------------------------------------------------------- |
---|
| 91 | ALIGN JUMP_ALIGN |
---|
| 92 | CompatibleDPT_CreateForDrive80h: |
---|
| 93 | mov si, FULLRAMVARS.drv80hCompDPT ; DS:SI now points compatible DPT |
---|
| 94 | call CompatibleDPT_CopyFromCustom |
---|
| 95 | mov [es:INTV_HD0DPT*4], si |
---|
| 96 | mov [es:INTV_HD0DPT*4+2], ds |
---|
| 97 | ret |
---|
| 98 | ALIGN JUMP_ALIGN |
---|
| 99 | CompatibleDPT_CreateForDrive81h: |
---|
| 100 | mov si, FULLRAMVARS.drv81hCompDPT ; DS:SI now points compatible DPT |
---|
| 101 | call CompatibleDPT_CopyFromCustom |
---|
| 102 | mov [es:INTV_HD1DPT*4], si |
---|
| 103 | mov [es:INTV_HD1DPT*4+2], ds |
---|
| 104 | ret |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | ;-------------------------------------------------------------------- |
---|
| 108 | ; Copies parameters from our custom DPT struct to a |
---|
| 109 | ; standard COMPATIBLE_FDPT or COMPATIBLE_EDPT struct. |
---|
| 110 | ; |
---|
| 111 | ; CompatibleDPT_CopyFromCustom |
---|
| 112 | ; Parameters: |
---|
| 113 | ; DS:SI: Ptr to COMPATIBLE_FDPT or COMPATIBLE_EDPT |
---|
| 114 | ; DS:DI: Ptr to DPT |
---|
| 115 | ; Returns: |
---|
| 116 | ; Nothing |
---|
| 117 | ; Corrupts registers: |
---|
| 118 | ; AX, BX, CX, DX |
---|
| 119 | ;-------------------------------------------------------------------- |
---|
| 120 | ALIGN JUMP_ALIGN |
---|
| 121 | CompatibleDPT_CopyFromCustom: |
---|
| 122 | call AccessDPT_GetLCHSfromPCHS ; AX=Lsects, BX=Lcyls, DX=Lheads |
---|
| 123 | test BYTE [di+DPT.bFlags], FLG_DPT_EBIOS ; Drive larger than 504 MiB? |
---|
| 124 | jnz SHORT CompatibleDPT_CopyFromCustomToEDPT |
---|
| 125 | ; Fall to CompatibleDPT_CopyFromCustomToFDPT |
---|
| 126 | |
---|
| 127 | ;-------------------------------------------------------------------- |
---|
| 128 | ; Copies parameters from our custom DPT struct to a |
---|
| 129 | ; standard COMPATIBLE_FDPT struct for drives up to 504 MiB. |
---|
| 130 | ; |
---|
| 131 | ; CompatibleDPT_CopyFromCustomToFDPT |
---|
| 132 | ; Parameters: |
---|
| 133 | ; AX: L-CHS sectors per track |
---|
| 134 | ; BX: L-CHS cylinders |
---|
| 135 | ; DX: L-CHS heads |
---|
| 136 | ; DS:SI: Ptr to COMPATIBLE_FDPT |
---|
| 137 | ; DS:DI: Ptr to DPT |
---|
| 138 | ; Returns: |
---|
| 139 | ; Nothing |
---|
| 140 | ; Corrupts registers: |
---|
| 141 | ; AX, BX |
---|
| 142 | ;-------------------------------------------------------------------- |
---|
| 143 | ;ALIGN JUMP_ALIGN |
---|
| 144 | CompatibleDPT_CopyFromCustomToFDPT: |
---|
| 145 | mov [si+COMPATIBLE_FDPT.wCyls], bx |
---|
| 146 | mov [si+COMPATIBLE_FDPT.bHeads], dl |
---|
| 147 | mov [si+COMPATIBLE_FDPT.bSectPerTrack], al |
---|
| 148 | mov WORD [si+COMPATIBLE_FDPT.wWrPreCmpCyl], -1 |
---|
| 149 | mov al, [di+DPT.bDrvCtrl] |
---|
| 150 | mov [si+COMPATIBLE_FDPT.bDrvCtrl], al |
---|
| 151 | mov BYTE [si+COMPATIBLE_FDPT.bNormTimeout], B_TIMEOUT_BSY |
---|
| 152 | mov BYTE [si+COMPATIBLE_FDPT.bFormatTimeout], B_TIMEOUT_DRQ |
---|
| 153 | mov BYTE [si+COMPATIBLE_FDPT.bCheckTimeout], B_TIMEOUT_DRQ |
---|
| 154 | dec bx |
---|
| 155 | mov [si+COMPATIBLE_FDPT.wLZoneCyl], bx |
---|
| 156 | ret |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | ;-------------------------------------------------------------------- |
---|
| 160 | ; Copies parameters from our custom DPT struct to a |
---|
| 161 | ; standard COMPATIBLE_EDPT struct. |
---|
| 162 | ; |
---|
| 163 | ; CompatibleDPT_CopyFromCustomToEDPT |
---|
| 164 | ; Parameters: |
---|
| 165 | ; AX: L-CHS sectors per track |
---|
| 166 | ; BX: L-CHS cylinders |
---|
| 167 | ; DX: L-CHS heads |
---|
| 168 | ; DS:SI: Ptr to COMPATIBLE_EDPT |
---|
| 169 | ; DS:DI: Ptr to DPT |
---|
| 170 | ; Returns: |
---|
| 171 | ; Nothing |
---|
| 172 | ; Corrupts registers: |
---|
| 173 | ; AX, BX, CX, DX |
---|
| 174 | ;-------------------------------------------------------------------- |
---|
| 175 | ALIGN JUMP_ALIGN |
---|
| 176 | CompatibleDPT_CopyFromCustomToEDPT: |
---|
| 177 | mov [si+COMPATIBLE_EDPT.wLCyls], bx |
---|
| 178 | mov [si+COMPATIBLE_EDPT.bLHeads], dl |
---|
| 179 | mov BYTE [si+COMPATIBLE_EDPT.bSignature], COMPATIBLE_EDPT_SIGNATURE |
---|
| 180 | mov [si+COMPATIBLE_EDPT.bPSect], al |
---|
| 181 | mov [si+COMPATIBLE_EDPT.bLSect], al |
---|
| 182 | mov al, [di+DPT.bDrvCtrl] |
---|
| 183 | mov [si+COMPATIBLE_EDPT.bDrvCtrl], al |
---|
| 184 | mov ax, [di+DPT.wPCyls] |
---|
| 185 | mov [si+COMPATIBLE_EDPT.wPCyls], ax |
---|
| 186 | mov al, [di+DPT.bPHeads] |
---|
| 187 | mov [si+COMPATIBLE_EDPT.bPHeads], al |
---|
| 188 | ; Fall to CompatibleDPT_StoreChecksum |
---|
| 189 | |
---|
| 190 | ;-------------------------------------------------------------------- |
---|
| 191 | ; Stores checksum byte to the end of COMPATIBLE_EDPT struct. |
---|
| 192 | ; |
---|
| 193 | ; CompatibleDPT_StoreChecksum |
---|
| 194 | ; Parameters: |
---|
| 195 | ; DS:SI: Ptr to COMPATIBLE_EDPT |
---|
| 196 | ; Returns: |
---|
| 197 | ; Nothing |
---|
| 198 | ; Corrupts registers: |
---|
| 199 | ; AX, BX, CX |
---|
| 200 | ;-------------------------------------------------------------------- |
---|
| 201 | ;ALIGN JUMP_ALIGN |
---|
| 202 | CompatibleDPT_StoreChecksum: |
---|
| 203 | xor ax, ax |
---|
| 204 | xor bx, bx |
---|
| 205 | mov cx, COMPATIBLE_EDPT_size-1 |
---|
| 206 | ALIGN JUMP_ALIGN |
---|
| 207 | .SumLoop: |
---|
| 208 | add al, [bx+si] |
---|
| 209 | inc bx |
---|
| 210 | loop .SumLoop |
---|
| 211 | neg al |
---|
| 212 | mov [si+COMPATIBLE_EDPT.bChecksum], al |
---|
| 213 | ret |
---|