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

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

Serial Port: split single byte port and baud into two bytes, taking advantage of the two bytes in DPT_SERIAL, which supports more serial baud rates and in particular fixed a bug where a 4x client machine couldn't talk to a 115.2K server machine. This is a wide change, touching lots of files, but most are shallow changes. DetectPrint.asm took the most significant changes, now it calculates the baud rate to display instead of using characters provided by the Configurator. The Configurator now has a new menu flag, FLG_MENUITEM_CHOICESTRINGS, for specifying that values are not linear and they should be lookedup rather than indexed. Finally, another important bug fixed here is that in some error cases, the serial port code could get into an infinite loop waiting ont the hardware; now it has a timeout.

File size: 4.7 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
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
[203]38%ifdef MODULE_SERIAL
[233]39 jcxz .done ; Set to zero on .ideVarsSerialAuto iteration (if any)
[196]40%endif
[233]41
[3]42 loop .DriveDetectLoop
[203]43
44%ifdef MODULE_SERIAL
45;
[233]46; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
[203]47;
[233]48 call FindDPT_ToDSDIforSerialDevice
49 jc .done
50
51 mov bp, ROMVARS.ideVarsSerialAuto ; Point to our special IDEVARS sructure, just for serial scans
52
[200]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
[233]56 jnz .DriveDetectLoop
57%endif
[203]58
[233]59.done:
[3]60 ret
61
[199]62%if FLG_ROMVARS_SERIAL_SCANDETECT != 8
[200]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."
[199]64%endif
65
[200]66
[3]67;--------------------------------------------------------------------
[98]68; StartDetectionWithDriveSelectByteInBHandStringInAX
[3]69; Parameters:
70; BH: Drive Select byte for Drive and Head Register
[233]71; CX: Offset to "Master" or "Slave" string
[3]72; CS:BP: Ptr to IDEVARS for the drive
73; DS: RAMVARS segment
74; ES: Zero (BDA segment)
75; Returns:
[203]76; None
[3]77; Corrupts registers:
[98]78; AX, BX, CX, DX, SI, DI
[3]79;--------------------------------------------------------------------
[98]80StartDetectionWithDriveSelectByteInBHandStringInAX:
81 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
[120]82 ; Fall to .ReadAtaInfoFromHardDisk
[3]83
84;--------------------------------------------------------------------
[120]85; .ReadAtaInfoFromHardDisk
[3]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:
[150]95; AX, BL, CX, DX, SI, DI
[3]96;--------------------------------------------------------------------
[120]97.ReadAtaInfoFromHardDisk:
[150]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
[120]106 jnc SHORT CreateBiosTablesForHardDisk
107 ; Fall to .ReadAtapiInfoFromDrive
[3]108
[120]109.ReadAtapiInfoFromDrive: ; Not yet implemented
110 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
111 ;jnc SHORT _CreateBiosTablesForCDROM
[203]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
[3]127
[120]128
[3]129;--------------------------------------------------------------------
[98]130; CreateBiosTablesForHardDisk
[3]131; Parameters:
132; BH: Drive Select byte for Drive and Head Register
133; CS:BP: Ptr to IDEVARS for the drive
[150]134; ES:SI Ptr to ATA information for the drive
[3]135; DS: RAMVARS segment
[98]136; ES: BDA/Bootnfo segment
[3]137; Returns:
[98]138; Nothing
[3]139; Corrupts registers:
[98]140; AX, BX, CX, DX, SI, DI
[3]141;--------------------------------------------------------------------
[98]142CreateBiosTablesForHardDisk:
[3]143 call CreateDPT_FromAtaInformation
[196]144 jc SHORT DetectDrives_DriveNotFound
[3]145 call BootInfo_CreateForHardDisk
[196]146 jmp short DetectPrint_DriveNameFromBootnfoInESBX
147
148
Note: See TracBrowser for help on using the repository browser.