Changeset 592 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src
- Timestamp:
- Jun 25, 2018, 10:29:27 PM (6 years ago)
- Location:
- trunk/XTIDE_Universal_BIOS/Src
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r589 r592 200 200 %ifdef MODULE_IRQ 201 201 test BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN 202 %ifdef USE_386 203 jnz IdeWait_IRQorStatusFlagInBLwithTimeoutInBH 204 %else 202 205 jz SHORT .PollStatusFlagInsteadOfWaitIrq 203 206 jmp IdeWait_IRQorStatusFlagInBLwithTimeoutInBH 204 207 .PollStatusFlagInsteadOfWaitIrq: 205 208 %endif 209 %endif ; MODULE_IRQ 206 210 jmp IdeWait_PollStatusFlagInBLwithTimeoutInBH 207 211 -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r582 r592 121 121 jnz SHORT .ChangeTo32bitDevice 122 122 123 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY ; No IORDY supported if need to limit123 and [di+DPT.bFlagsHigh], ah ; Mask off FLGH_DPT_IORDY if IORDY not supported 124 124 MIN_U [di+DPT_ADVANCED_ATA.bPioMode], al 125 125 mov [di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
r545 r592 147 147 lds di, [bp+MEMPIOVARS.fpDPT] ; DPT now in DS:DI 148 148 %ifdef USE_386 149 movzx cx, BYTE[bp+MEMPIOVARS.bSectorsDone]149 movzx cx, [bp+MEMPIOVARS.bSectorsDone] 150 150 %else 151 151 mov ch, 0 ; Preserve CF -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
r589 r592 97 97 sti ; Enable interrupts 98 98 %endif 99 %ifdef CLD_NEEDED 99 100 cld ; String instructions to increment pointers 101 %endif 100 102 ePUSHA 101 103 push ds … … 193 195 194 196 ; Push old INT 13h handler and restore registers 197 %ifdef USE_386 198 push DWORD [RAMVARS.fpOldI13h] 199 %else 195 200 push WORD [RAMVARS.fpOldI13h+2] 196 201 push WORD [RAMVARS.fpOldI13h] 202 %endif 197 203 mov bx, [bp+IDEPACK.intpack+INTPACK.bx] 198 204 mov di, [bp+IDEPACK.intpack+INTPACK.di] -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r567 r592 126 126 mov cx, NUMBER_OF_IDEVARS 127 127 128 . loop:128 .Loop: 129 129 call FindDPT_MasterOrSingleForIdevarsOffsetInDL 130 130 jc SHORT .ControllerNotAvailable … … 162 162 .ControllerNotAvailable: 163 163 add dl, IDEVARS_size ; move Idevars pointer forward 164 loop . loop164 loop .Loop 165 165 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
r589 r592 121 121 ; 122 122 ; Also note that some machines, noteably the Olivetti M24 (also known as 123 ; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,124 ; resulting in reversed byte ordering. Therefore, XTCF_8BIT_PIO_MODE is125 ; the default transfer mode for best system compatibility.123 ; the AT&T PC6300 or Xerox 6060 or Logabax Persona 1600), have hardware errors 124 ; in the BIU logic, resulting in reversed byte ordering. Therefore, 125 ; XTCF_8BIT_PIO_MODE is the default transfer mode for best system compatibility. 126 126 127 127 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm
r567 r592 46 46 47 47 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], EBIOS_VERSION 48 mov WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h48 not WORD [bp+IDEPACK.intpack+INTPACK.bx] ; 55AAh = AA55h 49 49 50 50 %ifdef MODULE_COMPATIBLE_TABLES … … 75 75 ;-------------------------------------------------------------------- 76 76 AH41h_GetSupportBitsToCX: 77 %ifdef USE_AT ; Always in Full mode 78 %ifndef MODULE_8BIT_IDE OR MODULE_SERIAL 79 mov cx, ENHANCED_DRIVE_ACCESS_SUPPORT | ENHANCED_DISK_DRIVE_SUPPORT 80 %else 81 mov cx, ENHANCED_DRIVE_ACCESS_SUPPORT 82 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_ATA 83 jae SHORT .DoNotSetEDDflag 84 or cl, ENHANCED_DISK_DRIVE_SUPPORT 85 %endif 86 %else ; ~USE_AT 77 87 mov cx, ENHANCED_DRIVE_ACCESS_SUPPORT 78 88 79 89 ; DPTE needs buffer from RAM so do not return it in lite mode 80 %ifndef USE_AT81 90 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE 82 91 jz SHORT .DoNotSetEDDflag 83 %endif84 92 85 93 %ifdef MODULE_8BIT_IDE OR MODULE_SERIAL … … 91 99 92 100 or cl, ENHANCED_DISK_DRIVE_SUPPORT ; AH=48h returns DPTE 101 %endif ; USE_AT 93 102 .DoNotSetEDDflag: 94 103 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
r589 r592 110 110 and al, MASKL_DPT_TRANSLATEMODE 111 111 112 ;;; 0: ADDRESSING_MODE_NORMAL112 ;;; 0: TRANSLATEMODE_NORMAL 113 113 jz SHORT DoNotConvertLCHS 114 114 115 ;;; 1: ADDRESSING_MODE_LARGE115 ;;; 1: TRANSLATEMODE_LARGE 116 116 test al, FLGL_DPT_ASSISTED_LBA 117 117 jz SHORT ConvertLargeModeLCHStoPCHS 118 118 119 ;;; 2: ADDRESSING_MODE_ASSISTED_LBA119 ;;; 2: TRANSLATEMODE_ASSISTED_LBA 120 120 ; Fall to ConvertAssistedLBAModeLCHStoLBARegisterValues 121 121 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
r567 r592 30 30 Int19h_BootLoaderHandler: 31 31 sti ; Enable interrupts 32 %ifdef CLD_NEEDED 32 33 cld ; String instructions to increment pointers 34 %endif 33 35 %ifdef MODULE_VERY_LATE_INIT 34 36 LOAD_BDA_SEGMENT_TO ds, ax ; Load BDA segment (zero) to DS -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm
r589 r592 60 60 ; AX: ID WORD specific for detected controller 61 61 ; Returns: 62 ; AL: Max supported PIO mode 63 ; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise62 ; AL: Max supported PIO mode (only if ZF set) 63 ; AH: ~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set) 64 64 ; BX: Min PIO cycle time (only if ZF set) 65 65 ; ZF: Set if PIO limit necessary -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm
r589 r592 127 127 128 128 ; PDC20230C and PDC20630 clears the bit we set at the beginning 129 in al, dx 129 in al, dx ; 1F2h 130 130 dec dx 131 131 dec dx ; Base port … … 139 139 ; AX: ID WORD specific for detected controller 140 140 ; Returns: 141 ; AL: Max supported PIO mode 142 ; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise141 ; AL: Max supported PIO mode (only if ZF set) 142 ; AH: ~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set) 143 143 ; BX: Min PIO cycle time (only if ZF set) 144 144 ; ZF: Set if PIO limit necessary … … 148 148 ;-------------------------------------------------------------------- 149 149 PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX: 150 cmp ah, ID_PDC20 630151 j e SHORT .Return ; No need to limit anything152 mov ax, 2; Limit PIO to 2 for ID_PDC20230150 cmp ah, ID_PDC20230 151 jne SHORT .Return ; No need to limit anything for ID_PDC20630 152 mov ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2 ; Limit PIO to 2 for ID_PDC20230 153 153 mov bx, PIO_2_MIN_CYCLE_TIME_NS 154 stc155 154 .Return: 156 155 ret … … 206 205 ;-------------------------------------------------------------------- 207 206 SetSpeedForDriveInCX: 208 eMOVZX bx, BYTE [di+DPT_ADVANCED_ATA.bPioMode] 209 MIN_U bl, 2 ; Limit to PIO2 210 mov bl, [cs:bx+.rgbPioModeToPDCspeedValue] 207 mov bx, .rgbPioModeToPDCspeedValue 208 mov al, [di+DPT_ADVANCED_ATA.bPioMode] 209 MIN_U al, 2 ; Limit to PIO2 210 cs xlat 211 xchg bx, ax 211 212 212 213 add dx, BYTE SECTOR_NUMBER_REGISTER -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm
r589 r592 131 131 ; AH: QDI Vision Controller ID 132 132 ; Returns: 133 ; AL: Max supported PIO mode 134 ; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise133 ; AL: Max supported PIO mode (only if ZF set) 134 ; AH: ~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set) 135 135 ; BX: Min PIO Cycle Time (only if ZF set) 136 136 ; ZF: Set if PIO limit necessary … … 142 142 cmp ah, ID_QD6500 143 143 jne SHORT .NoNeedToLimitForQD6580 144 145 mov ax, 2 ; Limit to PIO 2 because QD6500 does not support IORDY 144 mov ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2 ; Limit to PIO 2 because QD6500 does not support IORDY 146 145 mov bx, PIO_2_MIN_CYCLE_TIME_NS 147 146 .NoNeedToLimitForQD6580: -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r580 r592 104 104 ; DX: User defined P-CHS to L-CHS translate mode 105 105 ; Corrupts registers: 106 ; AX, BX , CX106 ; AX, BX 107 107 ;-------------------------------------------------------------------- 108 108 AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX: … … 113 113 pop ds 114 114 115 ; Load User Defined CHS or LBA to CX:AX116 mov d x, [bx+DRVPARAMS.wFlags]115 ; Load User Defined CHS or LBA to BX:AX 116 mov dl, [bx+DRVPARAMS.wFlags] ; Only load the flags we actually need 117 117 mov ax, [bx+DRVPARAMS.wCylinders] ; Or .dwMaximumLBA 118 mov cx, [bx+DRVPARAMS.wHeadsAndSectors] ; Or .dwMaximumLBA+2118 mov bx, [bx+DRVPARAMS.wHeadsAndSectors] ; Or .dwMaximumLBA+2 119 119 120 120 push es … … 127 127 ; Apply new CHS and disable LBA (we also want to set CHS addressing) 128 128 mov [si+ATA1.wCylCnt], ax 129 eMOVZX ax, cl129 eMOVZX ax, bl 130 130 mov [si+ATA1.wHeadCnt], ax 131 mov al, ch131 mov al, bh 132 132 mov [si+ATA1.wSPT], ax 133 133 and BYTE [si+ATA1.wCaps+1], ~(A1_wCaps_LBA>>8) … … 140 140 141 141 ; Apply new LBA and disable LBA48 142 cmp cx, [si+ATA1.dwLBACnt+2]142 cmp bx, [si+ATA1.dwLBACnt+2] 143 143 ja SHORT .NoUserDefinedLBA ; Do not set larger than drive 144 144 jb SHORT .StoreNewLBA … … 147 147 .StoreNewLBA: 148 148 mov [si+ATA1.dwLBACnt], ax 149 mov [si+ATA1.dwLBACnt+2], cx149 mov [si+ATA1.dwLBACnt+2], bx 150 150 and BYTE [si+ATA6.wSetSup83+1], ~(A6_wSetSup83_LBA48>>8) 151 151 .NoUserDefinedLBA: … … 173 173 AtaID_GetMaxPioModeToAXandMinCycleTimeToCX: 174 174 ; Get PIO mode and cycle time for PIO 0...2 175 mov bx, [es:si+ATA1.bPioMode] 176 mov ax, bx ; AH = 0, AL = PIO mode 0, 1 or 2 177 eSHL_IM bx, 1 ; Shift for WORD lookup 175 %ifdef USE_386 176 movzx ax, [es:si+ATA1.bPioMode] ; AH = 0, AL = PIO mode 0, 1 or 2 177 %else 178 mov al, [es:si+ATA1.bPioMode] 179 cbw 180 %endif 181 mov bx, ax 182 eSHL_IM bx, 1 ; Shift for WORD lookup 178 183 mov cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs] 179 184 180 185 ; Check if IORDY is supported 181 186 test BYTE [es:si+ATA2.wCaps+1], A2_wCaps_IORDY >> 8 182 jz SHORT .ReturnPioTimings ; No PIO 3 or higher if no IORDY183 mov ah, FLGH_DPT_IORDY 187 jz SHORT .ReturnPioTimings ; No PIO 3 or higher if no IORDY 188 mov ah, FLGH_DPT_IORDY ; *FIXME* Actually, CF specification v4.1 says that use of IORDY is invalid for PIO modes 5 and 6. 184 189 185 190 ; Check if Advanced PIO modes are supported (3 and above) … … 187 192 jz SHORT .ReturnPioTimings 188 193 189 ; Get Advanced PIO mode 190 ; (Hard Disks supports up to 4 but CF cards can support 5 and 6)191 mov bl, [es:si+ATA2.bPIOSupp]194 ; Get Advanced PIO mode (Hard Disks supports up to 4 but CF cards can support 5 and 6) 195 or bh, [es:si+ATA2.bPIOSupp] 196 jz SHORT .ReturnPioTimings 192 197 .CheckNextFlag: 193 198 inc ax 194 shr b l, 1199 shr bh, 1 195 200 jnz SHORT .CheckNextFlag 196 201 MIN_U al, 6 ; Make sure not above lookup tables -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
r589 r592 150 150 push bp 151 151 mov bp, sp 152 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS 153 %if DRVDETECTINFO.szDrvName = 0 154 push bx 155 %else 152 156 lea si, [bx+DRVDETECTINFO.szDrvName] 153 157 push si 158 %endif 159 %endif 154 160 mov si, g_szDriveName 155 161 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP -
trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
r567 r592 190 190 LOAD_BDA_SEGMENT_TO ds, ax 191 191 mov al, [BDA.wEquipment] ; Load Equipment WORD low byte 192 and al, 0C1h ; Leave bits 7..6 and 0 193 eAAM 64 194 add al, ah ; AL = Floppy Drive count 192 195 pop ds 193 194 %ifdef USE_UNDOC_INTEL195 and al, 0C1h196 eAAM 64197 %else198 mov ah, al ; Copy it to AH199 and ax, 0C001h ; Leave bits 15..14 and 0200 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0201 %endif ; USE_UNDOC_INTEL202 203 add al, ah ; AL = Floppy Drive count204 196 %endif ; USE_AT 205 197 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
r589 r592 239 239 .ClearBitFrom8259MaskRegister: 240 240 push cx 241 xchg ax, cx ; IRQ index to CL 241 xchg cx, ax ; IRQ index to CL 242 in al, dx ; Read Interrupt Mask Register 242 243 mov ch, ~1 ; Load bit mask to be rotated 243 244 rol ch, cl ; Rotate mask to correct position for clearing 244 in al, dx ; Read Interrupt Mask Register245 245 and al, ch ; Clear wanted bit 246 246 out dx, al ; Write modified Interrupt Mask Register -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r589 r592 32 32 33 33 ; We must define included libraries before including "AssemblyLibrary.inc". 34 %define EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS; Exclude unused library functions34 %define EXCLUDE_FROM_XUB ; Exclude unused library functions 35 35 %ifdef MODULE_BOOT_MENU 36 36 %define MENUEVENT_INLINE_OFFSETS ; Only one menu required, save space and inline offsets … … 81 81 %ifdef MODULE_BOOT_MENU 82 82 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT 83 at ROMVARS.pColorTheme, dw ColorTheme ; Offset to the ATTRIBUTE_CHARS struc that holds the color theme 83 84 %endif 84 85 at ROMVARS.bIdeCnt, db 2 ; Number of supported controllers … … 105 106 at ROMVARS.ideVars2+IDEVARS.wControlBlockPort, dw DEVICE_ATA_TERTIARY_PORTCTRL 106 107 at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_16BIT_ATA 107 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 108 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 ; Should be 11 on the GSI Inc. Model 2C 108 109 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, dw DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) 109 110 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, dw DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) … … 112 113 at ROMVARS.ideVars3+IDEVARS.wControlBlockPort, dw DEVICE_ATA_QUATERNARY_PORTCTRL 113 114 at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA 114 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0 115 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0 ; Should be 10 on the GSI Inc. Model 2C 115 116 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, dw DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) 116 117 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, dw DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) … … 127 128 %ifdef MODULE_BOOT_MENU 128 129 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT 130 at ROMVARS.pColorTheme, dw ColorTheme ; Offset to the ATTRIBUTE_CHARS struc that holds the color theme 129 131 %endif 130 132 at ROMVARS.bIdeCnt, db 1 … … 301 303 302 304 305 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS 303 306 ; Although it's very unlikely to happen, we give warnings for builds that cannot be automatically checksummed due to the size being too large. 304 307 ; In some cases it's theoretically possible to checksum the build anyway (manually) which is why these are warnings and not errors. … … 309 312 %endif 310 313 %endif 311 %elif ($-$$) = BIOS_SIZE ; A large build.314 %elif ($-$$) = BIOS_SIZE ; A large or tiny build. 312 315 %warning "This build is too large to be auto-checksummed!" 313 316 %endif 317 %endif -
trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm
r567 r592 141 141 142 142 ; Store default Menuitem (=default drive to boot from) 143 eMOVZX dx, BYTE[cs:ROMVARS.bBootDrv]143 eMOVZX dx, [cs:ROMVARS.bBootDrv] 144 144 call GetMenuitemToDXforDriveInDL 145 145 mov [bp+MENUINIT.wHighlightedItem], dx -
trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm
r589 r592 54 54 test dl, dl 55 55 js SHORT .go 56 mov bl, ( (g_szFloppyDrv)-$$ & 0xff); and revisit the earlier assumption...56 mov bl, (g_szFloppyDrv - $$) & 0xff ; and revisit the earlier assumption... 57 57 58 58 .go: -
trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm
r568 r592 63 63 ;; with AL clear, and so we exchange AL and AH after the multiply for the final result. 64 64 ;; 65 %ifdef USE_186 66 imul ax, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION) 67 %else 65 68 mov cx, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION) 66 69 mul cx 70 %endif 67 71 xchg al, ah ; AL = always zero after above multiplication 68 72 add ax, g_szAddressingModes -
trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
r568 r592 407 407 sbb di, BYTE 1 ; Sub CF if Floppy Drive 408 408 xchg ax, cx 409 mov [es:di], al409 stosb 410 410 stc ; Valid hotkey scancode returned in AL 411 411 -
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.