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

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

Serial Port: split single byte port and baud into two bytes, taking advantage of the two bytes in DPT_SERIAL, which supports more serial baud rates and in particular fixed a bug where a 4x client machine couldn't talk to a 115.2K server machine. This is a wide change, touching lots of files, but most are shallow changes. DetectPrint.asm took the most significant changes, now it calculates the baud rate to display instead of using characters provided by the Configurator. The Configurator now has a new menu flag, FLG_MENUITEM_CHOICESTRINGS, for specifying that values are not linear and they should be lookedup rather than indexed. Finally, another important bug fixed here is that in some error cases, the serial port code could get into an infinite loop waiting ont the hardware; now it has a timeout.

File size: 20.8 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : "IDE Controller" menu structs and functions.
3
4; Section containing initialized data
5SECTION .data
6
7ALIGN WORD_ALIGN
8g_MenupageForIdeControllerMenu:
9istruc MENUPAGE
10 at MENUPAGE.fnEnter, dw IdeControllerMenu_EnterMenuOrModifyItemVisibility
11 at MENUPAGE.fnBack, dw ConfigurationMenu_EnterMenuOrModifyItemVisibility
12 at MENUPAGE.wMenuitems, dw 11
13iend
14
15g_MenuitemIdeControllerBackToConfigurationMenu:
16istruc MENUITEM
17 at MENUITEM.fnActivate, dw ConfigurationMenu_EnterMenuOrModifyItemVisibility
18 at MENUITEM.szName, dw g_szItemBackToCfgMenu
19 at MENUITEM.szQuickInfo, dw g_szNfoIdeBackToCfgMenu
20 at MENUITEM.szHelp, dw g_szNfoIdeBackToCfgMenu
21 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
22 at MENUITEM.bType, db TYPE_MENUITEM_PAGEBACK
23iend
24
25g_MenuitemIdeControllerMasterDrive:
26istruc MENUITEM
27 at MENUITEM.fnActivate, dw MasterDrive
28 at MENUITEM.szName, dw g_szItemIdeMaster
29 at MENUITEM.szQuickInfo, dw g_szNfoIdeMaster
30 at MENUITEM.szHelp, dw g_szNfoIdeMaster
31 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
32 at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
33iend
34
35g_MenuitemIdeControllerSlaveDrive:
36istruc MENUITEM
37 at MENUITEM.fnActivate, dw SlaveDrive
38 at MENUITEM.szName, dw g_szItemIdeSlave
39 at MENUITEM.szQuickInfo, dw g_szNfoIdeSlave
40 at MENUITEM.szHelp, dw g_szNfoIdeSlave
41 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
42 at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
43iend
44
45g_MenuitemIdeControllerDevice:
46istruc MENUITEM
47 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
48 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
49 at MENUITEM.szName, dw g_szItemIdeDevice
50 at MENUITEM.szQuickInfo, dw g_szNfoIdeDevice
51 at MENUITEM.szHelp, dw g_szNfoIdeDevice
52 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_MODIFY_MENU
53 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
54 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
55 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgDevice
56 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceCfgDevice
57 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForDevice
58 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForDevice
59 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw IdeControllerMenu_WriteDevice
60iend
61
62g_MenuitemIdeControllerCommandBlockAddress:
63istruc MENUITEM
64 at MENUITEM.fnActivate, dw Menuitem_ActivateHexInputForMenuitemInDSSI
65 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
66 at MENUITEM.szName, dw g_szItemIdeCmdPort
67 at MENUITEM.szQuickInfo, dw g_szNfoIdeCmdPort
68 at MENUITEM.szHelp, dw g_szHelpIdeCmdPort
69 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
70 at MENUITEM.bType, db TYPE_MENUITEM_HEX
71 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
72 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeCmdPort
73 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 0
74 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw -1
75iend
76
77g_MenuitemIdeControllerControlBlockAddress:
78istruc MENUITEM
79 at MENUITEM.fnActivate, dw Menuitem_ActivateHexInputForMenuitemInDSSI
80 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
81 at MENUITEM.szName, dw g_szItemIdeCtrlPort
82 at MENUITEM.szQuickInfo, dw g_szNfoIdeCtrlPort
83 at MENUITEM.szHelp, dw g_szHelpIdeCtrlPort
84 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
85 at MENUITEM.bType, db TYPE_MENUITEM_HEX
86 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
87 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeCtrlPort
88 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 0
89 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw -1
90iend
91
92g_MenuitemIdeControllerSerialCOM:
93istruc MENUITEM
94 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
95 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
96 at MENUITEM.szName, dw g_szItemSerialCOM
97 at MENUITEM.szQuickInfo, dw g_szNfoIdeSerialCOM
98 at MENUITEM.szHelp, dw g_szHelpIdeSerialCOM
99 at MENUITEM.bFlags, db FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
100 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
101 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
102 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgDevice
103 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szSerialCOMChoice
104 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgbChoiceToValueLookupForCOM
105 at MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup, dw g_rgszChoiceToStringLookupForCOM
106 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw IdeControllerMenu_SerialWriteCOM
107iend
108
109g_MenuitemIdeControllerSerialPort:
110istruc MENUITEM
111 at MENUITEM.fnActivate, dw Menuitem_ActivateHexInputForMenuitemInDSSI
112 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
113 at MENUITEM.szName, dw g_szItemSerialPort
114 at MENUITEM.szQuickInfo, dw g_szNfoIdeSerialPort
115 at MENUITEM.szHelp, dw g_szHelpIdeSerialPort
116 at MENUITEM.bFlags, db FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
117 at MENUITEM.bType, db TYPE_MENUITEM_HEX
118 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
119 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeCmdPort
120 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 8h
121 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 3f8h
122 at MENUITEM.itemValue + ITEM_VALUE.fnValueReader, dw IdeControllerMenu_SerialReadPort
123 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw IdeControllerMenu_SerialWritePort
124iend
125
126g_MenuitemIdeControllerSerialBaud:
127istruc MENUITEM
128 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
129 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
130 at MENUITEM.szName, dw g_szItemSerialBaud
131 at MENUITEM.szQuickInfo, dw g_szNfoIdeSerialBaud
132 at MENUITEM.szHelp, dw g_szHelpIdeSerialBaud
133 at MENUITEM.bFlags, db FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
134 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
135 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
136 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgDevice
137 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szSerialBaudChoice
138 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgbChoiceToValueLookupForBaud
139 at MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup, dw g_rgszChoiceToStringLookupForBaud
140iend
141
142g_MenuitemIdeControllerEnableInterrupt:
143istruc MENUITEM
144 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
145 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
146 at MENUITEM.szName, dw g_szItemIdeEnIRQ
147 at MENUITEM.szQuickInfo, dw g_szNfoIdeEnIRQ
148 at MENUITEM.szHelp, dw g_szHelpIdeEnIRQ
149 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
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_szDlgIdeEnIRQ
153 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
154 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForFlagBooleans
155 at MENUITEM.itemValue + ITEM_VALUE.wValueBitmask, dw 15
156iend
157
158g_MenuitemIdeControllerIdeIRQ:
159istruc MENUITEM
160 at MENUITEM.fnActivate, dw Menuitem_ActivateUnsignedInputForMenuitemInDSSI
161 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
162 at MENUITEM.szName, dw g_szItemIdeIRQ
163 at MENUITEM.szQuickInfo, dw g_szNfoIdeIRQ
164 at MENUITEM.szHelp, dw g_szHelpIdeIRQ
165 at MENUITEM.bFlags, db FLG_MENUITEM_BYTEVALUE
166 at MENUITEM.bType, db TYPE_MENUITEM_UNSIGNED
167 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
168 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeIRQ
169 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 2
170 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 15
171iend
172
173g_rgwChoiceToValueLookupForDevice:
174 dw DEVICE_8BIT_DUAL_PORT_XTIDE
175 dw DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
176 dw DEVICE_8BIT_SINGLE_PORT
177 dw DEVICE_16BIT_ATA
178 dw DEVICE_32BIT_ATA
179 dw DEVICE_SERIAL_PORT
180g_rgszValueToStringLookupForDevice:
181 dw g_szValueCfgDeviceDual8b
182 dw g_szValueCfgDeviceMod
183 dw g_szValueCfgDeviceSingle8b
184 dw g_szValueCfgDevice16b
185 dw g_szValueCfgDevice32b
186 dw g_szValueCfgDeviceSerial
187
188g_rgbChoiceToValueLookupForCOM:
189 dw '1'
190 dw '2'
191 dw '3'
192 dw '4'
193 dw '5'
194 dw '6'
195 dw '7'
196 dw '8'
197 dw '9'
198 dw 'A'
199 dw 'B'
200 dw 'C'
201 dw 'x' ; must be last entry (see reader/write routines)
202g_rgszChoiceToStringLookupForCOM:
203 dw g_szValueCfgCOM1
204 dw g_szValueCfgCOM2
205 dw g_szValueCfgCOM3
206 dw g_szValueCfgCOM4
207 dw g_szValueCfgCOM5
208 dw g_szValueCfgCOM6
209 dw g_szValueCfgCOM7
210 dw g_szValueCfgCOM8
211 dw g_szValueCfgCOM9
212 dw g_szValueCfgCOMA
213 dw g_szValueCfgCOMB
214 dw g_szValueCfgCOMC
215 dw g_szValueCfgCOMx
216 dw NULL
217
218DEVICE_SERIAL_DEFAULT_CUSTOM_PORT EQU 300h ; can't be any of the pre-defined COM values
219
220PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
221 db DEVICE_SERIAL_COM1 >> 2
222 db DEVICE_SERIAL_COM2 >> 2
223 db DEVICE_SERIAL_COM3 >> 2
224 db DEVICE_SERIAL_COM4 >> 2
225 db DEVICE_SERIAL_COM5 >> 2
226 db DEVICE_SERIAL_COM6 >> 2
227 db DEVICE_SERIAL_COM7 >> 2
228 db DEVICE_SERIAL_COM8 >> 2
229 db DEVICE_SERIAL_COM9 >> 2
230 db DEVICE_SERIAL_COMA >> 2
231 db DEVICE_SERIAL_COMB >> 2
232 db DEVICE_SERIAL_COMC >> 2
233 db DEVICE_SERIAL_DEFAULT_CUSTOM_PORT >> 2 ; must be last entry (see reader/writer routines)
234DEVICE_SERIAL_DEFAULT_COM EQU '1'
235
236g_rgbChoiceToValueLookupForBaud:
237 dw (115200 / 115200) & 0xff
238 dw (115200 / 57600) & 0xff
239 dw (115200 / 38400) & 0xff
240 dw (115200 / 28800) & 0xff
241 dw (115200 / 19200) & 0xff
242 dw (115200 / 9600) & 0xff
243 dw (115200 / 4800) & 0xff
244 dw (115200 / 2400) & 0xff
245g_rgszChoiceToStringLookupForBaud:
246 dw g_szValueCfgBaud115_2
247 dw g_szValueCfgBaud57_6
248 dw g_szValueCfgBaud38_4
249 dw g_szValueCfgBaud28_8
250 dw g_szValueCfgBaud19_2
251 dw g_szValueCfgBaud9600
252 dw g_szValueCfgBaud4800
253 dw g_szValueCfgBaud2400
254 dw NULL
255DEVICE_SERIAL_DEFAULT_BAUD EQU ((115200 / 9600) & 0xff)
256
257; Section containing code
258SECTION .text
259
260;--------------------------------------------------------------------
261; IdeControllerMenu_InitializeToIdevarsOffsetInBX
262; Parameters:
263; SS:BP: Menu handle
264; Returns:
265; Nothing
266; Corrupts registers:
267; AX
268;--------------------------------------------------------------------
269ALIGN JUMP_ALIGN
270IdeControllerMenu_InitializeToIdevarsOffsetInBX:
271 lea ax, [bx+IDEVARS.drvParamsMaster]
272 mov [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
273
274 lea ax, [bx+IDEVARS.drvParamsSlave]
275 mov [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
276
277 lea ax, [bx+IDEVARS.bDevice]
278 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
279
280 lea ax, [bx+IDEVARS.wPort]
281 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
282
283 lea ax, [bx+IDEVARS.bSerialPort]
284 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
285
286 lea ax, [bx+IDEVARS.bSerialBaud]
287 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
288
289 lea ax, [bx+IDEVARS.wPortCtrl]
290 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
291
292 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
293 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
294
295 lea ax, [bx+IDEVARS.bIRQ]
296 mov [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
297 mov [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
298
299 ret
300
301
302;--------------------------------------------------------------------
303; IdeControllerMenu_EnterMenuOrModifyItemVisibility
304; Parameters:
305; SS:BP: Menu handle
306; Returns:
307; Nothing
308; Corrupts registers:
309; All, except BP
310;--------------------------------------------------------------------
311ALIGN JUMP_ALIGN
312IdeControllerMenu_EnterMenuOrModifyItemVisibility:
313 push cs
314 pop ds
315 call .EnableOrDisableIRQ
316 call .EnableOrDisableSerial
317 mov si, g_MenupageForIdeControllerMenu
318 jmp Menupage_ChangeToNewMenupageInDSSI
319
320;--------------------------------------------------------------------
321; .EnableOrDisableIRQ
322; Parameters:
323; SS:BP: Menu handle
324; Returns:
325; Nothing
326; Corrupts registers:
327; AX, BX
328;--------------------------------------------------------------------
329ALIGN JUMP_ALIGN
330.EnableOrDisableIRQ:
331 mov bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
332 call Buffers_GetRomvarsValueToAXfromOffsetInBX
333 mov bx, g_MenuitemIdeControllerIdeIRQ
334 test al, al
335 jz SHORT .DisableMenuitemFromCSBX
336 ; Fall to .EnableMenuitemFromCSBX
337
338;--------------------------------------------------------------------
339; .EnableMenuitemFromCSBX
340; .DisableMenuitemFromCSBX
341; Parameters:
342; CS:BX: Ptr to MENUITEM
343; Returns:
344; Nothing
345; Corrupts registers:
346; Nothing
347;--------------------------------------------------------------------
348ALIGN JUMP_ALIGN
349.EnableMenuitemFromCSBX:
350 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
351 ret
352
353ALIGN JUMP_ALIGN
354.DisableMenuitemFromCSBX:
355 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
356 ret
357
358.EnableOrDisableSerial:
359 mov bx, g_MenuitemIdeControllerCommandBlockAddress
360 call .DisableMenuitemFromCSBX
361
362 mov bx, g_MenuitemIdeControllerControlBlockAddress
363 call .DisableMenuitemFromCSBX
364
365 mov bx, g_MenuitemIdeControllerEnableInterrupt
366 call .DisableMenuitemFromCSBX
367
368 mov bx, g_MenuitemIdeControllerSerialBaud
369 call .DisableMenuitemFromCSBX
370
371 mov bx, g_MenuitemIdeControllerSerialCOM
372 call .DisableMenuitemFromCSBX
373
374 mov bx, g_MenuitemIdeControllerSerialPort
375 call .DisableMenuitemFromCSBX
376
377 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
378 call Buffers_GetRomvarsValueToAXfromOffsetInBX
379 cmp al,DEVICE_SERIAL_PORT
380 jnz .DisableAllSerial
381
382 mov bx, g_MenuitemIdeControllerSerialCOM
383 call .EnableMenuitemFromCSBX
384
385 mov bx, g_MenuitemIdeControllerSerialBaud
386 call .EnableMenuitemFromCSBX
387
388 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
389 call Buffers_GetRomvarsValueToAXfromOffsetInBX
390 mov bx, g_MenuitemIdeControllerSerialPort
391 cmp al,'x'
392 jz .EnableMenuitemFromCSBX
393 jmp .DisableMenuitemFromCSBX
394
395.DisableAllSerial:
396
397 mov bx, g_MenuitemIdeControllerCommandBlockAddress
398 call .EnableMenuitemFromCSBX
399
400 mov bx, g_MenuitemIdeControllerControlBlockAddress
401 call .EnableMenuitemFromCSBX
402
403 mov bx, g_MenuitemIdeControllerEnableInterrupt
404 call .EnableMenuitemFromCSBX
405
406 ret
407
408;--------------------------------------------------------------------
409; MENUITEM activation functions (.fnActivate)
410; Parameters:
411; SS:BP: Ptr to MENU
412; Returns:
413; Nothing
414; Corrupts registers:
415; All, except segments
416;--------------------------------------------------------------------
417ALIGN JUMP_ALIGN
418MasterDrive:
419 mov bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
420 jmp SHORT DisplayMasterSlaveMenu
421
422ALIGN JUMP_ALIGN
423SlaveDrive:
424 mov bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
425 ; Fall to DisplayMasterSlaveMenu
426
427ALIGN JUMP_ALIGN
428DisplayMasterSlaveMenu:
429;
430; block mode is not supported on serial drives, disable/enable the option as appropriate
431;
432 push bx
433 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
434 call Buffers_GetRomvarsValueToAXfromOffsetInBX
435 mov bx, g_MenuitemMasterSlaveBlockModeTransfers
436 cmp al,DEVICE_SERIAL_PORT
437 jz .isSerial
438 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
439 jmp .isDone
440.isSerial:
441 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
442.isDone:
443 pop bx
444
445 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
446 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
447
448;------------------------------------------------------------------------------------------
449;
450; Reader/Writer Routines
451;
452; For serial drives, we pack the port number and baud rate into a single byte, and thus
453; we need to take care to properly read/write just the bits we need. In addition, since
454; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
455; default the values stored in both these words when switching in and out of the Serial
456; device choice.
457;
458; Writers:
459; Parameters:
460; AX: Value that the MENUITEM system was interacting with
461; ES:DI: ROMVARS location where the value is to be stored
462; DS:SI: MENUITEM pointer
463; Returns:
464; AX: Value to actually write to ROMVARS
465; Corrupts registers:
466; AX
467;
468; Readers:
469; Parameters:
470; AX: Value read from the ROMVARS location
471; ES:DI: ROMVARS location where the value was just read from
472; DS:SI: MENUITEM pointer
473; Returns:
474; AX: Value that the MENUITEM system will interact with and display
475; Corrupts registers:
476; AX
477;
478
479;
480; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
481; changing in/out of a Serial device (since we use these bytes in radically different ways). Also clear the
482; interrupt informtion is we are moving into Serial (since the serial device does not use interrupts).
483;
484ALIGN JUMP_ALIGN
485IdeControllerMenu_WriteDevice:
486 push ax
487 push bx
488 push di
489
490 mov bl,[es:di] ; what is the current Device?
491
492 add di,IDEVARS.wPort - IDEVARS.bDevice ; Get ready to set the Port addresses
493
494 cmp al,DEVICE_SERIAL_PORT
495 jz .changingToSerial
496
497 cmp bl,DEVICE_SERIAL_PORT
498 jnz .done ; if we weren't Serial before, nothing to do
499
500.changingFromSerial:
501 cmp al,DEVICE_16BIT_ATA
502 jl .xtide
503
504 mov ax,DEVICE_ATA_DEFAULT_PORT ; Defaults for 16-bit and better ATA devices
505 mov bx,DEVICE_ATA_DEFAULT_PORTCTRL
506 jmp .writeNonSerial
507
508.xtide:
509 mov ax,DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE devices
510 mov bx,DEVICE_XTIDE_DEFAULT_PORTCTRL
511
512.writeNonSerial:
513 mov [es:di],ax ; Store defaults in IDEVARS.wPort and IDEVARS.wPortCtrl
514 mov [es:di+2],bx
515
516 jmp .done
517
518.changingToSerial:
519 cmp bl,DEVICE_SERIAL_PORT
520 jz .done ; if we were already serial, nothing to do
521
522 mov byte [es:di+IDEVARS.bSerialBaud-IDEVARS.wPort],DEVICE_SERIAL_DEFAULT_BAUD
523
524 mov al,DEVICE_SERIAL_DEFAULT_COM
525 add di,IDEVARS.bSerialCOMPortChar-IDEVARS.wPort
526 call IdeControllerMenu_SerialWriteCOM
527 mov [es:di],al
528
529.done:
530 pop di
531 pop bx
532 pop ax
533
534 ret
535
536;
537; Doesn't modify COM character (unless it is not recognized, which would be an error case),
538; But does update the port address based on COM port selection
539;
540ALIGN JUMP_ALIGN
541IdeControllerMenu_SerialWriteCOM:
542 push ax
543 push bx
544 push si
545
546 mov si,g_rgbChoiceToValueLookupForCOM
547 mov bx,PackedCOMPortAddresses
548
549.loop:
550 mov ah,[bx]
551
552 cmp ah,(DEVICE_SERIAL_DEFAULT_CUSTOM_PORT >> 2)
553 jz .notFound
554
555 cmp al,[si]
556 jz .found
557
558 inc si
559 inc si
560 inc bx
561
562 jmp .loop
563
564.notFound:
565 mov al, 'x'
566
567.found:
568 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
569
570 pop si
571 pop bx
572 pop ax
573
574 ret
575
576
577;
578; Packed Port (byte) -> Numeric Port (word)
579;
580ALIGN JUMP_ALIGN
581IdeControllerMenu_SerialReadPort:
582 xor ah,ah
583 shl ax,1
584 shl ax,1
585 ret
586
587;
588; Numeric Port (word) -> Packed Port (byte)
589; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
590;
591ALIGN JUMP_ALIGN
592IdeControllerMenu_SerialWritePort:
593 push bx
594 push si
595
596 shr ax,1
597 shr ax,1
598 and al,0feh ; force 8-byte boundary
599
600 mov si,g_rgbChoiceToValueLookupForCOM
601 mov bx,PackedCOMPortAddresses ; loop, looking for port address in known COM address list
602
603.loop:
604 mov ah,[si]
605 cmp ah,'x'
606 jz .found
607
608 cmp al,[bx]
609 jz .found
610
611 inc si
612 inc si
613 inc bx
614
615 jmp .loop
616
617.found:
618 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
619
620 pop si
621 pop bx
622
623 ret
624
625
626
627
628
629
630
Note: See TracBrowser for help on using the repository browser.