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

Last change on this file since 392 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 21.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 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 FLG_MENUITEM_VISIBLE
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_VISIBLE | 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_XTIDE_REV1
191 dw DEVICE_XTIDE_REV2
192 dw DEVICE_FAST_XTIDE
193 dw DEVICE_16BIT_ATA
194 dw DEVICE_32BIT_ATA
195 dw DEVICE_SERIAL_PORT
196 dw DEVICE_JRIDE_ISA
197g_rgszValueToStringLookupForDevice:
198 dw g_szValueCfgDeviceRev1
199 dw g_szValueCfgDeviceRev2
200 dw g_szValueCfgDeviceFast
201 dw g_szValueCfgDevice16b
202 dw g_szValueCfgDevice32b
203 dw g_szValueCfgDeviceSerial
204 dw g_szValueCfgDeviceJrIdeIsa
205
206g_rgbChoiceToValueLookupForCOM:
207 dw '1'
208 dw '2'
209 dw '3'
210 dw '4'
211 dw '5'
212 dw '6'
213 dw '7'
214 dw '8'
215 dw '9'
216 dw 'A'
217 dw 'B'
218 dw 'C'
219 dw 'x' ; must be last entry (see reader/write routines)
220g_rgszChoiceToStringLookupForCOM:
221 dw g_szValueCfgCOM1
222 dw g_szValueCfgCOM2
223 dw g_szValueCfgCOM3
224 dw g_szValueCfgCOM4
225 dw g_szValueCfgCOM5
226 dw g_szValueCfgCOM6
227 dw g_szValueCfgCOM7
228 dw g_szValueCfgCOM8
229 dw g_szValueCfgCOM9
230 dw g_szValueCfgCOMA
231 dw g_szValueCfgCOMB
232 dw g_szValueCfgCOMC
233 dw g_szValueCfgCOMx
234 dw NULL
235
236SERIAL_DEFAULT_CUSTOM_PORT EQU 300h ; can't be any of the pre-defined COM values
237
238PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
239 db SERIAL_COM1_IOADDRESS >> 2
240 db SERIAL_COM2_IOADDRESS >> 2
241 db SERIAL_COM3_IOADDRESS >> 2
242 db SERIAL_COM4_IOADDRESS >> 2
243 db SERIAL_COM5_IOADDRESS >> 2
244 db SERIAL_COM6_IOADDRESS >> 2
245 db SERIAL_COM7_IOADDRESS >> 2
246 db SERIAL_COM8_IOADDRESS >> 2
247 db SERIAL_COM9_IOADDRESS >> 2
248 db SERIAL_COMA_IOADDRESS >> 2
249 db SERIAL_COMB_IOADDRESS >> 2
250 db SERIAL_COMC_IOADDRESS >> 2
251 db SERIAL_DEFAULT_CUSTOM_PORT >> 2 ; must be last entry (see reader/writer routines)
252SERIAL_DEFAULT_COM EQU '1'
253
254g_rgbChoiceToValueLookupForBaud:
255 dw (115200 / 115200) & 0xff
256 dw (115200 / 57600) & 0xff
257 dw (115200 / 38400) & 0xff
258 dw (115200 / 28800) & 0xff
259 dw (115200 / 19200) & 0xff
260 dw (115200 / 9600) & 0xff
261 dw (115200 / 4800) & 0xff
262 dw (115200 / 2400) & 0xff
263g_rgszChoiceToStringLookupForBaud:
264 dw g_szValueCfgBaud115_2
265 dw g_szValueCfgBaud57_6
266 dw g_szValueCfgBaud38_4
267 dw g_szValueCfgBaud28_8
268 dw g_szValueCfgBaud19_2
269 dw g_szValueCfgBaud9600
270 dw g_szValueCfgBaud4800
271 dw g_szValueCfgBaud2400
272 dw NULL
273SERIAL_DEFAULT_BAUD EQU ((115200 / 9600) & 0xff)
274
275; Section containing code
276SECTION .text
277
278;--------------------------------------------------------------------
279; IdeControllerMenu_InitializeToIdevarsOffsetInBX
280; Parameters:
281; SS:BP: Menu handle
282; Returns:
283; Nothing
284; Corrupts registers:
285; AX
286;--------------------------------------------------------------------
287ALIGN JUMP_ALIGN
288IdeControllerMenu_InitializeToIdevarsOffsetInBX:
289 lea ax, [bx+IDEVARS.drvParamsMaster]
290 mov [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
291
292 lea ax, [bx+IDEVARS.drvParamsSlave]
293 mov [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
294
295 lea ax, [bx+IDEVARS.bDevice]
296 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
297
298 lea ax, [bx+IDEVARS.wPort]
299 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
300
301 lea ax, [bx+IDEVARS.bSerialPort]
302 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
303
304 lea ax, [bx+IDEVARS.bSerialBaud]
305 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
306
307 lea ax, [bx+IDEVARS.wPortCtrl]
308 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
309
310 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
311 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
312
313 lea ax, [bx+IDEVARS.bIRQ]
314 mov [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
315 mov [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
316
317 ret
318
319
320;--------------------------------------------------------------------
321; IdeControllerMenu_EnterMenuOrModifyItemVisibility
322; Parameters:
323; SS:BP: Menu handle
324; Returns:
325; Nothing
326; Corrupts registers:
327; All, except BP
328;--------------------------------------------------------------------
329ALIGN JUMP_ALIGN
330IdeControllerMenu_EnterMenuOrModifyItemVisibility:
331 push cs
332 pop ds
333 call .EnableOrDisableIRQ
334 call .EnableOrDisableSerial
335 mov si, g_MenupageForIdeControllerMenu
336 jmp Menupage_ChangeToNewMenupageInDSSI
337
338;--------------------------------------------------------------------
339; .EnableOrDisableIRQ
340; Parameters:
341; SS:BP: Menu handle
342; Returns:
343; Nothing
344; Corrupts registers:
345; AX, BX
346;--------------------------------------------------------------------
347ALIGN JUMP_ALIGN
348.EnableOrDisableIRQ:
349 mov bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
350 call Buffers_GetRomvarsValueToAXfromOffsetInBX
351 mov bx, g_MenuitemIdeControllerIdeIRQ
352 test al, al
353 jz SHORT .DisableMenuitemFromCSBX
354 ; Fall to .EnableMenuitemFromCSBX
355
356;--------------------------------------------------------------------
357; .EnableMenuitemFromCSBX
358; .DisableMenuitemFromCSBX
359; Parameters:
360; CS:BX: Ptr to MENUITEM
361; Returns:
362; Nothing
363; Corrupts registers:
364; Nothing
365;--------------------------------------------------------------------
366ALIGN JUMP_ALIGN
367.EnableMenuitemFromCSBX:
368 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
369 ret
370
371ALIGN JUMP_ALIGN
372.DisableMenuitemFromCSBX:
373 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
374 ret
375
376.EnableOrDisableSerial:
377 mov bx, g_MenuitemIdeControllerCommandBlockAddress
378 call .DisableMenuitemFromCSBX
379
380 mov bx, g_MenuitemIdeControllerControlBlockAddress
381 call .DisableMenuitemFromCSBX
382
383 mov bx, g_MenuitemIdeControllerEnableInterrupt
384 call .DisableMenuitemFromCSBX
385
386 mov bx, g_MenuitemIdeControllerSerialBaud
387 call .DisableMenuitemFromCSBX
388
389 mov bx, g_MenuitemIdeControllerSerialCOM
390 call .DisableMenuitemFromCSBX
391
392 mov bx, g_MenuitemIdeControllerSerialPort
393 call .DisableMenuitemFromCSBX
394
395 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
396 call Buffers_GetRomvarsValueToAXfromOffsetInBX
397 cmp al,DEVICE_SERIAL_PORT
398 jnz .DisableAllSerial
399
400 mov bx, g_MenuitemIdeControllerSerialCOM
401 call .EnableMenuitemFromCSBX
402
403 mov bx, g_MenuitemIdeControllerSerialBaud
404 call .EnableMenuitemFromCSBX
405
406 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
407 call Buffers_GetRomvarsValueToAXfromOffsetInBX
408 mov bx, g_MenuitemIdeControllerSerialPort
409 cmp al,'x'
410 jz .EnableMenuitemFromCSBX
411 jmp .DisableMenuitemFromCSBX
412
413.DisableAllSerial:
414
415 mov bx, g_MenuitemIdeControllerCommandBlockAddress
416 call .EnableMenuitemFromCSBX
417
418 mov bx, g_MenuitemIdeControllerControlBlockAddress
419 call .EnableMenuitemFromCSBX
420
421 mov bx, g_MenuitemIdeControllerEnableInterrupt
422 call .EnableMenuitemFromCSBX
423
424 ret
425
426;--------------------------------------------------------------------
427; MENUITEM activation functions (.fnActivate)
428; Parameters:
429; SS:BP: Ptr to MENU
430; Returns:
431; Nothing
432; Corrupts registers:
433; All, except segments
434;--------------------------------------------------------------------
435ALIGN JUMP_ALIGN
436MasterDrive:
437 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
438 jmp SHORT DisplayMasterSlaveMenu
439
440ALIGN JUMP_ALIGN
441SlaveDrive:
442 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
443 ; Fall to DisplayMasterSlaveMenu
444
445ALIGN JUMP_ALIGN
446DisplayMasterSlaveMenu:
447;
448; block mode is not supported on serial drives, disable/enable the option as appropriate
449;
450 push bx
451 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
452 call Buffers_GetRomvarsValueToAXfromOffsetInBX
453 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
454 cmp al,DEVICE_SERIAL_PORT
455 jz .isSerial
456 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
457 jmp .isDone
458.isSerial:
459 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
460.isDone:
461 pop bx
462
463 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
464 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
465
466;------------------------------------------------------------------------------------------
467;
468; Reader/Writer Routines
469;
470; For serial drives, we pack the port number and baud rate into a single byte, and thus
471; we need to take care to properly read/write just the bits we need. In addition, since
472; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
473; default the values stored in both these words when switching in and out of the Serial
474; device choice.
475;
476; Writers:
477; Parameters:
478; AX: Value that the MENUITEM system was interacting with
479; ES:DI: ROMVARS location where the value is to be stored
480; DS:SI: MENUITEM pointer
481; Returns:
482; AX: Value to actually write to ROMVARS
483; Corrupts registers:
484; AX
485;
486; Readers:
487; Parameters:
488; AX: Value read from the ROMVARS location
489; ES:DI: ROMVARS location where the value was just read from
490; DS:SI: MENUITEM pointer
491; Returns:
492; AX: Value that the MENUITEM system will interact with and display
493; Corrupts registers:
494; AX
495;
496
497;
498; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
499; changing in/out of a Serial device (since we use these bytes in radically different ways).
500;
501ALIGN JUMP_ALIGN
502IdeControllerMenu_WriteDevice:
503 push ax
504 push bx
505 push di
506
507 mov bl,[es:di] ; what is the current Device?
508
509 add di,IDEVARS.wPort - IDEVARS.bDevice ; Get ready to set the Port addresses
510
511 cmp al,DEVICE_SERIAL_PORT
512 jz .changingToSerial
513
514 cmp bl,DEVICE_SERIAL_PORT
515 jnz .done ; if we weren't Serial before, nothing to do
516
517.changingFromSerial:
518 cmp al,DEVICE_16BIT_ATA
519
520 mov ax,DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE devices
521 mov bx,DEVICE_XTIDE_DEFAULT_PORTCTRL
522
523 jb .writeNonSerial
524
525 mov ax,DEVICE_ATA_DEFAULT_PORT ; Defaults for 16-bit and better ATA devices
526 mov bx,DEVICE_ATA_DEFAULT_PORTCTRL
527
528.writeNonSerial:
529 stosw ; Store defaults in IDEVARS.wPort and IDEVARS.wPortCtrl
530 xchg bx, ax
531 stosw
532
533 jmp .done
534
535.changingToSerial:
536 cmp bl,DEVICE_SERIAL_PORT
537 jz .done ; if we were already serial, nothing to do
538
539 mov byte [es:di+IDEVARS.bSerialBaud-IDEVARS.wPort],SERIAL_DEFAULT_BAUD
540
541 mov al,SERIAL_DEFAULT_COM
542 add di,IDEVARS.bSerialCOMPortChar-IDEVARS.wPort
543 call IdeControllerMenu_SerialWriteCOM
544 stosb
545
546.done:
547 pop di
548 pop bx
549 pop ax
550
551 ret
552
553;
554; Doesn't modify COM character (unless it is not recognized, which would be an error case),
555; But does update the port address based on COM port selection
556;
557ALIGN JUMP_ALIGN
558IdeControllerMenu_SerialWriteCOM:
559 push ax
560 push bx
561 push si
562
563 mov si,g_rgbChoiceToValueLookupForCOM
564 mov bx,PackedCOMPortAddresses
565
566.loop:
567 mov ah,[bx]
568
569 cmp ah,(SERIAL_DEFAULT_CUSTOM_PORT >> 2)
570 jz .notFound
571
572 cmp al,[si]
573 jz .found
574
575 inc si
576 inc si
577 inc bx
578
579 jmp .loop
580
581.notFound:
582 mov al, 'x'
583
584.found:
585 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
586
587 pop si
588 pop bx
589 pop ax
590
591 ret
592
593
594;
595; Packed Port (byte) -> Numeric Port (word)
596;
597ALIGN JUMP_ALIGN
598IdeControllerMenu_SerialReadPort:
599 xor ah,ah
600 eSHL_IM ax, 2
601 ret
602
603;
604; Numeric Port (word) -> Packed Port (byte)
605; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
606;
607ALIGN JUMP_ALIGN
608IdeControllerMenu_SerialWritePort:
609 push bx
610 push si
611
612 eSHR_IM ax, 2
613 and al,0feh ; force 8-byte boundary
614
615 mov si,g_rgbChoiceToValueLookupForCOM
616 mov bx,PackedCOMPortAddresses ; loop, looking for port address in known COM address list
617
618.loop:
619 mov ah,[si]
620 cmp ah,'x'
621 jz .found
622
623 cmp al,[bx]
624 jz .found
625
626 inc si
627 inc si
628 inc bx
629
630 jmp .loop
631
632.found:
633 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
634
635 pop si
636 pop bx
637
638 ret
639
Note: See TracBrowser for help on using the repository browser.