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

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

Adding proper serial port support to the Configurator, which required some minor changes elsewhere. Also added an option, off by default, to automatically scan for serial drives at the end of normal drive detection (no ALT key required, although that is still available if the option is off).

File size: 22.0 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_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
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_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
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
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  NULL
105    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForCOM
106    at  MENUITEM.itemValue + ITEM_VALUE.fnValueReader,              dw  IdeControllerMenu_SerialReadCOM 
107    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_SerialWriteCOM
108iend
109
110g_MenuitemIdeControllerSerialPort:
111istruc MENUITEM
112    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateHexInputForMenuitemInDSSI
113    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
114    at  MENUITEM.szName,            dw  g_szItemSerialPort
115    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSerialPort
116    at  MENUITEM.szHelp,            dw  g_szHelpIdeSerialPort
117    at  MENUITEM.bFlags,            db  FLG_MENUITEM_MODIFY_MENU       
118    at  MENUITEM.bType,             db  TYPE_MENUITEM_HEX
119    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
120    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeCmdPort
121    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  240h
122    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  438h
123    at  MENUITEM.itemValue + ITEM_VALUE.fnValueReader,              dw  IdeControllerMenu_SerialReadPort
124    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_SerialWritePort
125iend       
126
127g_MenuitemIdeControllerSerialBaud:     
128istruc MENUITEM
129    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
130    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
131    at  MENUITEM.szName,            dw  g_szItemSerialBaud
132    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeSerialBaud
133    at  MENUITEM.szHelp,            dw  g_szHelpIdeSerialBaud
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  NULL
139    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForBaud
140    at  MENUITEM.itemValue + ITEM_VALUE.fnValueReader,              dw  IdeControllerMenu_SerialReadBaud
141    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  IdeControllerMenu_SerialWriteBaud
142iend
143       
144g_MenuitemIdeControllerEnableInterrupt:
145istruc MENUITEM
146    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
147    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
148    at  MENUITEM.szName,            dw  g_szItemIdeEnIRQ
149    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeEnIRQ
150    at  MENUITEM.szHelp,            dw  g_szHelpIdeEnIRQ
151    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
152    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
153    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
154    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeEnIRQ
155    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBooleanFlag
156    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForFlagBooleans
157    at  MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,              dw  15
158iend
159
160g_MenuitemIdeControllerIdeIRQ:
161istruc MENUITEM
162    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateUnsignedInputForMenuitemInDSSI
163    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
164    at  MENUITEM.szName,            dw  g_szItemIdeIRQ
165    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeIRQ
166    at  MENUITEM.szHelp,            dw  g_szHelpIdeIRQ
167    at  MENUITEM.bFlags,            db  FLG_MENUITEM_BYTEVALUE
168    at  MENUITEM.bType,             db  TYPE_MENUITEM_UNSIGNED
169    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  NULL
170    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgIdeIRQ
171    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  2
172    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  15
173iend
174
175g_rgwChoiceToValueLookupForDevice:
176    dw  DEVICE_8BIT_DUAL_PORT_XTIDE
177    dw  DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0
178    dw  DEVICE_8BIT_SINGLE_PORT
179    dw  DEVICE_16BIT_ATA
180    dw  DEVICE_32BIT_ATA
181    dw  DEVICE_SERIAL_PORT
182g_rgszValueToStringLookupForDevice:
183    dw  g_szValueCfgDeviceDual8b
184    dw  g_szValueCfgDeviceMod
185    dw  g_szValueCfgDeviceSingle8b
186    dw  g_szValueCfgDevice16b
187    dw  g_szValueCfgDevice32b
188    dw  g_szValueCfgDeviceSerial
189
190g_rgszValueToStringLookupForCOM:       
191    dw  g_szValueCfgCOM1
192    dw  g_szValueCfgCOM2
193    dw  g_szValueCfgCOM3
194    dw  g_szValueCfgCOM4
195    dw  g_szValueCfgCOM5
196    dw  g_szValueCfgCOM6
197    dw  g_szValueCfgCOM7
198    dw  g_szValueCfgCOM8
199    dw  g_szValueCfgCOM9
200    dw  g_szValueCfgCOMA
201    dw  g_szValueCfgCOMB
202    dw  g_szValueCfgCOMC
203    dw  g_szValueCfgCOMx
204
205g_rgszValueToStringLookupForBaud:
206    dw  g_szValueCfgBaud2400
207    dw  g_szValueCfgBaud9600
208    dw  g_szValueCfgBaud38_4
209    dw  g_szValueCfgBaud115_2
210
211g_wPrintBaud:
212    dw  DEVICE_SERIAL_PRINTBAUD_2400
213    dw  DEVICE_SERIAL_PRINTBAUD_9600
214    dw  DEVICE_SERIAL_PRINTBAUD_38_4
215    dw  DEVICE_SERIAL_PRINTBAUD_115_2
216
217; Section containing code
218SECTION .text
219
220;--------------------------------------------------------------------
221; IdeControllerMenu_InitializeToIdevarsOffsetInBX
222;   Parameters:
223;       SS:BP:  Menu handle
224;   Returns:
225;       Nothing
226;   Corrupts registers:
227;       AX
228;--------------------------------------------------------------------
229ALIGN JUMP_ALIGN
230IdeControllerMenu_InitializeToIdevarsOffsetInBX:
231    lea     ax, [bx+IDEVARS.drvParamsMaster]
232    mov     [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
233
234    lea     ax, [bx+IDEVARS.drvParamsSlave]
235    mov     [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
236
237    lea     ax, [bx+IDEVARS.bDevice]
238    mov     [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
239
240    lea     ax, [bx+IDEVARS.wPort]
241    mov     [cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
242    mov     [cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
243    mov     [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax     
244    mov     [cs:g_MenuitemIdeControllerSerialBaud+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
245                ;; baud also modifies the next two bytes (print chars in wPortCtrl), but it never reads them
246       
247    lea     ax, [bx+IDEVARS.wPortCtrl]
248    mov     [cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
249
250    lea     ax, [bx+IDEVARS.bIRQ]
251    mov     [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
252    mov     [cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
253
254    ret
255
256
257;--------------------------------------------------------------------
258; IdeControllerMenu_EnterMenuOrModifyItemVisibility
259;   Parameters:
260;       SS:BP:  Menu handle
261;   Returns:
262;       Nothing
263;   Corrupts registers:
264;       All, except BP
265;--------------------------------------------------------------------
266ALIGN JUMP_ALIGN
267IdeControllerMenu_EnterMenuOrModifyItemVisibility:
268    push    cs
269    pop     ds
270    call    .EnableOrDisableIRQ
271    call    .EnableOrDisableSerial
272    mov     si, g_MenupageForIdeControllerMenu
273    jmp     Menupage_ChangeToNewMenupageInDSSI
274
275;--------------------------------------------------------------------
276; .EnableOrDisableIRQ
277;   Parameters:
278;       SS:BP:  Menu handle
279;   Returns:
280;       Nothing
281;   Corrupts registers:
282;       AX, BX
283;--------------------------------------------------------------------
284ALIGN JUMP_ALIGN
285.EnableOrDisableIRQ:
286    mov     bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
287    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
288    mov     bx, g_MenuitemIdeControllerIdeIRQ
289    test    al, al
290    jz      SHORT .DisableMenuitemFromCSBX
291    ; Fall to .EnableMenuitemFromCSBX
292
293;--------------------------------------------------------------------
294; .EnableMenuitemFromCSBX
295; .DisableMenuitemFromCSBX
296;   Parameters:
297;       CS:BX:  Ptr to MENUITEM
298;   Returns:
299;       Nothing
300;   Corrupts registers:
301;       Nothing
302;--------------------------------------------------------------------
303ALIGN JUMP_ALIGN
304.EnableMenuitemFromCSBX:
305    or      BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
306    ret
307
308ALIGN JUMP_ALIGN
309.DisableMenuitemFromCSBX:
310    and     BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
311    ret
312
313.EnableOrDisableSerial:
314    mov     bx, g_MenuitemIdeControllerCommandBlockAddress
315    call    .DisableMenuitemFromCSBX
316
317    mov     bx, g_MenuitemIdeControllerControlBlockAddress
318    call    .DisableMenuitemFromCSBX
319
320    mov     bx, g_MenuitemIdeControllerEnableInterrupt
321    call    .DisableMenuitemFromCSBX
322
323    mov     bx, g_MenuitemIdeControllerSerialBaud
324    call    .DisableMenuitemFromCSBX
325
326    mov     bx, g_MenuitemIdeControllerSerialCOM
327    call    .DisableMenuitemFromCSBX
328
329    mov     bx, g_MenuitemIdeControllerSerialPort
330    call    .DisableMenuitemFromCSBX
331               
332    mov     bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]       
333    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
334    cmp     al,DEVICE_SERIAL_PORT
335    jnz     .DisableAllSerial
336
337    mov     bx, g_MenuitemIdeControllerSerialCOM
338    call    .EnableMenuitemFromCSBX
339
340    mov     bx, g_MenuitemIdeControllerSerialBaud
341    call    .EnableMenuitemFromCSBX
342
343    mov     bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]         
344    call    Buffers_GetRomvarsValueToAXfromOffsetInBX
345    mov     bx, g_MenuitemIdeControllerSerialPort
346    cmp     al,'x'
347    jz      .EnableMenuitemFromCSBX
348    jmp     .DisableMenuitemFromCSBX
349
350.DisableAllSerial:
351
352    mov     bx, g_MenuitemIdeControllerCommandBlockAddress
353    call    .EnableMenuitemFromCSBX
354
355    mov     bx, g_MenuitemIdeControllerControlBlockAddress
356    call    .EnableMenuitemFromCSBX
357
358    mov     bx, g_MenuitemIdeControllerEnableInterrupt
359    call    .EnableMenuitemFromCSBX             
360
361    ret
362       
363;--------------------------------------------------------------------
364; MENUITEM activation functions (.fnActivate)
365;   Parameters:
366;       SS:BP:  Ptr to MENU
367;   Returns:
368;       Nothing
369;   Corrupts registers:
370;       All, except segments
371;--------------------------------------------------------------------
372ALIGN JUMP_ALIGN
373MasterDrive:
374    mov     bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
375    jmp     SHORT DisplayMasterSlaveMenu
376
377ALIGN JUMP_ALIGN
378SlaveDrive:
379    mov     bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
380    ; Fall to DisplayMasterSlaveMenu
381
382ALIGN JUMP_ALIGN
383DisplayMasterSlaveMenu:
384    call    MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
385    jmp     MasterSlaveMenu_EnterMenuOrModifyItemVisibility
386
387PackedCOMPortAddresses:             ; COM1 - COMC (or COM12)
388    db      (DEVICE_SERIAL_COM1 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
389    db      (DEVICE_SERIAL_COM2 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
390    db      (DEVICE_SERIAL_COM3 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
391    db      (DEVICE_SERIAL_COM4 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1   
392    db      (DEVICE_SERIAL_COM5 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
393    db      (DEVICE_SERIAL_COM6 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
394    db      (DEVICE_SERIAL_COM7 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1   
395    db      (DEVICE_SERIAL_COM8 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1   
396    db      (DEVICE_SERIAL_COM9 - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
397    db      (DEVICE_SERIAL_COMA - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1   
398    db      (DEVICE_SERIAL_COMB - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1
399    db      (DEVICE_SERIAL_COMC - DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT) >> 1 
400    db      0                       ; null terminated
401
402;------------------------------------------------------------------------------------------
403;
404; Reader/Writer Routines
405;
406; For serial drives, we pack the port number and baud rate into a single byte, and thus
407; we need to take care to properly read/write just the bits we need.  In addition, since
408; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
409; default the values stored in both these words  when switching in and out of the Serial 
410; device choice.
411;
412; Writers:
413;   Parameters:
414;       AX:     Value that the MENUITEM system was interacting with
415;       ES:DI:  ROMVARS location where the value is to be stored
416;       DS:SI:  MENUITEM pointer
417;   Returns:
418;       AX:     Value to actually write to ROMVARS
419;   Corrupts registers:
420;       AX
421;
422; Readers:
423;   Parameters:
424;       AX:     Value read from the ROMVARS location
425;       ES:DI:  ROMVARS location where the value was just read from
426;       DS:SI:  MENUITEM pointer
427;   Returns:
428;       AX:     Value that the MENUITEM system will interact with and display
429;   Corrupts registers:
430;       AX
431;
432
433;
434; No change to Device byte, but use this opportunity to change defaults stored in wPort and wPortCtrl if we are
435; changing in/out of a Serial device (since we use these bytes in radically different ways).  Also clear the
436; interrupt informtion is we are moving into Serial (since the serial device does not use interrupts).
437;
438ALIGN JUMP_ALIGN
439IdeControllerMenu_WriteDevice:
440        push    ax
441        push    bx
442        push    di
443
444        mov     bl,[es:di]                          ; what is the current Device?
445       
446        add     di,IDEVARS.wPort - IDEVARS.bDevice  ; Get ready to set the Port addresses
447       
448        cmp     al,DEVICE_SERIAL_PORT
449        jz      .changingToSerial
450
451        cmp     bl,DEVICE_SERIAL_PORT
452        jnz     .done                               ; if we weren't Serial before, nothing to do
453
454.changingFromSerial:
455        cmp     al,DEVICE_16BIT_ATA
456        jl      .xtide
457
458        mov     ax,DEVICE_ATA_DEFAULT_PORT          ; Defaults for 16-bit and better ATA devices
459        mov     bx,DEVICE_ATA_DEFAULT_PORTCTRL
460        jmp     .writeNonSerial
461
462.xtide: 
463        mov     ax,DEVICE_XTIDE_DEFAULT_PORT        ; Defaults for 8-bit XTIDE devices
464        mov     bx,DEVICE_XTIDE_DEFAULT_PORTCTRL       
465
466.writeNonSerial:       
467        mov     [es:di],ax                          ; Store defaults in IDEVARS.wPort and IDEVARS.wPortCtrl
468        mov     [es:di+2],bx
469
470        jmp     .done
471
472.changingToSerial:     
473        cmp     bl,DEVICE_SERIAL_PORT
474        jz      .done                               ; if we were already serial, nothing to do
475
476        mov     ax,DEVICE_SERIAL_DEFAULT_COM
477        call    IdeControllerMenu_SerialWriteCOM
478        mov     [es:di],ax
479       
480        mov     ax,DEVICE_SERIAL_DEFAULT_BAUD
481        call    IdeControllerMenu_SerialWriteBaud
482        mov     [es:di],ax
483               
484        add     di,IDEVARS.bIRQ - IDEVARS.wPort     ; clear out the interrupt information, we don't use interrupts
485        mov     al,0
486        mov     [es:di],al
487
488.done: 
489        pop     di
490        pop     bx
491        pop     ax
492
493        ret
494
495;
496; "COMn" ASCII characer -> Numeric COM number
497;
498ALIGN JUMP_ALIGN
499IdeControllerMenu_SerialReadCOM:
500        xor     ah,ah                               ; clear out packedportbaud value
501
502        cmp     al,'x'                              ; base this on the ASCII character used to print
503        jz      .custom
504
505        cmp     al,'A'
506        jae     .over10
507
508        sub     al, '0'+1                           ; convert ASCII value '0'-'9' to numeric
509        ret
510
511.over10:
512        sub     al, 'A'-10+1                        ; convert ASCII value 'A'-'C' to numeric
513        ret
514
515.custom:
516        mov     al, 12                              ; convert ASCII value 'x' (for custom) to numeric
517        ret
518
519;
520; Numeric COM number -> Packed port address, and update ASCII character for printing "COMn"
521;               
522ALIGN JUMP_ALIGN
523IdeControllerMenu_SerialWriteCOM:
524        push    bx
525
526        cmp     al,12                               ; custom?
527        jge     .custom
528
529        mov     bx,ax                               ; lookup packed port address based on COM address
530        mov     ah,[cs:bx+PackedCOMPortAddresses]
531
532        cmp     al,9                                ; COMA or higher, but not custom
533        jge     .atorabove10
534
535        add     al, '0'+1                           ; convert numeric to ASCII '1' to '9'
536        jmp     IdeControllerMenu_SerialWriteCOM_PackAndRet
537
538.custom:
539        mov     al,'x'                              ; ASCII value 'x' for custom
540        mov     ah,0                                ; 240h is default custom value
541        jmp     IdeControllerMenu_SerialWriteCOM_PackAndRet
542
543.atorabove10:
544        add     al, 'A'-10+1                        ; convert numeric to ASCII 'A' to 'C'
545
546IdeControllerMenu_SerialWriteCOM_PackAndRet:
547        mov     bl,[es:di+1]                        ; read baud rate bits
548        and     bl,DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK     
549        or      ah,bl
550
551        pop     bx
552        ret     
553
554;
555; Packed Baud -> Numeric Baud
556;               
557ALIGN JUMP_ALIGN
558IdeControllerMenu_SerialReadBaud:
559        xchg    al,ah
560        and     ax,DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK         ; also clears high order byte
561        ret
562
563;
564; Numeric Baud -> Packed Baud, also update ASCII printing characters for baud rate
565;               
566ALIGN JUMP_ALIGN
567IdeControllerMenu_SerialWriteBaud:
568        and     ax,DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDBITS         ; ensure we only have the bits we want
569       
570        push    bx
571
572        mov     bx,ax                                               ; lookup printing word for wPortCtrl
573        shl     bx,1
574        mov     bx,[cs:bx+g_wPrintBaud]
575        mov     [es:di+2],bx
576
577        xchg    al,ah                                               ; or in port bits
578        mov     bx,[es:di]
579        and     bh,DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK 
580        or      ax,bx
581
582        pop     bx
583        ret
584
585;
586; Packed Port -> Numeric Port
587;               
588ALIGN JUMP_ALIGN
589IdeControllerMenu_SerialReadPort:       
590        mov     al,ah
591        and     ax,DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK         ; note that this clears AH
592        shl     ax,1
593        add     ax,DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT
594        ret
595
596;
597; Numeric Port -> Packed Port, convert from Custom to a defined COM port if we match one
598;
599ALIGN JUMP_ALIGN
600IdeControllerMenu_SerialWritePort:     
601        push    bx
602
603        sub     ax,DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT     ; convert from numeric to packed port number
604        shr     ax,1
605        and     al,DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK
606
607        mov     bx,PackedCOMPortAddresses                           ; loop, looking for port address in known COM address list
608.next: 
609        mov     ah,[cs:bx]
610        inc     bx
611        test    ah,ah
612        jz      .notfound
613        cmp     al,ah
614        jnz     .next
615
616        sub     bx,PackedCOMPortAddresses + 1                       ; FOUND!, +1 since we already incremented
617        mov     ax,bx
618        pop     bx
619        jmp     IdeControllerMenu_SerialWriteCOM                    ; if found, use that logic to get ASCII character
620
621.notfound:
622        xchg    ah,al                                               
623        mov     al,'x'
624        jmp     IdeControllerMenu_SerialWriteCOM_PackAndRet
625
626
Note: See TracBrowser for help on using the repository browser.