Changeset 227 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Timestamp:
- Jan 29, 2012, 1:33:44 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
r200 r227 40 40 ret 41 41 42 42 43 43 ;-------------------------------------------------------------------- 44 ; AccessDPT_GetLCHS 44 ; AccessDPT_GetLCHStoAXBLBH 45 45 ; Parameters: 46 46 ; DS:DI: Ptr to Disk Parameter Table 47 47 ; Returns: 48 ; AX: Number of L-CHS sectors per track49 ; B X: Number of L-CHS cylinders50 ; DX: Number of L-CHS heads48 ; AX: Number of L-CHS cylinders 49 ; BL: Number of L-CHS heads 50 ; BH: Number of L-CHS sectors per track 51 51 ; Corrupts registers: 52 ; CX 52 ; CX, DX 53 53 ;-------------------------------------------------------------------- 54 AccessDPT_GetLCHS: 55 ; Load CHS from DPT 56 eMOVZX ax, BYTE [di+DPT.bSectors] 57 mov bx, [di+DPT.dwCylinders] 58 cwd 59 mov dl, [di+DPT.bHeads] 54 AccessDPT_GetLCHStoAXBLBH: 55 ; Return LBA-assisted CHS if LBA addressing used 56 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA 57 jz SHORT .ConvertPchsToLchs 60 58 61 ; Only need to limit sectors for LBA assist 62 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA 63 jz SHORT AccessDPT_ShiftPCHinBXDXtoLCH 59 call AccessDPT_GetLbaSectorCountToBXDXAX 60 call AtaID_GetLbaAssistedCHStoDXAXBLBH 61 test dx, dx 62 jnz SHORT .LimitAXtoMaxLCHScylinders 63 cmp ax, MAX_LCHS_CYLINDERS 64 jbe SHORT .returnLCHS 65 .LimitAXtoMaxLCHScylinders: 66 mov ax, MAX_LCHS_CYLINDERS 67 .returnLCHS: 68 ret 64 69 65 cmp WORD [di+DPT.dwCylinders+2], BYTE 0 66 jnz SHORT .Return_MAX_LCHS_CYLINDERS 70 .ConvertPchsToLchs: 71 mov ax, [di+DPT.wPchsCylinders] 72 mov bx, [di+DPT.wPchsHeadsAndSectors] 73 jmp SHORT AccessDPT_ShiftPCHinAXBLtoLCH 67 74 68 ; Limit cylinders to 1024 69 cmp bx, MAX_LCHS_CYLINDERS 70 jb SHORT .Return 71 ALIGN JUMP_ALIGN 72 .Return_MAX_LCHS_CYLINDERS: 73 mov bx, MAX_LCHS_CYLINDERS 74 ALIGN JUMP_ALIGN, ret 75 .Return: 75 76 ;-------------------------------------------------------------------- 77 ; AccessDPT_GetLbaSectorCountToBXDXAX 78 ; Parameters: 79 ; DS:DI: Ptr to Disk Parameter Table 80 ; Returns: 81 ; BX:DX:AX: 48-bit sector count 82 ; Corrupts registers: 83 ; Nothing 84 ;-------------------------------------------------------------------- 85 AccessDPT_GetLbaSectorCountToBXDXAX: 86 mov ax, [di+DPT.twLbaSectors] 87 mov dx, [di+DPT.twLbaSectors+2] 88 mov bx, [di+DPT.twLbaSectors+4] 76 89 ret 77 90 78 91 79 92 ;-------------------------------------------------------------------- 80 ; AccessDPT_ShiftPCHin BXDXtoLCH93 ; AccessDPT_ShiftPCHinAXBLtoLCH 81 94 ; Parameters: 82 ; BX: P-CHS cylinders (1...16383)83 ; DX: P-CHS heads (1...16)95 ; AX: P-CHS cylinders (1...16383) 96 ; BL: P-CHS heads (1...16) 84 97 ; Returns: 85 ; BX: Number of L-CHS cylinders (1...1024)86 ; DX: Number of L-CHS heads (1...255)98 ; AX: Number of L-CHS cylinders (1...1024) 99 ; BL: Number of L-CHS heads (1...255) 87 100 ; CX: Number of bits shifted 88 101 ; Corrupts registers: 89 102 ; Nothing 90 103 ;-------------------------------------------------------------------- 91 AccessDPT_ShiftPCHin BXDXtoLCH:104 AccessDPT_ShiftPCHinAXBLtoLCH: 92 105 xor cx, cx 93 106 .ShiftLoop: 94 cmp bx, MAX_LCHS_CYLINDERS ; Need to shift?107 cmp ax, MAX_LCHS_CYLINDERS ; Need to shift? 95 108 jbe SHORT .LimitHeadsTo255 ; If not, return 96 109 inc cx ; Increment shift count 97 shr bx, 1 ; Halve cylinders98 shl dx, 1 ; Double heads110 shr ax, 1 ; Halve cylinders 111 shl bl, 1 ; Double heads 99 112 jmp SHORT .ShiftLoop 100 113 .LimitHeadsTo255: ; DOS does not support drives with 256 heads 101 sub dl, dh ; DH set only when 256 logical heads102 xor dh, dh114 cmp bl, cl ; Set CF if BL is zero 115 sbb bl, ch ; If BL=0 then BL=255 103 116 ret 104 117 105 118 106 119 ;-------------------------------------------------------------------- 107 120 ; Returns pointer to DRVPARAMS for master or slave drive. … … 144 157 and al, MASKL_DPT_ADDRESSING_MODE 145 158 %endmacro 146 147 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r193 r227 78 78 ; CS:BP: Ptr to IDEVARS for the controller 79 79 ; Returns: 80 ; DX:AX or AX: Number of cylinders 81 ; BH: Number of sectors per track 82 ; BL: Number of heads 83 ; Corrupts registers: 84 ; CX, (DX) 80 ; Nothing 81 ; Corrupts registers: 82 ; AX, BX, CX, DX 85 83 ;-------------------------------------------------------------------- 86 84 .StoreAddressing: … … 88 86 call AccessDPT_GetPointerToDRVPARAMStoCSBX 89 87 test byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS ; User specified CHS? 90 jnz SHORT .StoreUserDefined CHSaddressing88 jnz SHORT .StoreUserDefinedPCHS 91 89 92 90 ; Check if LBA supported 93 91 call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI 94 92 test BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8 95 jz SHORT .StoreCHS addressing93 jz SHORT .StoreCHSfromAXBHBL ; Small old drive with CHS addressing only 96 94 97 95 ; Check if 48-bit LBA supported … … 102 100 or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION 103 101 call AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI 102 mov [di+DPT.twLbaSectors], ax 103 mov [di+DPT.twLbaSectors+2], dx 104 mov [di+DPT.twLbaSectors+4], bx 104 105 call AtaID_GetLbaAssistedCHStoDXAXBLBH 105 jmp SHORT .StoreChsFromDXAXBX 106 107 ; Check if P-CHS to L-CHS translation required 108 .StoreUserDefinedCHSaddressing: 106 mov [di+DPT.bLbaHeads], bl 107 jmp SHORT .StoreBlockMode 108 109 ;-------------------------------------------------------------------- 110 ; .StoreUserDefinedPCHS 111 ; Parameters: 112 ; DS:DI: Ptr to Disk Parameter Table 113 ; ES:SI: Ptr to 512-byte ATA information read from the drive 114 ; CS:BP: Ptr to IDEVARS for the controller 115 ; Returns: 116 ; AX: Number of P-CHS cylinders 117 ; BH: Number of P-CHS sectors per track 118 ; BL: Number of P-CHS heads 119 ; Corrupts registers: 120 ; Nothing 121 ;-------------------------------------------------------------------- 122 .StoreUserDefinedPCHS: 109 123 call AccessDPT_GetPointerToDRVPARAMStoCSBX 110 124 mov ax, [cs:bx+DRVPARAMS.wCylinders] 111 125 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 112 .StoreCHSaddressing: 113 cmp ax, MAX_LCHS_CYLINDERS 114 jbe SHORT .StoreChsFromAXBX ; No translation required 115 116 ; We need to get number of bits to shift for translation 126 ; Fall to .StoreCHSfromAXBHBL 127 128 ;-------------------------------------------------------------------- 129 ; .StoreCHSfromAXBHBL 130 ; Parameters: 131 ; AX: Number of P-CHS cylinders 132 ; BH: Number of P-CHS sectors per track 133 ; BL: Number of P-CHS heads 134 ; DS:DI: Ptr to Disk Parameter Table 135 ; ES:SI: Ptr to 512-byte ATA information read from the drive 136 ; CS:BP: Ptr to IDEVARS for the controller 137 ; Returns: 138 ; AX: Number of P-CHS cylinders 139 ; BH: Number of P-CHS sectors per track 140 ; BL: Number of P-CHS heads 141 ; Corrupts registers: 142 ; CX 143 ;-------------------------------------------------------------------- 144 .StoreCHSfromAXBHBL: 117 145 push ax 118 eMOVZX dx, bl ; Heads now in DX 119 xchg bx, ax ; Cylinders now in BX 120 call AccessDPT_ShiftPCHinBXDXtoLCH ; Leaves AX untouched 121 xchg bx, ax ; Restore HeadsAndSectors to BX 146 push bx 147 call AccessDPT_ShiftPCHinAXBLtoLCH ; Get number of bits to shift 148 pop bx 149 pop ax 150 jcxz .StorePCHSfromAXDX ; Small drive so use L-CHS addressing 151 152 ; Store P-CHS addressing mode and number of bits to shift in L-CHS to P-CHS translation 122 153 or cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION 123 or [di+DPT.bFlagsLow], cl ; Store bits to shift 124 pop ax 125 ; Fall to .StoreChsFromAXBX 126 127 ;-------------------------------------------------------------------- 128 ; .StoreChsFromAXBX 129 ; .StoreChsFromDXAXBX 130 ; Parameters: 131 ; DX:AX or AX: Number of cylinders 132 ; BH: Number of sectors per track 133 ; BL: Number of heads 134 ; DS:DI: Ptr to Disk Parameter Table 135 ; ES:SI: Ptr to 512-byte ATA information read from the drive 136 ; CS:BP: Ptr to IDEVARS for the controller 137 ; Returns: 138 ; Nothing 139 ; Corrupts registers: 140 ; DX 141 ;-------------------------------------------------------------------- 142 .StoreChsFromAXBX: 143 xor dx, dx 144 .StoreChsFromDXAXBX: 145 mov [di+DPT.dwCylinders], ax 146 mov [di+DPT.dwCylinders+2], dx 147 mov [di+DPT.wHeadsAndSectors], bx 154 or [di+DPT.bFlagsLow], cl 155 ; Fall to .StoreChsFromAXBLBH 156 157 ;-------------------------------------------------------------------- 158 ; .StoreChsFromAXBLBH 159 ; Parameters: 160 ; AX: Number of P-CHS cylinders 161 ; BH: Number of P-CHS sectors per track 162 ; BL: Number of P-CHS heads 163 ; DS:DI: Ptr to Disk Parameter Table 164 ; ES:SI: Ptr to 512-byte ATA information read from the drive 165 ; CS:BP: Ptr to IDEVARS for the controller 166 ; Returns: 167 ; Nothing 168 ; Corrupts registers: 169 ; Nothing 170 ;-------------------------------------------------------------------- 171 .StorePCHSfromAXDX: 172 mov [di+DPT.wPchsCylinders], ax 173 mov [di+DPT.wPchsHeadsAndSectors], bx 148 174 ; Fall to .StoreBlockMode 149 175
Note:
See TracChangeset
for help on using the changeset viewer.