source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.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: 4.9 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.DriveDetectLoop:
23    mov     si, g_szDetect
24%ifdef MODULE_SERIAL
25    cmp     byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
26    jnz     .DriveNotSerial
27    mov     si, g_szDetectCOM
28.DriveNotSerial:
29%endif
30    call    .DetectDrives_WithIDEVARS       ; Detect Master and Slave
31    add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
32    loop    .DriveDetectLoop
33%ifdef MODULE_SERIAL
34    mov     al,[cs:ROMVARS.wFlags]
35    or      al,[es:BDA.bKBFlgs1]
36    and     al,8        ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
37    jz      .done
38    mov     bp, ROMVARS.ideVarsSerialAuto
39    mov     si, g_szDetectCOMAuto
40;;; fall-through                   
41%else
42    ret
43%endif
44
45%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
46%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_ALWAYSDETECT 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."
47%endif
48
49;--------------------------------------------------------------------
50; Detects IDE hard disks by using information from IDEVARS.
51;
52; DetectDrives_WithIDEVARS
53;   Parameters:
54;       CS:BP:      Ptr to IDEVARS
55;       DS:         RAMVARS segment
56;       ES:         Zero (BDA segment)
57;       SI:         Ptr to template string
58;   Returns:
59;       Nothing
60;   Corrupts registers:
61;       AX, BX, DX, SI, DI
62;--------------------------------------------------------------------
63.DetectDrives_WithIDEVARS:
64    push    cx
65
66    push    si     
67    mov     ax, g_szMaster
68    mov     bh, MASK_DRVNHEAD_SET                               ; Select Master drive
69    call    StartDetectionWithDriveSelectByteInBHandStringInAX  ; Detect and create DPT + BOOTNFO
70    pop     si
71
72    mov     ax, g_szSlave
73    mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
74    call    StartDetectionWithDriveSelectByteInBHandStringInAX
75    pop     cx
76.done: 
77    ret
78
79       
80;--------------------------------------------------------------------
81; StartDetectionWithDriveSelectByteInBHandStringInAX
82;   Parameters:
83;       AX:     Offset to "Master" or "Slave" string
84;       BH:     Drive Select byte for Drive and Head Register
85;       CS:BP:  Ptr to IDEVARS for the drive
86;       DS:     RAMVARS segment
87;       ES:     Zero (BDA segment)
88;   Returns:
89;       Nothing
90;   Corrupts registers:
91;       AX, BX, CX, DX, SI, DI
92;--------------------------------------------------------------------
93StartDetectionWithDriveSelectByteInBHandStringInAX:
94    call    DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
95    ; Fall to .ReadAtaInfoFromHardDisk
96
97;--------------------------------------------------------------------
98; .ReadAtaInfoFromHardDisk
99;   Parameters:
100;       BH:     Drive Select byte for Drive and Head Register
101;       CS:BP:  Ptr to IDEVARS for the drive
102;       DS:     RAMVARS segment
103;       ES:     Zero (BDA segment)
104;   Returns:
105;       CF:     Cleared if ATA-information read successfully
106;               Set if any error
107;   Corrupts registers:
108;       AX, BL, CX, DX, SI, DI
109;--------------------------------------------------------------------
110.ReadAtaInfoFromHardDisk:
111    mov     si, BOOTVARS.rgbAtaInfo     ; ES:SI now points to ATA info location
112    push    es
113    push    si
114    push    bx
115    call    Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
116    pop     bx
117    pop     si
118    pop     es
119    jnc     SHORT CreateBiosTablesForHardDisk
120    ; Fall to .ReadAtapiInfoFromDrive
121
122.ReadAtapiInfoFromDrive:                ; Not yet implemented
123    ;call   ReadAtapiInfoFromDrive      ; Assume CD-ROM
124    ;jnc    SHORT _CreateBiosTablesForCDROM
125    jmp     short DetectDrives_DriveNotFound
126
127
128;--------------------------------------------------------------------
129; CreateBiosTablesForHardDisk
130;   Parameters:
131;       BH:     Drive Select byte for Drive and Head Register
132;       CS:BP:  Ptr to IDEVARS for the drive
133;       ES:SI   Ptr to ATA information for the drive
134;       DS:     RAMVARS segment
135;       ES:     BDA/Bootnfo segment
136;   Returns:
137;       Nothing
138;   Corrupts registers:
139;       AX, BX, CX, DX, SI, DI
140;--------------------------------------------------------------------
141CreateBiosTablesForHardDisk:
142    call    CreateDPT_FromAtaInformation
143    jc      SHORT DetectDrives_DriveNotFound
144    call    BootInfo_CreateForHardDisk
145    jmp     short DetectPrint_DriveNameFromBootnfoInESBX
146
147;--------------------------------------------------------------------
148; DetectDrives_DriveNotFound
149;   Parameters:
150;       Nothing
151;   Returns:
152;       Nothing
153;   Corrupts registers:
154;       AX, SI
155;--------------------------------------------------------------------
156DetectDrives_DriveNotFound:     
157    mov     si, g_szNotFound
158    jmp     BootMenuPrint_NullTerminatedStringFromCSSIandSetCF     
159
Note: See TracBrowser for help on using the repository browser.