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

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

Changes:

  • Optimizations (both for size and speed) in IdeTransfer.asm and MemIdeTransfer.asm
  • Fixed a bug where the SingleByteRead/Write functions in IdeTransfer.asm would fail on 128 sector transfers.
  • Fixed some typos and errors in general, comments etc.
File size: 20.5 KB
RevLine 
[57]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
[59]11 at MENUPAGE.fnBack, dw ConfigurationMenu_EnterMenuOrModifyItemVisibility
[199]12 at MENUPAGE.wMenuitems, dw 11
[57]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
[153]45g_MenuitemIdeControllerDevice:
[57]46istruc MENUITEM
[108]47 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]48 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[153]49 at MENUITEM.szName, dw g_szItemIdeDevice
50 at MENUITEM.szQuickInfo, dw g_szNfoIdeDevice
51 at MENUITEM.szHelp, dw g_szNfoIdeDevice
[199]52 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_MODIFY_MENU
[108]53 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[57]54 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
[153]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
[199]59 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw IdeControllerMenu_WriteDevice
[57]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
[199]92g_MenuitemIdeControllerSerialCOM:
93istruc MENUITEM
94 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]95 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[199]96 at MENUITEM.szName, dw g_szItemSerialCOM
97 at MENUITEM.szQuickInfo, dw g_szNfoIdeSerialCOM
98 at MENUITEM.szHelp, dw g_szHelpIdeSerialCOM
[233]99 at MENUITEM.bFlags, db FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
[242]100 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[199]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
[233]104 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgbChoiceToValueLookupForCOM
105 at MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup, dw g_rgszChoiceToStringLookupForCOM
[199]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
[233]116 at MENUITEM.bFlags, db FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
[199]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
[233]120 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 8h
121 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 3f8h
[199]122 at MENUITEM.itemValue + ITEM_VALUE.fnValueReader, dw IdeControllerMenu_SerialReadPort
123 at MENUITEM.itemValue + ITEM_VALUE.fnValueWriter, dw IdeControllerMenu_SerialWritePort
[242]124iend
[199]125
[242]126g_MenuitemIdeControllerSerialBaud:
[199]127istruc MENUITEM
128 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[233]129 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
[199]130 at MENUITEM.szName, dw g_szItemSerialBaud
131 at MENUITEM.szQuickInfo, dw g_szNfoIdeSerialBaud
132 at MENUITEM.szHelp, dw g_szHelpIdeSerialBaud
[233]133 at MENUITEM.bFlags, db FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
[199]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
[233]138 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgbChoiceToValueLookupForBaud
139 at MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup, dw g_rgszChoiceToStringLookupForBaud
[199]140iend
[242]141
[57]142g_MenuitemIdeControllerEnableInterrupt:
143istruc MENUITEM
[108]144 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]145 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
[57]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
[108]150 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[57]151 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw NULL
152 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgIdeEnIRQ
[108]153 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
[57]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
[153]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
[57]187
[233]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)
[242]202g_rgszChoiceToStringLookupForCOM:
[199]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
[233]216 dw NULL
[57]217
[233]218DEVICE_SERIAL_DEFAULT_CUSTOM_PORT EQU 300h ; can't be any of the pre-defined COM values
[199]219
[233]220PackedCOMPortAddresses: ; COM1 - COMC (or COM12)
221 db DEVICE_SERIAL_COM1 >> 2
[242]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
[233]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'
[242]235
[233]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)
[199]256
[57]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
[153]277 lea ax, [bx+IDEVARS.bDevice]
278 mov [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[57]279
280 lea ax, [bx+IDEVARS.wPort]
281 mov [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]282
283 lea ax, [bx+IDEVARS.bSerialPort]
[199]284 mov [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[233]285
286 lea ax, [bx+IDEVARS.bSerialBaud]
[199]287 mov [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]288
[57]289 lea ax, [bx+IDEVARS.wPortCtrl]
290 mov [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[242]291
[233]292 lea ax, [bx+IDEVARS.bSerialCOMPortChar]
[242]293 mov [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
[57]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
[199]298
[57]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
[199]316 call .EnableOrDisableSerial
[57]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
[109]334 test al, al
[57]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
[199]358.EnableOrDisableSerial:
359 mov bx, g_MenuitemIdeControllerCommandBlockAddress
360 call .DisableMenuitemFromCSBX
[57]361
[199]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
[242]376
377 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[199]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
[242]388 mov bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[199]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
[242]404 call .EnableMenuitemFromCSBX
[199]405
406 ret
[242]407
[57]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:
[233]429;
430; block mode is not supported on serial drives, disable/enable the option as appropriate
431;
432 push bx
[242]433 mov bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
[233]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
[242]440.isSerial:
[233]441 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
442.isDone:
443 pop bx
[242]444
[57]445 call MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
446 jmp MasterSlaveMenu_EnterMenuOrModifyItemVisibility
[199]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
[242]455; default the values stored in both these words when switching in and out of the Serial
[199]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
[242]481; changing in/out of a Serial device (since we use these bytes in radically different ways).
[199]482;
483ALIGN JUMP_ALIGN
484IdeControllerMenu_WriteDevice:
485 push ax
486 push bx
487 push di
488
489 mov bl,[es:di] ; what is the current Device?
[242]490
[199]491 add di,IDEVARS.wPort - IDEVARS.bDevice ; Get ready to set the Port addresses
[242]492
[199]493 cmp al,DEVICE_SERIAL_PORT
494 jz .changingToSerial
495
496 cmp bl,DEVICE_SERIAL_PORT
497 jnz .done ; if we weren't Serial before, nothing to do
498
499.changingFromSerial:
500 cmp al,DEVICE_16BIT_ATA
501
[242]502 mov ax,DEVICE_XTIDE_DEFAULT_PORT ; Defaults for 8-bit XTIDE devices
503 mov bx,DEVICE_XTIDE_DEFAULT_PORTCTRL
504
505 jb .writeNonSerial
506
[199]507 mov ax,DEVICE_ATA_DEFAULT_PORT ; Defaults for 16-bit and better ATA devices
508 mov bx,DEVICE_ATA_DEFAULT_PORTCTRL
509
[242]510.writeNonSerial:
511 stosw ; Store defaults in IDEVARS.wPort and IDEVARS.wPortCtrl
512 xchg bx, ax
513 stosw
[199]514
515 jmp .done
516
[242]517.changingToSerial:
[199]518 cmp bl,DEVICE_SERIAL_PORT
519 jz .done ; if we were already serial, nothing to do
520
[233]521 mov byte [es:di+IDEVARS.bSerialBaud-IDEVARS.wPort],DEVICE_SERIAL_DEFAULT_BAUD
522
523 mov al,DEVICE_SERIAL_DEFAULT_COM
524 add di,IDEVARS.bSerialCOMPortChar-IDEVARS.wPort
[199]525 call IdeControllerMenu_SerialWriteCOM
[242]526 stosb
527
528.done:
[199]529 pop di
530 pop bx
531 pop ax
532
533 ret
534
535;
[233]536; Doesn't modify COM character (unless it is not recognized, which would be an error case),
[242]537; But does update the port address based on COM port selection
538;
[199]539ALIGN JUMP_ALIGN
540IdeControllerMenu_SerialWriteCOM:
[233]541 push ax
[199]542 push bx
[233]543 push si
[242]544
[233]545 mov si,g_rgbChoiceToValueLookupForCOM
546 mov bx,PackedCOMPortAddresses
[199]547
[233]548.loop:
549 mov ah,[bx]
[199]550
[233]551 cmp ah,(DEVICE_SERIAL_DEFAULT_CUSTOM_PORT >> 2)
552 jz .notFound
[242]553
[233]554 cmp al,[si]
555 jz .found
[242]556
[233]557 inc si
558 inc si
559 inc bx
[242]560
[233]561 jmp .loop
[199]562
[233]563.notFound:
564 mov al, 'x'
[242]565
566.found:
[233]567 mov [es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
[199]568
[233]569 pop si
[199]570 pop bx
[233]571 pop ax
[242]572
[199]573 ret
574
[242]575
[199]576;
[233]577; Packed Port (byte) -> Numeric Port (word)
[242]578;
[199]579ALIGN JUMP_ALIGN
[233]580IdeControllerMenu_SerialReadPort:
581 xor ah,ah
[242]582 eSHL_IM ax, 2
[199]583 ret
584
585;
[233]586; Numeric Port (word) -> Packed Port (byte)
587; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
[199]588;
589ALIGN JUMP_ALIGN
[242]590IdeControllerMenu_SerialWritePort:
[199]591 push bx
[233]592 push si
[199]593
[242]594 eSHR_IM ax, 2
[233]595 and al,0feh ; force 8-byte boundary
[199]596
[242]597 mov si,g_rgbChoiceToValueLookupForCOM
[233]598 mov bx,PackedCOMPortAddresses ; loop, looking for port address in known COM address list
599
600.loop:
601 mov ah,[si]
602 cmp ah,'x'
603 jz .found
[242]604
[233]605 cmp al,[bx]
606 jz .found
[242]607
[233]608 inc si
609 inc si
[199]610 inc bx
[242]611
[233]612 jmp .loop
[199]613
[242]614.found:
[233]615 mov [es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
616
617 pop si
[199]618 pop bx
619
[233]620 ret
[199]621
Note: See TracBrowser for help on using the repository browser.