source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm @ 592

Last change on this file since 592 was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 6.3 KB
RevLine 
[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
[526]7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[497]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
22SECTION .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;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36AutoConfigure_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
[592]45    call    EnableInterruptsForAllStandardControllers
[497]46    call    StoreAndDisplayNumberOfControllers
47
48    pop     ds
49    pop     es
50    ret
51
52
53;--------------------------------------------------------------------
54; ResetIdevarsToDefaultValues
55;   Parameters:
56;       DS:DI:  Ptr to ROMVARS
[592]57;       ES:DI:  Ptr to ROMVARS
[497]58;   Returns:
59;       Nothing
60;   Corrupts registers:
61;       AX, CX
62;--------------------------------------------------------------------
63ALIGN JUMP_ALIGN
64ResetIdevarsToDefaultValues:
65    push    di
66    add     di, BYTE ROMVARS.ideVarsBegin
67    mov     cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin
68    call    Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto
69    pop     di
70
71    ; Set default values (other than zero)
72    mov     ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
73    mov     [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
[502]74    mov     [di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
75
[497]76    mov     [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
[502]77    mov     [di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
78
[497]79    mov     [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
[502]80    mov     [di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
81
[497]82    mov     [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
[502]83    mov     [di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
[497]84    ret
85
86
87;--------------------------------------------------------------------
88; DetectIdePortsAndDevices
89;   Parameters:
90;       DS:DI:  Ptr to ROMVARS
91;   Returns:
92;       CX:     Number of controllers detected
93;   Corrupts registers:
94;       AX, BX, DX, SI
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
97DetectIdePortsAndDevices:
98    xor     cx, cx                          ; Number of devices found
99    xor     dx, dx                          ; IDE_PORT_TO_START_DETECTION
100    lea     si, [di+ROMVARS.ideVarsBegin]   ; DS:SI points to first IDEVARS
101
102.DetectFromNextPort:
103    call    IdeAutodetect_IncrementDXtoNextIdeBasePort
104    jz      SHORT .AllPortsAlreadyDetected
[504]105    push    si
106    call    IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI
107    mov     bx, si
108    pop     si
[497]109    jc      SHORT .DetectFromNextPort
110
111    ; Device found from port DX, Device Type returned in AL
112    inc     cx  ; Increment number of controllers found
113    mov     [si+IDEVARS.wBasePort], dx
114    mov     [si+IDEVARS.wControlBlockPort], bx
115    mov     [si+IDEVARS.bDevice], al
116
117    ; Point to next IDEVARS
[505]118    add     si, IDEVARS_size
[497]119    cmp     si, ROMVARS.ideVars3
[505]120    jbe     SHORT .DetectFromNextPort
[497]121.AllPortsAlreadyDetected:
122    ret
123
124
125;--------------------------------------------------------------------
[592]126; EnableInterruptsForAllStandardControllers
[523]127;   Parameters:
128;       DS:DI:  Ptr to ROMVARS
129;       CX:     Number of controllers detected
130;   Returns:
131;       Nothing
132;   Corrupts registers:
[592]133;       AX
[523]134;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
[592]136EnableInterruptsForAllStandardControllers:
[523]137    jcxz    .NoControllersDetected
138    call    Buffers_IsXTbuildLoaded
139    je      SHORT .DoNotEnableIRQforXTbuilds
140    push    di
141    push    cx
142
143    add     di, BYTE ROMVARS.ideVars0   ; DS:DI now points first IDEVARS
144.CheckNextController:
145    mov     al, 14
146    cmp     WORD [di+IDEVARS.wBasePort], DEVICE_ATA_PRIMARY_PORT
147    je      SHORT .EnableIrqAL
148
149    inc     ax  ; 15
150    cmp     WORD [di+IDEVARS.wBasePort], DEVICE_ATA_SECONDARY_PORT
[592]151
152%if 0
153    je      SHORT .EnableIrqAL
154
155    ; Defaults on the GSI Inc. Model 2C EIDE controller
156    mov     al, 11
157    cmp     WORD [di+IDEVARS.wBasePort], DEVICE_ATA_TERTIARY_PORT
158    je      SHORT .EnableIrqAL
159
160    dec     ax  ; 10
161    cmp     WORD [di+IDEVARS.wBasePort], DEVICE_ATA_QUATERNARY_PORT
162%endif
163
[523]164    jne     SHORT .DoNotEnableIRQ
165
166.EnableIrqAL:
167    mov     [di+IDEVARS.bIRQ], al
168.DoNotEnableIRQ:
[592]169    add     di, IDEVARS_size
[523]170    loop    .CheckNextController
171    pop     cx
172    pop     di
173.DoNotEnableIRQforXTbuilds:
174.NoControllersDetected:
175    ret
176
177
178;--------------------------------------------------------------------
[497]179; StoreAndDisplayNumberOfControllers
180;   Parameters:
181;       CX:     Number of controllers detected
182;       DS:DI:  Ptr to ROMVARS
183;       SS:BP:  Ptr to MENU
184;   Returns:
185;       Nothing
186;   Corrupts registers:
187;       AX, BX, DX, DI, SI, DS, ES
188;--------------------------------------------------------------------
189ALIGN JUMP_ALIGN
190StoreAndDisplayNumberOfControllers:
[525]191    xor     ax, ax
192    or      al, cl
193    jnz     SHORT .AtLeastOneController
194    inc     ax                          ; Cannot store zero
195.AtLeastOneController:
[497]196    test    BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
197    jnz     SHORT .FullModeSoNoNeedToLimit
198    MIN_U   al, MAX_LITE_MODE_CONTROLLERS
199.FullModeSoNoNeedToLimit:
200
201    ; Store number of IDE Controllers. This will also modify
202    ; menu and set unsaved changes flag.
203    push    cs
204    pop     ds
205    mov     si, g_MenuitemConfigurationIdeControllers
206    call    Menuitem_StoreValueFromAXtoMenuitemInDSSI
207
208    ; Display results (should be changed to proper string formatting)
209    add     cl, '0'
210    mov     [cs:g_bControllersDetected], cl
211    mov     dx, g_szDlgAutoConfigure
212    jmp     Dialogs_DisplayNotificationFromCSDX
Note: See TracBrowser for help on using the repository browser.