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

Last change on this file since 257 was 254, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Changed BOOTNFO to BOOTMENUINFO and moved it to BootMenu.inc.
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 structure, 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 BootMenuInfo_CreateForHardDisk
146 jmp short DetectPrint_DriveNameFromBootnfoInESBX
147
148
Note: See TracBrowser for help on using the repository browser.