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

Last change on this file since 172 was 150, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

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