[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 | |
---|
| 34 | %ifdef MODULE_SERIAL |
---|
[179] | 35 | test BYTE [es:BDA.bKBFlgs1], 8 ; alt key depressed |
---|
| 36 | jz .done |
---|
| 37 | mov bp, ROMVARS.ideVarsSerialAuto |
---|
[196] | 38 | mov si, g_szDetectCOMAuto |
---|
[175] | 39 | ;;; fall-through |
---|
| 40 | %else |
---|
[3] | 41 | ret |
---|
[175] | 42 | %endif |
---|
[3] | 43 | |
---|
| 44 | ;-------------------------------------------------------------------- |
---|
| 45 | ; Detects IDE hard disks by using information from IDEVARS. |
---|
| 46 | ; |
---|
| 47 | ; DetectDrives_WithIDEVARS |
---|
| 48 | ; Parameters: |
---|
| 49 | ; CS:BP: Ptr to IDEVARS |
---|
| 50 | ; DS: RAMVARS segment |
---|
| 51 | ; ES: Zero (BDA segment) |
---|
[189] | 52 | ; SI: Ptr to template string |
---|
[3] | 53 | ; Returns: |
---|
| 54 | ; Nothing |
---|
| 55 | ; Corrupts registers: |
---|
| 56 | ; AX, BX, DX, SI, DI |
---|
| 57 | ;-------------------------------------------------------------------- |
---|
[175] | 58 | .DetectDrives_WithIDEVARS: |
---|
[3] | 59 | push cx |
---|
[196] | 60 | |
---|
| 61 | push si |
---|
[97] | 62 | mov ax, g_szMaster |
---|
[150] | 63 | mov bh, MASK_DRVNHEAD_SET ; Select Master drive |
---|
[98] | 64 | call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO |
---|
[189] | 65 | pop si |
---|
[196] | 66 | |
---|
[97] | 67 | mov ax, g_szSlave |
---|
[150] | 68 | mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV |
---|
[98] | 69 | call StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
[3] | 70 | pop cx |
---|
[175] | 71 | .done: |
---|
[3] | 72 | ret |
---|
| 73 | |
---|
[175] | 74 | |
---|
[3] | 75 | ;-------------------------------------------------------------------- |
---|
[98] | 76 | ; StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
[3] | 77 | ; Parameters: |
---|
[98] | 78 | ; AX: Offset to "Master" or "Slave" string |
---|
[3] | 79 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 80 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
| 81 | ; DS: RAMVARS segment |
---|
| 82 | ; ES: Zero (BDA segment) |
---|
| 83 | ; Returns: |
---|
[98] | 84 | ; Nothing |
---|
[3] | 85 | ; Corrupts registers: |
---|
[98] | 86 | ; AX, BX, CX, DX, SI, DI |
---|
[3] | 87 | ;-------------------------------------------------------------------- |
---|
[98] | 88 | StartDetectionWithDriveSelectByteInBHandStringInAX: |
---|
| 89 | call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP |
---|
[120] | 90 | ; Fall to .ReadAtaInfoFromHardDisk |
---|
[3] | 91 | |
---|
| 92 | ;-------------------------------------------------------------------- |
---|
[120] | 93 | ; .ReadAtaInfoFromHardDisk |
---|
[3] | 94 | ; Parameters: |
---|
| 95 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 96 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
| 97 | ; DS: RAMVARS segment |
---|
| 98 | ; ES: Zero (BDA segment) |
---|
| 99 | ; Returns: |
---|
| 100 | ; CF: Cleared if ATA-information read successfully |
---|
| 101 | ; Set if any error |
---|
| 102 | ; Corrupts registers: |
---|
[150] | 103 | ; AX, BL, CX, DX, SI, DI |
---|
[3] | 104 | ;-------------------------------------------------------------------- |
---|
[120] | 105 | .ReadAtaInfoFromHardDisk: |
---|
[150] | 106 | mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location |
---|
| 107 | push es |
---|
| 108 | push si |
---|
| 109 | push bx |
---|
| 110 | call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH |
---|
| 111 | pop bx |
---|
| 112 | pop si |
---|
| 113 | pop es |
---|
[120] | 114 | jnc SHORT CreateBiosTablesForHardDisk |
---|
| 115 | ; Fall to .ReadAtapiInfoFromDrive |
---|
[3] | 116 | |
---|
[120] | 117 | .ReadAtapiInfoFromDrive: ; Not yet implemented |
---|
| 118 | ;call ReadAtapiInfoFromDrive ; Assume CD-ROM |
---|
| 119 | ;jnc SHORT _CreateBiosTablesForCDROM |
---|
[196] | 120 | jmp short DetectDrives_DriveNotFound |
---|
[3] | 121 | |
---|
[120] | 122 | |
---|
[3] | 123 | ;-------------------------------------------------------------------- |
---|
[98] | 124 | ; CreateBiosTablesForHardDisk |
---|
[3] | 125 | ; Parameters: |
---|
| 126 | ; BH: Drive Select byte for Drive and Head Register |
---|
| 127 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
[150] | 128 | ; ES:SI Ptr to ATA information for the drive |
---|
[3] | 129 | ; DS: RAMVARS segment |
---|
[98] | 130 | ; ES: BDA/Bootnfo segment |
---|
[3] | 131 | ; Returns: |
---|
[98] | 132 | ; Nothing |
---|
[3] | 133 | ; Corrupts registers: |
---|
[98] | 134 | ; AX, BX, CX, DX, SI, DI |
---|
[3] | 135 | ;-------------------------------------------------------------------- |
---|
[98] | 136 | CreateBiosTablesForHardDisk: |
---|
[3] | 137 | call CreateDPT_FromAtaInformation |
---|
[196] | 138 | jc SHORT DetectDrives_DriveNotFound |
---|
[3] | 139 | call BootInfo_CreateForHardDisk |
---|
[196] | 140 | jmp short DetectPrint_DriveNameFromBootnfoInESBX |
---|
| 141 | |
---|
| 142 | ;-------------------------------------------------------------------- |
---|
| 143 | ; DetectDrives_DriveNotFound |
---|
| 144 | ; Parameters: |
---|
| 145 | ; Nothing |
---|
| 146 | ; Returns: |
---|
| 147 | ; Nothing |
---|
| 148 | ; Corrupts registers: |
---|
| 149 | ; AX, SI |
---|
| 150 | ;-------------------------------------------------------------------- |
---|
| 151 | DetectDrives_DriveNotFound: |
---|
| 152 | mov si, g_szNotFound |
---|
| 153 | jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
| 154 | |
---|