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

Last change on this file since 607 was 607, checked in by Tomi Tilli, 3 years ago
  • IRQ can no longer be accidentally left enabled for XT-CF
File size: 27.3 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_XTIDE_REV2_OLIVETTI
196 dw DEVICE_8BIT_XTCF_PIO8
197 dw DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
198 dw DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
199 dw DEVICE_8BIT_XTCF_DMA
200 dw DEVICE_8BIT_JRIDE_ISA
201 dw DEVICE_8BIT_ADP50L
202 dw DEVICE_SERIAL_PORT
203g_rgszValueToStringLookupForDevice:
204 dw g_szValueCfgDevice16b
205 dw g_szValueCfgDevice32b
206 dw g_szValueCfgDevice8b
207 dw g_szValueCfgDeviceRev1
208 dw g_szValueCfgDeviceRev2
209 dw g_szValueCfgDeviceRev2Olivetti
210 dw g_szValueCfgDeviceXTCFPio8
211 dw g_szValueCfgDeviceXTCFPio8WithBIUOffload
212 dw g_szValueCfgDeviceXTCFPio16WithBIUOffload
213 dw g_szValueCfgDeviceXTCFDMA
214 dw g_szValueCfgDeviceJrIdeIsa
215 dw g_szValueCfgDeviceADP50L
216 dw g_szValueCfgDeviceSerial
217
218g_rgbChoiceToValueLookupForCOM:
219 dw '1'
220 dw '2'
221 dw '3'
222 dw '4'
223 dw '5'
224 dw '6'
225 dw '7'
226 dw '8'
227 dw '9'
228 dw 'A'
229 dw 'B'
230 dw 'C'
231 dw 'x' ; must be last entry (see reader/write routines)
232g_rgszChoiceToStringLookupForCOM:
233 dw g_szValueCfgCOM1
234 dw g_szValueCfgCOM2
235 dw g_szValueCfgCOM3
236 dw g_szValueCfgCOM4
237 dw g_szValueCfgCOM5
238 dw g_szValueCfgCOM6
239 dw g_szValueCfgCOM7
240 dw g_szValueCfgCOM8
241 dw g_szValueCfgCOM9
242 dw g_szValueCfgCOMA
243 dw g_szValueCfgCOMB
244 dw g_szValueCfgCOMC
245 dw g_szValueCfgCOMx
246 dw NULL
247
248SERIAL_DEFAULT_CUSTOM_PORT EQU 300h ; can't be any of the pre-defined COM values
249SERIAL_DEFAULT_COM EQU '1'
250SERIAL_DEFAULT_BAUD EQU ((115200 / 9600) & 0xff)
251
252PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
253 db SERIAL_COM1_IOADDRESS >> 2
254 db SERIAL_COM2_IOADDRESS >> 2
255 db SERIAL_COM3_IOADDRESS >> 2
256 db SERIAL_COM4_IOADDRESS >> 2
257 db SERIAL_COM5_IOADDRESS >> 2
258 db SERIAL_COM6_IOADDRESS >> 2
259 db SERIAL_COM7_IOADDRESS >> 2
260 db SERIAL_COM8_IOADDRESS >> 2
261 db SERIAL_COM9_IOADDRESS >> 2
262 db SERIAL_COMA_IOADDRESS >> 2
263 db SERIAL_COMB_IOADDRESS >> 2
264 db SERIAL_COMC_IOADDRESS >> 2
265 db SERIAL_DEFAULT_CUSTOM_PORT >> 2 ; must be last entry (see reader/writer routines)
266
267g_rgbChoiceToValueLookupForBaud:
268 dw (115200 / 115200) & 0xff
269 dw (115200 / 57600) & 0xff
270 dw (115200 / 38400) & 0xff
271 dw (115200 / 28800) & 0xff
272 dw (115200 / 19200) & 0xff
273 dw (115200 / 9600) & 0xff
274 dw (115200 / 4800) & 0xff
275 dw (115200 / 2400) & 0xff
276g_rgszChoiceToStringLookupForBaud:
277 dw g_szValueCfgBaud115_2
278 dw g_szValueCfgBaud57_6
279 dw g_szValueCfgBaud38_4
280 dw g_szValueCfgBaud28_8
281 dw g_szValueCfgBaud19_2
282 dw g_szValueCfgBaud9600
283 dw g_szValueCfgBaud4800
284 dw g_szValueCfgBaud2400
285 dw NULL
286
287; Section containing code
288SECTION .text
289
290;--------------------------------------------------------------------
291; IdeControllerMenu_InitializeToIdevarsOffsetInBX
292; Parameters:
293; SS:BP: Menu handle
294; Returns:
295; Nothing
296; Corrupts registers:
297; AX
298;--------------------------------------------------------------------
299ALIGN JUMP_ALIGN
300IdeControllerMenu_InitializeToIdevarsOffsetInBX:
301 lea ax, [bx+IDEVARS.drvParamsMaster]
302 mov [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
303
304 lea ax, [bx+IDEVARS.drvParamsSlave]
305 mov [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
306
307 lea ax, [bx+IDEVARS.bDevice]
308 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
309
310%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
311%if IDEVARS.wBasePort = 0
312 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
313%else
314 lea ax, [bx+IDEVARS.wBasePort]
315 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
316%endif
317
318%if IDEVARS.bSerialPort = 0
319 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
320%else
321 lea ax, [bx+IDEVARS.bSerialPort]
322 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
323%endif
324%endif
325
326 lea ax, [bx+IDEVARS.bSerialBaud]
327 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
328
329 lea ax, [bx+IDEVARS.wControlBlockPort]
330 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
331
332 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
333 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
334
335 lea ax, [bx+IDEVARS.bIRQ]
336 mov [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
337 mov [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
338
339 ret
340
341
342;--------------------------------------------------------------------
343; IdeControllerMenu_EnterMenuOrModifyItemVisibility
344; Parameters:
345; SS:BP: Menu handle
346; Returns:
347; Nothing
348; Corrupts registers:
349; All, except BP
350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
352IdeControllerMenu_EnterMenuOrModifyItemVisibility:
353 push cs
354 pop ds
355 call .EnableOrDisableCommandBlockPort
356 call .EnableOrDisableControlBlockPort
357 call .DisableIRQchannelSelection
358 call .EnableOrDisableEnableInterrupt
359 call .EnableOrDisableSerial
360 mov si, g_MenupageForIdeControllerMenu
361 jmp Menupage_ChangeToNewMenupageInDSSI
362
363
364;--------------------------------------------------------------------
365; .EnableOrDisableCommandBlockPort
366; Parameters:
367; SS:BP: Menu handle
368; Returns:
369; Nothing
370; Corrupts registers:
371; AX, BX
372;--------------------------------------------------------------------
373ALIGN JUMP_ALIGN
374.EnableOrDisableCommandBlockPort:
375 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
376 call Buffers_GetRomvarsValueToAXfromOffsetInBX
377 mov bx, g_MenuitemIdeControllerCommandBlockAddress
378 cmp al, DEVICE_SERIAL_PORT
379 je SHORT .DisableMenuitemFromCSBX
380 jmp SHORT .EnableMenuitemFromCSBX
381
382
383;--------------------------------------------------------------------
384; .EnableOrDisableControlBlockPort
385; Parameters:
386; SS:BP: Menu handle
387; Returns:
388; Nothing
389; Corrupts registers:
390; AX, BX
391;--------------------------------------------------------------------
392ALIGN JUMP_ALIGN
393.EnableOrDisableControlBlockPort:
394 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
395 call Buffers_GetRomvarsValueToAXfromOffsetInBX
396 mov bx, g_MenuitemIdeControllerControlBlockAddress
397 cmp al, DEVICE_8BIT_XTCF_PIO8
398 jb SHORT .EnableMenuitemFromCSBX ; Not needed for XT-CF, JR-IDE/ISA and ADP50L
399 jmp SHORT .DisableMenuitemFromCSBX
400
401
402;--------------------------------------------------------------------
403; .EnableOrDisableEnableInterrupt
404; Parameters:
405; SS:BP: Menu handle
406; Returns:
407; Nothing
408; Corrupts registers:
409; AX, BX
410;--------------------------------------------------------------------
411ALIGN JUMP_ALIGN
412.EnableOrDisableEnableInterrupt:
413 call Buffers_GetRomvarsFlagsToAX
414 mov bx, g_MenuitemIdeControllerEnableInterrupt
415 test ax, FLG_ROMVARS_MODULE_IRQ
416 jz SHORT .DisableMenuitemFromCSBX
417
418 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
419 call Buffers_GetRomvarsValueToAXfromOffsetInBX
420 mov bx, g_MenuitemIdeControllerEnableInterrupt
421 cmp al, DEVICE_8BIT_XTCF_PIO8
422 jae SHORT .DisableMenuitemFromCSBX
423
424 call EnableMenuitemFromCSBX
425 ; Fall to .EnableOrDisableIRQchannelSelection
426
427;--------------------------------------------------------------------
428; .EnableOrDisableIRQchannelSelection
429; Parameters:
430; SS:BP: Menu handle
431; Returns:
432; Nothing
433; Corrupts registers:
434; AX, BX
435;--------------------------------------------------------------------
436ALIGN JUMP_ALIGN
437.EnableOrDisableIRQchannelSelection:
438 mov bx, [g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
439 call Buffers_GetRomvarsValueToAXfromOffsetInBX
440 mov bx, g_MenuitemIdeControllerIdeIRQ
441 test al, al
442 jnz SHORT .EnableMenuitemFromCSBX
443.DisableIRQchannelSelection:
444 mov bx, g_MenuitemIdeControllerIdeIRQ
445 ; Fall to .DisableMenuitemFromCSBX
446
447
448;--------------------------------------------------------------------
449; .DisableMenuitemFromCSBX
450; .EnableMenuitemFromCSBX
451; Parameters:
452; CS:BX: Ptr to MENUITEM
453; Returns:
454; Nothing
455; Corrupts registers:
456; Nothing
457;--------------------------------------------------------------------
458ALIGN JUMP_ALIGN
459.DisableMenuitemFromCSBX:
460 jmp DisableMenuitemFromCSBX
461
462ALIGN JUMP_ALIGN
463.EnableMenuitemFromCSBX:
464 jmp EnableMenuitemFromCSBX
465
466
467;--------------------------------------------------------------------
468; .EnableOrDisableSerial
469; Parameters:
470; SS:BP: Menu handle
471; Returns:
472; Nothing
473; Corrupts registers:
474; AX, BX
475;--------------------------------------------------------------------
476.EnableOrDisableSerial:
477 mov bx, g_MenuitemIdeControllerSerialBaud
478 call DisableMenuitemFromCSBX
479
480 mov bx, g_MenuitemIdeControllerSerialCOM
481 call DisableMenuitemFromCSBX
482
483 mov bx, g_MenuitemIdeControllerSerialPort
484 call DisableMenuitemFromCSBX
485
486 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
487 call Buffers_GetRomvarsValueToAXfromOffsetInBX
488 cmp al, DEVICE_SERIAL_PORT
489 jne SHORT .DisableAllSerial
490
491 mov bx, g_MenuitemIdeControllerSerialCOM
492 call EnableMenuitemFromCSBX
493
494 mov bx, g_MenuitemIdeControllerSerialBaud
495 call EnableMenuitemFromCSBX
496
497 mov bx, [g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
498 call Buffers_GetRomvarsValueToAXfromOffsetInBX
499 mov bx, g_MenuitemIdeControllerSerialPort
500 cmp al, 'x'
501 je SHORT .EnableMenuitemFromCSBX
502 jmp SHORT .DisableMenuitemFromCSBX
503.DisableAllSerial:
504 ret
505
506
507;--------------------------------------------------------------------
508; MENUITEM activation functions (.fnActivate)
509; Parameters:
510; SS:BP: Ptr to MENU
511; Returns:
512; Nothing
513; Corrupts registers:
514; All, except segments
515;--------------------------------------------------------------------
516ALIGN JUMP_ALIGN
517MasterDrive:
518 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
519 jmp SHORT DisplayMasterSlaveMenu
520
521ALIGN JUMP_ALIGN
522SlaveDrive:
523 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
524 ; Fall to DisplayMasterSlaveMenu
525
526ALIGN JUMP_ALIGN
527DisplayMasterSlaveMenu:
528;
529; "Block Mode Transfers" and "Internal Write Cache" are not supported on serial drives, disable/enable the options as appropriate
530;
531 push bx
532 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
533 call Buffers_GetRomvarsValueToAXfromOffsetInBX
534 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
535
536 cmp al, DEVICE_SERIAL_PORT
537 je .isSerial
538
539 call EnableMenuitemFromCSBX
540 mov bx, g_MenuitemMasterSlaveWriteCache
541 call EnableMenuitemFromCSBX
542 jmp .isDone
543
544.isSerial:
545 call DisableMenuitemFromCSBX
546 mov bx, g_MenuitemMasterSlaveWriteCache
547 call DisableMenuitemFromCSBX
548
549.isDone:
550 pop bx
551
552 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
553 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
554
555
556;--------------------------------------------------------------------
557; IdeControllerMenu_WriteDevice
558;
559; Sets default values to ports and other device dependent stuff
560;
561; Parameters:
562; AX: IDE controller/Device type menu choice index
563; ES:DI: Ptr to IDEVARS.bDevice
564; DS:SI: MENUITEM pointer
565; Returns:
566; AX: IDE controller/Device type menu choice index
567; Corrupts registers:
568; BX, DX
569;--------------------------------------------------------------------
570ALIGN JUMP_ALIGN
571IdeControllerMenu_WriteDevice:
572 push di
573 push ax
574
575 mov bl, [es:di] ; What is the current Device we are changing from?
576 sub di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort ; Get ready to set the Port addresses
577
578 ; Note! AL is the choice index, not device code
579 eSHL_IM al, 1 ; Selection to device code
580 jz SHORT .StandardIdeDevice ; DEVICE_16BIT_ATA
581
582 cmp al, DEVICE_8BIT_ATA
583 ja SHORT .NotStandardIdeDevice
584 jb SHORT .AdvancedAtaDevice ; DEVICE_32BIT_ATA
585 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE
586 jmp SHORT .CheckZF
587
588.AdvancedAtaDevice:
589 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_ADVANCED_ATA >> 8
590.CheckZF:
591 jz SHORT .SupportForDeviceNotAvailable
592
593 ; Standard ATA controllers, including 8-bit mode
594.StandardIdeDevice:
595 ; Enable IRQ for standard ATA
596
597 lea ax, [di-ROMVARS.ideVars0+IDEVARS.wBasePort]
598 mov bl, IDEVARS_size
599 div bl
600 push ax
601 mov bx, .rgbDefaultIrqForStdIde ; Enable interrupt for primary and secondary IDE
602 xlat
603 mov [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], al
604 pop ax
605 sub bx, BYTE .rgbDefaultIrqForStdIde - .rgbLowByteOfStdIdeInterfacePorts
606 xlat ; DS=CS so no segment override needed
607 mov ah, 1 ; DEVICE_ATA_*_PORT >> 8
608 mov bh, 3 ; DEVICE_ATA_*_PORTCTRL >> 8
609 mov bl, al
610 jmp SHORT .WriteNonSerial
611
612.rgbLowByteOfStdIdeInterfacePorts: ; Defaults for 16-bit and better ATA devices
613 db DEVICE_ATA_PRIMARY_PORT & 0FFh
614 db DEVICE_ATA_SECONDARY_PORT & 0FFh
615 db DEVICE_ATA_TERTIARY_PORT & 0FFh
616 db DEVICE_ATA_QUATERNARY_PORT & 0FFh
617.rgbDefaultIrqForStdIde:
618 db 14
619 db 15
620 db 0 ; These can vary so lets disable by default
621 db 0
622
623.NotStandardIdeDevice:
624 cmp al, DEVICE_SERIAL_PORT
625 jb SHORT .NotSerialDevice
626 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_SERIAL >> 8
627 jnz SHORT .ChangingToSerial
628
629.SupportForDeviceNotAvailable:
630 mov dx, g_szUnsupportedDevice
631 call Dialogs_DisplayErrorFromCSDX
632
633 ; Restore device type to the previous value
634 pop ax ; Get choice index from stack
635 mov al, bl ; Previous device type to AL
636 shr al, 1 ; Device code to choice index
637 pop di
638 ret
639
640.NotSerialDevice:
641 ; Remaining device types all require MODULE_8BIT_IDE or MODULE_8BIT_IDE_ADVANCED
642 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE | FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED
643 jz SHORT .SupportForDeviceNotAvailable
644
645 ; We know MODULE_8BIT_IDE is included
646 lahf ; Save the PF
647 cmp al, DEVICE_8BIT_XTIDE_REV2_OLIVETTI
648 jbe SHORT .ChangingToXTIDEorXTCF
649 sahf ; Restore the PF
650 jpo SHORT .SupportForDeviceNotAvailable ; Jump if no MODULE_8BIT_IDE_ADVANCED
651 cmp al, DEVICE_8BIT_JRIDE_ISA
652 je SHORT .ChangingToJrIdeIsa
653 cmp al, DEVICE_8BIT_ADP50L
654 je SHORT .ChangingToADP50L
655
656.ChangingToXTIDEorXTCF:
657 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE and XT-CF devices
658 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
659
660 ; XT-CF does not support IRQ so it must be disabled (IRQ setting is not visible for XT-CF)
661 ; XTIDE does not use IRQs by default
662 mov BYTE [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], 0
663
664.WriteNonSerial:
665 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
666 xchg bx, ax
667 stosw
668 jmp SHORT .Done
669
670.ChangingToJrIdeIsa:
671 mov ah, JRIDE_DEFAULT_SEGMENT_ADDRESS >> 8
672 SKIP2B bx
673
674.ChangingToADP50L:
675 mov ah, ADP50L_DEFAULT_BIOS_SEGMENT_ADDRESS >> 8
676 xor al, al
677 xor bx, bx
678 jmp SHORT .WriteNonSerial
679
680.ChangingToSerial:
681;
682; For serial drives, we pack the port number and baud rate into a single byte, and thus
683; we need to take care to properly read/write just the bits we need. In addition, since
684; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
685; default the values stored in both these words when switching in and out of the Serial
686; device choice.
687;
688 mov al, SERIAL_DEFAULT_COM
689 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
690 mov [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], ah ; Clear .bIRQ to keep the boot menu from printing it
691
692 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
693 call IdeControllerMenu_SerialWriteCOM
694 stosb
695
696.Done:
697 pop ax
698 pop di
699 ret
700
701
702;--------------------------------------------------------------------
703; IdeControllerMenu_SerialWriteCOM
704;
705; Updates the port address based on COM port selection
706;
707; Parameters:
708; AL: COM port
709; ES:DI: Ptr to IDEVARS.bSerialCOMPortChar
710; DS:SI: MENUITEM pointer
711; Returns:
712; Nothing
713; Corrupts registers:
714; BX
715;--------------------------------------------------------------------
716ALIGN JUMP_ALIGN
717IdeControllerMenu_SerialWriteCOM:
718 push ax
719 push si
720
721 mov bx, PackedCOMPortAddresses - 1
722 mov si, g_rgbChoiceToValueLookupForCOM - 2
723
724.Loop:
725 inc bx
726 inc si
727 inc si
728
729 mov ah, [bx]
730 cmp ah, SERIAL_DEFAULT_CUSTOM_PORT >> 2
731 je SHORT .NotFound
732
733 cmp al, [si]
734 jne SHORT .Loop
735
736.NotFound:
737 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
738
739 pop si
740 pop ax
741 ret
742
743
744;--------------------------------------------------------------------
745; IdeControllerMenu_SerialReadPort
746;
747; Packed Port (byte) -> Numeric Port (word)
748;
749; Parameters:
750; AX: Value read from the ROMVARS location
751; ES:DI: ROMVARS location where the value was just read from
752; DS:SI: MENUITEM pointer
753; Returns:
754; AX: Value that the MENUITEM system will interact with and display
755; Corrupts registers:
756; Nothing
757;--------------------------------------------------------------------
758ALIGN JUMP_ALIGN
759IdeControllerMenu_SerialReadPort:
760 xor ah, ah
761 eSHL_IM ax, 2
762 ret
763
764
765;--------------------------------------------------------------------
766; IdeControllerMenu_SerialWritePort
767;
768; Numeric Port (word) -> Packed Port (byte)
769;
770; And convert from Custom to a defined COM port if we
771; match one of the pre-defined COM port numbers
772;
773; Parameters:
774; AX: Value that the MENUITEM system was interacting with
775; ES:DI: ROMVARS location where the value is to be stored
776; DS:SI: MENUITEM pointer
777; Returns:
778; AX: Value to actually write to ROMVARS
779; Corrupts registers:
780; BX
781;--------------------------------------------------------------------
782ALIGN JUMP_ALIGN
783IdeControllerMenu_SerialWritePort:
784 push si
785
786 eSHR_IM ax, 2
787 and al, 0FEh ; Force 8-byte boundary
788
789 mov si, g_rgbChoiceToValueLookupForCOM - 2
790 mov bx, PackedCOMPortAddresses - 1 ; Loop, looking for port address in known COM address list
791
792.Loop:
793 inc si
794 inc si
795 inc bx
796
797 mov ah, [si]
798 cmp ah, 'x'
799 je SHORT .Found
800
801 cmp al, [bx]
802 jne SHORT .Loop
803
804.Found:
805 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
806
807 pop si
808 ret
809
Note: See TracBrowser for help on using the repository browser.