Changeset 99 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Timestamp:
- Jan 31, 2011, 11:27:17 AM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
r3 r99 1 ; File name : AccessDPT.asm 2 ; Project name : IDE BIOS 3 ; Created date : 16.3.2010 4 ; Last update : 26.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for accessing DPT data. 7 3 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r3 r99 1 ; File name : CreateDPT.asm 2 ; Project name : IDE BIOS 3 ; Created date : 12.3.2010 4 ; Last update : 26.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for creating Disk Parameter Table. 7 3 … … 26 22 ; Set if any error 27 23 ; Corrupts registers: 28 ; AX, CX, BX, DH 29 ;-------------------------------------------------------------------- 30 ALIGN JUMP_ALIGN 24 ; AX, BX, CX, DH 25 ;-------------------------------------------------------------------- 31 26 CreateDPT_FromAtaInformation: 32 27 call FindDPT_ForNewDrive ; Get new DPT to DS:DI 33 call CreateDPT_Initialize 34 call CreateDPT_StoreDriveControlByte 35 call CreateDPT_StorePCHS 36 call CreateDPT_StoreLCHS 37 call CreateDPT_StoreAddressing 38 call CreateDPT_StoreBlockMode 39 call CreateDPT_StoreEBIOSSupport 40 jmp CreateDPT_StoreDriveNumberAndUpdateDriveCount 41 42 43 ;-------------------------------------------------------------------- 44 ; Initializes empty DPT by storing initial values that are not 45 ; read from ATA information. 46 ; 47 ; CreateDPT_Initialize 48 ; Parameters: 49 ; BH: Drive Select byte for Drive and Head Register 50 ; DS:DI: Ptr to Disk Parameter Table 51 ; CS:BP: Ptr to IDEVARS for the controller 52 ; Returns: 53 ; CF: Cleared if DPT parameters stored successfully 54 ; Set if any error 55 ; Corrupts registers: 56 ; Nothing 57 ;-------------------------------------------------------------------- 58 ALIGN JUMP_ALIGN 59 CreateDPT_Initialize: 60 xor ax, ax ; Clear AX and CF 28 ; Fall to .InitializeDPT 29 30 ;-------------------------------------------------------------------- 31 ; .InitializeDPT 32 ; Parameters: 33 ; BH: Drive Select byte for Drive and Head Register 34 ; DS:DI: Ptr to Disk Parameter Table 35 ; CS:BP: Ptr to IDEVARS for the controller 36 ; Returns: 37 ; AX: Zero 38 ; Corrupts registers: 39 ; Nothing 40 ;-------------------------------------------------------------------- 41 .InitializeDPT: 42 xor ax, ax 61 43 mov BYTE [di+DPT.bSize], DPT_size 62 mov BYTE [di+DPT.bDrvNum], al 63 mov BYTE [di+DPT.bFlags], al 44 mov [di+DPT.wDrvNumAndFlags], ax 64 45 mov BYTE [di+DPT.bReset], MASK_RESET_ALL 65 mov WORD [di+DPT.bIdeOff], bp 66 mov BYTE [di+DPT.bDrvSel], bh 67 ret 68 69 70 ;-------------------------------------------------------------------- 71 ; Stores Drive Control Byte for Device Control Register. 72 ; 73 ; CreateDPT_StoreDriveControlByte 74 ; Parameters: 75 ; BH: Drive Select byte for Drive and Head Register 76 ; DS:DI: Ptr to Disk Parameter Table 77 ; ES:SI: Ptr to 512-byte ATA information read from the drive 78 ; CS:BP: Ptr to IDEVARS for the controller 79 ; Returns: 80 ; CF: Cleared if DPT parameters stored successfully 81 ; Set if any error 46 mov [di+DPT.bIdeOff], bp 47 mov [di+DPT.bDrvSel], bh 48 ; Fall to .StoreDriveControlByte 49 50 ;-------------------------------------------------------------------- 51 ; .StoreDriveControlByte 52 ; Parameters: 53 ; AX: Zero 54 ; BH: Drive Select byte for Drive and Head Register 55 ; DS:DI: Ptr to Disk Parameter Table 56 ; ES:SI: Ptr to 512-byte ATA information read from the drive 57 ; CS:BP: Ptr to IDEVARS for the controller 58 ; Returns: 59 ; Nothing 82 60 ; Corrupts registers: 83 61 ; AX 84 62 ;-------------------------------------------------------------------- 85 ALIGN JUMP_ALIGN 86 CreateDPT_StoreDriveControlByte: 87 xor ax, ax ; Zero AX 88 cmp BYTE [cs:bp+IDEVARS.bIRQ], 0 ; Interrupts enabled? 63 .StoreDriveControlByte: 64 cmp BYTE [cs:bp+IDEVARS.bIRQ], al ; Interrupts enabled? 89 65 jne SHORT .CheckHeadCount 90 66 or al, FLG_IDE_CTRL_nIEN ; Disable interrupts 91 ALIGN JUMP_ALIGN92 67 .CheckHeadCount: 93 68 cmp BYTE [es:si+ATA1.wHeadCnt], 8 ; 1...8 heads? 94 jbe SHORT .StoreDr iveControlByte69 jbe SHORT .StoreDrvCtrlByteToDPT 95 70 or al, FLG_IDE_CTRL_O8H ; Over 8 heads (pre-ATA) 96 ALIGN JUMP_ALIGN 97 .StoreDriveControlByte: 71 .StoreDrvCtrlByteToDPT: 98 72 mov [di+DPT.bDrvCtrl], al 99 clc 100 ret 101 102 103 ;-------------------------------------------------------------------- 104 ; Stores P-CHS values from ATA information or user specified values to DPT. 105 ; 106 ; CreateDPT_StorePCHS 107 ; Parameters: 108 ; BH: Drive Select byte for Drive and Head Register 109 ; DS:DI: Ptr to Disk Parameter Table 110 ; ES:SI: Ptr to 512-byte ATA information read from the drive 111 ; CS:BP: Ptr to IDEVARS for the controller 112 ; Returns: 113 ; CF: Cleared if DPT parameters stored successfully 114 ; Set if any error 115 ; Corrupts registers: 116 ; AX, BX 117 ;-------------------------------------------------------------------- 118 ALIGN JUMP_ALIGN 119 CreateDPT_StorePCHS: 120 call CreateDPT_GetUserOrAtaPCHS 121 mov [di+DPT.wPCyls], ax 122 mov [di+DPT.bPHeads], bh 123 mov [di+DPT.bPSect], bl 124 clc 125 ret 126 127 ;-------------------------------------------------------------------- 128 ; Returns user specified P-CHS or values read from ATA information. 129 ; 130 ; CreateDPT_GetUserOrAtaPCHS 131 ; Parameters: 132 ; BH: Drive Select byte for Drive and Head Register 133 ; DS:DI: Ptr to Disk Parameter Table 134 ; ES:SI: Ptr to 512-byte ATA information read from the drive 135 ; CS:BP: Ptr to IDEVARS for the controller 136 ; Returns: 137 ; AX: Number of P-CHS cylinders 138 ; BL: Number of P-CHS sectors per track 139 ; BH: Number of P-CHS heads 140 ; Corrupts registers: 141 ; Nothing 142 ;-------------------------------------------------------------------- 143 ALIGN JUMP_ALIGN 144 CreateDPT_GetUserOrAtaPCHS: 145 mov ax, FLG_DRVPARAMS_USERCHS ; User specified CHS? 73 ; Fall to .StorePCHS 74 75 ;-------------------------------------------------------------------- 76 ; .StorePCHS 77 ; Parameters: 78 ; AH: Zero 79 ; BH: Drive Select byte for Drive and Head Register 80 ; DS:DI: Ptr to Disk Parameter Table 81 ; ES:SI: Ptr to 512-byte ATA information read from the drive 82 ; CS:BP: Ptr to IDEVARS for the controller 83 ; Returns: 84 ; AX: P-CHS cylinders 85 ; BL: P-CHS heads 86 ; BH: P-CHS sectors 87 ; Corrupts registers: 88 ; Nothing 89 ;-------------------------------------------------------------------- 90 .StorePCHS: 91 mov al, FLG_DRVPARAMS_USERCHS ; User specified CHS? 146 92 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 147 jnz SHORT CreateDPT_GetUserSpecifiedPCHS 148 jmp AtaID_GetPCHS 149 150 ;-------------------------------------------------------------------- 151 ; Returns user specified P-CHS values from ROMVARS. 152 ; 153 ; CreateDPT_GetUserSpecifiedPCHS 154 ; Parameters: 155 ; DS:DI: Ptr to Disk Parameter Table 156 ; CS:BP: Ptr to IDEVARS for the controller 157 ; Returns: 158 ; AX: Number of user specified P-CHS cylinders 159 ; BL: Number of user specified P-CHS sectors per track 160 ; BH: Number of user specified P-CHS heads 161 ; Corrupts registers: 162 ; Nothing 163 ;-------------------------------------------------------------------- 164 ALIGN JUMP_ALIGN 165 CreateDPT_GetUserSpecifiedPCHS: 93 jnz SHORT .GetUserSpecifiedPCHS 94 call AtaID_GetPCHS ; Get from ATA information 95 jmp SHORT .StorePCHStoDPT 96 97 .GetUserSpecifiedPCHS: 166 98 call AccessDPT_GetPointerToDRVPARAMStoCSBX 167 99 mov ax, [cs:bx+DRVPARAMS.wCylinders] 168 mov bx, [cs:bx+DRVPARAMS.w SectAndHeads]100 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 169 101 or BYTE [di+DPT.bFlags], FLG_DPT_USERCHS 170 ret 171 172 173 ;-------------------------------------------------------------------- 174 ; Stores L-CHS values by converting from P-CHS values if necessary. 175 ; 176 ; CreateDPT_StoreLCHS 177 ; Parameters: 178 ; DS:DI: Ptr to Disk Parameter Table 179 ; ES:SI: Ptr to 512-byte ATA information read from the drive 180 ; Returns: 181 ; CF: Cleared if DPT parameters stored successfully 182 ; Set if any error 183 ; Corrupts registers: 184 ; AX, CX, DX 185 ;-------------------------------------------------------------------- 186 ALIGN JUMP_ALIGN 187 CreateDPT_StoreLCHS: 188 mov cx, [di+DPT.wPCyls] ; P-CHS Cylinders (1...16383) 189 eMOVZX dx, BYTE [di+DPT.bPHeads] ; P-CHS Heads (1...16) 190 call CreateDPT_ShiftPCHtoLCH 191 test dh, dh ; 256 heads? 192 jz SHORT .StoreToDPT ; If less, no correction needed 193 dec dx ; Limit to 255 heads since DOS does not support 256 heads 194 ALIGN JUMP_ALIGN 195 .StoreToDPT: 196 mov [di+DPT.bShLtoP], al 197 mov [di+DPT.wLHeads], dx 198 clc 199 ret 200 201 ;-------------------------------------------------------------------- 202 ; Returns L-CHS values from P-CHS values. 203 ; Sectors per track is always the same for both addressing modes. 204 ; 205 ; CreateDPT_ShiftPCHtoLCH: 206 ; Parameters: 207 ; CX: Number of P-CHS cylinders (1...16383) 208 ; DX: Number of P-CHS heads (1...16) 209 ; Returns: 210 ; AL: Number of bits shifted 211 ; CX: Number of L-CHS cylinders (1...1024) 212 ; DX: Number of L-CHS heads (1...256) 213 ; Corrupts registers: 214 ; Nothing 215 ;-------------------------------------------------------------------- 216 ALIGN JUMP_ALIGN 217 CreateDPT_ShiftPCHtoLCH: 218 xor al, al ; Zero AL 219 ALIGN JUMP_ALIGN 102 103 .StorePCHStoDPT: 104 mov [di+DPT.wPCyls], ax 105 mov [di+DPT.wHeadsAndSectors], bx 106 ; Fall to .StoreLCHS 107 108 ;-------------------------------------------------------------------- 109 ; .StoreLCHS 110 ; Parameters: 111 ; AX: P-CHS cylinders 112 ; BL: P-CHS heads 113 ; DS:DI: Ptr to Disk Parameter Table 114 ; ES:SI: Ptr to 512-byte ATA information read from the drive 115 ; Returns: 116 ; Nothing 117 ; Corrupts registers: 118 ; AX, BX, CX 119 ;-------------------------------------------------------------------- 120 .StoreLCHS: 121 xor bh, bh ; BX = P-CHS Heads (1...16) 122 xor cx, cx 220 123 .ShiftLoop: 221 cmp cx, 1024; Need to shift?222 jbe SHORT . Return; If not, return223 inc ax; Increment shift count224 shr cx, 1; Halve cylinders225 shl dx, 1; Double heads124 cmp ax, 1024 ; Need to shift? 125 jbe SHORT .LimitHeadsTo255 ; If not, return 126 inc cx ; Increment shift count 127 shr ax, 1 ; Halve cylinders 128 shl bx, 1 ; Double heads 226 129 jmp SHORT .ShiftLoop 227 ALIGN JUMP_ALIGN 228 .Return: 229 ret 230 231 232 ;-------------------------------------------------------------------- 233 ; Stores addressing information (L-CHS, P-CHS, LBA28 or LBA48). 234 ; 235 ; CreateDPT_StoreAddressing 236 ; Parameters: 237 ; DS:DI: Ptr to Disk Parameter Table 238 ; ES:SI: Ptr to 512-byte ATA information read from the drive 239 ; Returns: 240 ; CF: Cleared if DPT parameters stored successfully 241 ; Set if any error 242 ; Corrupts registers: 243 ; Nothing 244 ;-------------------------------------------------------------------- 245 ALIGN JUMP_ALIGN 246 CreateDPT_StoreAddressing: 130 131 .LimitHeadsTo255: 132 test bh, bh ; 256 heads? 133 jz SHORT .StoreLCHStoDPT ; If less, no correction needed 134 dec bx ; Limit to 255 heads since DOS does not support 256 heads 135 .StoreLCHStoDPT: 136 mov [di+DPT.bShLtoP], cl 137 mov [di+DPT.wLHeads], bx 138 ; Fall to .StoreAddressing 139 140 ;-------------------------------------------------------------------- 141 ; .StoreAddressing 142 ; Parameters: 143 ; DS:DI: Ptr to Disk Parameter Table 144 ; ES:SI: Ptr to 512-byte ATA information read from the drive 145 ; Returns: 146 ; Nothing 147 ; Corrupts registers: 148 ; Nothing 149 ;-------------------------------------------------------------------- 150 .StoreAddressing: 247 151 cmp WORD [di+DPT.wPCyls], 1024 ; L-CHS possible? (no translation needed) 248 jbe SHORT . Return; If so, nothing needs to be changed152 jbe SHORT .StoreBlockMode ; If so, nothing needs to be changed 249 153 test BYTE [di+DPT.bFlags], FLG_DPT_USERCHS 250 jnz SHORT .StorePCHS 154 jnz SHORT .StorePCHSaddressing ; Use user defined P-CHS 251 155 test WORD [es:si+ATA1.wCaps], A2_wCaps_LBA 252 jz SHORT .StorePCHS 156 jz SHORT .StorePCHSaddressing ; Use P-CHS since LBA not supported 253 157 test WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48 254 jz SHORT .StoreLBA28 158 jz SHORT .StoreLBA28addressing ; Use LBA-28 since LBA-48 not supported 255 159 or BYTE [di+DPT.bFlags], ADDR_DPT_LBA48<<1 256 ALIGN JUMP_ALIGN 257 .StoreLBA28: 160 .StoreLBA28addressing: 258 161 or BYTE [di+DPT.bFlags], ADDR_DPT_LBA28<<1 259 162 or BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA 260 ret 261 ALIGN JUMP_ALIGN 262 .StorePCHS: 163 jmp SHORT .StoreBlockMode 164 .StorePCHSaddressing: 263 165 or BYTE [di+DPT.bFlags], ADDR_DPT_PCHS<<1 264 ALIGN JUMP_ALIGN 265 .Return: 266 clc 267 ret 268 269 270 ;-------------------------------------------------------------------- 271 ; Stores Block Mode information. 272 ; 273 ; CreateDPT_StoreBlockMode 274 ; Parameters: 275 ; DS:DI: Ptr to Disk Parameter Table 276 ; ES:SI: Ptr to 512-byte ATA information read from the drive 277 ; Returns: 278 ; CF: Cleared if DPT parameters stored successfully 279 ; Set if any error 280 ; Corrupts registers: 281 ; Nothing 282 ;-------------------------------------------------------------------- 283 ALIGN JUMP_ALIGN 284 CreateDPT_StoreBlockMode: 166 ; Fall to .StoreBlockMode 167 168 ;-------------------------------------------------------------------- 169 ; .StoreBlockMode 170 ; Parameters: 171 ; DS:DI: Ptr to Disk Parameter Table 172 ; ES:SI: Ptr to 512-byte ATA information read from the drive 173 ; Returns: 174 ; Nothing 175 ; Corrupts registers: 176 ; AX 177 ;-------------------------------------------------------------------- 178 .StoreBlockMode: 285 179 mov al, 1 ; Minimum block size is 1 sector 286 180 mov ah, [es:si+ATA1.bBlckSize] ; Load max block size in sectors 287 181 mov [di+DPT.wSetAndMaxBlock], ax 288 ret 289 290 291 ;-------------------------------------------------------------------- 292 ; Stores variables required by EBIOS functions. 293 ; 294 ; CreateDPT_StoreEBIOSSupport 295 ; Parameters: 296 ; DS:DI: Ptr to Disk Parameter Table 297 ; ES:SI: Ptr to 512-byte ATA information read from the drive 298 ; Returns: 299 ; CF: Cleared if DPT parameters stored successfully 300 ; Set if any error 182 ; Fall to .StoreEBIOSSupport 183 184 ;-------------------------------------------------------------------- 185 ; .StoreEBIOSSupport 186 ; Parameters: 187 ; DS:DI: Ptr to Disk Parameter Table 188 ; ES:SI: Ptr to 512-byte ATA information read from the drive 189 ; Returns: 190 ; Nothing 301 191 ; Corrupts registers: 302 192 ; AX, BX, DX 303 193 ;-------------------------------------------------------------------- 304 ALIGN JUMP_ALIGN 305 CreateDPT_StoreEBIOSSupport: 306 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE ; (clears CF)307 jz SHORT .DoNotSupportEBIOS ; No EBIOS support since small DPTs needed 194 .StoreEBIOSSupport: 195 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE 196 jz SHORT .StoreDriveNumberAndUpdateDriveCount ; No EBIOS support since small DPTs needed 197 308 198 mov bl, [di+DPT.bFlags] 309 and bx, BYTE MASK_DPT_ADDR ; Addressing mode (clears CF) 310 jmp [cs:bx+.rgwAddrJmp] ; Jump to handle addressing mode 311 ALIGN WORD_ALIGN 199 and bx, BYTE MASK_DPT_ADDR ; Addressing mode 200 jmp [cs:bx+.rgwAddrJmp] ; Jump to handle addressing mode 312 201 .rgwAddrJmp: 313 dw .DoNotSupportEBIOS ; ADDR_DPT_LCHS 314 dw .DoNotSupportEBIOS ; ADDR_DPT_PCHS 315 dw .SupportForLBA28 ; ADDR_DPT_LBA28 316 dw .SupportForLBA48 ; ADDR_DPT_LBA48 317 ALIGN JUMP_ALIGN 318 .DoNotSupportEBIOS: 319 ret 320 ALIGN JUMP_ALIGN 202 dw .StoreDriveNumberAndUpdateDriveCount ; ADDR_DPT_LCHS 203 dw .StoreDriveNumberAndUpdateDriveCount ; ADDR_DPT_PCHS 204 dw .SupportForLBA28 ; ADDR_DPT_LBA28 205 dw .SupportForLBA48 ; ADDR_DPT_LBA48 206 321 207 .SupportForLBA28: 322 208 sub BYTE [di+DPT.bSize], 2 ; Only 4 bytes for sector count 323 ALIGN JUMP_ALIGN324 209 .SupportForLBA48: 325 210 add BYTE [di+DPT.bSize], EBDPT_size - DPT_size 326 211 or BYTE [di+DPT.bFlags], FLG_DPT_EBIOS 327 ; Fall to CreateDPT_StoreEbiosSectorCount328 329 ;--------------------------------------------------------------------330 ; Stores EBIOS total sector count for LBA addressing.331 ;332 ; CreateDPT_StoreEbiosSectorCount333 ; Parameters:334 ; DS:DI: Ptr to Disk Parameter Table335 ; ES:SI: Ptr to 512-byte ATA information read from the drive336 ; Returns:337 ; CF: Cleared if DPT parameters stored successfully338 ; Set if any error339 ; Corrupts registers:340 ; AX, BX, DX341 ;--------------------------------------------------------------------342 ;ALIGN JUMP_ALIGN343 CreateDPT_StoreEbiosSectorCount:344 212 call AtaID_GetTotalSectorCount 345 213 mov [di+EBDPT.twCapacity], ax 346 214 mov [di+EBDPT.twCapacity+2], dx 347 215 mov [di+EBDPT.twCapacity+4], bx 348 clc 349 ret 350 351 352 ;-------------------------------------------------------------------- 353 ; Stores number for drive and updates drive count. 354 ; 355 ; CreateDPT_StoreDriveNumberAndUpdateDriveCount 216 ; Fall to .StoreDriveNumberAndUpdateDriveCount 217 218 ;-------------------------------------------------------------------- 219 ; .StoreDriveNumberAndUpdateDriveCount 356 220 ; Parameters: 357 221 ; DS:DI: Ptr to Disk Parameter Table … … 365 229 ; Nothing 366 230 ;-------------------------------------------------------------------- 367 ALIGN JUMP_ALIGN 368 CreateDPT_StoreDriveNumberAndUpdateDriveCount: 231 .StoreDriveNumberAndUpdateDriveCount: 369 232 ; Make sure that more drives can be accepted 370 233 mov dl, [es:BDA.bHDCount] ; Load number of hard disks -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r97 r99 171 171 172 172 ;-------------------------------------------------------------------- 173 ; Increments hard disk count to RAMVARS.174 ;175 173 ; RamVars_IncrementHardDiskCount 176 174 ; Parameters: … … 182 180 ; Nothing 183 181 ;-------------------------------------------------------------------- 184 ALIGN JUMP_ALIGN185 182 RamVars_IncrementHardDiskCount: 186 183 inc BYTE [RAMVARS.bDrvCnt] ; Increment drive count to RAMVARS … … 188 185 ja SHORT .Return ; If so, return 189 186 mov [RAMVARS.bFirstDrv], dl ; Store first drive number 190 ALIGN JUMP_ALIGN191 187 .Return: 192 188 ret … … 242 238 ; Nothing 243 239 ;-------------------------------------------------------------------- 244 ALIGN JUMP_ALIGN245 240 RamVars_GetIdeControllerCountToCX: 246 mov cx, 1 ; Assume lite mode (one controller) 247 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE 248 jz SHORT .Return 249 mov cl, [cs:ROMVARS.bIdeCnt] 250 ALIGN JUMP_ALIGN, ret 251 .Return: 252 ret 241 eMOVZX cx, BYTE [cs:ROMVARS.bIdeCnt] 242 ret
Note:
See TracChangeset
for help on using the changeset viewer.