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

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

Reworked the 'skip detecting the slave if there was no master' code to be more complete (includes configurator drives) and to take into account int13h/25h calls. Some of the changes in my last checkin have been rolled back as a result (they are no longer needed). I did take a byte out of RAMVARS, but there was an alignment byte available for the taking. I also added a perl script for padding and adding the checksum byte to a binary image, which can be invoked manually or with 'make checksum'.

File size: 5.8 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 mov si, g_szDetect ; Setup standard print string
25%ifdef MODULE_SERIAL
26 cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
27 jnz .DriveNotSerial ; Special print string for serial drives
28 mov si, g_szDetectCOM
29.DriveNotSerial:
30%endif
31
32 call .DetectDrives_WithIDEVARS ; Detect Master and Slave
33 add bp, BYTE IDEVARS_size ; Point to next IDEVARS
34 loop .DriveDetectLoop
35
36%ifdef MODULE_SERIAL
37;
38; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we have a connection)
39; Note that XLATEVARS.bLastSerial is zero'd in RamVars_Initialize, called in Initialize_AutoDetectDrives;
40; bLastSerial it set in the detection code of SerialCommand.asm
41;
42 cmp byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial],cl ; cx = zero after the loop above
43 ; less instruction bytes than using immediate
44 jnz .done
45
46 mov al,[cs:ROMVARS.wFlags] ; Configurator set to always scan?
47 or al,[es:BDA.bKBFlgs1] ; Or, did the user hold down the ALT key?
48 and al,8 ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
49 jz .done
50
51 mov bp, ROMVARS.ideVarsSerialAuto ; Point to our special IDEVARS sructure, just for serial scans
52 mov si, g_szDetectCOMAuto ; Special, special print string for serial drives during a scan
53;;; fall-through
54%else
55 ret
56%endif
57
58%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
59%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."
60%endif
61
62;--------------------------------------------------------------------
63; Detects IDE hard disks by using information from IDEVARS.
64;
65; DetectDrives_WithIDEVARS
66; Parameters:
67; CS:BP: Ptr to IDEVARS
68; DS: RAMVARS segment
69; ES: Zero (BDA segment)
70; SI: Ptr to template string
71; Returns:
72; Nothing
73; Corrupts registers:
74; AX, BX, DX, SI, DI
75;--------------------------------------------------------------------
76.DetectDrives_WithIDEVARS:
77 push cx
78
79 push si
80 mov ax, g_szMaster
81 mov bh, MASK_DRVNHEAD_SET ; Select Master drive
82 call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO
83 pop si
84
85 mov ax, g_szSlave
86 mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
87 call StartDetectionWithDriveSelectByteInBHandStringInAX
88 pop cx
89
90.done:
91 ret
92
93
94;--------------------------------------------------------------------
95; StartDetectionWithDriveSelectByteInBHandStringInAX
96; Parameters:
97; AX: Offset to "Master" or "Slave" string
98; BH: Drive Select byte for Drive and Head Register
99; CS:BP: Ptr to IDEVARS for the drive
100; DS: RAMVARS segment
101; ES: Zero (BDA segment)
102; Returns:
103; None
104; Corrupts registers:
105; AX, BX, CX, DX, SI, DI
106;--------------------------------------------------------------------
107StartDetectionWithDriveSelectByteInBHandStringInAX:
108 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
109 ; Fall to .ReadAtaInfoFromHardDisk
110
111;--------------------------------------------------------------------
112; .ReadAtaInfoFromHardDisk
113; Parameters:
114; BH: Drive Select byte for Drive and Head Register
115; CS:BP: Ptr to IDEVARS for the drive
116; DS: RAMVARS segment
117; ES: Zero (BDA segment)
118; Returns:
119; CF: Cleared if ATA-information read successfully
120; Set if any error
121; Corrupts registers:
122; AX, BL, CX, DX, SI, DI
123;--------------------------------------------------------------------
124.ReadAtaInfoFromHardDisk:
125 mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location
126 push es
127 push si
128 push bx
129 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
130 pop bx
131 pop si
132 pop es
133 jnc SHORT CreateBiosTablesForHardDisk
134 ; Fall to .ReadAtapiInfoFromDrive
135
136.ReadAtapiInfoFromDrive: ; Not yet implemented
137 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
138 ;jnc SHORT _CreateBiosTablesForCDROM
139
140 ;jmp short DetectDrives_DriveNotFound
141;;; fall-through instead of previous jmp instruction
142;--------------------------------------------------------------------
143; DetectDrives_DriveNotFound
144; Parameters:
145; Nothing
146; Returns:
147; CF: Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
148; Corrupts registers:
149; AX, SI
150;--------------------------------------------------------------------
151DetectDrives_DriveNotFound:
152 mov si, g_szNotFound
153 jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
154
155
156;--------------------------------------------------------------------
157; CreateBiosTablesForHardDisk
158; Parameters:
159; BH: Drive Select byte for Drive and Head Register
160; CS:BP: Ptr to IDEVARS for the drive
161; ES:SI Ptr to ATA information for the drive
162; DS: RAMVARS segment
163; ES: BDA/Bootnfo segment
164; Returns:
165; Nothing
166; Corrupts registers:
167; AX, BX, CX, DX, SI, DI
168;--------------------------------------------------------------------
169CreateBiosTablesForHardDisk:
170 call CreateDPT_FromAtaInformation
171 jc SHORT DetectDrives_DriveNotFound
172 call BootInfo_CreateForHardDisk
173 jmp short DetectPrint_DriveNameFromBootnfoInESBX
174
175
Note: See TracBrowser for help on using the repository browser.