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

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

Changes to XTIDE Universal BIOS:

  • Display library now gets initialized.
  • Small optimizations.
  • Something is still broken.
File size: 3.9 KB
Line 
1; Project name : IDE BIOS
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:
20 call RamVars_GetIdeControllerCountToCX
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
44 mov ax, g_szMaster
45 mov bh, MASK_IDE_DRVHD_SET ; Select Master drive
46 call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO
47
48 mov ax, g_szSlave
49 mov bh, MASK_IDE_DRVHD_SET | FLG_IDE_DRVHD_DRV
50 call StartDetectionWithDriveSelectByteInBHandStringInAX
51 pop cx
52 ret
53
54
55;--------------------------------------------------------------------
56; StartDetectionWithDriveSelectByteInBHandStringInAX
57; Parameters:
58; AX: Offset to "Master" or "Slave" string
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:
64; Nothing
65; Corrupts registers:
66; AX, BX, CX, DX, SI, DI
67;--------------------------------------------------------------------
68StartDetectionWithDriveSelectByteInBHandStringInAX:
69 call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
70 ; Fall to .ReadAtaInfoFromHardDisk
71
72;--------------------------------------------------------------------
73; .ReadAtaInfoFromHardDisk
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; ES:SI Ptr to ATA information (read with IDENTIFY DEVICE command)
81; CF: Cleared if ATA-information read successfully
82; Set if any error
83; Corrupts registers:
84; AX, BL, CX, DX, DI
85;--------------------------------------------------------------------
86.ReadAtaInfoFromHardDisk:
87 mov bl, [cs:bp+IDEVARS.bBusType]; Load BUS type
88 mov dx, [cs:bp+IDEVARS.wPort] ; Load IDE Base Port address
89 mov di, BOOTVARS.rgbAtaInfo ; ES:DI now points to ATA info location
90 call AH25h_GetDriveInfo
91 jnc SHORT CreateBiosTablesForHardDisk
92 ; Fall to .ReadAtapiInfoFromDrive
93
94.ReadAtapiInfoFromDrive: ; Not yet implemented
95 ;call ReadAtapiInfoFromDrive ; Assume CD-ROM
96 ;jnc SHORT _CreateBiosTablesForCDROM
97 jmp DetectPrint_DriveNotFound
98
99
100;--------------------------------------------------------------------
101; CreateBiosTablesForHardDisk
102; Parameters:
103; BH: Drive Select byte for Drive and Head Register
104; CS:BP: Ptr to IDEVARS for the drive
105; ES:DI Ptr to ATA information for the drive
106; DS: RAMVARS segment
107; ES: BDA/Bootnfo segment
108; Returns:
109; Nothing
110; Corrupts registers:
111; AX, BX, CX, DX, SI, DI
112;--------------------------------------------------------------------
113CreateBiosTablesForHardDisk:
114 mov si, di ; ES:SI now points to ATA information
115 call CreateDPT_FromAtaInformation
116 jc SHORT .InvalidAtaInfo
117 call BootInfo_CreateForHardDisk
118 jmp DetectPrint_DriveNameFromBootnfoInESBX
119.InvalidAtaInfo:
120 jmp DetectPrint_DriveNotFound
Note: See TracBrowser for help on using the repository browser.