Changeset 592 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Timestamp:
- Jun 25, 2018, 10:29:27 PM (6 years ago)
- Location:
- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
r580 r592 114 114 ; slower. The speed difference doesn't matter on AT systems. 115 115 .UseAssistedLBA: 116 call GetSectorCountToDXAXfromCHSinAXBLBH 117 call ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH 118 xor cx, cx ; No bits to shift 116 ; Fall to GetSectorCountToDXAXfromCHSinAXBLBH 117 118 119 ;-------------------------------------------------------------------- 120 ; GetSectorCountToDXAXfromCHSinAXBLBH 121 ; Parameters: 122 ; AX: Number of cylinders (1...16383) 123 ; BL: Number of heads (1...255) 124 ; BH: Number of sectors per track (1...63) 125 ; Returns: 126 ; DX:AX: Total number of CHS addressable sectors 127 ; Corrupts registers: 128 ; BX 129 ;-------------------------------------------------------------------- 130 GetSectorCountToDXAXfromCHSinAXBLBH: 131 xchg ax, bx 132 mul ah ; AX = Heads * Sectors per track 133 mul bx 134 ; Fall to ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH 135 136 137 ;-------------------------------------------------------------------- 138 ; LBA assist calculation (or Assisted LBA) 139 ; 140 ; This algorithm translates P-CHS sector count up to largest possible 141 ; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows 142 ; 256 heads but DOS supports up to 255 head. That is why BIOSes never 143 ; use 256 heads. 144 ; 145 ; L-CHS parameters generated here require the drive to use LBA addressing. 146 ; 147 ; Here is the algorithm: 148 ; If cylinders > 8192 149 ; Variable CH = Total CHS Sectors / 63 150 ; Divide (CH - 1) by 1024 and add 1 151 ; Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads. 152 ; Divide CH by the number of heads. This is the value to be used for the number of cylinders. 153 ; 154 ; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH: 155 ; Parameters: 156 ; DX:AX: Total number of P-CHS sectors for CHS addressing 157 ; (max = 16383 * 16 * 63 = 16,514,064) 158 ; Returns: 159 ; AX: Number of cylinders (?...1027) 160 ; BL: Number of heads (16, 32, 64, 128 or 255) 161 ; BH: Number of sectors per track (always 63) 162 ; CX: Number of bits shifted (0) 163 ; DL: TRANSLATEMODE_ASSISTED_LBA 164 ; Corrupts registers: 165 ; DH 166 ;-------------------------------------------------------------------- 167 ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH: 168 ; Value CH = Total sector count / 63 169 ; Max = 16,514,064 / 63 = 262128 170 mov cx, LBA_ASSIST_SPT ; CX = 63 171 172 ; --- Math_DivDXAXbyCX inlined (and slightly modified) since it's only used here 173 xor bx, bx 174 xchg bx, ax 175 xchg dx, ax 176 div cx 177 xchg ax, bx 178 div cx 179 mov dx, bx 180 ; --- 181 182 push ax 183 push dx ; Value CH stored for later use 184 185 ; BX:DX:AX = Value CH - 1 186 ; Max = 262128 - 1 = 262127 187 xor bx, bx 188 sub ax, BYTE 1 189 sbb dx, bx 190 191 ; AX = Number of heads = ((Value CH - 1) / 1024) + 1 192 ; Max = (262127 / 1024) + 1 = 256 193 call Size_DivideSizeInBXDXAXby1024 ; Preserves CX and returns with BH cleared 194 pop dx 195 inc ax ; + 1 196 197 ; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest) 198 ; Max = 255 199 mov bl, 16 ; Min number of heads 200 .CompareNextValidNumberOfHeads: 201 cmp ax, bx 202 jbe SHORT .NumberOfHeadsNowInBX 203 eSHL_IM bx, 1 ; Double number of heads 204 jpo SHORT .CompareNextValidNumberOfHeads ; Reached 256 heads? 205 dec bx ; If so, limit heads to 255 206 .NumberOfHeadsNowInBX: 207 208 ; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads 209 ; Max = 262128 / 255 = 1027 210 pop ax ; Value CH back to DX:AX 211 div bx 212 213 xchg bh, cl ; Sectors per Track to BH, zero to CL (CX) 119 214 mov dl, TRANSLATEMODE_ASSISTED_LBA 215 ReturnLCHSinAXBLBH: 120 216 ret 121 217 … … 136 232 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16) 137 233 mov bh, [es:si+ATA1.wSPT] ; Sectors per Track (1...63) 138 ret139 140 141 ;--------------------------------------------------------------------142 ; GetSectorCountToDXAXfromCHSinAXBLBH143 ; Parameters:144 ; AX: Number of cylinders (1...16383)145 ; BL: Number of heads (1...255)146 ; BH: Number of sectors per track (1...63)147 ; Returns:148 ; DX:AX: Total number of CHS addressable sectors149 ; Corrupts registers:150 ; BX151 ;--------------------------------------------------------------------152 GetSectorCountToDXAXfromCHSinAXBLBH:153 xchg ax, bx154 mul ah ; AX = Heads * Sectors per track155 mul bx156 234 ret 157 235 … … 175 253 ; Do a standard ECHS translation 176 254 ; 255 ; *FIXME* The above algorithm seems to be conflicting with info found here 256 ; https://web.archive.org/web/20000817071418/http://www.firmware.com:80/support/bios/over4gb.htm 257 ; which says that Revised ECHS is used when the cylinder count is > 8191. 258 ; 177 259 ; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL: 178 260 ; Parameters: … … 183 265 ; BL: Number of L-CHS heads (?...240) 184 266 ; CX: Number of bits shifted (0...3) 185 ; DX: ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE267 ; DX: TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE 186 268 ; Corrupts registers: 187 269 ; Nothing … … 271 353 ret 272 354 273 274 ;--------------------------------------------------------------------275 ; LBA assist calculation (or Assisted LBA)276 ;277 ; This algorithm translates P-CHS sector count up to largest possible278 ; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows279 ; 256 heads but DOS supports up to 255 head. That is why BIOSes never280 ; use 256 heads.281 ;282 ; L-CHS parameters generated here require the drive to use LBA addressing.283 ;284 ; Here is the algorithm:285 ; If cylinders > 8192286 ; Variable CH = Total CHS Sectors / 63287 ; Divide (CH 1) by 1024 and add 1288 ; Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.289 ; Divide CH by the number of heads. This is the value to be used for the number of cylinders.290 ;291 ; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:292 ; Parameters:293 ; DX:AX: Total number of P-CHS sectors for CHS addressing294 ; (max = 16383 * 16 * 63 = 16,514,064)295 ; Returns:296 ; AX: Number of cylinders (?...1027)297 ; BL: Number of heads (16, 32, 64, 128 or 255)298 ; BH: Number of sectors per track (always 63)299 ; Corrupts registers:300 ; CX, DX301 ;--------------------------------------------------------------------302 ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:303 ; Value CH = Total sector count / 63304 ; Max = 16,514,064 / 63 = 262128305 mov cx, LBA_ASSIST_SPT ; CX = 63306 call Math_DivDXAXbyCX ; Preserves CX307 push dx308 push ax ; Value CH stored for later use309 310 ; BX:DX:AX = Value CH - 1311 ; Max = 262128 - 1 = 262127312 xor bx, bx313 sub ax, BYTE 1314 sbb dx, bx315 316 ; AX = Number of heads = ((Value CH - 1) / 1024) + 1317 ; Max = (262127 / 1024) + 1 = 256318 call Size_DivideSizeInBXDXAXby1024 ; Preserves CX319 inc ax ; + 1320 321 ; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)322 ; Max = 255323 mov cl, 16 ; Min number of heads324 .CompareNextValidNumberOfHeads:325 cmp ax, cx326 jbe SHORT .NumberOfHeadsNowInCX327 eSHL_IM cx, 1 ; Double number of heads328 jpo SHORT .CompareNextValidNumberOfHeads ; Reached 256 heads?329 dec cx ; If so, limit heads to 255330 .NumberOfHeadsNowInCX:331 mov bx, cx ; Number of heads are returned in BL332 mov bh, LBA_ASSIST_SPT ; Sectors per Track333 334 ; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads335 ; Max = 262128 / 255 = 1027336 pop ax337 pop dx ; Value CH back to DX:AX338 div cx339 340 ; Return L-CHS341 ReturnLCHSinAXBLBH:342 ret -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm
r591 r592 46 46 47 47 add si, BYTE ATA1.strModel ; DS:SI now points drive name (Clears CF) 48 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS 48 49 %if DRVDETECTINFO.szDrvName = 0 49 50 mov di, bx 50 51 %else 51 52 lea di, [bx+DRVDETECTINFO.szDrvName] ; ES:DI now points to name destination 53 %endif 52 54 %endif 53 55 mov cx, MAX_HARD_DISK_NAME_LENGTH / 2 ; Max number of WORDs allowed … … 78 80 ;-------------------------------------------------------------------- 79 81 DriveDetectInfo_ConvertDPTtoBX: 82 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS 80 83 %if DPT_DRVDETECTINFO_SIZE_MULTIPLIER = 2 81 84 %if BOOTVARS.rgDrvDetectInfo & 1 ; Should never be odd but better safe than sorry 82 lea ax, [di-RAMVARS_size]83 eSHL_IM ax, 184 add ax, BOOTVARS.rgDrvDetectInfo85 lea bx, [di-RAMVARS_size] 86 eSHL_IM bx, 1 87 add bx, BOOTVARS.rgDrvDetectInfo 85 88 %else 86 lea ax, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)] 87 ; eSHL_IM ax, 1 ; *FIXME* For some reason this will cause NASM to crap itself. 88 shl ax, 1 ; So this will have to suffice for now. 89 lea bx, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)] 90 eSHL_IM bx, 1 89 91 %endif 92 %else 93 %ifdef USE_186 94 lea bx, [di-RAMVARS_size] 95 imul bx, DPT_DRVDETECTINFO_SIZE_MULTIPLIER 96 add bx, BOOTVARS.rgDrvDetectInfo 90 97 %else 91 98 lea ax, [di-RAMVARS_size] ; subtract off base of DPTs … … 93 100 mul bl 94 101 add ax, BOOTVARS.rgDrvDetectInfo ; add base of DRVDETECTINFO 102 xchg bx, ax 95 103 %endif 96 xchg bx, ax 104 %endif 105 %endif 97 106 ret -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r567 r592 31 31 ; DS: RAMVARS segment 32 32 ; Corrupts registers: 33 ; AX, CX, D I33 ; AX, CX, DX, DI 34 34 ;-------------------------------------------------------------------- 35 35 RamVars_Initialize: 36 36 push es 37 ; Fall to .StealMemoryForRAMVARS38 37 39 ;--------------------------------------------------------------------40 ; .StealMemoryForRAMVARS41 ; Parameters:42 ; Nothing43 ; Returns:44 ; DS: RAMVARS segment45 ; Corrupts registers:46 ; AX, CL47 ;--------------------------------------------------------------------48 .StealMemoryForRAMVARS:49 38 %ifndef USE_AT 50 39 mov ax, LITE_MODE_RAMVARS_SEGMENT … … 56 45 mov al, [cs:ROMVARS.bStealSize] 57 46 sub [BDA.wBaseMem], ax 58 mov ax, [BDA.wBaseMem]59 47 %ifdef USE_186 60 shl ax, 6 ; Segment to first stolen kB (*=40h)48 imul ax, [BDA.wBaseMem], 64 61 49 %else 62 mov cl, 663 shl ax, cl50 mov al, 64 51 mul WORD [BDA.wBaseMem] 64 52 %endif 65 ; Fall to .InitializeRamvars66 53 67 ;--------------------------------------------------------------------68 ; .InitializeRamvars69 ; Parameters:70 ; AX: RAMVARS segment71 ; Returns:72 ; DS: RAMVARS segment73 ; Corrupts registers:74 ; AX, CX, DI, ES75 ;--------------------------------------------------------------------76 54 .InitializeRamvars: 55 xor di, di 77 56 mov ds, ax 78 57 mov es, ax 79 58 mov cx, RAMVARS_size 80 xor di, di81 59 call Memory_ZeroESDIwithSizeInCX 82 60 mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE … … 121 99 .GetStolenSegmentToDS: 122 100 LOAD_BDA_SEGMENT_TO ds, di 101 ;%ifdef USE_186 102 ; imul di, [BDA.wBaseMem], 64 ; 2 bytes less but slower, especially on 386/486 processors 103 ;%else 123 104 mov di, [BDA.wBaseMem] ; Load available base memory size in kB 124 105 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h) 106 ;%endif 125 107 ALIGN JUMP_ALIGN 126 108 .LoopStolenKBs:
Note:
See TracChangeset
for help on using the changeset viewer.