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
RevLine 
[150]1; Project name : XTIDE Universal BIOS
[3]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:
[33]20 call RamVars_GetIdeControllerCountToCX
[3]21 mov bp, ROMVARS.ideVars0 ; CS:BP now points to first IDEVARS
[200]22
23.DriveDetectLoop: ; Loop through IDEVARS
24 mov si, g_szDetect ; Setup standard print string
[203]25%ifdef MODULE_SERIAL
[196]26 cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
[200]27 jnz .DriveNotSerial ; Special print string for serial drives
[196]28 mov si, g_szDetectCOM
29.DriveNotSerial:
30%endif
[203]31
[175]32 call .DetectDrives_WithIDEVARS ; Detect Master and Slave
[3]33 add bp, BYTE IDEVARS_size ; Point to next IDEVARS
34 loop .DriveDetectLoop
[203]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
[200]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
[203]50
[200]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
[199]53;;; fall-through
[175]54%else
[3]55 ret
[175]56%endif
[3]57
[199]58%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
[200]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."
[199]60%endif
61
[3]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)
[189]70; SI: Ptr to template string
[3]71; Returns:
72; Nothing
73; Corrupts registers:
74; AX, BX, DX, SI, DI
75;--------------------------------------------------------------------
[175]76.DetectDrives_WithIDEVARS:
[3]77 push cx
[196]78
79 push si
[97]80 mov ax, g_szMaster
[150]81 mov bh, MASK_DRVNHEAD_SET ; Select Master drive
[98]82 call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO
[189]83 pop si
[196]84
[97]85 mov ax, g_szSlave
[150]86 mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
[98]87 call StartDetectionWithDriveSelectByteInBHandStringInAX
[3]88 pop cx
[200]89
[175]90.done:
[3]91 ret
92
[175]93
[3]94;--------------------------------------------------------------------
[98]95; StartDetectionWithDriveSelectByteInBHandStringInAX
[3]96; Parameters:
[98]97; AX: Offset to "Master" or "Slave" string
[3]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:
[203]103; None
[3]104; Corrupts registers:
[98]105; AX, BX, CX, DX, SI, DI
[3]106;--------------------------------------------------------------------
[98]107StartDetectionWithDriveSelectByteInBHandStringInAX:
108 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
[120]109 ; Fall to .ReadAtaInfoFromHardDisk
[3]110
111;--------------------------------------------------------------------
[120]112; .ReadAtaInfoFromHardDisk
[3]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:
[150]122; AX, BL, CX, DX, SI, DI
[3]123;--------------------------------------------------------------------
[120]124.ReadAtaInfoFromHardDisk:
[150]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
[120]133 jnc SHORT CreateBiosTablesForHardDisk
134 ; Fall to .ReadAtapiInfoFromDrive
[3]135
[120]136.ReadAtapiInfoFromDrive: ; Not yet implemented
137 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
138 ;jnc SHORT _CreateBiosTablesForCDROM
[203]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
[3]154
[120]155
[3]156;--------------------------------------------------------------------
[98]157; CreateBiosTablesForHardDisk
[3]158; Parameters:
159; BH: Drive Select byte for Drive and Head Register
160; CS:BP: Ptr to IDEVARS for the drive
[150]161; ES:SI Ptr to ATA information for the drive
[3]162; DS: RAMVARS segment
[98]163; ES: BDA/Bootnfo segment
[3]164; Returns:
[98]165; Nothing
[3]166; Corrupts registers:
[98]167; AX, BX, CX, DX, SI, DI
[3]168;--------------------------------------------------------------------
[98]169CreateBiosTablesForHardDisk:
[3]170 call CreateDPT_FromAtaInformation
[196]171 jc SHORT DetectDrives_DriveNotFound
[3]172 call BootInfo_CreateForHardDisk
[196]173 jmp short DetectPrint_DriveNameFromBootnfoInESBX
174
175
Note: See TracBrowser for help on using the repository browser.