; Project name : XTIDE Universal BIOS ; Description : Functions for detecting drive for the BIOS. ; Section containing code SECTION .text ;-------------------------------------------------------------------- ; Detects all IDE hard disks to be controlled by this BIOS. ; ; DetectDrives_FromAllIDEControllers ; Parameters: ; DS: RAMVARS segment ; ES: BDA segment (zero) ; Returns: ; Nothing ; Corrupts registers: ; All (not segments) ;-------------------------------------------------------------------- DetectDrives_FromAllIDEControllers: call RamVars_GetIdeControllerCountToCX mov bp, ROMVARS.ideVars0 ; CS:BP now points to first IDEVARS .DriveDetectLoop: ; Loop through IDEVARS push cx mov cx, g_szDetectMaster mov bh, MASK_DRVNHEAD_SET ; Select Master drive call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO mov cx, g_szDetectSlave mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV call StartDetectionWithDriveSelectByteInBHandStringInAX pop cx add bp, BYTE IDEVARS_size ; Point to next IDEVARS %ifdef MODULE_SERIAL jcxz .done ; Set to zero on .ideVarsSerialAuto iteration (if any) %endif loop .DriveDetectLoop %ifdef MODULE_SERIAL ; ; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection) ; call FindDPT_ToDSDIforSerialDevice jc .done mov bp, ROMVARS.ideVarsSerialAuto ; Point to our special IDEVARS structure, just for serial scans mov al,[cs:ROMVARS.wFlags] ; Configurator set to always scan? or al,[es:BDA.bKBFlgs1] ; Or, did the user hold down the ALT key? and al,8 ; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT jnz .DriveDetectLoop %endif .done: ret %if FLG_ROMVARS_SERIAL_SCANDETECT != 8 %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." %endif ;-------------------------------------------------------------------- ; StartDetectionWithDriveSelectByteInBHandStringInAX ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; CX: Offset to "Master" or "Slave" string ; CS:BP: Ptr to IDEVARS for the drive ; DS: RAMVARS segment ; ES: Zero (BDA segment) ; Returns: ; None ; Corrupts registers: ; AX, BX, CX, DX, SI, DI ;-------------------------------------------------------------------- StartDetectionWithDriveSelectByteInBHandStringInAX: call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP ; Fall to .ReadAtaInfoFromHardDisk ;-------------------------------------------------------------------- ; .ReadAtaInfoFromHardDisk ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; CS:BP: Ptr to IDEVARS for the drive ; DS: RAMVARS segment ; ES: Zero (BDA segment) ; Returns: ; CF: Cleared if ATA-information read successfully ; Set if any error ; Corrupts registers: ; AX, BL, CX, DX, SI, DI ;-------------------------------------------------------------------- .ReadAtaInfoFromHardDisk: mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location push es push si push bx call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH pop bx pop si pop es jnc SHORT CreateBiosTablesForHardDisk ; Fall to .ReadAtapiInfoFromDrive .ReadAtapiInfoFromDrive: ; Not yet implemented ;call ReadAtapiInfoFromDrive ; Assume CD-ROM ;jnc SHORT _CreateBiosTablesForCDROM ;jmp short DetectDrives_DriveNotFound ;;; fall-through instead of previous jmp instruction ;-------------------------------------------------------------------- ; DetectDrives_DriveNotFound ; Parameters: ; Nothing ; Returns: ; CF: Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF) ; Corrupts registers: ; AX, SI ;-------------------------------------------------------------------- DetectDrives_DriveNotFound: mov si, g_szNotFound jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF ;-------------------------------------------------------------------- ; CreateBiosTablesForHardDisk ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; CS:BP: Ptr to IDEVARS for the drive ; ES:SI Ptr to ATA information for the drive ; DS: RAMVARS segment ; ES: BDA/Bootnfo segment ; Returns: ; Nothing ; Corrupts registers: ; AX, BX, CX, DX, SI, DI ;-------------------------------------------------------------------- CreateBiosTablesForHardDisk: call CreateDPT_FromAtaInformation jc SHORT DetectDrives_DriveNotFound call BootMenuInfo_CreateForHardDisk jmp short DetectPrint_DriveNameFromBootnfoInESBX