Changeset 421 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
- Timestamp:
- May 9, 2012, 7:12:53 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r411 r421 33 33 ; ES: BDA Segment 34 34 ; Returns: 35 ; DL: Drive number for new drive36 35 ; DS:DI: Ptr to Disk Parameter Table (if successful) 37 36 ; CF: Cleared if DPT created successfully … … 81 80 %endif 82 81 mov [di+DPT.wFlags], ax 83 ; Fall to .Store Addressing84 85 ;-------------------------------------------------------------------- 86 ; .Store Addressing82 ; Fall to .StoreCHSparametersAndAddressingMode 83 84 ;-------------------------------------------------------------------- 85 ; .StoreCHSparametersAndAddressingMode 87 86 ; Parameters: 88 87 ; DS:DI: Ptr to Disk Parameter Table … … 94 93 ; AX, BX, CX, DX 95 94 ;-------------------------------------------------------------------- 96 .Store Addressing:95 .StoreCHSparametersAndAddressingMode: 97 96 ; Check if CHS defined in ROMVARS 98 97 call AccessDPT_GetPointerToDRVPARAMStoCSBX 99 test byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS ; User specified CHS? 100 jnz SHORT .StoreUserDefinedPCHS 101 98 test byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS ; User specified P-CHS? 99 jz SHORT .AutodetectPCHSvalues 100 101 ; Use DRVPARAMS P-CHS values instead of autodetected 102 mov ax, [cs:bx+DRVPARAMS.wCylinders] 103 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 104 call AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH 105 jmp SHORT .StoreLCHStoDPT 106 107 ; Get L-CHS parameters and addressing mode 108 .AutodetectPCHSvalues: 109 call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI 110 111 .StoreLCHStoDPT: 112 eSHL_IM dl, ADDRESSING_MODE_FIELD_POSITION 113 or cl, dl 114 or [di+DPT.bFlagsLow], cl ; Shift count and addressing mode 115 mov [di+DPT.wLchsCylinders], ax 116 mov [di+DPT.wLchsHeadsAndSectors], bx 117 118 ; Store P-CHS to DPT 119 call AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI 120 mov [di+DPT.bPchsHeads], bl 121 %ifdef MODULE_EBIOS 122 mov [di+DPT.wPchsCylinders], ax 123 mov [di+DPT.bPchsSectorsPerTrack], bh 124 ; Fall to .StoreNumberOfLbaSectors 125 126 ;-------------------------------------------------------------------- 127 ; .StoreNumberOfLbaSectors 128 ; Parameters: 129 ; DS:DI: Ptr to Disk Parameter Table 130 ; ES:SI: Ptr to 512-byte ATA information read from the drive 131 ; CS:BP: Ptr to IDEVARS for the controller 132 ; Returns: 133 ; Nothing 134 ; Corrupts registers: 135 ; AX, BX, CX, DX 136 ;-------------------------------------------------------------------- 102 137 ; Check if LBA supported 103 call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI104 138 test BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8 105 jz SHORT . StoreCHSfromAXBHBL ; Small old drive with CHS addressing only106 107 ; Store LBA 28/48 addressing andtotal sector count108 call Ata ID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI109 call StoreLba AddressingAndTotalSectorCountFromBXDXAX110 111 ; Replace sector count with user defined if necessary139 jz SHORT .NoLbaSupportedSoNoEBIOS 140 141 ; Store LBA 28/48 total sector count 142 call AtaGeometry_GetLbaSectorCountToBXDXAXfromAtaInfoInESSI 143 call StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX 144 145 ; Load user defined LBA 112 146 call AccessDPT_GetPointerToDRVPARAMStoCSBX 113 147 test BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA … … 126 160 jae SHORT .KeepTotalSectorsFromAtaID 127 161 .StoreUserDefinedSectorCountToDPT: 128 call StoreLbaAddressingAndTotalSectorCountFromBXDXAX129 130 ; Calculate L-CHS for old INT 13h 162 xor cx, cx ; Always LBA28 for user defined values 163 call StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX 164 131 165 .KeepTotalSectorsFromAtaID: 132 mov bx, [di+DPT.twLbaSectors+4] ; Restore BX 133 call LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH 134 mov [di+DPT.bLbaHeads], bl 135 jmp SHORT .StoreBlockMode 136 137 ;-------------------------------------------------------------------- 138 ; .StoreUserDefinedPCHS 139 ; Parameters: 140 ; DS:DI: Ptr to Disk Parameter Table 141 ; ES:SI: Ptr to 512-byte ATA information read from the drive 142 ; CS:BP: Ptr to IDEVARS for the controller 143 ; Returns: 144 ; AX: Number of P-CHS cylinders 145 ; BH: Number of P-CHS sectors per track 146 ; BL: Number of P-CHS heads 147 ; Corrupts registers: 148 ; Nothing 149 ;-------------------------------------------------------------------- 150 .StoreUserDefinedPCHS: 151 call AccessDPT_GetPointerToDRVPARAMStoCSBX 152 mov ax, [cs:bx+DRVPARAMS.wCylinders] 153 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 154 ; Fall to .StoreCHSfromAXBHBL 155 156 ;-------------------------------------------------------------------- 157 ; .StoreCHSfromAXBHBL 158 ; Parameters: 159 ; AX: Number of P-CHS cylinders 160 ; BH: Number of P-CHS sectors per track 161 ; BL: Number of P-CHS heads 162 ; DS:DI: Ptr to Disk Parameter Table 163 ; ES:SI: Ptr to 512-byte ATA information read from the drive 164 ; CS:BP: Ptr to IDEVARS for the controller 165 ; Returns: 166 ; AX: Number of P-CHS cylinders 167 ; BH: Number of P-CHS sectors per track 168 ; BL: Number of P-CHS heads 169 ; Corrupts registers: 170 ; CX 171 ;-------------------------------------------------------------------- 172 .StoreCHSfromAXBHBL: 173 push ax 174 push bx 175 call AccessDPT_ShiftPCHinAXBLtoLCH ; Get number of bits to shift 176 pop bx 177 pop ax 178 jcxz .StorePCHSfromAXDX ; Small drive so use L-CHS addressing 179 180 ; Store P-CHS addressing mode and number of bits to shift in L-CHS to P-CHS translation 181 or cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION 182 or [di+DPT.bFlagsLow], cl 183 ; Fall to .StoreChsFromAXBLBH 184 185 ;-------------------------------------------------------------------- 186 ; .StoreChsFromAXBLBH 187 ; Parameters: 188 ; AX: Number of P-CHS cylinders 189 ; BH: Number of P-CHS sectors per track 190 ; BL: Number of P-CHS heads 191 ; DS:DI: Ptr to Disk Parameter Table 192 ; ES:SI: Ptr to 512-byte ATA information read from the drive 193 ; CS:BP: Ptr to IDEVARS for the controller 194 ; Returns: 195 ; Nothing 196 ; Corrupts registers: 197 ; Nothing 198 ;-------------------------------------------------------------------- 199 .StorePCHSfromAXDX: 200 mov [di+DPT.wPchsCylinders], ax 201 mov [di+DPT.wPchsHeadsAndSectors], bx 166 .NoLbaSupportedSoNoEBIOS: 167 %endif ; MODULE_EBIOS 202 168 ; Fall to .StoreBlockMode 203 169 … … 268 234 269 235 270 ;-------------------------------------------------------------------- 271 ; StoreLbaAddressingAndTotalSectorCountFromBXDXAX 236 %ifdef MODULE_EBIOS 237 ;-------------------------------------------------------------------- 238 ; StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX 272 239 ; Parameters: 273 240 ; BX:DX:AX: Total Sector Count 241 ; CL: FLGL_DPT_LBA48 if LBA48 supported 274 242 ; DS:DI: Ptr to Disk Parameter Table 275 243 ; Returns: 276 244 ; Nothing 277 245 ; Corrupts registers: 278 ; CX 279 ;-------------------------------------------------------------------- 280 StoreLbaAddressingAndTotalSectorCountFromBXDXAX: 246 ; CL 247 ;-------------------------------------------------------------------- 248 StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX: 249 or cl, FLGL_DPT_LBA_AND_EBIOS_SUPPORTED 250 and BYTE [di+DPT.bFlagsLow], ~FLGL_DPT_LBA48 251 or [di+DPT.bFlagsLow], cl 281 252 mov [di+DPT.twLbaSectors], ax 282 253 mov [di+DPT.twLbaSectors+2], dx 283 254 mov [di+DPT.twLbaSectors+4], bx 284 285 %ifdef MODULE_EBIOS286 and BYTE [di+DPT.bFlagsLow], ~MASKL_DPT_ADDRESSING_MODE287 test bx, bx288 jnz SHORT .SetLba48AddressingToDPT ; Must be LBA48289 290 ; Drives can report at most 0FFF FFFFh LBA28 sectors according to ATA specification.291 ; That is (2^28)-1 so we can simply check if DH is zero or not.292 test dh, dh293 jz SHORT .SetLba28AddressingToDPT294 .SetLba48AddressingToDPT:295 or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION296 .SetLba28AddressingToDPT:297 %endif298 or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION299 255 ret 256 %endif ; MODULE_EBIOS
Note:
See TracChangeset
for help on using the changeset viewer.