source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm @ 585

Last change on this file since 585 was 585, checked in by aitotat, 9 years ago

Changes to Configurator v2:

  • Added support for Lo-tech 8-bit IDE Adapter (untested)
File size: 23.9 KB
RevLine 
[57]1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   "IDE Controller" menu structs and functions.
3
[376]4;
[399]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.
[399]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
[399]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[399]18;
[376]19
[57]20; Section containing initialized data
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_MenupageForIdeControllerMenu:
25istruc MENUPAGE
26    at  MENUPAGE.fnEnter,           dw  IdeControllerMenu_EnterMenuOrModifyItemVisibility
[59]27    at  MENUPAGE.fnBack,            dw  ConfigurationMenu_EnterMenuOrModifyItemVisibility
[546]28    at  MENUPAGE.wMenuitems,        dw  11
[57]29iend
30
31g_MenuitemIdeControllerBackToConfigurationMenu:
32istruc MENUITEM
33    at  MENUITEM.fnActivate,        dw  ConfigurationMenu_EnterMenuOrModifyItemVisibility
34    at  MENUITEM.szName,            dw  g_szItemBackToCfgMenu
35    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeBackToCfgMenu
36    at  MENUITEM.szHelp,            dw  g_szNfoIdeBackToCfgMenu
37    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
38    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGEBACK
39iend
40
41g_MenuitemIdeControllerMasterDrive:
42istruc MENUITEM
43    at  MENUITEM.fnActivate,        dw  MasterDrive
44    at  MENUITEM.szName,            dw  g_szItemIdeMaster
45    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeMaster
46    at  MENUITEM.szHelp,            dw  g_szNfoIdeMaster
47    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
48    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
49iend
50
51g_MenuitemIdeControllerSlaveDrive:
52istruc MENUITEM
53    at  MENUITEM.fnActivate,        dw  SlaveDrive
54    at  MENUITEM.szName,            dw  g_szItemIdeSlave
55    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSlave
56    at  MENUITEM.szHelp,            dw  g_szNfoIdeSlave
57    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
58    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGENEXT
59iend
60
[153]61g_MenuitemIdeControllerDevice:
[57]62istruc MENUITEM
[108]63    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]64    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[153]65    at  MENUITEM.szName,            dw  g_szItemIdeDevice
66    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeDevice
67    at  MENUITEM.szHelp,            dw  g_szNfoIdeDevice
[199]68    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_MODIFY_MENU
[108]69    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
[57]70    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
[153]71    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgDevice
72    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceCfgDevice
73    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  g_rgwChoiceToValueLookupForDevice
74    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForDevice
[199]75    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_WriteDevice
[57]76iend
77
78g_MenuitemIdeControllerCommandBlockAddress:
79istruc MENUITEM
80    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateHexInputForMenuitemInDSSI
81    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
82    at  MENUITEM.szName,            dw  g_szItemIdeCmdPort
83    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeCmdPort
84    at  MENUITEM.szHelp,            dw  g_szHelpIdeCmdPort
[502]85    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
[57]86    at  MENUITEM.bType,             db  TYPE_MENUITEM_HEX
87    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
88    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeCmdPort
89    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  0
90    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  -1
91iend
92
93g_MenuitemIdeControllerControlBlockAddress:
94istruc MENUITEM
95    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateHexInputForMenuitemInDSSI
96    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
97    at  MENUITEM.szName,            dw  g_szItemIdeCtrlPort
98    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeCtrlPort
99    at  MENUITEM.szHelp,            dw  g_szHelpIdeCtrlPort
[483]100    at  MENUITEM.bFlags,            db  NULL
[57]101    at  MENUITEM.bType,             db  TYPE_MENUITEM_HEX
102    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
103    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeCtrlPort
104    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  0
105    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  -1
106iend
107
[199]108g_MenuitemIdeControllerSerialCOM:
109istruc MENUITEM
110    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]111    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[199]112    at  MENUITEM.szName,            dw  g_szItemSerialCOM
113    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSerialCOM
114    at  MENUITEM.szHelp,            dw  g_szHelpIdeSerialCOM
[233]115    at  MENUITEM.bFlags,            db  FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
[242]116    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
[199]117    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
118    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgDevice
119    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szSerialCOMChoice
[233]120    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  g_rgbChoiceToValueLookupForCOM
121    at  MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup,   dw  g_rgszChoiceToStringLookupForCOM
[199]122    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_SerialWriteCOM
123iend
124
125g_MenuitemIdeControllerSerialPort:
126istruc MENUITEM
127    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateHexInputForMenuitemInDSSI
128    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
129    at  MENUITEM.szName,            dw  g_szItemSerialPort
130    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSerialPort
131    at  MENUITEM.szHelp,            dw  g_szHelpIdeSerialPort
[233]132    at  MENUITEM.bFlags,            db  FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
[199]133    at  MENUITEM.bType,             db  TYPE_MENUITEM_HEX
134    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
135    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeCmdPort
[233]136    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  8h
137    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  3f8h
[199]138    at  MENUITEM.itemValue + ITEM_VALUE.fnValueReader,              dw  IdeControllerMenu_SerialReadPort
139    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_SerialWritePort
[242]140iend
[199]141
[242]142g_MenuitemIdeControllerSerialBaud:
[199]143istruc MENUITEM
144    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]145    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[199]146    at  MENUITEM.szName,            dw  g_szItemSerialBaud
147    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSerialBaud
148    at  MENUITEM.szHelp,            dw  g_szHelpIdeSerialBaud
[233]149    at  MENUITEM.bFlags,            db  FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
[199]150    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
151    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
152    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgDevice
153    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szSerialBaudChoice
[233]154    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  g_rgbChoiceToValueLookupForBaud
155    at  MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup,   dw  g_rgszChoiceToStringLookupForBaud
[199]156iend
[242]157
[57]158g_MenuitemIdeControllerEnableInterrupt:
159istruc MENUITEM
[108]160    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]161    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
[57]162    at  MENUITEM.szName,            dw  g_szItemIdeEnIRQ
163    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeEnIRQ
164    at  MENUITEM.szHelp,            dw  g_szHelpIdeEnIRQ
[459]165    at  MENUITEM.bFlags,            db  FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
[108]166    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
[57]167    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
168    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeEnIRQ
[108]169    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBooleanFlag
[57]170    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForFlagBooleans
171    at  MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,              dw  15
172iend
173
174g_MenuitemIdeControllerIdeIRQ:
175istruc MENUITEM
176    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateUnsignedInputForMenuitemInDSSI
177    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
178    at  MENUITEM.szName,            dw  g_szItemIdeIRQ
179    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeIRQ
180    at  MENUITEM.szHelp,            dw  g_szHelpIdeIRQ
181    at  MENUITEM.bFlags,            db  FLG_MENUITEM_BYTEVALUE
182    at  MENUITEM.bType,             db  TYPE_MENUITEM_UNSIGNED
183    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
184    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeIRQ
185    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  2
186    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  15
187iend
188
[153]189g_rgwChoiceToValueLookupForDevice:
190    dw  DEVICE_16BIT_ATA
191    dw  DEVICE_32BIT_ATA
[481]192    dw  DEVICE_8BIT_ATA
193    dw  DEVICE_8BIT_XTIDE_REV1
194    dw  DEVICE_8BIT_XTIDE_REV2
195    dw  DEVICE_8BIT_XTCF_PIO8
[546]196    dw  DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
[585]197    dw  DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
[481]198    dw  DEVICE_8BIT_XTCF_DMA
199    dw  DEVICE_8BIT_JRIDE_ISA
[536]200    dw  DEVICE_8BIT_ADP50L
[153]201    dw  DEVICE_SERIAL_PORT
202g_rgszValueToStringLookupForDevice:
203    dw  g_szValueCfgDevice16b
204    dw  g_szValueCfgDevice32b
[481]205    dw  g_szValueCfgDevice8b
206    dw  g_szValueCfgDeviceRev1
207    dw  g_szValueCfgDeviceRev2
[546]208    dw  g_szValueCfgDeviceXTCFPio8
209    dw  g_szValueCfgDeviceXTCFPio8WithBIUOffload
[585]210    dw  g_szValueCfgDeviceXTCFPio16WithBIUOffload
[546]211    dw  g_szValueCfgDeviceXTCFDMA
[481]212    dw  g_szValueCfgDeviceJrIdeIsa
[536]213    dw  g_szValueCfgDeviceADP50L
[153]214    dw  g_szValueCfgDeviceSerial
[57]215
[233]216g_rgbChoiceToValueLookupForCOM:
217    dw  '1'
218    dw  '2'
219    dw  '3'
220    dw  '4'
221    dw  '5'
222    dw  '6'
223    dw  '7'
224    dw  '8'
225    dw  '9'
226    dw  'A'
227    dw  'B'
228    dw  'C'
229    dw  'x'             ; must be last entry (see reader/write routines)
[242]230g_rgszChoiceToStringLookupForCOM:
[199]231    dw  g_szValueCfgCOM1
232    dw  g_szValueCfgCOM2
233    dw  g_szValueCfgCOM3
234    dw  g_szValueCfgCOM4
235    dw  g_szValueCfgCOM5
236    dw  g_szValueCfgCOM6
237    dw  g_szValueCfgCOM7
238    dw  g_szValueCfgCOM8
239    dw  g_szValueCfgCOM9
240    dw  g_szValueCfgCOMA
241    dw  g_szValueCfgCOMB
242    dw  g_szValueCfgCOMC
243    dw  g_szValueCfgCOMx
[233]244    dw  NULL
[57]245
[567]246SERIAL_DEFAULT_CUSTOM_PORT      EQU     300h        ; can't be any of the pre-defined COM values
247SERIAL_DEFAULT_COM              EQU     '1'
248SERIAL_DEFAULT_BAUD             EQU     ((115200 / 9600)    & 0xff)
[199]249
[567]250PackedCOMPortAddresses:                             ; COM1 - COMC (or COM12)
251    db      SERIAL_COM1_IOADDRESS >> 2
[280]252    db      SERIAL_COM2_IOADDRESS >> 2
253    db      SERIAL_COM3_IOADDRESS >> 2
254    db      SERIAL_COM4_IOADDRESS >> 2
255    db      SERIAL_COM5_IOADDRESS >> 2
256    db      SERIAL_COM6_IOADDRESS >> 2
257    db      SERIAL_COM7_IOADDRESS >> 2
258    db      SERIAL_COM8_IOADDRESS >> 2
259    db      SERIAL_COM9_IOADDRESS >> 2
260    db      SERIAL_COMA_IOADDRESS >> 2
261    db      SERIAL_COMB_IOADDRESS >> 2
262    db      SERIAL_COMC_IOADDRESS >> 2
263    db      SERIAL_DEFAULT_CUSTOM_PORT >> 2         ; must be last entry (see reader/writer routines)
[242]264
[233]265g_rgbChoiceToValueLookupForBaud:
266    dw      (115200 / 115200) & 0xff
267    dw      (115200 /  57600) & 0xff
268    dw      (115200 /  38400) & 0xff
269    dw      (115200 /  28800) & 0xff
270    dw      (115200 /  19200) & 0xff
271    dw      (115200 /   9600) & 0xff
272    dw      (115200 /   4800) & 0xff
273    dw      (115200 /   2400) & 0xff
274g_rgszChoiceToStringLookupForBaud:
275    dw      g_szValueCfgBaud115_2
276    dw      g_szValueCfgBaud57_6
277    dw      g_szValueCfgBaud38_4
278    dw      g_szValueCfgBaud28_8
279    dw      g_szValueCfgBaud19_2
280    dw      g_szValueCfgBaud9600
281    dw      g_szValueCfgBaud4800
282    dw      g_szValueCfgBaud2400
283    dw      NULL
[199]284
[57]285; Section containing code
286SECTION .text
287
288;--------------------------------------------------------------------
289; IdeControllerMenu_InitializeToIdevarsOffsetInBX
290;   Parameters:
291;       SS:BP:  Menu handle
292;   Returns:
293;       Nothing
294;   Corrupts registers:
295;       AX
296;--------------------------------------------------------------------
297ALIGN JUMP_ALIGN
298IdeControllerMenu_InitializeToIdevarsOffsetInBX:
299    lea     ax, [bx+IDEVARS.drvParamsMaster]
300    mov     [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
301
302    lea     ax, [bx+IDEVARS.drvParamsSlave]
303    mov     [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
304
[153]305    lea     ax, [bx+IDEVARS.bDevice]
306    mov     [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[57]307
[481]308    lea     ax, [bx+IDEVARS.wBasePort]
[57]309    mov     [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]310
311    lea     ax, [bx+IDEVARS.bSerialPort]
[199]312    mov     [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[233]313
314    lea     ax, [bx+IDEVARS.bSerialBaud]
[199]315    mov     [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]316
[481]317    lea     ax, [bx+IDEVARS.wControlBlockPort]
[57]318    mov     [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]319
[233]320    lea     ax, [bx+IDEVARS.bSerialCOMPortChar]
[242]321    mov     [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[57]322
323    lea     ax, [bx+IDEVARS.bIRQ]
324    mov     [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
325    mov     [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[199]326
[57]327    ret
328
329
330;--------------------------------------------------------------------
331; IdeControllerMenu_EnterMenuOrModifyItemVisibility
332;   Parameters:
333;       SS:BP:  Menu handle
334;   Returns:
335;       Nothing
336;   Corrupts registers:
337;       All, except BP
338;--------------------------------------------------------------------
339ALIGN JUMP_ALIGN
340IdeControllerMenu_EnterMenuOrModifyItemVisibility:
341    push    cs
342    pop     ds
[567]343    call    .EnableOrDisableCommandBlockPort
[483]344    call    .EnableOrDisableControlBlockPort
[459]345    call    .DisableIRQchannelSelection
346    call    .EnableOrDisableEnableInterrupt
[199]347    call    .EnableOrDisableSerial
[57]348    mov     si, g_MenupageForIdeControllerMenu
349    jmp     Menupage_ChangeToNewMenupageInDSSI
350
[459]351
[57]352;--------------------------------------------------------------------
[567]353; .EnableOrDisableCommandBlockPort
354;   Parameters:
355;       SS:BP:  Menu handle
356;   Returns:
357;       Nothing
358;   Corrupts registers:
359;       AX, BX
360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362.EnableOrDisableCommandBlockPort:
363    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
364    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
365    mov     bx, g_MenuitemIdeControllerCommandBlockAddress
366    cmp     al, DEVICE_SERIAL_PORT
367    je      SHORT .DisableMenuitemFromCSBX
368    jmp     SHORT .EnableMenuitemFromCSBX
369
370
371;--------------------------------------------------------------------
[483]372; .EnableOrDisableControlBlockPort
373;   Parameters:
374;       SS:BP:  Menu handle
375;   Returns:
376;       Nothing
377;   Corrupts registers:
378;       AX, BX
379;--------------------------------------------------------------------
380ALIGN JUMP_ALIGN
381.EnableOrDisableControlBlockPort:
382    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
383    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
384    mov     bx, g_MenuitemIdeControllerControlBlockAddress
385    cmp     al, DEVICE_8BIT_XTCF_PIO8
[536]386    jb      SHORT .EnableMenuitemFromCSBX   ; Not needed for XT-CF, JR-IDE/ISA and ADP50L
[483]387    jmp     SHORT .DisableMenuitemFromCSBX
388
389
390;--------------------------------------------------------------------
[459]391; .EnableOrDisableEnableInterrupt
[57]392;   Parameters:
393;       SS:BP:  Menu handle
394;   Returns:
395;       Nothing
396;   Corrupts registers:
397;       AX, BX
398;--------------------------------------------------------------------
399ALIGN JUMP_ALIGN
[459]400.EnableOrDisableEnableInterrupt:
401    call    Buffers_GetRomvarsFlagsToAX
402    mov     bx, g_MenuitemIdeControllerEnableInterrupt
403    test    ax, FLG_ROMVARS_MODULE_IRQ
404    jz      SHORT .DisableMenuitemFromCSBX
405
406    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
407    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
408    mov     bx, g_MenuitemIdeControllerEnableInterrupt
[567]409    cmp     al, DEVICE_8BIT_XTCF_PIO8
[459]410    jae     SHORT .DisableMenuitemFromCSBX
411
[567]412    call    EnableMenuitemFromCSBX
[459]413    ; Fall to .EnableOrDisableIRQchannelSelection
414
415;--------------------------------------------------------------------
416; .EnableOrDisableIRQchannelSelection
417;   Parameters:
418;       SS:BP:  Menu handle
419;   Returns:
420;       Nothing
421;   Corrupts registers:
422;       AX, BX
423;--------------------------------------------------------------------
424ALIGN JUMP_ALIGN
425.EnableOrDisableIRQchannelSelection:
[57]426    mov     bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
427    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
428    mov     bx, g_MenuitemIdeControllerIdeIRQ
[109]429    test    al, al
[459]430    jnz     SHORT .EnableMenuitemFromCSBX
431.DisableIRQchannelSelection:
432    mov     bx, g_MenuitemIdeControllerIdeIRQ
433    ; Fall to .DisableMenuitemFromCSBX
[57]434
[459]435
[57]436;--------------------------------------------------------------------
[459]437; .DisableMenuitemFromCSBX
[57]438; .EnableMenuitemFromCSBX
439;   Parameters:
440;       CS:BX:  Ptr to MENUITEM
441;   Returns:
442;       Nothing
443;   Corrupts registers:
444;       Nothing
445;--------------------------------------------------------------------
446ALIGN JUMP_ALIGN
[459]447.DisableMenuitemFromCSBX:
[567]448    jmp     DisableMenuitemFromCSBX
[57]449
450ALIGN JUMP_ALIGN
[459]451.EnableMenuitemFromCSBX:
[567]452    jmp     EnableMenuitemFromCSBX
[57]453
[459]454
[199]455.EnableOrDisableSerial:
456    mov     bx, g_MenuitemIdeControllerSerialBaud
[567]457    call    DisableMenuitemFromCSBX
[199]458
459    mov     bx, g_MenuitemIdeControllerSerialCOM
[567]460    call    DisableMenuitemFromCSBX
[199]461
462    mov     bx, g_MenuitemIdeControllerSerialPort
[567]463    call    DisableMenuitemFromCSBX
[242]464
465    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[199]466    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
[459]467    cmp     al, DEVICE_SERIAL_PORT
[567]468    jne     .DisableAllSerial
[199]469
470    mov     bx, g_MenuitemIdeControllerSerialCOM
[567]471    call    EnableMenuitemFromCSBX
[199]472
473    mov     bx, g_MenuitemIdeControllerSerialBaud
[567]474    call    EnableMenuitemFromCSBX
[199]475
[242]476    mov     bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[199]477    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
478    mov     bx, g_MenuitemIdeControllerSerialPort
[567]479    cmp     al, 'x'
480    je      SHORT .EnableMenuitemFromCSBX
481    jmp     SHORT .DisableMenuitemFromCSBX
[199]482.DisableAllSerial:
483    ret
[242]484
[57]485;--------------------------------------------------------------------
486; MENUITEM activation functions (.fnActivate)
487;   Parameters:
488;       SS:BP:  Ptr to MENU
489;   Returns:
490;       Nothing
491;   Corrupts registers:
492;       All, except segments
493;--------------------------------------------------------------------
494ALIGN JUMP_ALIGN
495MasterDrive:
496    mov     bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
497    jmp     SHORT DisplayMasterSlaveMenu
498
499ALIGN JUMP_ALIGN
500SlaveDrive:
501    mov     bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
502    ; Fall to DisplayMasterSlaveMenu
503
504ALIGN JUMP_ALIGN
505DisplayMasterSlaveMenu:
[233]506;
[567]507; "Block Mode Transfers" and "Internal Write Cache" are not supported on serial drives, disable/enable the options as appropriate
[233]508;
509    push    bx
[242]510    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[233]511    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
512    mov     bx, g_MenuitemMasterSlaveBlockModeTransfers
[567]513
514    cmp     al, DEVICE_SERIAL_PORT
515    je      .isSerial
516
517    call    EnableMenuitemFromCSBX
518    mov     bx, g_MenuitemMasterSlaveWriteCache
519    call    EnableMenuitemFromCSBX
[233]520    jmp     .isDone
[567]521
[242]522.isSerial:
[567]523    call    DisableMenuitemFromCSBX
524    mov     bx, g_MenuitemMasterSlaveWriteCache
525    call    DisableMenuitemFromCSBX
526
[233]527.isDone:
528    pop     bx
[242]529
[57]530    call    MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
531    jmp     MasterSlaveMenu_EnterMenuOrModifyItemVisibility
[199]532
533;------------------------------------------------------------------------------------------
534;
535; Reader/Writer Routines
536;
537; For serial drives, we pack the port number and baud rate into a single byte, and thus
538; we need to take care to properly read/write just the bits we need.  In addition, since
539; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
[242]540; default the values stored in both these words when switching in and out of the Serial
[199]541; device choice.
542;
543; Writers:
544;   Parameters:
[567]545;       AX:     Value that the MENUITEM system was interacting with
546;       ES:DI:  ROMVARS location where the value is to be stored
547;       DS:SI:  MENUITEM pointer
[199]548;   Returns:
549;       AX:     Value to actually write to ROMVARS
550;   Corrupts registers:
551;       AX
552;
553; Readers:
554;   Parameters:
[567]555;       AX:     Value read from the ROMVARS location
556;       ES:DI:  ROMVARS location where the value was just read from
557;       DS:SI:  MENUITEM pointer
[199]558;   Returns:
559;       AX:     Value that the MENUITEM system will interact with and display
560;   Corrupts registers:
561;       AX
562;
[483]563ALIGN JUMP_ALIGN
564WriterForXTCFwindow:
[567]565    xor     al, al
566    SKIP2B  f
567ReaderForXTCFwindow:
[483]568    xor     ah, ah
[567]569    xchg    al, ah
[483]570    ret
[199]571
[483]572
[199]573;
574; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
[242]575; changing in/out of a Serial device (since we use these bytes in radically different ways).
[199]576;
577ALIGN JUMP_ALIGN
578IdeControllerMenu_WriteDevice:
[567]579    push    bx
580    push    di
581    push    ax
[199]582
[567]583    ; Note! AL is the choice index, not device code
584    shl     ax, 1                               ; Selection to device code
585    mov     bl, [es:di]                         ; what is the current Device we are changing from?
586    sub     di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort    ; Get ready to set the Port addresses
587    cmp     al, DEVICE_SERIAL_PORT
588    je      SHORT .ChangingToSerial
589    cmp     al, DEVICE_8BIT_JRIDE_ISA
590    je      SHORT .ChangingToJrIdeIsa
591    cmp     al, DEVICE_8BIT_ADP50L
592    je      SHORT .ChangingToADP50L
[242]593
[567]594    ; Restore ports to default values
595    cmp     al, DEVICE_8BIT_ATA                 ; Standard ATA controllers, including 8-bit mode
596    mov     ax, DEVICE_ATA_PRIMARY_PORT         ; Defaults for 16-bit and better ATA devices
597    mov     bx, DEVICE_ATA_PRIMARY_PORTCTRL
598    jbe     SHORT .WriteNonSerial
[199]599
[567]600    mov     ax, DEVICE_XTIDE_DEFAULT_PORT       ; Defaults for 8-bit XTIDE and XT-CF devices
601    mov     bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
[483]602
[567]603.WriteNonSerial:
604    stosw                                       ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
605    xchg    bx, ax
606    stosw
607    jmp     SHORT .Done
[199]608
[483]609.ChangingToJrIdeIsa:
[567]610    mov     ah, JRIDE_DEFAULT_SEGMENT_ADDRESS >> 8
611    SKIP2B  bx
[536]612
613.ChangingToADP50L:
[567]614    mov     ah, ADP50L_DEFAULT_BIOS_SEGMENT_ADDRESS >> 8
615    xor     al, al
616    xor     bx, bx
617    jmp     SHORT .WriteNonSerial
[199]618
[567]619.ChangingToSerial:
620    cmp     bl, DEVICE_SERIAL_PORT
621    je      SHORT .Done                         ; if we were already serial, nothing to do
[199]622
[567]623    mov     BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
[233]624
[567]625    mov     al, SERIAL_DEFAULT_COM
626    sub     di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
627    call    IdeControllerMenu_SerialWriteCOM
628    stosb
[242]629
[567]630.Done:
631    pop     ax
632    pop     di          ; IDEVARS.bDevice
633    pop     bx
634    ret
[199]635
636;
[233]637; Doesn't modify COM character (unless it is not recognized, which would be an error case),
[242]638; But does update the port address based on COM port selection
639;
[199]640ALIGN JUMP_ALIGN
641IdeControllerMenu_SerialWriteCOM:
[567]642    push    ax
643    push    bx
644    push    si
[242]645
[567]646    mov     si, g_rgbChoiceToValueLookupForCOM
647    mov     bx, PackedCOMPortAddresses
[199]648
[233]649.loop:
[567]650    mov     ah, [bx]
[199]651
[567]652    cmp     ah, (SERIAL_DEFAULT_CUSTOM_PORT >> 2)
653    je      .notFound
[242]654
[567]655    cmp     al, [si]
656    je      .found
[242]657
[567]658    inc     si
659    inc     si
660    inc     bx
[242]661
[567]662    jmp     .loop
[199]663
[233]664.notFound:
[567]665    mov     al, 'x'
[242]666
667.found:
[567]668    mov     [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
[199]669
[567]670    pop     si
671    pop     bx
672    pop     ax
[242]673
[567]674    ret
[199]675
[242]676
[199]677;
[233]678; Packed Port (byte) -> Numeric Port (word)
[242]679;
[199]680ALIGN JUMP_ALIGN
[233]681IdeControllerMenu_SerialReadPort:
[567]682    xor     ah, ah
683    eSHL_IM ax, 2
684    ret
[199]685
686;
[233]687; Numeric Port (word) -> Packed Port (byte)
688; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
[199]689;
690ALIGN JUMP_ALIGN
[242]691IdeControllerMenu_SerialWritePort:
[567]692    push    bx
693    push    si
[199]694
[567]695    eSHR_IM ax, 2
696    and     al, 0feh            ; force 8-byte boundary
[199]697
[567]698    mov     si, g_rgbChoiceToValueLookupForCOM
699    mov     bx, PackedCOMPortAddresses          ; loop, looking for port address in known COM address list
[233]700
701.loop:
[567]702    mov     ah, [si]
703    cmp     ah, 'x'
704    je      .found
[242]705
[567]706    cmp     al, [bx]
707    je      .found
[242]708
[567]709    inc     si
710    inc     si
711    inc     bx
[242]712
[567]713    jmp     .loop
[199]714
[242]715.found:
[567]716    mov     [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
[233]717
[567]718    pop     si
719    pop     bx
[199]720
[567]721    ret
[199]722
Note: See TracBrowser for help on using the repository browser.