source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm @ 233

Last change on this file since 233 was 233, checked in by gregli@…, 12 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: 4.7 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Functions for detecting drive for the BIOS.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Detects all IDE hard disks to be controlled by this BIOS.
9;
10; DetectDrives_FromAllIDEControllers
11;   Parameters:
12;       DS:     RAMVARS segment
13;       ES:     BDA segment (zero)
14;   Returns:
15;       Nothing
16;   Corrupts registers:
17;       All (not segments)
18;--------------------------------------------------------------------
19DetectDrives_FromAllIDEControllers:
20    call    RamVars_GetIdeControllerCountToCX
21    mov     bp, ROMVARS.ideVars0            ; CS:BP now points to first IDEVARS
22
23.DriveDetectLoop:                           ; Loop through IDEVARS
24    push    cx
25
26    mov     cx, g_szDetectMaster
27    mov     bh, MASK_DRVNHEAD_SET                               ; Select Master drive
28    call    StartDetectionWithDriveSelectByteInBHandStringInAX  ; Detect and create DPT + BOOTNFO
29
30    mov     cx, g_szDetectSlave
31    mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV 
32    call    StartDetectionWithDriveSelectByteInBHandStringInAX
33       
34    pop     cx
35
36    add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
37
38%ifdef MODULE_SERIAL       
39    jcxz    .done                           ; Set to zero on .ideVarsSerialAuto iteration (if any)
40%endif
41       
42    loop    .DriveDetectLoop
43
44%ifdef MODULE_SERIAL       
45;
46; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
47;
48    call    FindDPT_ToDSDIforSerialDevice
49    jc      .done
50
51    mov     bp, ROMVARS.ideVarsSerialAuto   ; Point to our special IDEVARS sructure, just for serial scans     
52               
53    mov     al,[cs:ROMVARS.wFlags]          ; Configurator set to always scan?
54    or      al,[es:BDA.bKBFlgs1]            ; Or, did the user hold down the ALT key?
55    and     al,8                            ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
56    jnz     .DriveDetectLoop                           
57%endif
58
59.done:
60    ret
61
62%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
63%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_SCANDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
64%endif
65
66       
67;--------------------------------------------------------------------
68; StartDetectionWithDriveSelectByteInBHandStringInAX
69;   Parameters:
70;       BH:     Drive Select byte for Drive and Head Register
71;       CX:     Offset to "Master" or "Slave" string
72;       CS:BP:  Ptr to IDEVARS for the drive
73;       DS:     RAMVARS segment
74;       ES:     Zero (BDA segment)
75;   Returns:
76;       None
77;   Corrupts registers:
78;       AX, BX, CX, DX, SI, DI
79;--------------------------------------------------------------------
80StartDetectionWithDriveSelectByteInBHandStringInAX:
81    call    DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
82    ; Fall to .ReadAtaInfoFromHardDisk
83
84;--------------------------------------------------------------------
85; .ReadAtaInfoFromHardDisk
86;   Parameters:
87;       BH:     Drive Select byte for Drive and Head Register
88;       CS:BP:  Ptr to IDEVARS for the drive
89;       DS:     RAMVARS segment
90;       ES:     Zero (BDA segment)
91;   Returns:
92;       CF:     Cleared if ATA-information read successfully
93;               Set if any error
94;   Corrupts registers:
95;       AX, BL, CX, DX, SI, DI
96;--------------------------------------------------------------------
97.ReadAtaInfoFromHardDisk:
98    mov     si, BOOTVARS.rgbAtaInfo     ; ES:SI now points to ATA info location
99    push    es
100    push    si
101    push    bx
102    call    Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
103    pop     bx
104    pop     si
105    pop     es
106    jnc     SHORT CreateBiosTablesForHardDisk
107    ; Fall to .ReadAtapiInfoFromDrive
108
109.ReadAtapiInfoFromDrive:                ; Not yet implemented
110    ;call   ReadAtapiInfoFromDrive      ; Assume CD-ROM
111    ;jnc    SHORT _CreateBiosTablesForCDROM
112   
113    ;jmp    short DetectDrives_DriveNotFound
114;;; fall-through instead of previous jmp instruction
115;--------------------------------------------------------------------
116; DetectDrives_DriveNotFound
117;   Parameters:
118;       Nothing
119;   Returns:
120;       CF:     Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
121;   Corrupts registers:
122;       AX, SI
123;--------------------------------------------------------------------
124DetectDrives_DriveNotFound:     
125    mov     si, g_szNotFound
126    jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF     
127
128
129;--------------------------------------------------------------------
130; CreateBiosTablesForHardDisk
131;   Parameters:
132;       BH:     Drive Select byte for Drive and Head Register
133;       CS:BP:  Ptr to IDEVARS for the drive
134;       ES:SI   Ptr to ATA information for the drive
135;       DS:     RAMVARS segment
136;       ES:     BDA/Bootnfo segment
137;   Returns:
138;       Nothing
139;   Corrupts registers:
140;       AX, BX, CX, DX, SI, DI
141;--------------------------------------------------------------------
142CreateBiosTablesForHardDisk:
143    call    CreateDPT_FromAtaInformation
144    jc      SHORT DetectDrives_DriveNotFound
145    call    BootInfo_CreateForHardDisk
146    jmp     short DetectPrint_DriveNameFromBootnfoInESBX
147
148
Note: See TracBrowser for help on using the repository browser.