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

Last change on this file since 267 was 263, checked in by gregli@…, 12 years ago

Oops, forgot to check if it still compiled without floppy support, fixed up a couple of typos and put an ifdef back into place.

File size: 6.6 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
[233]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
[242]31 mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
[233]32 call StartDetectionWithDriveSelectByteInBHandStringInAX
[242]33
[233]34 pop cx
35
36 add bp, BYTE IDEVARS_size ; Point to next IDEVARS
37
[242]38%ifdef MODULE_SERIAL
[262]39 jcxz .AddHardDisks ; Set to zero on .ideVarsSerialAuto iteration (if any)
[196]40%endif
[242]41
[3]42 loop .DriveDetectLoop
[203]43
[242]44%ifdef MODULE_SERIAL
[258]45;----------------------------------------------------------------------
[203]46;
[233]47; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
[203]48;
[233]49 call FindDPT_ToDSDIforSerialDevice
[262]50 jnc .AddHardDisks
[233]51
[242]52 mov bp, ROMVARS.ideVarsSerialAuto ; Point to our special IDEVARS structure, just for serial scans
53
[200]54 mov al,[cs:ROMVARS.wFlags] ; Configurator set to always scan?
55 or al,[es:BDA.bKBFlgs1] ; Or, did the user hold down the ALT key?
56 and al,8 ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
[242]57 jnz .DriveDetectLoop
[233]58%endif
[203]59
[262]60.AddHardDisks:
[258]61;----------------------------------------------------------------------
62;
[262]63; Add in hard disks to BDA, finalize our Count and First variables
[258]64;
[262]65 mov cx, [RAMVARS.wDrvCntAndFlopCnt] ; Our count of hard disks
66 test cl, cl
67 jz .AddFloppies ; If none, nothing more to do
[258]68
[262]69 mov al, [es:BDA.bHDCount]
70 add cl, al ; Add our drives to the system count
71 mov [es:BDA.bHDCount], cl
72 or al, 80h ; Or in hard disk flag
73 mov [RAMVARS.bFirstDrv], al ; Store first drive number
74
75
76.AddFloppies:
[263]77%ifdef MODULE_SERIAL_FLOPPY
[262]78;----------------------------------------------------------------------
79;
80; Add in any emulated serial floppy drives, finalize our packed Count and First variables
81;
82 dec ch
83 mov al, ch
84 js .NoFloppies ; if no drives are present, we store 0ffh
85
[258]86 call FloppyDrive_GetCountFromBIOS_or_BDA
87
88 push ax
89
[262]90 add al, ch ; Add our drives to existing drive count
[258]91 cmp al, 3 ; For BDA, max out at 4 drives (ours is zero based)
92 jl .MaxBDAFloppiesExceeded
93 mov al, 3
94.MaxBDAFloppiesExceeded:
95 eROR_IM al, 2 ; move to bits 6-7
96 inc ax ; low order bit, indicating floppy drive exists
97
98 mov ah, [es:BDA.wEquipment] ; Load Equipment WORD low byte
99 and ah, 03eh ; Mask off drive number and drives present bit
100 or al, ah ; Or in new values
101 mov [es:BDA.wEquipment], al ; and store
102
103 mov al, 1eh ; BDA pointer to Floppy DPT
104 mov si, AH8h_FloppyDPT
105 call Interrupts_InstallHandlerToVectorInALFromCSSI
106
107 pop ax
108
[262]109 shr ch, 1 ; number of drives, 1 or 2 only, to CF flag (clear=1, set=2)
[258]110 rcl al, 1 ; starting drive number in upper 7 bits, number of drives in low bit
111.NoFloppies:
112 mov [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], al
[263]113%endif
[258]114
[3]115 ret
116
[261]117%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
118 %if FLG_ROMVARS_SERIAL_SCANDETECT != 8
119 %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."
120 %endif
[199]121%endif
122
[242]123
[3]124;--------------------------------------------------------------------
[98]125; StartDetectionWithDriveSelectByteInBHandStringInAX
[3]126; Parameters:
127; BH: Drive Select byte for Drive and Head Register
[233]128; CX: Offset to "Master" or "Slave" string
[3]129; CS:BP: Ptr to IDEVARS for the drive
130; DS: RAMVARS segment
131; ES: Zero (BDA segment)
132; Returns:
[203]133; None
[3]134; Corrupts registers:
[98]135; AX, BX, CX, DX, SI, DI
[3]136;--------------------------------------------------------------------
[98]137StartDetectionWithDriveSelectByteInBHandStringInAX:
138 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
[120]139 ; Fall to .ReadAtaInfoFromHardDisk
[3]140
141;--------------------------------------------------------------------
[120]142; .ReadAtaInfoFromHardDisk
[3]143; Parameters:
144; BH: Drive Select byte for Drive and Head Register
145; CS:BP: Ptr to IDEVARS for the drive
146; DS: RAMVARS segment
147; ES: Zero (BDA segment)
148; Returns:
149; CF: Cleared if ATA-information read successfully
150; Set if any error
151; Corrupts registers:
[150]152; AX, BL, CX, DX, SI, DI
[3]153;--------------------------------------------------------------------
[120]154.ReadAtaInfoFromHardDisk:
[150]155 mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location
156 push es
157 push si
158 push bx
159 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
160 pop bx
161 pop si
162 pop es
[120]163 jnc SHORT CreateBiosTablesForHardDisk
164 ; Fall to .ReadAtapiInfoFromDrive
[3]165
[120]166.ReadAtapiInfoFromDrive: ; Not yet implemented
167 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
168 ;jnc SHORT _CreateBiosTablesForCDROM
[242]169
[203]170 ;jmp short DetectDrives_DriveNotFound
171;;; fall-through instead of previous jmp instruction
172;--------------------------------------------------------------------
173; DetectDrives_DriveNotFound
174; Parameters:
175; Nothing
176; Returns:
177; CF: Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
178; Corrupts registers:
179; AX, SI
180;--------------------------------------------------------------------
[242]181DetectDrives_DriveNotFound:
[203]182 mov si, g_szNotFound
[242]183 jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
[3]184
[120]185
[3]186;--------------------------------------------------------------------
[98]187; CreateBiosTablesForHardDisk
[3]188; Parameters:
189; BH: Drive Select byte for Drive and Head Register
190; CS:BP: Ptr to IDEVARS for the drive
[150]191; ES:SI Ptr to ATA information for the drive
[3]192; DS: RAMVARS segment
[98]193; ES: BDA/Bootnfo segment
[3]194; Returns:
[98]195; Nothing
[3]196; Corrupts registers:
[98]197; AX, BX, CX, DX, SI, DI
[3]198;--------------------------------------------------------------------
[98]199CreateBiosTablesForHardDisk:
[3]200 call CreateDPT_FromAtaInformation
[196]201 jc SHORT DetectDrives_DriveNotFound
[254]202 call BootMenuInfo_CreateForHardDisk
[196]203 jmp short DetectPrint_DriveNameFromBootnfoInESBX
204
205
Note: See TracBrowser for help on using the repository browser.