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

Last change on this file since 569 was 567, checked in by krille_n_@…, 10 years ago

Changes:

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