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

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

Additional space optimizations, including making IdleProcessing an option in MENUEVENT. Note the fall-through from one file to another, but that there are assembler checks to ensure the proper linkage is maintained. First version of StringsCompress.pl, a perl script to make StringsCompressed.asm from Strings.asm.

File size: 4.1 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
22.DriveDetectLoop:
[189]23 mov si,g_szDetect
[175]24 call .DetectDrives_WithIDEVARS ; Detect Master and Slave
[3]25 add bp, BYTE IDEVARS_size ; Point to next IDEVARS
26 loop .DriveDetectLoop
[175]27
28%ifdef MODULE_SERIAL
[179]29 test BYTE [es:BDA.bKBFlgs1], 8 ; alt key depressed
30 jz .done
31 mov bp, ROMVARS.ideVarsSerialAuto
[189]32 mov si,g_szSerial
[175]33;;; fall-through
34%else
[3]35 ret
[175]36%endif
[3]37
38;--------------------------------------------------------------------
39; Detects IDE hard disks by using information from IDEVARS.
40;
41; DetectDrives_WithIDEVARS
42; Parameters:
43; CS:BP: Ptr to IDEVARS
44; DS: RAMVARS segment
45; ES: Zero (BDA segment)
[189]46; SI: Ptr to template string
[3]47; Returns:
48; Nothing
49; Corrupts registers:
50; AX, BX, DX, SI, DI
51;--------------------------------------------------------------------
[175]52.DetectDrives_WithIDEVARS:
[3]53 push cx
[189]54
55 push si
[97]56 mov ax, g_szMaster
[150]57 mov bh, MASK_DRVNHEAD_SET ; Select Master drive
[98]58 call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO
[189]59 pop si
60
[97]61 mov ax, g_szSlave
[150]62 mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
[98]63 call StartDetectionWithDriveSelectByteInBHandStringInAX
[3]64 pop cx
[175]65.done:
[3]66 ret
67
[175]68
[3]69;--------------------------------------------------------------------
[98]70; StartDetectionWithDriveSelectByteInBHandStringInAX
[3]71; Parameters:
[98]72; AX: Offset to "Master" or "Slave" string
[3]73; BH: Drive Select byte for Drive and Head Register
74; CS:BP: Ptr to IDEVARS for the drive
75; DS: RAMVARS segment
76; ES: Zero (BDA segment)
77; Returns:
[98]78; Nothing
[3]79; Corrupts registers:
[98]80; AX, BX, CX, DX, SI, DI
[3]81;--------------------------------------------------------------------
[98]82StartDetectionWithDriveSelectByteInBHandStringInAX:
83 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
[120]84 ; Fall to .ReadAtaInfoFromHardDisk
[3]85
86;--------------------------------------------------------------------
[120]87; .ReadAtaInfoFromHardDisk
[3]88; Parameters:
89; BH: Drive Select byte for Drive and Head Register
90; CS:BP: Ptr to IDEVARS for the drive
91; DS: RAMVARS segment
92; ES: Zero (BDA segment)
93; Returns:
94; CF: Cleared if ATA-information read successfully
95; Set if any error
96; Corrupts registers:
[150]97; AX, BL, CX, DX, SI, DI
[3]98;--------------------------------------------------------------------
[120]99.ReadAtaInfoFromHardDisk:
[150]100 mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location
101 push es
102 push si
103 push bx
104 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
105 pop bx
106 pop si
107 pop es
[120]108 jnc SHORT CreateBiosTablesForHardDisk
109 ; Fall to .ReadAtapiInfoFromDrive
[3]110
[120]111.ReadAtapiInfoFromDrive: ; Not yet implemented
112 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
113 ;jnc SHORT _CreateBiosTablesForCDROM
114 jmp DetectPrint_DriveNotFound
[3]115
[120]116
[3]117;--------------------------------------------------------------------
[98]118; CreateBiosTablesForHardDisk
[3]119; Parameters:
120; BH: Drive Select byte for Drive and Head Register
121; CS:BP: Ptr to IDEVARS for the drive
[150]122; ES:SI Ptr to ATA information for the drive
[3]123; DS: RAMVARS segment
[98]124; ES: BDA/Bootnfo segment
[3]125; Returns:
[98]126; Nothing
[3]127; Corrupts registers:
[98]128; AX, BX, CX, DX, SI, DI
[3]129;--------------------------------------------------------------------
[98]130CreateBiosTablesForHardDisk:
[3]131 call CreateDPT_FromAtaInformation
132 jc SHORT .InvalidAtaInfo
133 call BootInfo_CreateForHardDisk
[98]134 jmp DetectPrint_DriveNameFromBootnfoInESBX
[3]135.InvalidAtaInfo:
[98]136 jmp DetectPrint_DriveNotFound
Note: See TracBrowser for help on using the repository browser.