[497] | 1 | ; Project name : XTIDE Universal BIOS Configurator v2 |
---|
| 2 | ; Description : Functions to automatically configure XTIDE |
---|
| 3 | ; Universal BIOS for current system. |
---|
| 4 | |
---|
| 5 | ; |
---|
| 6 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 8 | ; |
---|
| 9 | ; This program is free software; you can redistribute it and/or modify |
---|
| 10 | ; it under the terms of the GNU General Public License as published by |
---|
| 11 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | ; (at your option) any later version. |
---|
| 13 | ; |
---|
| 14 | ; This program is distributed in the hope that it will be useful, |
---|
| 15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | ; GNU General Public License for more details. |
---|
| 18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 19 | ; |
---|
| 20 | |
---|
| 21 | ; Section containing code |
---|
| 22 | SECTION .text |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | ;-------------------------------------------------------------------- |
---|
| 26 | ; AutoConfigure_ForThisSystem |
---|
| 27 | ; MENUITEM activation function (.fnActivate) |
---|
| 28 | ; Parameters: |
---|
| 29 | ; SS:BP: Ptr to MENU |
---|
| 30 | ; Returns: |
---|
| 31 | ; Nothing |
---|
| 32 | ; Corrupts registers: |
---|
| 33 | ; All, except segments |
---|
| 34 | ;-------------------------------------------------------------------- |
---|
| 35 | ALIGN JUMP_ALIGN |
---|
| 36 | AutoConfigure_ForThisSystem: |
---|
| 37 | push es |
---|
| 38 | push ds |
---|
| 39 | |
---|
| 40 | call Buffers_GetFileBufferToESDI ; ROMVARS now in ES:DI |
---|
| 41 | push es |
---|
| 42 | pop ds ; ROMVARS now in DS:DI |
---|
| 43 | call ResetIdevarsToDefaultValues |
---|
| 44 | call DetectIdePortsAndDevices |
---|
| 45 | call StoreAndDisplayNumberOfControllers |
---|
| 46 | |
---|
| 47 | pop ds |
---|
| 48 | pop es |
---|
| 49 | ret |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | ;-------------------------------------------------------------------- |
---|
| 53 | ; ResetIdevarsToDefaultValues |
---|
| 54 | ; Parameters: |
---|
| 55 | ; DS:DI: Ptr to ROMVARS |
---|
| 56 | ; Returns: |
---|
| 57 | ; Nothing |
---|
| 58 | ; Corrupts registers: |
---|
| 59 | ; AX, CX |
---|
| 60 | ;-------------------------------------------------------------------- |
---|
| 61 | ALIGN JUMP_ALIGN |
---|
| 62 | ResetIdevarsToDefaultValues: |
---|
| 63 | push di |
---|
| 64 | add di, BYTE ROMVARS.ideVarsBegin |
---|
| 65 | mov cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin |
---|
| 66 | call Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto |
---|
| 67 | pop di |
---|
| 68 | |
---|
| 69 | ; Set default values (other than zero) |
---|
| 70 | mov ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE |
---|
| 71 | mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax |
---|
| 72 | mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax |
---|
| 73 | mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax |
---|
| 74 | mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax |
---|
| 75 | ret |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | ;-------------------------------------------------------------------- |
---|
| 79 | ; DetectIdePortsAndDevices |
---|
| 80 | ; Parameters: |
---|
| 81 | ; DS:DI: Ptr to ROMVARS |
---|
| 82 | ; Returns: |
---|
| 83 | ; CX: Number of controllers detected |
---|
| 84 | ; Corrupts registers: |
---|
| 85 | ; AX, BX, DX, SI |
---|
| 86 | ;-------------------------------------------------------------------- |
---|
| 87 | ALIGN JUMP_ALIGN |
---|
| 88 | DetectIdePortsAndDevices: |
---|
| 89 | xor cx, cx ; Number of devices found |
---|
| 90 | xor dx, dx ; IDE_PORT_TO_START_DETECTION |
---|
| 91 | lea si, [di+ROMVARS.ideVarsBegin] ; DS:SI points to first IDEVARS |
---|
| 92 | |
---|
| 93 | .DetectFromNextPort: |
---|
| 94 | call IdeAutodetect_IncrementDXtoNextIdeBasePort |
---|
| 95 | jz SHORT .AllPortsAlreadyDetected |
---|
| 96 | push cx |
---|
| 97 | call IdeAutodetect_DetectIdeDeviceFromPortDX |
---|
| 98 | pop cx |
---|
| 99 | jc SHORT .DetectFromNextPort |
---|
| 100 | |
---|
| 101 | ; Device found from port DX, Device Type returned in AL |
---|
| 102 | inc cx ; Increment number of controllers found |
---|
| 103 | call GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX |
---|
| 104 | mov [si+IDEVARS.wBasePort], dx |
---|
| 105 | mov [si+IDEVARS.wControlBlockPort], bx |
---|
| 106 | mov [si+IDEVARS.bDevice], al |
---|
| 107 | |
---|
| 108 | ; Point to next IDEVARS |
---|
| 109 | cmp si, ROMVARS.ideVars3 |
---|
| 110 | jae SHORT .AllPortsAlreadyDetected |
---|
| 111 | add si, IDEVARS_size |
---|
| 112 | jmp SHORT .DetectFromNextPort |
---|
| 113 | .AllPortsAlreadyDetected: |
---|
| 114 | ret |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | ;-------------------------------------------------------------------- |
---|
| 118 | ; GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX |
---|
| 119 | ; Parameters: |
---|
| 120 | ; AL: Device Type |
---|
| 121 | ; DX: Base port |
---|
| 122 | ; Returns: |
---|
| 123 | ; BX: Control Block Port |
---|
| 124 | ; Corrupts registers: |
---|
| 125 | ; Nothing |
---|
| 126 | ;-------------------------------------------------------------------- |
---|
| 127 | ALIGN JUMP_ALIGN |
---|
| 128 | GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX: |
---|
| 129 | mov bx, dx |
---|
| 130 | cmp al, DEVICE_8BIT_XTIDE_REV1 |
---|
| 131 | jae SHORT .NonStandardControlBlockPortLocation |
---|
| 132 | |
---|
| 133 | ; Standard IDE Devices |
---|
| 134 | add bx, STANDARD_CONTROL_BLOCK_OFFSET |
---|
| 135 | ret |
---|
| 136 | |
---|
| 137 | .NonStandardControlBlockPortLocation: |
---|
| 138 | cmp al, DEVICE_8BIT_JRIDE_ISA |
---|
| 139 | je SHORT .JrIdeIsaDoesNotNeedControlBlockAddress |
---|
| 140 | |
---|
| 141 | ; 8-bit Devices |
---|
| 142 | add bx, BYTE XTIDE_CONTROL_BLOCK_OFFSET ; XT-CF also |
---|
| 143 | .JrIdeIsaDoesNotNeedControlBlockAddress: |
---|
| 144 | ret |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | ;-------------------------------------------------------------------- |
---|
| 148 | ; StoreAndDisplayNumberOfControllers |
---|
| 149 | ; Parameters: |
---|
| 150 | ; CX: Number of controllers detected |
---|
| 151 | ; DS:DI: Ptr to ROMVARS |
---|
| 152 | ; SS:BP: Ptr to MENU |
---|
| 153 | ; Returns: |
---|
| 154 | ; Nothing |
---|
| 155 | ; Corrupts registers: |
---|
| 156 | ; AX, BX, DX, DI, SI, DS, ES |
---|
| 157 | ;-------------------------------------------------------------------- |
---|
| 158 | ALIGN JUMP_ALIGN |
---|
| 159 | StoreAndDisplayNumberOfControllers: |
---|
| 160 | mov ax, 1 |
---|
| 161 | MAX_U al, cl ; Cannot store zero |
---|
| 162 | test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
| 163 | jnz SHORT .FullModeSoNoNeedToLimit |
---|
| 164 | MIN_U al, MAX_LITE_MODE_CONTROLLERS |
---|
| 165 | .FullModeSoNoNeedToLimit: |
---|
| 166 | |
---|
| 167 | ; Store number of IDE Controllers. This will also modify |
---|
| 168 | ; menu and set unsaved changes flag. |
---|
| 169 | push cs |
---|
| 170 | pop ds |
---|
| 171 | mov si, g_MenuitemConfigurationIdeControllers |
---|
| 172 | call Menuitem_StoreValueFromAXtoMenuitemInDSSI |
---|
| 173 | |
---|
| 174 | ; Display results (should be changed to proper string formatting) |
---|
| 175 | add cl, '0' |
---|
| 176 | mov [cs:g_bControllersDetected], cl |
---|
| 177 | mov dx, g_szDlgAutoConfigure |
---|
| 178 | jmp Dialogs_DisplayNotificationFromCSDX |
---|