[150] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for detecting drive for the BIOS. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; Detects all IDE hard disks to be controlled by this BIOS. |
---|
| 9 | ; |
---|
| 10 | ; DetectDrives_FromAllIDEControllers |
---|
| 11 | ; Parameters: |
---|
| 12 | ; DS: RAMVARS segment |
---|
| 13 | ; ES: BDA segment (zero) |
---|
| 14 | ; Returns: |
---|
| 15 | ; Nothing |
---|
| 16 | ; Corrupts registers: |
---|
| 17 | ; All (not segments) |
---|
| 18 | ;-------------------------------------------------------------------- |
---|
| 19 | DetectDrives_FromAllIDEControllers: |
---|
[33] | 20 | call RamVars_GetIdeControllerCountToCX |
---|
[3] | 21 | mov bp, ROMVARS.ideVars0 ; CS:BP now points to first IDEVARS |
---|
| 22 | .DriveDetectLoop: |
---|
[196] | 23 | mov si, g_szDetect |
---|
| 24 | %ifdef MODULE_SERIAL |
---|
| 25 | cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT |
---|
| 26 | jnz .DriveNotSerial |
---|
| 27 | mov si, g_szDetectCOM |
---|
| 28 | .DriveNotSerial: |
---|
| 29 | %endif |
---|
[175] | 30 | call .DetectDrives_WithIDEVARS ; Detect Master and Slave |
---|
[3] | 31 | add bp, BYTE IDEVARS_size ; Point to next IDEVARS |
---|
| 32 | loop .DriveDetectLoop |
---|
[175] | 33 | %ifdef MODULE_SERIAL |
---|
[199] | 34 | mov al,[cs:ROMVARS.wFlags] |
---|
| 35 | or al,[es:BDA.bKBFlgs1] |
---|
| 36 | and al,8 ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT |
---|
| 37 | jz .done |
---|
[179] | 38 | mov bp, ROMVARS.ideVarsSerialAuto |
---|
[196] | 39 | mov si, g_szDetectCOMAuto |
---|
[199] | 40 | ;;; fall-through |
---|
[175] | 41 | %else |
---|
[3] | 42 | ret |
---|
[175] | 43 | %endif |
---|
[3] | 44 | |
---|
[199] | 45 | %if FLG_ROMVARS_SERIAL_SCANDETECT != 8 |
---|
| 46 | %error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_ALWAYSDETECT is the same bit as the ALT key code in the BDA. Changes in the code will be needed if these values are no longer the same." |
---|
| 47 | %endif |
---|
| 48 | |
---|
[3] | 49 | ;-------------------------------------------------------------------- |
---|
| 50 | ; Detects IDE hard disks by using information from IDEVARS. |
---|
| 51 | ; |
---|
| 52 | ; DetectDrives_WithIDEVARS |
---|
| 53 | ; Parameters: |
---|
| 54 | ; CS:BP: Ptr to IDEVARS |
---|
| 55 | ; DS: RAMVARS segment |
---|
| 56 | ; ES: Zero (BDA segment) |
---|
[189] | 57 | ; SI: Ptr to template string |
---|
[3] | 58 | ; Returns: |
---|
| 59 | ; Nothing |
---|
| 60 | ; Corrupts registers: |
---|
| 61 | ; AX, BX, DX, SI, DI |
---|
| 62 | ;-------------------------------------------------------------------- |
---|
[175] | 63 | .DetectDrives_WithIDEVARS: |
---|
[3] | 64 | push cx |
---|
[196] | 65 | |
---|
| 66 | push si |
---|
[97] | 67 | mov ax, g_szMaster |
---|
[150] | 68 | mov bh, MASK_DRVNHEAD_SET ; Select Master drive |
---|
[98] | 69 | call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO |
---|
[189] | 70 | pop si |
---|
[196] | 71 | |
---|
[97] | 72 | mov ax, g_szSlave |
---|
[150] | 73 | mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV |
---|
[98] | 74 | call StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
[3] | 75 | pop cx |
---|
[175] | 76 | .done: |
---|
[3] | 77 | ret |
---|
| 78 | |
---|
[175] | 79 | |
---|
[3] | 80 | ;-------------------------------------------------------------------- |
---|
[98] | 81 | ; StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
[3] | 82 | ; Parameters: |
---|
[98] | 83 | ; AX: Offset to "Master" or "Slave" string |
---|
[3] | 84 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 85 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
| 86 | ; DS: RAMVARS segment |
---|
| 87 | ; ES: Zero (BDA segment) |
---|
| 88 | ; Returns: |
---|
[98] | 89 | ; Nothing |
---|
[3] | 90 | ; Corrupts registers: |
---|
[98] | 91 | ; AX, BX, CX, DX, SI, DI |
---|
[3] | 92 | ;-------------------------------------------------------------------- |
---|
[98] | 93 | StartDetectionWithDriveSelectByteInBHandStringInAX: |
---|
| 94 | call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP |
---|
[120] | 95 | ; Fall to .ReadAtaInfoFromHardDisk |
---|
[3] | 96 | |
---|
| 97 | ;-------------------------------------------------------------------- |
---|
[120] | 98 | ; .ReadAtaInfoFromHardDisk |
---|
[3] | 99 | ; Parameters: |
---|
| 100 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 101 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
| 102 | ; DS: RAMVARS segment |
---|
| 103 | ; ES: Zero (BDA segment) |
---|
| 104 | ; Returns: |
---|
| 105 | ; CF: Cleared if ATA-information read successfully |
---|
| 106 | ; Set if any error |
---|
| 107 | ; Corrupts registers: |
---|
[150] | 108 | ; AX, BL, CX, DX, SI, DI |
---|
[3] | 109 | ;-------------------------------------------------------------------- |
---|
[120] | 110 | .ReadAtaInfoFromHardDisk: |
---|
[150] | 111 | mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location |
---|
| 112 | push es |
---|
| 113 | push si |
---|
| 114 | push bx |
---|
| 115 | call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH |
---|
| 116 | pop bx |
---|
| 117 | pop si |
---|
| 118 | pop es |
---|
[120] | 119 | jnc SHORT CreateBiosTablesForHardDisk |
---|
| 120 | ; Fall to .ReadAtapiInfoFromDrive |
---|
[3] | 121 | |
---|
[120] | 122 | .ReadAtapiInfoFromDrive: ; Not yet implemented |
---|
| 123 | ;call ReadAtapiInfoFromDrive ; Assume CD-ROM |
---|
| 124 | ;jnc SHORT _CreateBiosTablesForCDROM |
---|
[196] | 125 | jmp short DetectDrives_DriveNotFound |
---|
[3] | 126 | |
---|
[120] | 127 | |
---|
[3] | 128 | ;-------------------------------------------------------------------- |
---|
[98] | 129 | ; CreateBiosTablesForHardDisk |
---|
[3] | 130 | ; Parameters: |
---|
| 131 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 132 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
[150] | 133 | ; ES:SI Ptr to ATA information for the drive |
---|
[3] | 134 | ; DS: RAMVARS segment |
---|
[98] | 135 | ; ES: BDA/Bootnfo segment |
---|
[3] | 136 | ; Returns: |
---|
[98] | 137 | ; Nothing |
---|
[3] | 138 | ; Corrupts registers: |
---|
[98] | 139 | ; AX, BX, CX, DX, SI, DI |
---|
[3] | 140 | ;-------------------------------------------------------------------- |
---|
[98] | 141 | CreateBiosTablesForHardDisk: |
---|
[3] | 142 | call CreateDPT_FromAtaInformation |
---|
[196] | 143 | jc SHORT DetectDrives_DriveNotFound |
---|
[3] | 144 | call BootInfo_CreateForHardDisk |
---|
[196] | 145 | jmp short DetectPrint_DriveNameFromBootnfoInESBX |
---|
| 146 | |
---|
| 147 | ;-------------------------------------------------------------------- |
---|
| 148 | ; DetectDrives_DriveNotFound |
---|
| 149 | ; Parameters: |
---|
| 150 | ; Nothing |
---|
| 151 | ; Returns: |
---|
| 152 | ; Nothing |
---|
| 153 | ; Corrupts registers: |
---|
| 154 | ; AX, SI |
---|
| 155 | ;-------------------------------------------------------------------- |
---|
| 156 | DetectDrives_DriveNotFound: |
---|
| 157 | mov si, g_szNotFound |
---|
| 158 | jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
| 159 | |
---|