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

Last change on this file since 587 was 585, checked in by Tomi Tilli, 10 years ago

Changes to Configurator v2:

  • Added support for Lo-tech 8-bit IDE Adapter (untested)
File size: 23.9 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_PIO16_WITH_BIU_OFFLOAD
198 dw DEVICE_8BIT_XTCF_DMA
199 dw DEVICE_8BIT_JRIDE_ISA
200 dw DEVICE_8BIT_ADP50L
201 dw DEVICE_SERIAL_PORT
202g_rgszValueToStringLookupForDevice:
203 dw g_szValueCfgDevice16b
204 dw g_szValueCfgDevice32b
205 dw g_szValueCfgDevice8b
206 dw g_szValueCfgDeviceRev1
207 dw g_szValueCfgDeviceRev2
208 dw g_szValueCfgDeviceXTCFPio8
209 dw g_szValueCfgDeviceXTCFPio8WithBIUOffload
210 dw g_szValueCfgDeviceXTCFPio16WithBIUOffload
211 dw g_szValueCfgDeviceXTCFDMA
212 dw g_szValueCfgDeviceJrIdeIsa
213 dw g_szValueCfgDeviceADP50L
214 dw g_szValueCfgDeviceSerial
215
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)
230g_rgszChoiceToStringLookupForCOM:
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
244 dw NULL
245
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)
249
250PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
251 db SERIAL_COM1_IOADDRESS >> 2
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)
264
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
284
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
305 lea ax, [bx+IDEVARS.bDevice]
306 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
307
308 lea ax, [bx+IDEVARS.wBasePort]
309 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
310
311 lea ax, [bx+IDEVARS.bSerialPort]
312 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
313
314 lea ax, [bx+IDEVARS.bSerialBaud]
315 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
316
317 lea ax, [bx+IDEVARS.wControlBlockPort]
318 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
319
320 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
321 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
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
326
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
343 call .EnableOrDisableCommandBlockPort
344 call .EnableOrDisableControlBlockPort
345 call .DisableIRQchannelSelection
346 call .EnableOrDisableEnableInterrupt
347 call .EnableOrDisableSerial
348 mov si, g_MenupageForIdeControllerMenu
349 jmp Menupage_ChangeToNewMenupageInDSSI
350
351
352;--------------------------------------------------------------------
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;--------------------------------------------------------------------
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
386 jb SHORT .EnableMenuitemFromCSBX ; Not needed for XT-CF, JR-IDE/ISA and ADP50L
387 jmp SHORT .DisableMenuitemFromCSBX
388
389
390;--------------------------------------------------------------------
391; .EnableOrDisableEnableInterrupt
392; Parameters:
393; SS:BP: Menu handle
394; Returns:
395; Nothing
396; Corrupts registers:
397; AX, BX
398;--------------------------------------------------------------------
399ALIGN JUMP_ALIGN
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
409 cmp al, DEVICE_8BIT_XTCF_PIO8
410 jae SHORT .DisableMenuitemFromCSBX
411
412 call EnableMenuitemFromCSBX
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:
426 mov bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
427 call Buffers_GetRomvarsValueToAXfromOffsetInBX
428 mov bx, g_MenuitemIdeControllerIdeIRQ
429 test al, al
430 jnz SHORT .EnableMenuitemFromCSBX
431.DisableIRQchannelSelection:
432 mov bx, g_MenuitemIdeControllerIdeIRQ
433 ; Fall to .DisableMenuitemFromCSBX
434
435
436;--------------------------------------------------------------------
437; .DisableMenuitemFromCSBX
438; .EnableMenuitemFromCSBX
439; Parameters:
440; CS:BX: Ptr to MENUITEM
441; Returns:
442; Nothing
443; Corrupts registers:
444; Nothing
445;--------------------------------------------------------------------
446ALIGN JUMP_ALIGN
447.DisableMenuitemFromCSBX:
448 jmp DisableMenuitemFromCSBX
449
450ALIGN JUMP_ALIGN
451.EnableMenuitemFromCSBX:
452 jmp EnableMenuitemFromCSBX
453
454
455.EnableOrDisableSerial:
456 mov bx, g_MenuitemIdeControllerSerialBaud
457 call DisableMenuitemFromCSBX
458
459 mov bx, g_MenuitemIdeControllerSerialCOM
460 call DisableMenuitemFromCSBX
461
462 mov bx, g_MenuitemIdeControllerSerialPort
463 call DisableMenuitemFromCSBX
464
465 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
466 call Buffers_GetRomvarsValueToAXfromOffsetInBX
467 cmp al, DEVICE_SERIAL_PORT
468 jne .DisableAllSerial
469
470 mov bx, g_MenuitemIdeControllerSerialCOM
471 call EnableMenuitemFromCSBX
472
473 mov bx, g_MenuitemIdeControllerSerialBaud
474 call EnableMenuitemFromCSBX
475
476 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
477 call Buffers_GetRomvarsValueToAXfromOffsetInBX
478 mov bx, g_MenuitemIdeControllerSerialPort
479 cmp al, 'x'
480 je SHORT .EnableMenuitemFromCSBX
481 jmp SHORT .DisableMenuitemFromCSBX
482.DisableAllSerial:
483 ret
484
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:
506;
507; "Block Mode Transfers" and "Internal Write Cache" are not supported on serial drives, disable/enable the options as appropriate
508;
509 push bx
510 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
511 call Buffers_GetRomvarsValueToAXfromOffsetInBX
512 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
513
514 cmp al, DEVICE_SERIAL_PORT
515 je .isSerial
516
517 call EnableMenuitemFromCSBX
518 mov bx, g_MenuitemMasterSlaveWriteCache
519 call EnableMenuitemFromCSBX
520 jmp .isDone
521
522.isSerial:
523 call DisableMenuitemFromCSBX
524 mov bx, g_MenuitemMasterSlaveWriteCache
525 call DisableMenuitemFromCSBX
526
527.isDone:
528 pop bx
529
530 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
531 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
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
540; default the values stored in both these words when switching in and out of the Serial
541; device choice.
542;
543; Writers:
544; Parameters:
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
548; Returns:
549; AX: Value to actually write to ROMVARS
550; Corrupts registers:
551; AX
552;
553; Readers:
554; Parameters:
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
558; Returns:
559; AX: Value that the MENUITEM system will interact with and display
560; Corrupts registers:
561; AX
562;
563ALIGN JUMP_ALIGN
564WriterForXTCFwindow:
565 xor al, al
566 SKIP2B f
567ReaderForXTCFwindow:
568 xor ah, ah
569 xchg al, ah
570 ret
571
572
573;
574; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
575; changing in/out of a Serial device (since we use these bytes in radically different ways).
576;
577ALIGN JUMP_ALIGN
578IdeControllerMenu_WriteDevice:
579 push bx
580 push di
581 push ax
582
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
593
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
599
600 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE and XT-CF devices
601 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
602
603.WriteNonSerial:
604 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
605 xchg bx, ax
606 stosw
607 jmp SHORT .Done
608
609.ChangingToJrIdeIsa:
610 mov ah, JRIDE_DEFAULT_SEGMENT_ADDRESS >> 8
611 SKIP2B bx
612
613.ChangingToADP50L:
614 mov ah, ADP50L_DEFAULT_BIOS_SEGMENT_ADDRESS >> 8
615 xor al, al
616 xor bx, bx
617 jmp SHORT .WriteNonSerial
618
619.ChangingToSerial:
620 cmp bl, DEVICE_SERIAL_PORT
621 je SHORT .Done ; if we were already serial, nothing to do
622
623 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
624
625 mov al, SERIAL_DEFAULT_COM
626 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
627 call IdeControllerMenu_SerialWriteCOM
628 stosb
629
630.Done:
631 pop ax
632 pop di ; IDEVARS.bDevice
633 pop bx
634 ret
635
636;
637; Doesn't modify COM character (unless it is not recognized, which would be an error case),
638; But does update the port address based on COM port selection
639;
640ALIGN JUMP_ALIGN
641IdeControllerMenu_SerialWriteCOM:
642 push ax
643 push bx
644 push si
645
646 mov si, g_rgbChoiceToValueLookupForCOM
647 mov bx, PackedCOMPortAddresses
648
649.loop:
650 mov ah, [bx]
651
652 cmp ah, (SERIAL_DEFAULT_CUSTOM_PORT >> 2)
653 je .notFound
654
655 cmp al, [si]
656 je .found
657
658 inc si
659 inc si
660 inc bx
661
662 jmp .loop
663
664.notFound:
665 mov al, 'x'
666
667.found:
668 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
669
670 pop si
671 pop bx
672 pop ax
673
674 ret
675
676
677;
678; Packed Port (byte) -> Numeric Port (word)
679;
680ALIGN JUMP_ALIGN
681IdeControllerMenu_SerialReadPort:
682 xor ah, ah
683 eSHL_IM ax, 2
684 ret
685
686;
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
689;
690ALIGN JUMP_ALIGN
691IdeControllerMenu_SerialWritePort:
692 push bx
693 push si
694
695 eSHR_IM ax, 2
696 and al, 0feh ; force 8-byte boundary
697
698 mov si, g_rgbChoiceToValueLookupForCOM
699 mov bx, PackedCOMPortAddresses ; loop, looking for port address in known COM address list
700
701.loop:
702 mov ah, [si]
703 cmp ah, 'x'
704 je .found
705
706 cmp al, [bx]
707 je .found
708
709 inc si
710 inc si
711 inc bx
712
713 jmp .loop
714
715.found:
716 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
717
718 pop si
719 pop bx
720
721 ret
722
Note: See TracBrowser for help on using the repository browser.