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

Last change on this file since 590 was 589, checked in by Krister Nordvall, 9 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 25.6 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
573ALIGN JUMP_ALIGN
574IdeControllerMenu_WriteDevice:
575 push bx
576 push di
577 push ax
578
579 mov bl, [es:di] ; What is the current Device we are changing from?
580 sub di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort ; Get ready to set the Port addresses
581
582 ; Note! AL is the choice index, not device code
583 shl al, 1 ; Selection to device code
584
585 ; Restore ports and other stuff to default values
586 jz SHORT .StandardIdeDevice ; DEVICE_16BIT_ATA
587
588 cmp al, DEVICE_8BIT_ATA
589 ja SHORT .NotStandardIdeDevice
590 jb SHORT .AdvancedAtaDevice ; DEVICE_32BIT_ATA
591 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE
592 jmp SHORT .CheckZF
593
594.AdvancedAtaDevice:
595 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_ADVANCED_ATA >> 8
596.CheckZF:
597 jz SHORT .SupportForDeviceNotAvailable
598
599 ; Standard ATA controllers, including 8-bit mode
600.StandardIdeDevice:
601 lea ax, [di-ROMVARS.ideVars0+IDEVARS.wBasePort]
602 mov bl, IDEVARS_size
603 div bl
604 mov bx, .rgbLowByteOfStdIdeInterfacePorts
605 xlat
606 mov ah, 1 ; DEVICE_ATA_*_PORT >> 8
607 mov bh, 3 ; DEVICE_ATA_*_PORTCTRL >> 8
608 mov bl, al
609 jmp SHORT .WriteNonSerial
610
611.rgbLowByteOfStdIdeInterfacePorts: ; Defaults for 16-bit and better ATA devices
612 db DEVICE_ATA_PRIMARY_PORT & 0FFh
613 db DEVICE_ATA_SECONDARY_PORT & 0FFh
614 db DEVICE_ATA_TERTIARY_PORT & 0FFh
615 db DEVICE_ATA_QUATERNARY_PORT & 0FFh
616
617.NotStandardIdeDevice:
618 cmp al, DEVICE_SERIAL_PORT
619 jb SHORT .NotSerialDevice
620 test BYTE [es:ROMVARS.wFlags+1], FLG_ROMVARS_MODULE_SERIAL >> 8
621 jnz SHORT .ChangingToSerial
622
623.SupportForDeviceNotAvailable:
624 push dx
625 mov dx, g_szUnsupportedDevice
626 call Dialogs_DisplayErrorFromCSDX
627 pop dx
628
629 ; Restore device type to the previous value
630 pop ax ; Get choice index from stack
631 mov al, bl ; Previous device type to AL
632 shr al, 1 ; Device code to choice index
633 jmp SHORT .DoneWithNoChangeOfDevice
634
635.NotSerialDevice:
636 ; Remaining device types all require MODULE_8BIT_IDE or MODULE_8BIT_IDE_ADVANCED
637 test BYTE [es:ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE | FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED
638 jz SHORT .SupportForDeviceNotAvailable
639
640 ; We know MODULE_8BIT_IDE is included
641 lahf ; Save the PF
642 cmp al, DEVICE_8BIT_XTIDE_REV2
643 jbe SHORT .ChangingToXTIDEorXTCF
644 sahf ; Restore the PF
645 jpo SHORT .SupportForDeviceNotAvailable ; Jump if no MODULE_8BIT_IDE_ADVANCED
646 cmp al, DEVICE_8BIT_JRIDE_ISA
647 je SHORT .ChangingToJrIdeIsa
648 cmp al, DEVICE_8BIT_ADP50L
649 je SHORT .ChangingToADP50L
650
651.ChangingToXTIDEorXTCF:
652 mov ax, DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE and XT-CF devices
653 mov bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
654
655.WriteNonSerial:
656 stosw ; Store defaults in IDEVARS.wBasePort and IDEVARS.wBasePortCtrl
657 xchg bx, ax
658 stosw
659 jmp SHORT .Done
660
661.ChangingToJrIdeIsa:
662 mov ah, JRIDE_DEFAULT_SEGMENT_ADDRESS >> 8
663 SKIP2B bx
664
665.ChangingToADP50L:
666 mov ah, ADP50L_DEFAULT_BIOS_SEGMENT_ADDRESS >> 8
667 xor al, al
668 xor bx, bx
669 jmp SHORT .WriteNonSerial
670
671.ChangingToSerial:
672 cmp bl, DEVICE_SERIAL_PORT
673 je SHORT .Done ; if we were already serial, nothing to do
674
675 mov BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
676 mov BYTE [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], 0 ; Clear .bIRQ to keep the boot menu from printing it
677
678 mov al, SERIAL_DEFAULT_COM
679 sub di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
680 call IdeControllerMenu_SerialWriteCOM
681 stosb
682
683.Done:
684 pop ax
685.DoneWithNoChangeOfDevice:
686 pop di ; IDEVARS.bDevice
687 pop bx
688 ret
689
690;
691; Doesn't modify COM character (unless it is not recognized, which would be an error case),
692; But does update the port address based on COM port selection
693;
694ALIGN JUMP_ALIGN
695IdeControllerMenu_SerialWriteCOM:
696 push ax
697 push bx
698 push si
699
700 mov si, g_rgbChoiceToValueLookupForCOM
701 mov bx, PackedCOMPortAddresses
702
703.loop:
704 mov ah, [bx]
705
706 cmp ah, (SERIAL_DEFAULT_CUSTOM_PORT >> 2)
707 je .notFound
708
709 cmp al, [si]
710 je .found
711
712 inc si
713 inc si
714 inc bx
715
716 jmp .loop
717
718.notFound:
719 mov al, 'x'
720
721.found:
722 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
723
724 pop si
725 pop bx
726 pop ax
727
728 ret
729
730
731;
732; Packed Port (byte) -> Numeric Port (word)
733;
734ALIGN JUMP_ALIGN
735IdeControllerMenu_SerialReadPort:
736 xor ah, ah
737 eSHL_IM ax, 2
738 ret
739
740;
741; Numeric Port (word) -> Packed Port (byte)
742; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
743;
744ALIGN JUMP_ALIGN
745IdeControllerMenu_SerialWritePort:
746 push bx
747 push si
748
749 eSHR_IM ax, 2
750 and al, 0feh ; force 8-byte boundary
751
752 mov si, g_rgbChoiceToValueLookupForCOM
753 mov bx, PackedCOMPortAddresses ; loop, looking for port address in known COM address list
754
755.loop:
756 mov ah, [si]
757 cmp ah, 'x'
758 je .found
759
760 cmp al, [bx]
761 je .found
762
763 inc si
764 inc si
765 inc bx
766
767 jmp .loop
768
769.found:
770 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
771
772 pop si
773 pop bx
774
775 ret
776
Note: See TracBrowser for help on using the repository browser.