1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Functions for detecting drive for the BIOS. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .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 | ;-------------------------------------------------------------------- |
---|
19 | DetectDrives_FromAllIDEControllers: |
---|
20 | call RamVars_GetIdeControllerCountToCX |
---|
21 | mov bp, ROMVARS.ideVars0 ; CS:BP now points to first IDEVARS |
---|
22 | .DriveDetectLoop: |
---|
23 | mov si, g_szDetect |
---|
24 | %ifdef MODULE_SERIAL |
---|
25 | cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT |
---|
26 | jnz .DriveNotSerial |
---|
27 | mov si, g_szDetectCOM |
---|
28 | .DriveNotSerial: |
---|
29 | %endif |
---|
30 | call .DetectDrives_WithIDEVARS ; Detect Master and Slave |
---|
31 | add bp, BYTE IDEVARS_size ; Point to next IDEVARS |
---|
32 | loop .DriveDetectLoop |
---|
33 | |
---|
34 | %ifdef MODULE_SERIAL |
---|
35 | test BYTE [es:BDA.bKBFlgs1], 8 ; alt key depressed |
---|
36 | jz .done |
---|
37 | mov bp, ROMVARS.ideVarsSerialAuto |
---|
38 | mov si, g_szDetectCOMAuto |
---|
39 | ;;; fall-through |
---|
40 | %else |
---|
41 | ret |
---|
42 | %endif |
---|
43 | |
---|
44 | ;-------------------------------------------------------------------- |
---|
45 | ; Detects IDE hard disks by using information from IDEVARS. |
---|
46 | ; |
---|
47 | ; DetectDrives_WithIDEVARS |
---|
48 | ; Parameters: |
---|
49 | ; CS:BP: Ptr to IDEVARS |
---|
50 | ; DS: RAMVARS segment |
---|
51 | ; ES: Zero (BDA segment) |
---|
52 | ; SI: Ptr to template string |
---|
53 | ; Returns: |
---|
54 | ; Nothing |
---|
55 | ; Corrupts registers: |
---|
56 | ; AX, BX, DX, SI, DI |
---|
57 | ;-------------------------------------------------------------------- |
---|
58 | .DetectDrives_WithIDEVARS: |
---|
59 | push cx |
---|
60 | |
---|
61 | push si |
---|
62 | mov ax, g_szMaster |
---|
63 | mov bh, MASK_DRVNHEAD_SET ; Select Master drive |
---|
64 | call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO |
---|
65 | pop si |
---|
66 | |
---|
67 | mov ax, g_szSlave |
---|
68 | mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV |
---|
69 | call StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
70 | pop cx |
---|
71 | .done: |
---|
72 | ret |
---|
73 | |
---|
74 | |
---|
75 | ;-------------------------------------------------------------------- |
---|
76 | ; StartDetectionWithDriveSelectByteInBHandStringInAX |
---|
77 | ; Parameters: |
---|
78 | ; AX: Offset to "Master" or "Slave" string |
---|
79 | ; BH: Drive Select byte for Drive and Head Register |
---|
80 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
81 | ; DS: RAMVARS segment |
---|
82 | ; ES: Zero (BDA segment) |
---|
83 | ; Returns: |
---|
84 | ; Nothing |
---|
85 | ; Corrupts registers: |
---|
86 | ; AX, BX, CX, DX, SI, DI |
---|
87 | ;-------------------------------------------------------------------- |
---|
88 | StartDetectionWithDriveSelectByteInBHandStringInAX: |
---|
89 | call DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP |
---|
90 | ; Fall to .ReadAtaInfoFromHardDisk |
---|
91 | |
---|
92 | ;-------------------------------------------------------------------- |
---|
93 | ; .ReadAtaInfoFromHardDisk |
---|
94 | ; Parameters: |
---|
95 | ; BH: Drive Select byte for Drive and Head Register |
---|
96 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
97 | ; DS: RAMVARS segment |
---|
98 | ; ES: Zero (BDA segment) |
---|
99 | ; Returns: |
---|
100 | ; CF: Cleared if ATA-information read successfully |
---|
101 | ; Set if any error |
---|
102 | ; Corrupts registers: |
---|
103 | ; AX, BL, CX, DX, SI, DI |
---|
104 | ;-------------------------------------------------------------------- |
---|
105 | .ReadAtaInfoFromHardDisk: |
---|
106 | mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location |
---|
107 | push es |
---|
108 | push si |
---|
109 | push bx |
---|
110 | call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH |
---|
111 | pop bx |
---|
112 | pop si |
---|
113 | pop es |
---|
114 | jnc SHORT CreateBiosTablesForHardDisk |
---|
115 | ; Fall to .ReadAtapiInfoFromDrive |
---|
116 | |
---|
117 | .ReadAtapiInfoFromDrive: ; Not yet implemented |
---|
118 | ;call ReadAtapiInfoFromDrive ; Assume CD-ROM |
---|
119 | ;jnc SHORT _CreateBiosTablesForCDROM |
---|
120 | jmp short DetectDrives_DriveNotFound |
---|
121 | |
---|
122 | |
---|
123 | ;-------------------------------------------------------------------- |
---|
124 | ; CreateBiosTablesForHardDisk |
---|
125 | ; Parameters: |
---|
126 | ; BH: Drive Select byte for Drive and Head Register |
---|
127 | ; CS:BP: Ptr to IDEVARS for the drive |
---|
128 | ; ES:SI Ptr to ATA information for the drive |
---|
129 | ; DS: RAMVARS segment |
---|
130 | ; ES: BDA/Bootnfo segment |
---|
131 | ; Returns: |
---|
132 | ; Nothing |
---|
133 | ; Corrupts registers: |
---|
134 | ; AX, BX, CX, DX, SI, DI |
---|
135 | ;-------------------------------------------------------------------- |
---|
136 | CreateBiosTablesForHardDisk: |
---|
137 | call CreateDPT_FromAtaInformation |
---|
138 | jc SHORT DetectDrives_DriveNotFound |
---|
139 | call BootInfo_CreateForHardDisk |
---|
140 | jmp short DetectPrint_DriveNameFromBootnfoInESBX |
---|
141 | |
---|
142 | ;-------------------------------------------------------------------- |
---|
143 | ; DetectDrives_DriveNotFound |
---|
144 | ; Parameters: |
---|
145 | ; Nothing |
---|
146 | ; Returns: |
---|
147 | ; Nothing |
---|
148 | ; Corrupts registers: |
---|
149 | ; AX, SI |
---|
150 | ;-------------------------------------------------------------------- |
---|
151 | DetectDrives_DriveNotFound: |
---|
152 | mov si, g_szNotFound |
---|
153 | jmp BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
154 | |
---|