- Timestamp:
- Sep 18, 2011, 11:41:29 AM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
r165 r173 6 6 7 7 ; Base DPT for all device types 8 struc DPT ; 8bytes8 struc DPT ; 10 bytes 9 9 ; General Disk Parameter Table related 10 10 .wFlags: … … 12 12 .bFlagsHigh resb 1 13 13 .bIdevarsOffset resb 1 ; Offset to IDEVARS for this drive 14 15 ; L-CHS to P-CHS and L-CHS to LBA28 conversion related 16 .bLchsHeads resb 1 ; Number of L-CHS Heads (1...255) 14 resb 1 17 15 18 16 ; IDE Drive related 19 . wPchsCylinders resb 2 ; Number of P-CHS (IDE) Cylinders (1...16383)20 .w PchsHeadsAndSectors:21 .b PchsHeads resb 1 ; Number of P-CHS (IDE) Heads (1...16)22 .b PchsSectors resb 1 ; Number of P-CHS (IDE)Sectors per Track (1...63)17 .dwCylinders resb 4 ; Number of Cylinders 18 .wHeadsAndSectors: 19 .bHeads resb 1 ; Number of Heads (1...255) 20 .bSectors resb 1 ; Number of Sectors per Track (1...63) 23 21 endstruc 24 22 25 23 ; DPT for ATA devices 26 struc DPT_ATA ; 8 + 2 bytes = 10bytes24 struc DPT_ATA ; 10 + 2 bytes = 12 bytes 27 25 .dpt resb DPT_size 28 26 … … 61 59 ADDRESSING_MODE_LBA48 EQU 3 ; 48-bit LBA Addressing Mode 62 60 61 ; Number of Sectors per Track is fixed to 63 for LBA assist calculation. 62 ; 1024 cylinders, 256 heads, 63 sectors = 8.4 GB limit (but DOS does not support more than 255 heads) 63 MAX_LCHS_CYLINDERS EQU 1024 64 LBA_ASSIST_SPT EQU 63 65 63 66 64 67 %endif ; CUSTOMDPT_INC -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
r150 r173 58 58 ALIGN JUMP_ALIGN 59 59 AH8h_GetDriveParameters: 60 call AccessDPT_GetLCHS fromPCHS; AX=sectors, BX=cylinders, DX=heads60 call AccessDPT_GetLCHS ; AX=sectors, BX=cylinders, DX=heads 61 61 ; Fall to .PackReturnValues 62 62 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r170 r173 94 94 95 95 ; Initialize Logical Sectors per Track and Max Head number 96 mov ah, [di+DPT.b PchsHeads]96 mov ah, [di+DPT.bHeads] 97 97 dec ah ; Max Head number 98 mov dl, [di+DPT.b PchsSectors]; Sectors per Track98 mov dl, [di+DPT.bSectors] ; Sectors per Track 99 99 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS 100 100 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
r165 r173 83 83 ; LHead / PHeadCount and LHead % PHeadCount 84 84 eMOVZX ax, bh ; Copy L-CHS Head number to AX 85 div BYTE [di+DPT.b PchsHeads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount85 div BYTE [di+DPT.bHeads] ; AL = LHead / PHeadCount, AH = LHead % PHeadCount 86 86 mov bh, ah ; Copy P-CHS Head number to BH 87 87 xor ah, ah ; AX = LHead / PHeadCount … … 124 124 ; cylToSeek*headsPerCyl (18-bit result) 125 125 mov ax, cx ; Copy Cylinder number to AX 126 eMOVZX dx, BYTE [di+DPT.b LchsHeads]126 eMOVZX dx, BYTE [di+DPT.bHeads] 127 127 mul dx ; DX:AX = cylToSeek*headsPerCyl 128 128 … … 133 133 134 134 ; *=sectPerTrack (18-bit by 6-bit multiplication with 24-bit result) 135 eMOVZX cx, BYTE [di+DPT.bPchsSectors]; Load Sectors per Track135 mov cx, LBA_ASSIST_SPT ; Load Sectors per Track 136 136 xchg ax, dx ; Hiword to AX, loword to DX 137 137 mul cl ; AX = hiword * Sectors per Track -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r169 r173 5 5 ; Section containing code 6 6 SECTION .text 7 8 ;-------------------------------------------------------------------- 9 ; LBA assist calculation: 10 ; this is how to fit a big drive into INT13's skimpy size requirements, 11 ; with a maximum of 8.4G available. 12 ; 13 ; total LBAs (as obtained by words 60+61) 14 ; divided by 63 (sectors per track) (save as value A) 15 ; Sub 1 from A 16 ; divide A by 1024 + truncate. 17 ; == total number of heads to use. 18 ; add 1 19 ; this value must be either 16, 32, 64, 128, or 256 (round up) 20 ; then take the value A above and divide by # of heads 21 ; to get the # of cylinders to use. 22 ; 23 ; 24 ; so a LBA28 drive will have 268,435,456 as maximum LBAs 25 ; 26 ; 10000000h / 63 = 410410h (total cylinders or tracks) 27 ; 410410h / 1024 = 1041h, which is way more than 256 heads, but 256 is max. 28 ; 410410h / 256 = 4104h cylinders 29 ; 30 ; there's a wealth of information at: http://www.mossywell.com/boot-sequence 31 ; they show a slightly different approach to LBA assist calulations, but 32 ; the method here provides compatibility with phoenix BIOS 33 ; 34 ; we're using the values from 60+61 here because we're topping out at 8.4G 35 ; anyway, so there's no need to use the 48bit LBA values. 36 ; 37 ; AtaID_GetLbaAssistedCHStoAXBLBH: 38 ; Parameters: 39 ; BX:DX:AX: Total number of sectors 40 ; Returns: 41 ; DX:AX: Number of cylinders 42 ; BH: Number of sectors per track (always 63) 43 ; BL: Number of heads (16, 32, 64, 128 or 255) 44 ; Corrupts registers: 45 ; CX 46 ;-------------------------------------------------------------------- 47 AtaID_GetLbaAssistedCHStoDXAXBLBH: 48 push bp 49 push si 50 51 ; Value A = Total sector count / 63 52 xor cx, cx 53 push cx ; Push zero for bits 48...63 54 push bx 55 push dx 56 push ax ; 64-bit sector count now in stack 57 mov cl, LBA_ASSIST_SPT 58 mov bp, sp ; SS:BP now points sector count 59 call Math_DivQWatSSBPbyCX ; Temporary value A now in stack 60 61 ; BX = Number of heads = A / 1024 62 mov ax, [bp] 63 mov dx, [bp+2] 64 mov bx, [bp+4] 65 call Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX 66 67 ; Heads must be 16, 32, 64, 128 or 256 (round up) 68 mov bx, 256 ; Max number of heads 69 test dx, dx ; 65536 or more heads? 70 jnz SHORT .GetNumberOfCylinders 71 mov cx, 128 ; Half BX for rounding up 72 .FindMostSignificantBitForHeadSize: 73 cmp ax, cx 74 jae SHORT .GetNumberOfCylinders 75 shr cx, 1 76 shr bx, 1 ; Halve number of heads 77 jmp SHORT .FindMostSignificantBitForHeadSize 78 79 ; DX:AX = Number of cylinders = A / number of heads 80 .GetNumberOfCylinders: 81 mov cx, bx 82 call Math_DivQWatSSBPbyCX 83 mov ax, [bp] 84 mov dx, [bp+2] ; Cylinders now in DX:AX 85 86 ; Return LBA assisted CHS 87 add sp, BYTE 8 ; Clean stack 88 sub bl, bh ; Limit heads to 255 89 mov bh, LBA_ASSIST_SPT 90 pop si 91 pop bp 92 ret 93 7 94 8 95 ;-------------------------------------------------------------------- … … 34 121 ;-------------------------------------------------------------------- 35 122 AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI: 36 push ds 37 38 push es 39 pop ds 123 call Registers_ExchangeDSSIwithESDI ; ATA info now in DSDI 40 124 xor bx, bx 41 test WORD [si+ATA1.wCaps], A1_wCaps_LBA125 test BYTE [di+ATA1.wCaps+1], A1_wCaps_LBA>>8 42 126 jz SHORT .GetChsSectorCount 43 127 ; Fall to .GetLbaSectorCount … … 45 129 ;-------------------------------------------------------------------- 46 130 ; .GetLbaSectorCount 131 ; .GetLba28SectorCount 132 ; .GetChsSectorCount 47 133 ; Parameters: 48 134 ; BX: Zero … … 54 140 ;-------------------------------------------------------------------- 55 141 .GetLbaSectorCount: 56 test WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48142 test BYTE [di+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8 57 143 jz SHORT .GetLba28SectorCount 58 mov ax, [ si+ATA6.qwLBACnt]59 mov dx, [ si+ATA6.qwLBACnt+2]60 mov bx, [ si+ATA6.qwLBACnt+4]61 pop ds62 ret 144 mov ax, [di+ATA6.qwLBACnt] 145 mov dx, [di+ATA6.qwLBACnt+2] 146 mov bx, [di+ATA6.qwLBACnt+4] 147 jmp SHORT .ExchangePtrAndReturn 148 63 149 .GetLba28SectorCount: 64 mov ax, [si+ATA1.dwLBACnt] 65 mov dx, [si+ATA1.dwLBACnt+2] 66 pop ds 67 ret 150 mov ax, [di+ATA1.dwLBACnt] 151 mov dx, [di+ATA1.dwLBACnt+2] 152 jmp SHORT .ExchangePtrAndReturn 68 153 69 ;--------------------------------------------------------------------70 ; .GetChsSectorCount71 ; Parameters:72 ; DS:SI: Ptr to 512-byte ATA information read from the drive73 ; Returns:74 ; DX:AX: 24-bit sector count75 ; Corrupts registers:76 ; Nothing77 ;--------------------------------------------------------------------78 154 .GetChsSectorCount: 79 mov al, [ si+ATA1.wSPT] ; AL=Sectors per track80 mul BYTE [ si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads81 mul WORD [ si+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders82 pop ds 83 ret155 mov al, [di+ATA1.wSPT] ; AL=Sectors per track 156 mul BYTE [di+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads 157 mul WORD [di+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders 158 .ExchangePtrAndReturn: 159 jmp Registers_ExchangeDSSIwithESDI -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
r161 r173 59 59 60 60 ;-------------------------------------------------------------------- 61 ; AccessDPT_GetLCHS fromPCHS61 ; AccessDPT_GetLCHS 62 62 ; Parameters: 63 63 ; DS:DI: Ptr to Disk Parameter Table … … 67 67 ; DX: Number of L-CHS heads 68 68 ; Corrupts registers: 69 ; CX 70 ;-------------------------------------------------------------------- 71 AccessDPT_GetLCHS: 72 ; Load CHS from DPT 73 eMOVZX ax, BYTE [di+DPT.bSectors] 74 mov bx, [di+DPT.dwCylinders] 75 cwd 76 mov dl, [di+DPT.bHeads] 77 78 ; Only need to limit sectors for LBA assist 79 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA 80 jnz SHORT .ReturnLbaAssistedLCHS 81 82 ; P-CHS to L-CHS translation when necessary 83 jmp SHORT AccessDPT_ShiftPCHinBXDXtoLCH 84 85 .ReturnLbaAssistedLCHS: 86 cmp WORD [di+DPT.dwCylinders+2], BYTE 0 87 jz SHORT .LimitCylindersTo1024 88 mov bx, MAX_LCHS_CYLINDERS 89 .LimitCylindersTo1024: 90 MIN_U bx, MAX_LCHS_CYLINDERS 91 ret 92 93 94 ;-------------------------------------------------------------------- 95 ; AccessDPT_ShiftPCHinBXDXtoLCH 96 ; Parameters: 97 ; BX: P-CHS cylinders (1...16383) 98 ; DX: P-CHS heads (1...16) 99 ; Returns: 100 ; BX: Number of L-CHS cylinders (1...1024) 101 ; DX: Number of L-CHS heads (1...255) 102 ; CX: Number of bits shifted 103 ; Corrupts registers: 69 104 ; Nothing 70 105 ;-------------------------------------------------------------------- 71 ALIGN JUMP_ALIGN 72 AccessDPT_GetLCHSfromPCHS: 73 mov al, [di+DPT.bFlagsLow] 74 and al, MASKL_DPT_CHS_SHIFT_COUNT ; Load shift count 75 xchg cx, ax 76 mov bx, [di+DPT.wPchsCylinders] ; Load P-CHS cylinders 77 shr bx, cl ; Shift to L-CHS cylinders 78 xchg cx, ax 79 eMOVZX ax, BYTE [di+DPT.bPchsSectors] ; Load Sectors per track 80 cwd 81 mov dl, [di+DPT.bLchsHeads] ; Load L-CHS heads 106 AccessDPT_ShiftPCHinBXDXtoLCH: 107 xor cx, cx 108 .ShiftLoop: 109 cmp bx, MAX_LCHS_CYLINDERS ; Need to shift? 110 jbe SHORT .LimitHeadsTo255 ; If not, return 111 inc cx ; Increment shift count 112 shr bx, 1 ; Halve cylinders 113 shl dx, 1 ; Double heads 114 jmp SHORT .ShiftLoop 115 .LimitHeadsTo255: ; DOS does not support drives with 256 heads 116 sub dl, dh ; BH set only when 256 logical heads 117 xor dh, dh 82 118 ret 83 119 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r169 r173 63 63 .StoreFlags: 64 64 mov [di+DPT.wFlags], ax 65 ; Fall to .Store PCHS66 67 ;-------------------------------------------------------------------- 68 ; .Store PCHS69 ; Parameters: 70 ; BH: Drive Select byte for Drive and Head Register71 ; DS:DI: Ptr to Disk Parameter Table72 ; ES:SI: Ptr to 512-byte ATA information read from the drive73 ; CS:BP: Ptr to IDEVARS for the controller74 ; Returns:75 ; AX: P-CHS cylinders76 ; BL: P-CHSheads77 ; BH: P-CHS sectors78 ; Corrupts registers:79 ; Nothing80 ;-------------------------------------------------------------------- 81 .StorePCHS: 65 ; Fall to .StoreAddressing 66 67 ;-------------------------------------------------------------------- 68 ; .StoreAddressing 69 ; Parameters: 70 ; DS:DI: Ptr to Disk Parameter Table 71 ; ES:SI: Ptr to 512-byte ATA information read from the drive 72 ; CS:BP: Ptr to IDEVARS for the controller 73 ; Returns: 74 ; DX:AX or AX: Number of cylinders 75 ; BH: Number of sectors per track 76 ; BL: Number of heads 77 ; Corrupts registers: 78 ; CX, (DX) 79 ;-------------------------------------------------------------------- 80 .StoreAddressing: 81 ; Check if CHS defined in ROMVARS 82 82 mov al, FLG_DRVPARAMS_USERCHS ; User specified CHS? 83 83 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 84 jnz SHORT .GetUserSpecifiedPCHS 84 jnz SHORT .StoreUserDefinedCHSaddressing 85 86 ; Check if LBA supported 85 87 call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI 86 jmp SHORT .StorePCHStoDPT 87 88 .GetUserSpecifiedPCHS: 88 test BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8 89 jz SHORT .StoreCHSaddressing 90 91 ; Check if 48-bit LBA supported 92 test BYTE [es:si+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8 93 jz SHORT .StoreLBA28addressing 94 or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION 95 .StoreLBA28addressing: 96 or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION 97 call AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI 98 call AtaID_GetLbaAssistedCHStoDXAXBLBH 99 jmp SHORT .StoreChsFromDXAXBX 100 101 ; Check if P-CHS to L-CHS translation required 102 .StoreUserDefinedCHSaddressing: 89 103 call AccessDPT_GetPointerToDRVPARAMStoCSBX 90 104 mov ax, [cs:bx+DRVPARAMS.wCylinders] 91 105 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 92 93 .StorePCHStoDPT: 94 mov [di+DPT.wPchsCylinders], ax 95 mov [di+DPT.wPchsHeadsAndSectors], bx 96 ; Fall to .StoreLCHS 97 98 ;-------------------------------------------------------------------- 99 ; .StoreLCHS 100 ; Parameters: 101 ; AX: P-CHS cylinders 102 ; BL: P-CHS heads 103 ; DS:DI: Ptr to Disk Parameter Table 104 ; ES:SI: Ptr to 512-byte ATA information read from the drive 105 ; CS:BP: Ptr to IDEVARS for the controller 106 ; Returns: 107 ; Nothing 108 ; Corrupts registers: 109 ; AX, BX, CX 110 ;-------------------------------------------------------------------- 111 .StoreLCHS: 112 xor bh, bh ; BX = P-CHS Heads (1...16) 113 xor cx, cx 114 .ShiftLoop: 115 cmp ax, 1024 ; Need to shift? 116 jbe SHORT .LimitHeadsTo255 ; If not, return 117 inc cx ; Increment shift count 118 shr ax, 1 ; Halve cylinders 119 shl bx, 1 ; Double heads 120 jmp SHORT .ShiftLoop 121 122 .LimitHeadsTo255: ; DOS does not support drives with 256 heads 123 rcr bh, 1 ; Set CF if 256 heads 124 sbb bl, 0 ; Decrement to 255 if 256 heads 125 or [di+DPT.wFlags], cl 126 mov [di+DPT.bLchsHeads], bl 127 ; Fall to .StoreAddressing 128 129 ;-------------------------------------------------------------------- 130 ; .StoreAddressing 131 ; Parameters: 132 ; DS:DI: Ptr to Disk Parameter Table 133 ; ES:SI: Ptr to 512-byte ATA information read from the drive 134 ; CS:BP: Ptr to IDEVARS for the controller 135 ; Returns: 136 ; Nothing 137 ; Corrupts registers: 138 ; AX, BX 139 ;-------------------------------------------------------------------- 140 .StoreAddressing: 141 ; Check if L-CHS addressing should be used 142 cmp WORD [di+DPT.wPchsCylinders], 1024 ; L-CHS possible? (no translation needed) 143 jbe SHORT .StoreBlockMode ; If so, nothing needs to be changed 144 145 ; Check if P-CHS addressing should be used 146 mov al, FLG_DRVPARAMS_USERCHS ; User specified CHS? 147 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 148 jnz SHORT .StorePCHSaddressing 149 test WORD [es:si+ATA1.wCaps], A2_wCaps_LBA 150 jz SHORT .StorePCHSaddressing ; Use P-CHS since LBA not supported 151 152 ; LBA needs to be used. Check if 48-bit LBA is supported 153 test WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48 154 jz SHORT .StoreLBA28addressing ; Use LBA-28 since LBA-48 not supported 155 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION 156 .StoreLBA28addressing: 157 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION 158 jmp SHORT .StoreBlockMode 159 .StorePCHSaddressing: 160 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION 106 .StoreCHSaddressing: 107 cmp ax, MAX_LCHS_CYLINDERS 108 jbe SHORT .StoreChsFromAXBX ; No translation required 109 110 ; We need to get number of bits to shift for translation 111 push bx 112 push ax 113 eMOVZX dx, bl ; Heads now in DX 114 xchg bx, ax ; Sectors now in BX 115 call AccessDPT_ShiftPCHinBXDXtoLCH 116 or cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION 117 or [di+DPT.bFlagsLow], cl ; Store bits to shift 118 pop ax 119 pop bx 120 ; Fall to .StoreChsFromAXBX 121 122 ;-------------------------------------------------------------------- 123 ; .StoreChsFromAXBX 124 ; .StoreChsFromDXAXBX 125 ; Parameters: 126 ; DX:AX or AX: Number of cylinders 127 ; BH: Number of sectors per track 128 ; BL: Number of heads 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 ; DX 136 ;-------------------------------------------------------------------- 137 .StoreChsFromAXBX: 138 xor dx, dx 139 .StoreChsFromDXAXBX: 140 mov [di+DPT.dwCylinders], ax 141 mov [di+DPT.dwCylinders+2], dx 142 mov [di+DPT.wHeadsAndSectors], bx 161 143 ; Fall to .StoreBlockMode 162 144
Note:
See TracChangeset
for help on using the changeset viewer.