- Timestamp:
- Jan 31, 2011, 11:27:17 AM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
r3 r99 1 ; File name : CustomDPT.inc 2 ; Project name : IDE BIOS 3 ; Created date : 23.3.2010 4 ; Last update : 10.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Defines for DPT structs containing custom 7 3 ; Disk Parameter Table used by this BIOS. … … 15 11 ; General Disk Parameter Table related 16 12 .bSize resb 1 ; Size of DPT (with extensions) in bytes 13 .wDrvNumAndFlags: 17 14 .bDrvNum resb 1 ; Drive number 18 15 .bFlags resb 1 ; DPT and Drive related flags … … 26 23 ; IDE related 27 24 .wPCyls resb 2 ; Number of P-CHS (IDE) Cylinders (1...16383) 25 .wHeadsAndSectors: 28 26 .bPHeads resb 1 ; Number of P-CHS (IDE) Heads (1...16) 29 27 .bPSect resb 1 ; Number of P-CHS (IDE) Sectors per Track (1...63) -
trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
r97 r99 54 54 .wFlags resb 2 ; Drive flags 55 55 .wCylinders resb 2 ; User specified cylinders (1...16383) 56 .wSectAndHeads: 56 .wHeadsAndSectors: 57 .bHeads resb 1 ; User specified Heads (1...16) 57 58 .bSect resb 1 ; User specified Sectors per track (1...63) 58 .bHeads resb 1 ; User specified Heads (1...16)59 59 endstruc 60 60 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r3 r99 1 ; File name : AtaID.asm 2 ; Project name : IDE BIOS 3 ; Created date : 6.4.2010 4 ; Last update : 9.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for accessing ATA information read with 7 3 ; IDENTIFY DEVICE command. … … 11 7 12 8 ;-------------------------------------------------------------------- 13 ; Returns P-CHS values from ATA information.14 ;15 9 ; AtaID_GetPCHS 16 10 ; Parameters: … … 18 12 ; Returns: 19 13 ; AX: Number of user specified P-CHS cylinders 20 ; B L: Number of user specified P-CHS sectors per track21 ; B H: Number of user specified P-CHS heads14 ; BH: Number of user specified P-CHS sectors per track 15 ; BL: Number of user specified P-CHS heads 22 16 ; Corrupts registers: 23 17 ; Nothing 24 18 ;-------------------------------------------------------------------- 25 ALIGN JUMP_ALIGN26 19 AtaID_GetPCHS: 27 20 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383) 28 mov b h, [es:si+ATA1.wHeadCnt] ; Heads (1...16)29 mov b l, [es:si+ATA1.wSPT] ; Sectors per Track (1...63)21 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16) 22 mov bh, [es:si+ATA1.wSPT] ; Sectors per Track (1...63) 30 23 ret 31 24 32 25 33 26 ;-------------------------------------------------------------------- 34 ; Returns total number of available sectors from ATA information.35 ;36 27 ; AtaID_GetTotalSectorCount 37 28 ; Parameters: … … 42 33 ; Nothing 43 34 ;-------------------------------------------------------------------- 44 ALIGN JUMP_ALIGN45 35 AtaID_GetTotalSectorCount: 36 push ds 37 38 push es 39 pop ds 46 40 xor bx, bx 47 test WORD [ es:si+ATA1.wCaps], A1_wCaps_LBA48 jz SHORT AtaID_GetChsSectorCount49 ; Fall to AtaID_GetLbaSectorCount41 test WORD [si+ATA1.wCaps], A1_wCaps_LBA 42 jz SHORT .GetChsSectorCount 43 ; Fall to .GetLbaSectorCount 50 44 51 45 ;-------------------------------------------------------------------- 52 ; Returns total number of available sectors for LBA addressing. 53 ; 54 ; AtaID_GetLbaSectorCount 46 ; .GetLbaSectorCount 55 47 ; Parameters: 56 48 ; BX: Zero 57 ; ES:SI: Ptr to 512-byte ATA information read from the drive49 ; DS:SI: Ptr to 512-byte ATA information read from the drive 58 50 ; Returns: 59 51 ; BX:DX:AX: 48-bit sector count … … 61 53 ; Nothing 62 54 ;-------------------------------------------------------------------- 63 ;ALIGN JUMP_ALIGN 64 AtaID_GetLbaSectorCount: 65 test WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48 55 .GetLbaSectorCount: 56 test WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48 66 57 jz SHORT .GetLba28SectorCount 67 mov ax, [es:si+ATA6.qwLBACnt] 68 mov dx, [es:si+ATA6.qwLBACnt+2] 69 mov bx, [es:si+ATA6.qwLBACnt+4] 58 mov ax, [si+ATA6.qwLBACnt] 59 mov dx, [si+ATA6.qwLBACnt+2] 60 mov bx, [si+ATA6.qwLBACnt+4] 61 pop ds 70 62 ret 71 ALIGN JUMP_ALIGN72 63 .GetLba28SectorCount: 73 mov ax, [es:si+ATA1.dwLBACnt] 74 mov dx, [es:si+ATA1.dwLBACnt+2] 64 mov ax, [si+ATA1.dwLBACnt] 65 mov dx, [si+ATA1.dwLBACnt+2] 66 pop ds 75 67 ret 76 68 77 69 ;-------------------------------------------------------------------- 78 ; Returns total number of available sectors for P-CHS addressing. 79 ; 80 ; AtaID_GetChsSectorCount 70 ; .GetChsSectorCount 81 71 ; Parameters: 82 ; ES:SI: Ptr to 512-byte ATA information read from the drive72 ; DS:SI: Ptr to 512-byte ATA information read from the drive 83 73 ; Returns: 84 74 ; DX:AX: 24-bit sector count … … 86 76 ; Nothing 87 77 ;-------------------------------------------------------------------- 88 ALIGN JUMP_ALIGN 89 AtaID_GetChsSectorCount: 90 m ov al, [es:si+ATA1.wSPT] ; AL=Sectors per track91 mul BYTE [es:si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads92 mul WORD [es:si+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders78 .GetChsSectorCount: 79 mov al, [si+ATA1.wSPT] ; AL=Sectors per track 80 mul BYTE [si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads 81 mul WORD [si+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders 82 pop ds 93 83 ret -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm
r35 r99 1 ; File name : DriveXlate.asm 2 ; Project name : IDE BIOS 3 ; Created date : 15.3.2010 4 ; Last update : 24.8.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for swapping drive letters. 7 3 … … 100 96 DriveXlate_SwapFloppyDriveOrHardDisk: 101 97 test dl, 80h ; Hard disk? 102 jnz SHORT DriveXlate_SwapHardDisk ; If so, jump to swap 103 ; Fall to DriveXlate_SwapFloppyDrive 104 105 ;-------------------------------------------------------------------- 106 ; Swaps Floppy Drive number. 107 ; 108 ; DriveXlate_SwapFloppyDrive 109 ; Parameters: 110 ; DL: Drive number to be possibly swapped 111 ; DS: RAMVARS segment 112 ; Returns: 113 ; DL: Translated drive number 114 ; Corrupts registers: 115 ; AX 116 ;-------------------------------------------------------------------- 117 ;ALIGN JUMP_ALIGN 118 DriveXlate_SwapFloppyDrive: 98 jnz SHORT .SwapHardDisk ; If so, jump to swap 99 ; Fall to .SwapFloppyDrive 100 101 ;-------------------------------------------------------------------- 102 ; .SwapFloppyDrive 103 ; Parameters: 104 ; DL: Drive number to be possibly swapped 105 ; DS: RAMVARS segment 106 ; Returns: 107 ; DL: Translated drive number 108 ; Corrupts registers: 109 ; AX 110 ;-------------------------------------------------------------------- 111 .SwapFloppyDrive: 119 112 eMOVZX ax, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap] 120 jmp SHORT DriveXlate_SwapDrive 121 122 ;-------------------------------------------------------------------- 123 ; Swaps Hard Disk number. 124 ; 125 ; DriveXlate_SwapHardDisk 126 ; Parameters: 127 ; DL: Drive number to be possibly swapped 128 ; DS: RAMVARS segment 129 ; Returns: 130 ; DL: Translated drive number 131 ; Corrupts registers: 132 ; AX 133 ;-------------------------------------------------------------------- 134 ALIGN JUMP_ALIGN 135 DriveXlate_SwapHardDisk: 113 jmp SHORT SwapDrive 114 115 ;-------------------------------------------------------------------- 116 ; .SwapHardDisk 117 ; Parameters: 118 ; DL: Drive number to be possibly swapped 119 ; DS: RAMVARS segment 120 ; Returns: 121 ; DL: Translated drive number 122 ; Corrupts registers: 123 ; AX 124 ;-------------------------------------------------------------------- 125 ALIGN JUMP_ALIGN 126 .SwapHardDisk: 136 127 mov ah, 80h 137 128 mov al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap] 138 ; Fall to DriveXlate_SwapDrive 139 140 ;-------------------------------------------------------------------- 141 ; Swaps Hard Disk or Floppy Drive number. 142 ; 143 ; DriveXlate_SwapDrive 129 ; Fall to SwapDrive 130 131 ;-------------------------------------------------------------------- 132 ; SwapDrive 144 133 ; Parameters: 145 134 ; AL: Drive number to swap to 00h/80h … … 151 140 ; Nothing 152 141 ;-------------------------------------------------------------------- 153 ;ALIGN JUMP_ALIGN 154 DriveXlate_SwapDrive: 142 SwapDrive: 155 143 cmp ah, dl ; Swap DL from 00h/80h to xxh? 156 144 je SHORT .SwapToXXhInAL … … 201 189 DriveXlate_SetDriveToSwap: 202 190 test dl, 80h ; Floppy drive? 203 jnz SHORT DriveXlate_SetHardDiskToSwap 204 ; Fall to DriveXlate_SetFloppyDriveToSwap 205 206 ;-------------------------------------------------------------------- 207 ; Stores floppy drive to be swapped. 208 ; 209 ; DriveXlate_SetFloppyDriveToSwap 210 ; Parameters: 211 ; DL: Drive to swap to 00h 212 ; DS: RAMVARS segment 213 ; Returns: 214 ; Nothing 215 ; Corrupts registers: 216 ; Nothing 217 ;-------------------------------------------------------------------- 218 ALIGN JUMP_ALIGN 219 DriveXlate_SetFloppyDriveToSwap: 191 jnz SHORT .SetHardDiskToSwap 192 .SetFloppyDriveToSwap: 220 193 mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl 221 194 ret 222 223 ;-------------------------------------------------------------------- 224 ; Stores hard disk to be swapped. 225 ; 226 ; DriveXlate_SetHardDiskToSwap 227 ; Parameters: 228 ; DL: Drive to swap to 80h 229 ; DS: RAMVARS segment 230 ; Returns: 231 ; Nothing 232 ; Corrupts registers: 233 ; Nothing 234 ;-------------------------------------------------------------------- 235 ALIGN JUMP_ALIGN 236 DriveXlate_SetHardDiskToSwap: 195 ALIGN JUMP_ALIGN 196 .SetHardDiskToSwap: 237 197 mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl 238 198 ret -
trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
r86 r99 18 18 ; BX, CX, DI 19 19 ;-------------------------------------------------------------------- 20 ;ALIGN JUMP_ALIGN21 20 FloppyDrive_IsInt40hInstalled: 22 21 cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment? 23 22 jb SHORT .Int40hHandlerIsNotInstalled 23 %ifdef USE_AT 24 24 call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h 25 %else 26 clc ; INT 40h installed. No need to verify on XT systems. 27 %endif 25 28 .Int40hHandlerIsNotInstalled: 26 29 cmc … … 37 40 ; BX, CX, DI 38 41 ;-------------------------------------------------------------------- 39 ;ALIGN JUMP_ALIGN 42 %ifdef USE_AT 40 43 .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h: 41 44 push es … … 45 48 call .LoadInt40hVerifyParameters 46 49 int INTV_DISK_FUNC 47 jc SHORT . AH08hNotSupported ; AH=08h not supported on XTs but that doesn't48 push es ; matter since INT 40h does not need to be verified49 push di ; on XTs50 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all 51 push es 52 push di 50 53 51 54 call .LoadInt40hVerifyParameters … … 58 61 mov dx, es 59 62 cmp cx, dx ; Difference in segments? 60 jne SHORT .Int40hNotInstalled 61 .AH08hNotSupported: 62 clc 63 jmp SHORT .Int40hIsInstalled 63 je SHORT .Int40hIsInstalled 64 64 .Int40hNotInstalled: 65 65 stc … … 81 81 ; DH 82 82 ;-------------------------------------------------------------------- 83 ;ALIGN JUMP_ALIGN84 83 .LoadInt40hVerifyParameters: 85 84 mov ah, 08h ; Get Drive Parameters … … 88 87 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs 89 88 ret 89 %endif 90 90 91 91 … … 133 133 FloppyDrive_GetCount: 134 134 push es 135 %ifdef USE_AT 135 136 call FloppyDrive_GetCountFromBIOS 136 jnc SHORT .CompareToUserMinimum 137 %else 137 138 call FloppyDrive_GetCountFromBDA 138 ALIGN JUMP_ALIGN 139 .CompareToUserMinimum: 139 %endif 140 140 MAX_U cl, [cs:ROMVARS.bMinFddCnt] 141 141 xor ch, ch … … 159 159 ; CH, ES 160 160 ;-------------------------------------------------------------------- 161 %ifdef USE_AT 161 162 ALIGN JUMP_ALIGN 162 163 FloppyDrive_GetCountFromBIOS: … … 176 177 pop di 177 178 ret 179 %endif 178 180 179 181 … … 190 192 ; CH, ES 191 193 ;-------------------------------------------------------------------- 194 %ifndef USE_AT 192 195 ALIGN JUMP_ALIGN 193 196 FloppyDrive_GetCountFromBDA: … … 199 202 add cl, ch ; CL = Floppy Drive count 200 203 ret 204 %endif -
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.