Changeset 441 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Initialization
- Timestamp:
- Aug 19, 2012, 10:58:42 AM (12 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Initialization
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r421 r441 22 22 SECTION .text 23 23 24 ;-------------------------------------------------------------------- 25 ; AtaID_VerifyFromESSI 26 ; Parameters: 27 ; ES:SI: Ptr to 512-byte ATA information read from the drive 28 ; Returns: 29 ; CF: Set if failed to verify ATA-ID 30 ; Cleared if ATA-ID verified succesfully 31 ; Corrupts registers: 32 ; AX, BX, CX 33 ;-------------------------------------------------------------------- 34 AtaID_VerifyFromESSI: 35 ; We cannot start by reading ATA version since the ID might be 36 ; corrupted. We start by making sure P-CHS values are valid. 37 ; If they are, we assume the ATA ID to be valid. Fortunately we can do 38 ; futher checking for ATA-5 and later since they contain signature and 39 ; checksum bytes. Those are not available for ATA-4 and older. 40 41 ; Verify P-CHS cylinders 42 mov bx, ATA1.wCylCnt 43 mov cx, MAX_VALID_PCHS_CYLINDERS 44 call .CompareCHorSfromOffsetBXtoMaxValueInCX 45 46 add bx, BYTE ATA1.wHeadCnt - ATA1.wCylCnt 47 mov cl, MAX_VALID_PCHS_HEADS 48 call .CompareCHorSfromOffsetBXtoMaxValueInCX 49 50 add bx, BYTE ATA1.wSPT - ATA1.wHeadCnt 51 mov cl, MAX_VALID_PCHS_SECTORS_PER_TRACK 52 call .CompareCHorSfromOffsetBXtoMaxValueInCX 53 54 ; We now verified P-CHS parameters so we assume ATA ID to be valid 55 ; for ATA-4 and older. For ATA-5 and later we check signature 56 ; and checksum. 57 mov ax, [es:si+ATA6.wMajorVer] ; ATA-3 and later have this word 58 inc ax 59 jz SHORT .AtaIDverifiedSuccessfully ; FFFFh means no version info available 60 dec ax 61 jz SHORT .AtaIDverifiedSuccessfully ; Zero means no version info available 62 cmp ax, A6_wMajorVer_ATA5 63 jb SHORT .AtaIDverifiedSuccessfully ; ATA-3 and ATA-4 do not have checksum 64 65 ; Check signature byte 66 cmp BYTE [es:si+ATA6.bSignature], A6_wIntegrity_SIGNATURE 67 jne SHORT .FailedToVerifyAtaID 68 69 ; Check checksum byte 70 mov cx, ATA6_size 71 call Memory_SumCXbytesFromESSItoAL 72 test al, al 73 jnz SHORT .FailedToVerifyAtaID 74 75 ; ATA-ID is now verified to be valid 76 .AtaIDverifiedSuccessfully: 77 clc 78 ret 79 80 ;-------------------------------------------------------------------- 81 ; .CompareCHorSfromOffsetBXtoMaxValueInCX 82 ; Parameters: 83 ; BX: C, H or S offset to ATA-ID 84 ; CX: Maximum valid C, H or S value 85 ; ES:SI: Ptr to 512-byte ATA information read from the drive 86 ; Returns: 87 ; Exits from AtaID_VerifyFromESSI with CF set if invalid value 88 ; Corrupts registers: 89 ; AX 90 ;-------------------------------------------------------------------- 91 .CompareCHorSfromOffsetBXtoMaxValueInCX: 92 mov ax, [es:bx+si] 93 test ax, ax 94 jz SHORT .InvalidPCHorSinOffsetBX 95 cmp ax, cx ; Compare to max valid value 96 jbe SHORT .ValidPCHorSinOffsetBX 97 .InvalidPCHorSinOffsetBX: 98 add sp, 2 ; Clear return address for this function 99 .FailedToVerifyAtaID: 100 stc ; Set carry to indicate invalid ATA-ID 101 .ValidPCHorSinOffsetBX: 102 ret 103 104 24 105 %ifdef MODULE_ADVANCED_ATA 25 106 ;-------------------------------------------------------------------- -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
r397 r441 218 218 ;-------------------------------------------------------------------- 219 219 CreateBiosTablesForHardDisk: 220 push bx 221 call AtaID_VerifyFromESSI 222 pop bx 223 jc SHORT DetectDrives_DriveNotFound 220 224 call CreateDPT_FromAtaInformation 221 225 jc SHORT DetectDrives_DriveNotFound
Note:
See TracChangeset
for help on using the changeset viewer.