source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm @ 589

Last change on this file since 589 was 589, checked in by krille_n_, 8 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 15.6 KB
RevLine 
[57]1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   "Configure XTIDE Universal BIOS" menu structs and functions.
3
[376]4;
[380]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[380]12;
[376]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[380]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[380]18;
[376]19
[57]20; Section containing initialized data
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_MenupageForConfigurationMenu:
25istruc MENUPAGE
26    at  MENUPAGE.fnEnter,           dw  ConfigurationMenu_EnterMenuOrModifyItemVisibility
[59]27    at  MENUPAGE.fnBack,            dw  MainMenu_EnterMenuOrModifyItemVisibility
[497]28    at  MENUPAGE.wMenuitems,        dw  11
[57]29iend
30
31g_MenuitemConfigurationBackToMainMenu:
32istruc MENUITEM
33    at  MENUITEM.fnActivate,        dw  MainMenu_EnterMenuOrModifyItemVisibility
34    at  MENUITEM.szName,            dw  g_szItemCfgBackToMain
35    at  MENUITEM.szQuickInfo,       dw  g_szItemCfgBackToMain
36    at  MENUITEM.szHelp,            dw  g_szItemCfgBackToMain
37    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
38    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGEBACK
39iend
40
41g_MenuitemConfigurationPrimaryIdeController:
42istruc MENUITEM
43    at  MENUITEM.fnActivate,        dw  PrimaryIdeController
44    at  MENUITEM.szName,            dw  g_szItemCfgIde1
45    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIde
46    at  MENUITEM.szHelp,            dw  g_szNfoCfgIde
47    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
48    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
49iend
50
51g_MenuitemConfigurationSecondaryIdeController:
52istruc MENUITEM
53    at  MENUITEM.fnActivate,        dw  SecondaryIdeController
54    at  MENUITEM.szName,            dw  g_szItemCfgIde2
55    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIde
56    at  MENUITEM.szHelp,            dw  g_szNfoCfgIde
57    at  MENUITEM.bFlags,            db  NULL
58    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
59iend
60
61g_MenuitemConfigurationTertiaryIdeController:
62istruc MENUITEM
63    at  MENUITEM.fnActivate,        dw  TertiaryIdeController
64    at  MENUITEM.szName,            dw  g_szItemCfgIde3
65    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIde
66    at  MENUITEM.szHelp,            dw  g_szNfoCfgIde
67    at  MENUITEM.bFlags,            db  NULL
68    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
69iend
70
71g_MenuitemConfigurationQuaternaryIdeController:
72istruc MENUITEM
73    at  MENUITEM.fnActivate,        dw  QuaternaryIdeController
74    at  MENUITEM.szName,            dw  g_szItemCfgIde4
75    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIde
76    at  MENUITEM.szHelp,            dw  g_szNfoCfgIde
77    at  MENUITEM.bFlags,            db  NULL
78    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
79iend
80
81g_MenuitemConfigurationBootMenuSettings:
82istruc MENUITEM
[59]83    at  MENUITEM.fnActivate,        dw  BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility
[57]84    at  MENUITEM.szName,            dw  g_szItemCfgBootMenu
85    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgBootMenu
86    at  MENUITEM.szHelp,            dw  g_szNfoCfgBootMenu
[109]87    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
[57]88    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
89iend
90
[497]91g_MenuitemAutoConfigure:
92istruc MENUITEM
93    at  MENUITEM.fnActivate,        dw  AutoConfigure_ForThisSystem
94    at  MENUITEM.szName,            dw  g_szItemAutoConfigure
95    at  MENUITEM.szQuickInfo,       dw  g_szNfoAutoConfigure
96    at  MENUITEM.szHelp,            dw  g_szNfoAutoConfigure
97    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU
98    at  MENUITEM.bType,             db  TYPE_MENUITEM_ACTION
99iend
100
[57]101g_MenuitemConfigurationFullOperatingMode:
102istruc MENUITEM
[108]103    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]104    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
[57]105    at  MENUITEM.szName,            dw  g_szItemCfgFullMode
106    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgFullMode
107    at  MENUITEM.szHelp,            dw  g_szHelpCfgFullMode
[457]108    at  MENUITEM.bFlags,            db  FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
[108]109    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
[57]110    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.wFlags
111    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgCfgFullMode
[108]112    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBooleanFlag
[57]113    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForFlagBooleans
114    at  MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,              dw  FLG_ROMVARS_FULLMODE
115iend
116
117g_MenuitemConfigurationKiBtoStealFromRAM:
118istruc MENUITEM
119    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateUnsignedInputForMenuitemInDSSI
120    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
121    at  MENUITEM.szName,            dw  g_szItemCfgStealSize
122    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgStealSize
123    at  MENUITEM.szHelp,            dw  g_szHelpCfgStealSize
124    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
125    at  MENUITEM.bType,             db  TYPE_MENUITEM_UNSIGNED
126    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.bStealSize
127    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgCfgStealSize
128    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  1
129    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  255
130iend
131
132g_MenuitemConfigurationIdeControllers:
133istruc MENUITEM
[204]134    at  MENUITEM.fnActivate,        dw  ActivateInputForNumberOfIdeControllersMenuitemInDSSI
[57]135    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
136    at  MENUITEM.szName,            dw  g_szItemCfgIdeCnt
137    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIdeCnt
138    at  MENUITEM.szHelp,            dw  g_szNfoCfgIdeCnt
[206]139    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
[57]140    at  MENUITEM.bType,             db  TYPE_MENUITEM_UNSIGNED
141    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.bIdeCnt
142    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgCfgIdeCnt
143    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  1
[204]144    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  MAX_ALLOWED_IDE_CONTROLLERS
[57]145iend
146
[380]147g_MenuitemConfigurationIdleTimeout:
148istruc MENUITEM
149    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
150    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
151    at  MENUITEM.szName,            dw  g_szItemCfgIdleTimeout
152    at  MENUITEM.szQuickInfo,       dw  g_szNfoCfgIdleTimeout
153    at  MENUITEM.szHelp,            dw  g_szHelpCfgIdleTimeout
[457]154    at  MENUITEM.bFlags,            db  FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
[380]155    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
156    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.bIdleTimeout
157    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgCfgIdleTimeout
158    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceIdleTimeout
159    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  g_rgwChoiceToValueLookupForIdleTimeout
160    at  MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup,   dw  g_rgszChoiceToStringLookupForIdleTimeout
161iend
[57]162
[380]163g_rgwChoiceToValueLookupForIdleTimeout:
164    %assign i -12
165    %rep 21
166        %assign i i+12
167        dw  i       ; i / 12 = 0 (disabled) or 1...20 minutes
168    %endrep
169    %rep 4
170        %assign i i+1
171        dw  i       ; 241...244 = (i - 240) * 30 minutes
172    %endrep
173g_rgszChoiceToStringLookupForIdleTimeout:
174    %assign i 0
175    %rep 25
176        dw  g_szIdleTimeoutChoice%[i]
177        %assign i i+1
178    %endrep
[589]179        dw  NULL
[380]180
[589]181
[57]182; Section containing code
183SECTION .text
184
185;--------------------------------------------------------------------
186; MainMenu_EnterMenuOrModifyItemVisibility
187;   Parameters:
188;       SS:BP:  Menu handle
189;   Returns:
190;       Nothing
191;   Corrupts registers:
192;       All, except BP
193;--------------------------------------------------------------------
194ALIGN JUMP_ALIGN
195ConfigurationMenu_EnterMenuOrModifyItemVisibility:
196    push    cs
197    pop     ds
198    call    .DisableAllIdeControllerMenuitems
199    call    .EnableIdeControllerMenuitemsBasedOnConfiguration
[457]200    call    .EnableOrDisableOperatingModeSelection
[57]201    call    .EnableOrDisableKiBtoStealFromRAM
[457]202    call    .EnableOrDisableIdleTimeout
[204]203    call    LimitIdeControllersForLiteMode
[57]204    mov     si, g_MenupageForConfigurationMenu
205    jmp     Menupage_ChangeToNewMenupageInDSSI
206
207;--------------------------------------------------------------------
208; .DisableAllIdeControllerMenuitems
209; .EnableIdeControllerMenuitemsBasedOnConfiguration
210;   Parameters:
211;       SS:BP:  Menu handle
212;   Returns:
213;       Nothing
214;   Corrupts registers:
[204]215;       AX, BX, CX, DI, ES
[57]216;--------------------------------------------------------------------
217ALIGN JUMP_ALIGN
218.DisableAllIdeControllerMenuitems:
219    mov     cx, MAX_ALLOWED_IDE_CONTROLLERS-1
[567]220    mov     ax, DisableMenuitemFromCSBX
221    jmp     SHORT .Go
[57]222
223ALIGN JUMP_ALIGN
224.EnableIdeControllerMenuitemsBasedOnConfiguration:
[204]225    call    Buffers_GetIdeControllerCountToCX
[57]226    dec     cx          ; Primary always enabled
[204]227    jz      SHORT .PrimaryControllerAlreadyEnabled
[567]228    mov     ax, EnableMenuitemFromCSBX
229.Go:
[57]230    mov     bx, g_MenuitemConfigurationSecondaryIdeController
231ALIGN JUMP_ALIGN
[567]232.EnableOrDisableNextIdeControllerMenuitem:
233    call    ax
[57]234    add     bx, BYTE MENUITEM_size
[567]235    loop    .EnableOrDisableNextIdeControllerMenuitem
[57]236.PrimaryControllerAlreadyEnabled:
237    ret
238
239
240;--------------------------------------------------------------------
[457]241; .EnableOrDisableOperatingModeSelection
242;   Parameters:
243;       SS:BP:  Menu handle
244;   Returns:
245;       Nothing
246;   Corrupts registers:
247;       BX, DI, ES
248;--------------------------------------------------------------------
249ALIGN JUMP_ALIGN
250.EnableOrDisableOperatingModeSelection:
251    mov     bx, g_MenuitemConfigurationFullOperatingMode
252    call    Buffers_IsXTbuildLoaded
253    je      SHORT .EnableMenuitemFromCSBX
254    jmp     SHORT .DisableMenuitemFromCSBX
255
256
257;--------------------------------------------------------------------
[57]258; .EnableOrDisableKiBtoStealFromRAM
259;   Parameters:
260;       SS:BP:  Menu handle
261;   Returns:
262;       Nothing
263;   Corrupts registers:
264;       AX, BX, CX
265;--------------------------------------------------------------------
266ALIGN JUMP_ALIGN
267.EnableOrDisableKiBtoStealFromRAM:
[59]268    call    Buffers_GetRomvarsFlagsToAX
[57]269    mov     bx, g_MenuitemConfigurationKiBtoStealFromRAM
270    test    ax, FLG_ROMVARS_FULLMODE
271    jz      SHORT .DisableMenuitemFromCSBX
[457]272    jmp     SHORT .EnableMenuitemFromCSBX
273
274
275;--------------------------------------------------------------------
276; .EnableOrDisableIdleTimeout
277;   Parameters:
278;       SS:BP:  Menu handle
279;   Returns:
280;       Nothing
281;   Corrupts registers:
282;       AX, BX
283;--------------------------------------------------------------------
284ALIGN JUMP_ALIGN
285.EnableOrDisableIdleTimeout:
286    call    Buffers_GetRomvarsFlagsToAX
287    mov     bx, g_MenuitemConfigurationIdleTimeout
[589]288    test    al, FLG_ROMVARS_MODULE_POWER_MANAGEMENT
[457]289    jz      SHORT .DisableMenuitemFromCSBX
[204]290    ; Fall to .EnableMenuitemFromCSBX
[57]291
[153]292
[57]293;--------------------------------------------------------------------
294; .EnableMenuitemFromCSBX
295; .DisableMenuitemFromCSBX
296;   Parameters:
297;       CS:BX:  Ptr to MENUITEM
298;   Returns:
299;       Nothing
300;   Corrupts registers:
301;       Nothing
302;--------------------------------------------------------------------
303ALIGN JUMP_ALIGN
304.EnableMenuitemFromCSBX:
[567]305    jmp     EnableMenuitemFromCSBX
[57]306
307ALIGN JUMP_ALIGN
308.DisableMenuitemFromCSBX:
[567]309    jmp     DisableMenuitemFromCSBX
[57]310
311
312;--------------------------------------------------------------------
313; MENUITEM activation functions (.fnActivate)
314;   Parameters:
315;       SS:BP:  Ptr to MENU
316;   Returns:
317;       Nothing
318;   Corrupts registers:
319;       All, except segments
320;--------------------------------------------------------------------
321ALIGN JUMP_ALIGN
322PrimaryIdeController:
323    mov     bx, ROMVARS.ideVars0
324    jmp     SHORT DisplayIdeControllerMenu
325
326ALIGN JUMP_ALIGN
327SecondaryIdeController:
328    mov     bx, ROMVARS.ideVars1
329    jmp     SHORT DisplayIdeControllerMenu
330
331ALIGN JUMP_ALIGN
332TertiaryIdeController:
333    mov     bx, ROMVARS.ideVars2
334    jmp     SHORT DisplayIdeControllerMenu
335
336ALIGN JUMP_ALIGN
337QuaternaryIdeController:
338    mov     bx, ROMVARS.ideVars3
339    ; Fall to DisplayIdeControllerMenu
340
341ALIGN JUMP_ALIGN
342DisplayIdeControllerMenu:
343    call    IdeControllerMenu_InitializeToIdevarsOffsetInBX
344    jmp     IdeControllerMenu_EnterMenuOrModifyItemVisibility
[204]345
346
347ALIGN JUMP_ALIGN
348ActivateInputForNumberOfIdeControllersMenuitemInDSSI:
349    call    Menuitem_ActivateUnsignedInputForMenuitemInDSSI
350    ; Fall to LimitIdeControllersForLiteMode
351
352;--------------------------------------------------------------------
353; LimitIdeControllersForLiteMode
354;   Parameters:
355;       SS:BP:  Menu handle
356;   Returns:
357;       Nothing
358;   Corrupts registers:
359;       AX, CX, DI
360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362LimitIdeControllersForLiteMode:
363    push    es
364    call    Buffers_GetIdeControllerCountToCX
365    mov     [es:di+ROMVARS.bIdeCnt], cl
366    CALL_MENU_LIBRARY GetHighlightedItemToAX
367    CALL_MENU_LIBRARY RefreshItemFromAX
368    pop     es
[258]369    ; Fall to ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
370
371;----------------------------------------------------------------------
372; ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
373;
[380]374; Checks to ensure that serial adapters are at the end of the
375; IDEVARS structures list, as serial floppies (if present) need to be
[258]376; the last drives detected by the BIOS.  If there are other controllers
377; after a serial controller, the other controllers are moved up on the list
378; and the serial controller is placed at the end of the list.
379;
380;   Parameters:
381;       SS:BP:  Menu handle
382;   Returns:
383;       Nothing
384;   Corrupts registers:
385;       All
[380]386;----------------------------------------------------------------------
387ConfigurationMenu_CheckAndMoveSerialDrivesToBottom:
[258]388    push    es
389    push    ds
390    push    di
391    push    si
392
393    call    Buffers_GetIdeControllerCountToCX   ; will also set ES:DI to point to file buffer
394    push    es
395    pop     ds
[589]396    mov     dx, cx                      ; Controller count to DL (will always be at least 1) while also clearing notification flag in DH
[258]397
[380]398    lea     bx, [di+ROMVARS.ideVars0]   ; add in offset of first idevars
[258]399
400.outerLoop:
401    mov     di, bx                      ; start of idevars
402    xor     si, si                      ; first serial found
403    xor     ax, ax                      ; first non-serial found
404    mov     cl, dl                      ; idevars count
405
406.loop:
[589]407    cmp     BYTE [di+IDEVARS.bDevice], DEVICE_SERIAL_PORT
408    jne     SHORT .notSerial
[258]409
[380]410    test    si, si                      ; record the first serial controller that we find
[589]411    jnz     SHORT .next
[258]412    mov     si, di
[567]413    SKIP2B  f
[258]414
415.notSerial:
416    mov     ax, di                      ; record the *last* non-serial controller that we find
417
[380]418.next:
[258]419    add     di, IDEVARS_size
420    loop    .loop
421
[380]422    test    si, si                      ; no serial drives, nothing to do
[589]423    jz      SHORT .done
[380]424    cmp     si, ax                      ; serial port is already later on the list than any other controllers
[589]425    ja      SHORT .done                 ; (also takes care of the case where there are no other controllers)
[258]426
427;
428; move serial to end of list, others up
429;
430    cld
431
432    mov     ax, di                      ; save end pointer of list after scan
433
434    sub     sp, IDEVARS_size            ; copy serial to temporary space on stack
435
436    mov     di, sp
437
438    push    ss
439    pop     es
440
[589]441%if IDEVARS_size & 1
442    mov     cl, IDEVARS_size
[258]443    rep movsb
[589]444%else
445    mov     cl, IDEVARS_size / 2
446    rep movsw
447%endif
[258]448
[380]449    lea     di, [si-IDEVARS_size]       ; move up all the idevars below the serial, by one slot
[258]450
451    mov     cx, ax                      ; restore end pointer of list, subtract off end of serial idevars
452    sub     cx, si
453
454    push    ds
455    pop     es
456
457    rep movsb
458
459    mov     si, sp                      ; place serial (currently on the stack) at bottom of list
460    push    ss
461    pop     ds
462    ; di is already at last IDEVARS position
[380]463
[589]464%if IDEVARS_size & 1
465    mov     cl, IDEVARS_size
[258]466    rep movsb
[589]467%else
468    mov     cl, IDEVARS_size / 2
469    rep movsw
470%endif
[258]471
[380]472    add     sp, IDEVARS_size
[258]473
474    push    es
475    pop     ds
476
477    mov     dh, 1                       ; set flag that we have done a relocation
[380]478
[589]479    jmp     SHORT .outerLoop
[258]480
481.done:
482    pop     si
483    pop     di
484    pop     ds
485    pop     es
486
487    test    dh, dh
[589]488    jz      SHORT .noWorkDone
[380]489
[258]490    mov     dx, g_szSerialMoved
491    call    Dialogs_DisplayNotificationFromCSDX
492
[380]493.noWorkDone:
[457]494    ret
Note: See TracBrowser for help on using the repository browser.