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

Last change on this file since 485 was 483, checked in by aitotat@…, 12 years ago

Changes to Configurator v2:

  • XT-CF Sector Window address can now be selected.
  • Default port settings will now be restored when selecting device.
File size: 26.2 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-2012 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 12
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 NULL
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_MenuitemIdeControllerXTCFwindow:
190istruc MENUITEM
191 at MENUITEM.fnActivate, dw Menuitem_ActivateHexInputForMenuitemInDSSI
192 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
193 at MENUITEM.szName, dw g_szItemIdeXTCFwindow
194 at MENUITEM.szQuickInfo, dw g_szNfoIdeXTCFwindow
195 at MENUITEM.szHelp, dw g_szNfoIdeXTCFwindow
196 at MENUITEM.bFlags, db FLG_MENUITEM_BYTEVALUE
197 at MENUITEM.bType, db TYPE_MENUITEM_HEX
198 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
199 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeXTCFwindow
200 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 0A000h
201 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 0E800h
202 at MENUITEM.itemValue + ITEM_VALUE.fnValueReader, dw ReaderForXTCFwindow
203 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw WriterForXTCFwindow
204iend
205
206g_rgwChoiceToValueLookupForDevice:
207 dw DEVICE_16BIT_ATA
208 dw DEVICE_32BIT_ATA
209 dw DEVICE_8BIT_ATA
210 dw DEVICE_8BIT_XTIDE_REV1
211 dw DEVICE_8BIT_XTIDE_REV2
212 dw DEVICE_8BIT_XTCF_PIO8
213 dw DEVICE_8BIT_XTCF_DMA
214 dw DEVICE_8BIT_XTCF_MEMMAP
215 dw DEVICE_8BIT_JRIDE_ISA
216 dw DEVICE_SERIAL_PORT
217g_rgszValueToStringLookupForDevice:
218 dw g_szValueCfgDevice16b
219 dw g_szValueCfgDevice32b
220 dw g_szValueCfgDevice8b
221 dw g_szValueCfgDeviceRev1
222 dw g_szValueCfgDeviceRev2
223 dw g_szValueCfgDevicePioXTCF
224 dw g_szValueCfgDeviceDmaXTCF
225 dw g_szValueCfgDeviceMemXTCF
226 dw g_szValueCfgDeviceJrIdeIsa
227 dw g_szValueCfgDeviceSerial
228
229g_rgbChoiceToValueLookupForCOM:
230 dw '1'
231 dw '2'
232 dw '3'
233 dw '4'
234 dw '5'
235 dw '6'
236 dw '7'
237 dw '8'
238 dw '9'
239 dw 'A'
240 dw 'B'
241 dw 'C'
242 dw 'x' ; must be last entry (see reader/write routines)
243g_rgszChoiceToStringLookupForCOM:
244 dw g_szValueCfgCOM1
245 dw g_szValueCfgCOM2
246 dw g_szValueCfgCOM3
247 dw g_szValueCfgCOM4
248 dw g_szValueCfgCOM5
249 dw g_szValueCfgCOM6
250 dw g_szValueCfgCOM7
251 dw g_szValueCfgCOM8
252 dw g_szValueCfgCOM9
253 dw g_szValueCfgCOMA
254 dw g_szValueCfgCOMB
255 dw g_szValueCfgCOMC
256 dw g_szValueCfgCOMx
257 dw NULL
258
259SERIAL_DEFAULT_CUSTOM_PORT EQU 300h ; can't be any of the pre-defined COM values
260
261PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
262 db SERIAL_COM1_IOADDRESS >> 2
263 db SERIAL_COM2_IOADDRESS >> 2
264 db SERIAL_COM3_IOADDRESS >> 2
265 db SERIAL_COM4_IOADDRESS >> 2
266 db SERIAL_COM5_IOADDRESS >> 2
267 db SERIAL_COM6_IOADDRESS >> 2
268 db SERIAL_COM7_IOADDRESS >> 2
269 db SERIAL_COM8_IOADDRESS >> 2
270 db SERIAL_COM9_IOADDRESS >> 2
271 db SERIAL_COMA_IOADDRESS >> 2
272 db SERIAL_COMB_IOADDRESS >> 2
273 db SERIAL_COMC_IOADDRESS >> 2
274 db SERIAL_DEFAULT_CUSTOM_PORT >> 2 ; must be last entry (see reader/writer routines)
275SERIAL_DEFAULT_COM EQU '1'
276
277g_rgbChoiceToValueLookupForBaud:
278 dw (115200 / 115200) & 0xff
279 dw (115200 / 57600) & 0xff
280 dw (115200 / 38400) & 0xff
281 dw (115200 / 28800) & 0xff
282 dw (115200 / 19200) & 0xff
283 dw (115200 / 9600) & 0xff
284 dw (115200 / 4800) & 0xff
285 dw (115200 / 2400) & 0xff
286g_rgszChoiceToStringLookupForBaud:
287 dw g_szValueCfgBaud115_2
288 dw g_szValueCfgBaud57_6
289 dw g_szValueCfgBaud38_4
290 dw g_szValueCfgBaud28_8
291 dw g_szValueCfgBaud19_2
292 dw g_szValueCfgBaud9600
293 dw g_szValueCfgBaud4800
294 dw g_szValueCfgBaud2400
295 dw NULL
296SERIAL_DEFAULT_BAUD EQU ((115200 / 9600) & 0xff)
297
298; Section containing code
299SECTION .text
300
301;--------------------------------------------------------------------
302; IdeControllerMenu_InitializeToIdevarsOffsetInBX
303; Parameters:
304; SS:BP: Menu handle
305; Returns:
306; Nothing
307; Corrupts registers:
308; AX
309;--------------------------------------------------------------------
310ALIGN JUMP_ALIGN
311IdeControllerMenu_InitializeToIdevarsOffsetInBX:
312 lea ax, [bx+IDEVARS.drvParamsMaster]
313 mov [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
314
315 lea ax, [bx+IDEVARS.drvParamsSlave]
316 mov [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
317
318 lea ax, [bx+IDEVARS.bDevice]
319 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
320
321 lea ax, [bx+IDEVARS.wBasePort]
322 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
323
324 lea ax, [bx+IDEVARS.bSerialPort]
325 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
326
327 lea ax, [bx+IDEVARS.bSerialBaud]
328 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
329
330 lea ax, [bx+IDEVARS.wControlBlockPort]
331 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
332
333 lea ax, [bx+IDEVARS.bXTCFcontrolRegister]
334 mov [cs:g_MenuitemIdeControllerXTCFwindow+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
335
336 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
337 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
338
339 lea ax, [bx+IDEVARS.bIRQ]
340 mov [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
341 mov [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
342
343 ret
344
345
346;--------------------------------------------------------------------
347; IdeControllerMenu_EnterMenuOrModifyItemVisibility
348; Parameters:
349; SS:BP: Menu handle
350; Returns:
351; Nothing
352; Corrupts registers:
353; All, except BP
354;--------------------------------------------------------------------
355ALIGN JUMP_ALIGN
356IdeControllerMenu_EnterMenuOrModifyItemVisibility:
357 push cs
358 pop ds
359 call .EnableOrDisableCommandBlockPort
360 call .EnableOrDisableControlBlockPort
361 call .DisableIRQchannelSelection
362 call .EnableOrDisableEnableInterrupt
363 call .EnableOrDisableXTCFwindow
364 call .EnableOrDisableSerial
365 mov si, g_MenupageForIdeControllerMenu
366 jmp Menupage_ChangeToNewMenupageInDSSI
367
368
369;--------------------------------------------------------------------
370; .EnableOrDisableCommandBlockPort
371; Parameters:
372; SS:BP: Menu handle
373; Returns:
374; Nothing
375; Corrupts registers:
376; AX, BX
377;--------------------------------------------------------------------
378ALIGN JUMP_ALIGN
379.EnableOrDisableCommandBlockPort:
380 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
381 call Buffers_GetRomvarsValueToAXfromOffsetInBX
382 mov bx, g_MenuitemIdeControllerCommandBlockAddress
383 cmp al, DEVICE_8BIT_XTCF_PIO8
384 jb SHORT .EnableMenuitemFromCSBX
385 cmp al, DEVICE_SERIAL_PORT
386 je SHORT .DisableMenuitemFromCSBX
387 cmp al, DEVICE_8BIT_XTCF_MEMMAP
388 ja SHORT .EnableMenuitemFromCSBX
389 jmp SHORT .DisableMenuitemFromCSBX
390
391
392;--------------------------------------------------------------------
393; .EnableOrDisableControlBlockPort
394; Parameters:
395; SS:BP: Menu handle
396; Returns:
397; Nothing
398; Corrupts registers:
399; AX, BX
400;--------------------------------------------------------------------
401ALIGN JUMP_ALIGN
402.EnableOrDisableControlBlockPort:
403 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
404 call Buffers_GetRomvarsValueToAXfromOffsetInBX
405 mov bx, g_MenuitemIdeControllerControlBlockAddress
406 cmp al, DEVICE_8BIT_XTCF_PIO8
407 jb SHORT .EnableMenuitemFromCSBX
408 jmp SHORT .DisableMenuitemFromCSBX
409
410
411;--------------------------------------------------------------------
412; .EnableOrDisableEnableInterrupt
413; Parameters:
414; SS:BP: Menu handle
415; Returns:
416; Nothing
417; Corrupts registers:
418; AX, BX
419;--------------------------------------------------------------------
420ALIGN JUMP_ALIGN
421.EnableOrDisableEnableInterrupt:
422 call Buffers_GetRomvarsFlagsToAX
423 mov bx, g_MenuitemIdeControllerEnableInterrupt
424 test ax, FLG_ROMVARS_MODULE_IRQ
425 jz SHORT .DisableMenuitemFromCSBX
426
427 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
428 call Buffers_GetRomvarsValueToAXfromOffsetInBX
429 mov bx, g_MenuitemIdeControllerEnableInterrupt
430 cmp al, DEVICE_8BIT_XTIDE_REV2
431 jae SHORT .DisableMenuitemFromCSBX
432
433 call .EnableMenuitemFromCSBX
434 ; Fall to .EnableOrDisableIRQchannelSelection
435
436;--------------------------------------------------------------------
437; .EnableOrDisableIRQchannelSelection
438; Parameters:
439; SS:BP: Menu handle
440; Returns:
441; Nothing
442; Corrupts registers:
443; AX, BX
444;--------------------------------------------------------------------
445ALIGN JUMP_ALIGN
446.EnableOrDisableIRQchannelSelection:
447 mov bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
448 call Buffers_GetRomvarsValueToAXfromOffsetInBX
449 mov bx, g_MenuitemIdeControllerIdeIRQ
450 test al, al
451 jnz SHORT .EnableMenuitemFromCSBX
452.DisableIRQchannelSelection:
453 mov bx, g_MenuitemIdeControllerIdeIRQ
454 jz SHORT .DisableMenuitemFromCSBX
455 jmp SHORT .DisableMenuitemFromCSBX
456
457
458;--------------------------------------------------------------------
459; .EnableOrDisableXTCFwindow
460; Parameters:
461; SS:BP: Menu handle
462; Returns:
463; Nothing
464; Corrupts registers:
465; AX, BX
466;--------------------------------------------------------------------
467ALIGN JUMP_ALIGN
468.EnableOrDisableXTCFwindow:
469 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
470 call Buffers_GetRomvarsValueToAXfromOffsetInBX
471 mov bx, g_MenuitemIdeControllerXTCFwindow
472 cmp al, DEVICE_8BIT_XTCF_MEMMAP
473 je SHORT .EnableMenuitemFromCSBX
474 ; Fall to .DisableMenuitemFromCSBX
475
476
477;--------------------------------------------------------------------
478; .DisableMenuitemFromCSBX
479; .EnableMenuitemFromCSBX
480; Parameters:
481; CS:BX: Ptr to MENUITEM
482; Returns:
483; Nothing
484; Corrupts registers:
485; Nothing
486;--------------------------------------------------------------------
487ALIGN JUMP_ALIGN
488.DisableMenuitemFromCSBX:
489 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
490 ret
491
492ALIGN JUMP_ALIGN
493.EnableMenuitemFromCSBX:
494 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
495 ret
496
497
498.EnableOrDisableSerial:
499 mov bx, g_MenuitemIdeControllerSerialBaud
500 call .DisableMenuitemFromCSBX
501
502 mov bx, g_MenuitemIdeControllerSerialCOM
503 call .DisableMenuitemFromCSBX
504
505 mov bx, g_MenuitemIdeControllerSerialPort
506 call .DisableMenuitemFromCSBX
507
508 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
509 call Buffers_GetRomvarsValueToAXfromOffsetInBX
510 cmp al, DEVICE_SERIAL_PORT
511 jnz .DisableAllSerial
512
513 mov bx, g_MenuitemIdeControllerSerialCOM
514 call .EnableMenuitemFromCSBX
515
516 mov bx, g_MenuitemIdeControllerSerialBaud
517 call .EnableMenuitemFromCSBX
518
519 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
520 call Buffers_GetRomvarsValueToAXfromOffsetInBX
521 mov bx, g_MenuitemIdeControllerSerialPort
522 cmp al,'x'
523 jz .EnableMenuitemFromCSBX
524 jmp .DisableMenuitemFromCSBX
525.DisableAllSerial:
526 ret
527
528;--------------------------------------------------------------------
529; MENUITEM activation functions (.fnActivate)
530; Parameters:
531; SS:BP: Ptr to MENU
532; Returns:
533; Nothing
534; Corrupts registers:
535; All, except segments
536;--------------------------------------------------------------------
537ALIGN JUMP_ALIGN
538MasterDrive:
539 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
540 jmp SHORT DisplayMasterSlaveMenu
541
542ALIGN JUMP_ALIGN
543SlaveDrive:
544 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
545 ; Fall to DisplayMasterSlaveMenu
546
547ALIGN JUMP_ALIGN
548DisplayMasterSlaveMenu:
549;
550; block mode is not supported on serial drives, disable/enable the option as appropriate
551;
552 push bx
553 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
554 call Buffers_GetRomvarsValueToAXfromOffsetInBX
555 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
556 cmp al,DEVICE_SERIAL_PORT
557 jz .isSerial
558 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
559 jmp .isDone
560.isSerial:
561 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
562.isDone:
563 pop bx
564
565 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
566 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
567
568;------------------------------------------------------------------------------------------
569;
570; Reader/Writer Routines
571;
572; For serial drives, we pack the port number and baud rate into a single byte, and thus
573; we need to take care to properly read/write just the bits we need. In addition, since
574; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
575; default the values stored in both these words when switching in and out of the Serial
576; device choice.
577;
578; Writers:
579; Parameters:
580; AX: Value that the MENUITEM system was interacting with
581; ES:DI: ROMVARS location where the value is to be stored
582; DS:SI: MENUITEM pointer
583; Returns:
584; AX: Value to actually write to ROMVARS
585; Corrupts registers:
586; AX
587;
588; Readers:
589; Parameters:
590; AX: Value read from the ROMVARS location
591; ES:DI: ROMVARS location where the value was just read from
592; DS:SI: MENUITEM pointer
593; Returns:
594; AX: Value that the MENUITEM system will interact with and display
595; Corrupts registers:
596; AX
597;
598ALIGN JUMP_ALIGN
599WriterForXTCFwindow:
600 mov al, ah
601 xor ah, ah
602 ret
603
604ALIGN JUMP_ALIGN
605ReaderForXTCFwindow:
606 mov ah, al
607 xor al, al
608 ret
609
610
611;
612; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
613; changing in/out of a Serial device (since we use these bytes in radically different ways).
614;
615ALIGN JUMP_ALIGN
616IdeControllerMenu_WriteDevice:
617 push bx
618 push di
619 push di
620 push ax
621
622 ; Note! AL is the choice index, not device code
623 shl ax, 1 ; Selection to device code
624 mov bl, [es:di] ; what is the current Device we are changing from?
625 sub di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort ; Get ready to set the Port addresses
626 cmp al, DEVICE_SERIAL_PORT
627 je SHORT .changingToSerial
628 cmp al, DEVICE_8BIT_JRIDE_ISA
629 je SHORT .ChangingToJrIdeIsa
630
631 ; Restore ports to default values
632 cmp al, DEVICE_8BIT_ATA ; Standard ATA controllers, including 8-bit mode
633 mov ax, DEVICE_ATA_PRIMARY_PORT ; Defaults for 16-bit and better ATA devices
634 mov bx, DEVICE_ATA_PRIMARY_PORTCTRL
635 jbe SHORT .writeNonSerial
636
637 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE devices
638 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
639
640.writeNonSerial:
641 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
642 xchg bx, ax
643 stosw
644 jmp SHORT .done
645
646.ChangingToJrIdeIsa:
647 mov ax, JRIDE_DEFAULT_SEGMENT_ADDRESS
648 xor bx, bx
649 jmp SHORT .writeNonSerial
650
651.changingToSerial:
652 cmp bl, DEVICE_SERIAL_PORT
653 je SHORT .done ; if we were already serial, nothing to do
654
655 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
656
657 mov al, SERIAL_DEFAULT_COM
658 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
659 call IdeControllerMenu_SerialWriteCOM
660 stosb
661
662.done:
663 ; See if we are changing to XT-CF. If we are, store
664 ; byte for Control Register.
665 pop ax
666 pop di ; IDEVARS.bDevice
667 sub di, BYTE IDEVARS.bDevice - IDEVARS.bXTCFcontrolRegister ; IDEVARS.bXTCFcontrolRegister
668 cmp al, DEVICE_8BIT_XTCF_PIO8 >> 1
669 je SHORT .ChangingToPioModeXTCF
670 cmp al, DEVICE_8BIT_XTCF_DMA >> 1
671 je SHORT .ChangingToDmaModeXTCF
672 cmp al, DEVICE_8BIT_XTCF_MEMMAP >> 1
673 jne SHORT .NoNeedToChangeXTCFsettings
674
675 ; XT-CF Memory Mapped Mode
676 mov WORD [es:di], DEFAULT_XTCF_SECTOR_WINDOW_SEGMENT >> 8 ; Store word to clear Control Block Port high byte
677 jmp SHORT .NoNeedToChangeXTCFsettings
678.ChangingToPioModeXTCF:
679 mov BYTE [es:di], XTCF_8BIT_PIO_MODE
680 jmp SHORT .NoNeedToChangeXTCFsettings
681.ChangingToDmaModeXTCF:
682 mov BYTE [es:di], XTCF_DMA_MODE
683 ; Fall to .NoNeedToChangeXTCFsettings
684
685.NoNeedToChangeXTCFsettings:
686 pop di
687 pop bx
688 ret
689
690;
691; Doesn't modify COM character (unless it is not recognized, which would be an error case),
692; But does update the port address based on COM port selection
693;
694ALIGN JUMP_ALIGN
695IdeControllerMenu_SerialWriteCOM:
696 push ax
697 push bx
698 push si
699
700 mov si,g_rgbChoiceToValueLookupForCOM
701 mov bx,PackedCOMPortAddresses
702
703.loop:
704 mov ah,[bx]
705
706 cmp ah,(SERIAL_DEFAULT_CUSTOM_PORT >> 2)
707 jz .notFound
708
709 cmp al,[si]
710 jz .found
711
712 inc si
713 inc si
714 inc bx
715
716 jmp .loop
717
718.notFound:
719 mov al, 'x'
720
721.found:
722 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
723
724 pop si
725 pop bx
726 pop ax
727
728 ret
729
730
731;
732; Packed Port (byte) -> Numeric Port (word)
733;
734ALIGN JUMP_ALIGN
735IdeControllerMenu_SerialReadPort:
736 xor ah,ah
737 eSHL_IM ax, 2
738 ret
739
740;
741; Numeric Port (word) -> Packed Port (byte)
742; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
743;
744ALIGN JUMP_ALIGN
745IdeControllerMenu_SerialWritePort:
746 push bx
747 push si
748
749 eSHR_IM ax, 2
750 and al,0feh ; force 8-byte boundary
751
752 mov si,g_rgbChoiceToValueLookupForCOM
753 mov bx,PackedCOMPortAddresses ; loop, looking for port address in known COM address list
754
755.loop:
756 mov ah,[si]
757 cmp ah,'x'
758 jz .found
759
760 cmp al,[bx]
761 jz .found
762
763 inc si
764 inc si
765 inc bx
766
767 jmp .loop
768
769.found:
770 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
771
772 pop si
773 pop bx
774
775 ret
776
Note: See TracBrowser for help on using the repository browser.