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

Last change on this file since 498 was 491, checked in by krille_n_@…, 12 years ago

Changes:

  • Added a new define (USE_UNDOC_INTEL) that enables optimizations possible by using undocumented instructions available on all Intel processors and truly compatible clones. AFAIK the only exceptions are the NEC V-series and the Sony CXQ70108 processors so this option should be safe for use on the AT builds.
  • Building BIOSDRVS or the BIOS without MODULE_STRINGS_COMPRESSED would fail due to the recent code exclusions so I changed them a bit. Also fixed the mistaken change to Main.asm
  • Changed the Tandy specific info in Configuration_FullMode.txt so it matches the info in the Wiki.
  • Optimizations and fixes in general.
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 jmp SHORT .DisableMenuitemFromCSBX
455
456
457;--------------------------------------------------------------------
458; .EnableOrDisableXTCFwindow
459; Parameters:
460; SS:BP: Menu handle
461; Returns:
462; Nothing
463; Corrupts registers:
464; AX, BX
465;--------------------------------------------------------------------
466ALIGN JUMP_ALIGN
467.EnableOrDisableXTCFwindow:
468 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
469 call Buffers_GetRomvarsValueToAXfromOffsetInBX
470 mov bx, g_MenuitemIdeControllerXTCFwindow
471 cmp al, DEVICE_8BIT_XTCF_MEMMAP
472 je SHORT .EnableMenuitemFromCSBX
473 ; Fall to .DisableMenuitemFromCSBX
474
475
476;--------------------------------------------------------------------
477; .DisableMenuitemFromCSBX
478; .EnableMenuitemFromCSBX
479; Parameters:
480; CS:BX: Ptr to MENUITEM
481; Returns:
482; Nothing
483; Corrupts registers:
484; Nothing
485;--------------------------------------------------------------------
486ALIGN JUMP_ALIGN
487.DisableMenuitemFromCSBX:
488 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
489 ret
490
491ALIGN JUMP_ALIGN
492.EnableMenuitemFromCSBX:
493 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
494 ret
495
496
497.EnableOrDisableSerial:
498 mov bx, g_MenuitemIdeControllerSerialBaud
499 call .DisableMenuitemFromCSBX
500
501 mov bx, g_MenuitemIdeControllerSerialCOM
502 call .DisableMenuitemFromCSBX
503
504 mov bx, g_MenuitemIdeControllerSerialPort
505 call .DisableMenuitemFromCSBX
506
507 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
508 call Buffers_GetRomvarsValueToAXfromOffsetInBX
509 cmp al, DEVICE_SERIAL_PORT
510 jnz .DisableAllSerial
511
512 mov bx, g_MenuitemIdeControllerSerialCOM
513 call .EnableMenuitemFromCSBX
514
515 mov bx, g_MenuitemIdeControllerSerialBaud
516 call .EnableMenuitemFromCSBX
517
518 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
519 call Buffers_GetRomvarsValueToAXfromOffsetInBX
520 mov bx, g_MenuitemIdeControllerSerialPort
521 cmp al,'x'
522 jz .EnableMenuitemFromCSBX
523 jmp .DisableMenuitemFromCSBX
524.DisableAllSerial:
525 ret
526
527;--------------------------------------------------------------------
528; MENUITEM activation functions (.fnActivate)
529; Parameters:
530; SS:BP: Ptr to MENU
531; Returns:
532; Nothing
533; Corrupts registers:
534; All, except segments
535;--------------------------------------------------------------------
536ALIGN JUMP_ALIGN
537MasterDrive:
538 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
539 jmp SHORT DisplayMasterSlaveMenu
540
541ALIGN JUMP_ALIGN
542SlaveDrive:
543 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
544 ; Fall to DisplayMasterSlaveMenu
545
546ALIGN JUMP_ALIGN
547DisplayMasterSlaveMenu:
548;
549; block mode is not supported on serial drives, disable/enable the option as appropriate
550;
551 push bx
552 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
553 call Buffers_GetRomvarsValueToAXfromOffsetInBX
554 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
555 cmp al,DEVICE_SERIAL_PORT
556 jz .isSerial
557 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
558 jmp .isDone
559.isSerial:
560 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
561.isDone:
562 pop bx
563
564 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
565 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
566
567;------------------------------------------------------------------------------------------
568;
569; Reader/Writer Routines
570;
571; For serial drives, we pack the port number and baud rate into a single byte, and thus
572; we need to take care to properly read/write just the bits we need. In addition, since
573; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
574; default the values stored in both these words when switching in and out of the Serial
575; device choice.
576;
577; Writers:
578; Parameters:
579; AX: Value that the MENUITEM system was interacting with
580; ES:DI: ROMVARS location where the value is to be stored
581; DS:SI: MENUITEM pointer
582; Returns:
583; AX: Value to actually write to ROMVARS
584; Corrupts registers:
585; AX
586;
587; Readers:
588; Parameters:
589; AX: Value read from the ROMVARS location
590; ES:DI: ROMVARS location where the value was just read from
591; DS:SI: MENUITEM pointer
592; Returns:
593; AX: Value that the MENUITEM system will interact with and display
594; Corrupts registers:
595; AX
596;
597ALIGN JUMP_ALIGN
598WriterForXTCFwindow:
599 mov al, ah
600 xor ah, ah
601 ret
602
603ALIGN JUMP_ALIGN
604ReaderForXTCFwindow:
605 mov ah, al
606 xor al, al
607 ret
608
609
610;
611; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
612; changing in/out of a Serial device (since we use these bytes in radically different ways).
613;
614ALIGN JUMP_ALIGN
615IdeControllerMenu_WriteDevice:
616 push bx
617 push di
618 push di
619 push ax
620
621 ; Note! AL is the choice index, not device code
622 shl ax, 1 ; Selection to device code
623 mov bl, [es:di] ; what is the current Device we are changing from?
624 sub di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort ; Get ready to set the Port addresses
625 cmp al, DEVICE_SERIAL_PORT
626 je SHORT .changingToSerial
627 cmp al, DEVICE_8BIT_JRIDE_ISA
628 je SHORT .ChangingToJrIdeIsa
629
630 ; Restore ports to default values
631 cmp al, DEVICE_8BIT_ATA ; Standard ATA controllers, including 8-bit mode
632 mov ax, DEVICE_ATA_PRIMARY_PORT ; Defaults for 16-bit and better ATA devices
633 mov bx, DEVICE_ATA_PRIMARY_PORTCTRL
634 jbe SHORT .writeNonSerial
635
636 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE devices
637 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
638
639.writeNonSerial:
640 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
641 xchg bx, ax
642 stosw
643 jmp SHORT .done
644
645.ChangingToJrIdeIsa:
646 mov ax, JRIDE_DEFAULT_SEGMENT_ADDRESS
647 xor bx, bx
648 jmp SHORT .writeNonSerial
649
650.changingToSerial:
651 cmp bl, DEVICE_SERIAL_PORT
652 je SHORT .done ; if we were already serial, nothing to do
653
654 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
655
656 mov al, SERIAL_DEFAULT_COM
657 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
658 call IdeControllerMenu_SerialWriteCOM
659 stosb
660
661.done:
662 ; See if we are changing to XT-CF. If we are, store
663 ; byte for Control Register.
664 pop ax
665 pop di ; IDEVARS.bDevice
666 sub di, BYTE IDEVARS.bDevice - IDEVARS.bXTCFcontrolRegister ; IDEVARS.bXTCFcontrolRegister
667 cmp al, DEVICE_8BIT_XTCF_PIO8 >> 1
668 je SHORT .ChangingToPioModeXTCF
669 cmp al, DEVICE_8BIT_XTCF_DMA >> 1
670 je SHORT .ChangingToDmaModeXTCF
671 cmp al, DEVICE_8BIT_XTCF_MEMMAP >> 1
672 jne SHORT .NoNeedToChangeXTCFsettings
673
674 ; XT-CF Memory Mapped Mode
675 mov WORD [es:di], DEFAULT_XTCF_SECTOR_WINDOW_SEGMENT >> 8 ; Store word to clear Control Block Port high byte
676 jmp SHORT .NoNeedToChangeXTCFsettings
677.ChangingToPioModeXTCF:
678 mov BYTE [es:di], XTCF_8BIT_PIO_MODE
679 jmp SHORT .NoNeedToChangeXTCFsettings
680.ChangingToDmaModeXTCF:
681 mov BYTE [es:di], XTCF_DMA_MODE
682 ; Fall to .NoNeedToChangeXTCFsettings
683
684.NoNeedToChangeXTCFsettings:
685 pop di
686 pop bx
687 ret
688
689;
690; Doesn't modify COM character (unless it is not recognized, which would be an error case),
691; But does update the port address based on COM port selection
692;
693ALIGN JUMP_ALIGN
694IdeControllerMenu_SerialWriteCOM:
695 push ax
696 push bx
697 push si
698
699 mov si,g_rgbChoiceToValueLookupForCOM
700 mov bx,PackedCOMPortAddresses
701
702.loop:
703 mov ah,[bx]
704
705 cmp ah,(SERIAL_DEFAULT_CUSTOM_PORT >> 2)
706 jz .notFound
707
708 cmp al,[si]
709 jz .found
710
711 inc si
712 inc si
713 inc bx
714
715 jmp .loop
716
717.notFound:
718 mov al, 'x'
719
720.found:
721 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
722
723 pop si
724 pop bx
725 pop ax
726
727 ret
728
729
730;
731; Packed Port (byte) -> Numeric Port (word)
732;
733ALIGN JUMP_ALIGN
734IdeControllerMenu_SerialReadPort:
735 xor ah,ah
736 eSHL_IM ax, 2
737 ret
738
739;
740; Numeric Port (word) -> Packed Port (byte)
741; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
742;
743ALIGN JUMP_ALIGN
744IdeControllerMenu_SerialWritePort:
745 push bx
746 push si
747
748 eSHR_IM ax, 2
749 and al,0feh ; force 8-byte boundary
750
751 mov si,g_rgbChoiceToValueLookupForCOM
752 mov bx,PackedCOMPortAddresses ; loop, looking for port address in known COM address list
753
754.loop:
755 mov ah,[si]
756 cmp ah,'x'
757 jz .found
758
759 cmp al,[bx]
760 jz .found
761
762 inc si
763 inc si
764 inc bx
765
766 jmp .loop
767
768.found:
769 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
770
771 pop si
772 pop bx
773
774 ret
775
Note: See TracBrowser for help on using the repository browser.