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

Last change on this file since 595 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 26.7 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%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
309%if IDEVARS.wBasePort = 0
310 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
311%else
312 lea ax, [bx+IDEVARS.wBasePort]
313 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
314%endif
315
316%if IDEVARS.bSerialPort = 0
317 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
318%else
319 lea ax, [bx+IDEVARS.bSerialPort]
320 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
321%endif
322%endif
323
324 lea ax, [bx+IDEVARS.bSerialBaud]
325 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
326
327 lea ax, [bx+IDEVARS.wControlBlockPort]
328 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
329
330 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
331 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
332
333 lea ax, [bx+IDEVARS.bIRQ]
334 mov [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
335 mov [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
336
337 ret
338
339
340;--------------------------------------------------------------------
341; IdeControllerMenu_EnterMenuOrModifyItemVisibility
342; Parameters:
343; SS:BP: Menu handle
344; Returns:
345; Nothing
346; Corrupts registers:
347; All, except BP
348;--------------------------------------------------------------------
349ALIGN JUMP_ALIGN
350IdeControllerMenu_EnterMenuOrModifyItemVisibility:
351 push cs
352 pop ds
353 call .EnableOrDisableCommandBlockPort
354 call .EnableOrDisableControlBlockPort
355 call .DisableIRQchannelSelection
356 call .EnableOrDisableEnableInterrupt
357 call .EnableOrDisableSerial
358 mov si, g_MenupageForIdeControllerMenu
359 jmp Menupage_ChangeToNewMenupageInDSSI
360
361
362;--------------------------------------------------------------------
363; .EnableOrDisableCommandBlockPort
364; Parameters:
365; SS:BP: Menu handle
366; Returns:
367; Nothing
368; Corrupts registers:
369; AX, BX
370;--------------------------------------------------------------------
371ALIGN JUMP_ALIGN
372.EnableOrDisableCommandBlockPort:
373 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
374 call Buffers_GetRomvarsValueToAXfromOffsetInBX
375 mov bx, g_MenuitemIdeControllerCommandBlockAddress
376 cmp al, DEVICE_SERIAL_PORT
377 je SHORT .DisableMenuitemFromCSBX
378 jmp SHORT .EnableMenuitemFromCSBX
379
380
381;--------------------------------------------------------------------
382; .EnableOrDisableControlBlockPort
383; Parameters:
384; SS:BP: Menu handle
385; Returns:
386; Nothing
387; Corrupts registers:
388; AX, BX
389;--------------------------------------------------------------------
390ALIGN JUMP_ALIGN
391.EnableOrDisableControlBlockPort:
392 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
393 call Buffers_GetRomvarsValueToAXfromOffsetInBX
394 mov bx, g_MenuitemIdeControllerControlBlockAddress
395 cmp al, DEVICE_8BIT_XTCF_PIO8
396 jb SHORT .EnableMenuitemFromCSBX ; Not needed for XT-CF, JR-IDE/ISA and ADP50L
397 jmp SHORT .DisableMenuitemFromCSBX
398
399
400;--------------------------------------------------------------------
401; .EnableOrDisableEnableInterrupt
402; Parameters:
403; SS:BP: Menu handle
404; Returns:
405; Nothing
406; Corrupts registers:
407; AX, BX
408;--------------------------------------------------------------------
409ALIGN JUMP_ALIGN
410.EnableOrDisableEnableInterrupt:
411 call Buffers_GetRomvarsFlagsToAX
412 mov bx, g_MenuitemIdeControllerEnableInterrupt
413 test ax, FLG_ROMVARS_MODULE_IRQ
414 jz SHORT .DisableMenuitemFromCSBX
415
416 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
417 call Buffers_GetRomvarsValueToAXfromOffsetInBX
418 mov bx, g_MenuitemIdeControllerEnableInterrupt
419 cmp al, DEVICE_8BIT_XTCF_PIO8
420 jae SHORT .DisableMenuitemFromCSBX
421
422 call EnableMenuitemFromCSBX
423 ; Fall to .EnableOrDisableIRQchannelSelection
424
425;--------------------------------------------------------------------
426; .EnableOrDisableIRQchannelSelection
427; Parameters:
428; SS:BP: Menu handle
429; Returns:
430; Nothing
431; Corrupts registers:
432; AX, BX
433;--------------------------------------------------------------------
434ALIGN JUMP_ALIGN
435.EnableOrDisableIRQchannelSelection:
436 mov bx, [g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
437 call Buffers_GetRomvarsValueToAXfromOffsetInBX
438 mov bx, g_MenuitemIdeControllerIdeIRQ
439 test al, al
440 jnz SHORT .EnableMenuitemFromCSBX
441.DisableIRQchannelSelection:
442 mov bx, g_MenuitemIdeControllerIdeIRQ
443 ; Fall to .DisableMenuitemFromCSBX
444
445
446;--------------------------------------------------------------------
447; .DisableMenuitemFromCSBX
448; .EnableMenuitemFromCSBX
449; Parameters:
450; CS:BX: Ptr to MENUITEM
451; Returns:
452; Nothing
453; Corrupts registers:
454; Nothing
455;--------------------------------------------------------------------
456ALIGN JUMP_ALIGN
457.DisableMenuitemFromCSBX:
458 jmp DisableMenuitemFromCSBX
459
460ALIGN JUMP_ALIGN
461.EnableMenuitemFromCSBX:
462 jmp EnableMenuitemFromCSBX
463
464
465;--------------------------------------------------------------------
466; .EnableOrDisableSerial
467; Parameters:
468; SS:BP: Menu handle
469; Returns:
470; Nothing
471; Corrupts registers:
472; AX, BX
473;--------------------------------------------------------------------
474.EnableOrDisableSerial:
475 mov bx, g_MenuitemIdeControllerSerialBaud
476 call DisableMenuitemFromCSBX
477
478 mov bx, g_MenuitemIdeControllerSerialCOM
479 call DisableMenuitemFromCSBX
480
481 mov bx, g_MenuitemIdeControllerSerialPort
482 call DisableMenuitemFromCSBX
483
484 mov bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
485 call Buffers_GetRomvarsValueToAXfromOffsetInBX
486 cmp al, DEVICE_SERIAL_PORT
487 jne SHORT .DisableAllSerial
488
489 mov bx, g_MenuitemIdeControllerSerialCOM
490 call EnableMenuitemFromCSBX
491
492 mov bx, g_MenuitemIdeControllerSerialBaud
493 call EnableMenuitemFromCSBX
494
495 mov bx, [g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
496 call Buffers_GetRomvarsValueToAXfromOffsetInBX
497 mov bx, g_MenuitemIdeControllerSerialPort
498 cmp al, 'x'
499 je SHORT .EnableMenuitemFromCSBX
500 jmp SHORT .DisableMenuitemFromCSBX
501.DisableAllSerial:
502 ret
503
504
505;--------------------------------------------------------------------
506; MENUITEM activation functions (.fnActivate)
507; Parameters:
508; SS:BP: Ptr to MENU
509; Returns:
510; Nothing
511; Corrupts registers:
512; All, except segments
513;--------------------------------------------------------------------
514ALIGN JUMP_ALIGN
515MasterDrive:
516 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
517 jmp SHORT DisplayMasterSlaveMenu
518
519ALIGN JUMP_ALIGN
520SlaveDrive:
521 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
522 ; Fall to DisplayMasterSlaveMenu
523
524ALIGN JUMP_ALIGN
525DisplayMasterSlaveMenu:
526;
527; "Block Mode Transfers" and "Internal Write Cache" are not supported on serial drives, disable/enable the options as appropriate
528;
529 push bx
530 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
531 call Buffers_GetRomvarsValueToAXfromOffsetInBX
532 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
533
534 cmp al, DEVICE_SERIAL_PORT
535 je .isSerial
536
537 call EnableMenuitemFromCSBX
538 mov bx, g_MenuitemMasterSlaveWriteCache
539 call EnableMenuitemFromCSBX
540 jmp .isDone
541
542.isSerial:
543 call DisableMenuitemFromCSBX
544 mov bx, g_MenuitemMasterSlaveWriteCache
545 call DisableMenuitemFromCSBX
546
547.isDone:
548 pop bx
549
550 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
551 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
552
553
554;--------------------------------------------------------------------
555; IdeControllerMenu_WriteDevice
556;
557; Sets default values to ports and other device dependent stuff
558;
559; Parameters:
560; AX: IDE controller/Device type menu choice index
561; ES:DI: Ptr to IDEVARS.bDevice
562; DS:SI: MENUITEM pointer
563; Returns:
564; AX: IDE controller/Device type menu choice index
565; Corrupts registers:
566; BX, DX
567;--------------------------------------------------------------------
568ALIGN JUMP_ALIGN
569IdeControllerMenu_WriteDevice:
570 push di
571 push ax
572
573 mov bl, [es:di] ; What is the current Device we are changing from?
574 sub di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort ; Get ready to set the Port addresses
575
576 ; Note! AL is the choice index, not device code
577 eSHL_IM al, 1 ; Selection to device code
578 jz SHORT .StandardIdeDevice ; DEVICE_16BIT_ATA
579
580 cmp al, DEVICE_8BIT_ATA
581 ja SHORT .NotStandardIdeDevice
582 jb SHORT .AdvancedAtaDevice ; DEVICE_32BIT_ATA
583 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE
584 jmp SHORT .CheckZF
585
586.AdvancedAtaDevice:
587 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_ADVANCED_ATA >> 8
588.CheckZF:
589 jz SHORT .SupportForDeviceNotAvailable
590
591 ; Standard ATA controllers, including 8-bit mode
592.StandardIdeDevice:
593 lea ax, [di-ROMVARS.ideVars0+IDEVARS.wBasePort]
594 mov bl, IDEVARS_size
595 div bl
596 mov bx, .rgbLowByteOfStdIdeInterfacePorts
597 xlat ; DS=CS so no segment override needed
598 mov ah, 1 ; DEVICE_ATA_*_PORT >> 8
599 mov bh, 3 ; DEVICE_ATA_*_PORTCTRL >> 8
600 mov bl, al
601 jmp SHORT .WriteNonSerial
602
603.rgbLowByteOfStdIdeInterfacePorts: ; Defaults for 16-bit and better ATA devices
604 db DEVICE_ATA_PRIMARY_PORT & 0FFh
605 db DEVICE_ATA_SECONDARY_PORT & 0FFh
606 db DEVICE_ATA_TERTIARY_PORT & 0FFh
607 db DEVICE_ATA_QUATERNARY_PORT & 0FFh
608
609.NotStandardIdeDevice:
610 cmp al, DEVICE_SERIAL_PORT
611 jb SHORT .NotSerialDevice
612 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_SERIAL >> 8
613 jnz SHORT .ChangingToSerial
614
615.SupportForDeviceNotAvailable:
616 mov dx, g_szUnsupportedDevice
617 call Dialogs_DisplayErrorFromCSDX
618
619 ; Restore device type to the previous value
620 pop ax ; Get choice index from stack
621 mov al, bl ; Previous device type to AL
622 shr al, 1 ; Device code to choice index
623 pop di
624 ret
625
626.NotSerialDevice:
627 ; Remaining device types all require MODULE_8BIT_IDE or MODULE_8BIT_IDE_ADVANCED
628 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE | FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED
629 jz SHORT .SupportForDeviceNotAvailable
630
631 ; We know MODULE_8BIT_IDE is included
632 lahf ; Save the PF
633 cmp al, DEVICE_8BIT_XTIDE_REV2
634 jbe SHORT .ChangingToXTIDEorXTCF
635 sahf ; Restore the PF
636 jpo SHORT .SupportForDeviceNotAvailable ; Jump if no MODULE_8BIT_IDE_ADVANCED
637 cmp al, DEVICE_8BIT_JRIDE_ISA
638 je SHORT .ChangingToJrIdeIsa
639 cmp al, DEVICE_8BIT_ADP50L
640 je SHORT .ChangingToADP50L
641
642.ChangingToXTIDEorXTCF:
643 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE and XT-CF devices
644 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
645
646.WriteNonSerial:
647 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
648 xchg bx, ax
649 stosw
650 jmp SHORT .Done
651
652.ChangingToJrIdeIsa:
653 mov ah, JRIDE_DEFAULT_SEGMENT_ADDRESS >> 8
654 SKIP2B bx
655
656.ChangingToADP50L:
657 mov ah, ADP50L_DEFAULT_BIOS_SEGMENT_ADDRESS >> 8
658 xor al, al
659 xor bx, bx
660 jmp SHORT .WriteNonSerial
661
662.ChangingToSerial:
663;
664; For serial drives, we pack the port number and baud rate into a single byte, and thus
665; we need to take care to properly read/write just the bits we need. In addition, since
666; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
667; default the values stored in both these words when switching in and out of the Serial
668; device choice.
669;
670 mov al, SERIAL_DEFAULT_COM
671 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
672 mov [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], ah ; Clear .bIRQ to keep the boot menu from printing it
673
674 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
675 call IdeControllerMenu_SerialWriteCOM
676 stosb
677
678.Done:
679 pop ax
680 pop di
681 ret
682
683
684;--------------------------------------------------------------------
685; IdeControllerMenu_SerialWriteCOM
686;
687; Updates the port address based on COM port selection
688;
689; Parameters:
690; AL: COM port
691; ES:DI: Ptr to IDEVARS.bSerialCOMPortChar
692; DS:SI: MENUITEM pointer
693; Returns:
694; Nothing
695; Corrupts registers:
696; BX
697;--------------------------------------------------------------------
698ALIGN JUMP_ALIGN
699IdeControllerMenu_SerialWriteCOM:
700 push ax
701 push si
702
703 mov bx, PackedCOMPortAddresses - 1
704 mov si, g_rgbChoiceToValueLookupForCOM - 2
705
706.Loop:
707 inc bx
708 inc si
709 inc si
710
711 mov ah, [bx]
712 cmp ah, SERIAL_DEFAULT_CUSTOM_PORT >> 2
713 je SHORT .NotFound
714
715 cmp al, [si]
716 jne SHORT .Loop
717
718.NotFound:
719 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
720
721 pop si
722 pop ax
723 ret
724
725
726;--------------------------------------------------------------------
727; IdeControllerMenu_SerialReadPort
728;
729; Packed Port (byte) -> Numeric Port (word)
730;
731; Parameters:
732; AX: Value read from the ROMVARS location
733; ES:DI: ROMVARS location where the value was just read from
734; DS:SI: MENUITEM pointer
735; Returns:
736; AX: Value that the MENUITEM system will interact with and display
737; Corrupts registers:
738; Nothing
739;--------------------------------------------------------------------
740ALIGN JUMP_ALIGN
741IdeControllerMenu_SerialReadPort:
742 xor ah, ah
743 eSHL_IM ax, 2
744 ret
745
746
747;--------------------------------------------------------------------
748; IdeControllerMenu_SerialWritePort
749;
750; Numeric Port (word) -> Packed Port (byte)
751;
752; And convert from Custom to a defined COM port if we
753; match one of the pre-defined COM port numbers
754;
755; Parameters:
756; AX: Value that the MENUITEM system was interacting with
757; ES:DI: ROMVARS location where the value is to be stored
758; DS:SI: MENUITEM pointer
759; Returns:
760; AX: Value to actually write to ROMVARS
761; Corrupts registers:
762; BX
763;--------------------------------------------------------------------
764ALIGN JUMP_ALIGN
765IdeControllerMenu_SerialWritePort:
766 push si
767
768 eSHR_IM ax, 2
769 and al, 0FEh ; Force 8-byte boundary
770
771 mov si, g_rgbChoiceToValueLookupForCOM - 2
772 mov bx, PackedCOMPortAddresses - 1 ; Loop, looking for port address in known COM address list
773
774.Loop:
775 inc si
776 inc si
777 inc bx
778
779 mov ah, [si]
780 cmp ah, 'x'
781 je SHORT .Found
782
783 cmp al, [bx]
784 jne SHORT .Loop
785
786.Found:
787 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
788
789 pop si
790 ret
791
Note: See TracBrowser for help on using the repository browser.