Rev 6842 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 8051 $ |
||
9 | |||
5852 | pathoswith | 10 | ; HDD and CD search |
2288 | clevermous | 11 | |
4700 | mario79 | 12 | cmp [ecx+IDE_DATA.ProgrammingInterface], 0 |
3785 | mario79 | 13 | je EndFindHDD |
2288 | clevermous | 14 | FindHDD: |
4700 | mario79 | 15 | xor ebx, ebx |
16 | inc ebx |
||
5852 | pathoswith | 17 | mov [DeviceNumber], 0 |
18 | cmp ecx, IDE_controller_1 |
||
19 | jz .find |
||
20 | add bl, 5 |
||
21 | add [DeviceNumber], sizeof.HD_DATA*4 |
||
4700 | mario79 | 22 | cmp ecx, IDE_controller_2 |
5852 | pathoswith | 23 | jz .find |
4700 | mario79 | 24 | add bl, 5 |
5852 | pathoswith | 25 | add [DeviceNumber], sizeof.HD_DATA*4 |
4700 | mario79 | 26 | .find: |
2288 | clevermous | 27 | mov [ChannelNumber], 1 |
28 | mov [DiskNumber], 0 |
||
5852 | pathoswith | 29 | call FindHDD_1 |
30 | inc [DiskNumber] |
||
4700 | mario79 | 31 | call FindHDD_2 |
2288 | clevermous | 32 | inc [ChannelNumber] |
5852 | pathoswith | 33 | dec [DiskNumber] |
34 | call FindHDD_2 |
||
35 | inc [DiskNumber] |
||
4700 | mario79 | 36 | call FindHDD_2 |
2288 | clevermous | 37 | jmp EndFindHDD |
4700 | mario79 | 38 | ;----------------------------------------------------------------------------- |
39 | FindHDD_2: |
||
5852 | pathoswith | 40 | add [DeviceNumber], sizeof.HD_DATA |
4700 | mario79 | 41 | shl byte [ebx+DRIVE_DATA], 2 |
2288 | clevermous | 42 | FindHDD_1: |
6464 | pathoswith | 43 | DEBUGF 1, "K : Channel %d ",[ChannelNumber]:1 |
3706 | mario79 | 44 | DEBUGF 1, "Disk %d\n",[DiskNumber]:1 |
6842 | pathoswith | 45 | push ecx ebx |
2288 | clevermous | 46 | call ReadHDD_ID |
5030 | clevermous | 47 | cmp [DevErrorCode], 7 |
48 | je .end |
||
2288 | clevermous | 49 | cmp [DevErrorCode], 0 |
4700 | mario79 | 50 | jne .FindCD |
2288 | clevermous | 51 | cmp [Sector512+6], word 16 |
4700 | mario79 | 52 | ja .FindCD |
2288 | clevermous | 53 | cmp [Sector512+12], word 255 |
4700 | mario79 | 54 | ja .FindCD |
6842 | pathoswith | 55 | pop ebx |
5852 | pathoswith | 56 | movzx eax, [DeviceNumber] |
6842 | pathoswith | 57 | mov ecx, [Sector512+120] |
58 | mov dword[eax+hd0_data.sectors], ecx |
||
59 | and dword[eax+hd0_data.sectors+4], 0 |
||
5852 | pathoswith | 60 | bt word [Sector512+166], 10 |
6842 | pathoswith | 61 | jnc .Print_Device_Name |
62 | mov [eax+hd0_data.hd48], 1 |
||
63 | mov ecx, [Sector512+200] |
||
64 | mov dword[eax+hd0_data.sectors], ecx |
||
65 | mov ecx, [Sector512+204] |
||
66 | mov dword[eax+hd0_data.sectors+4], ecx |
||
4700 | mario79 | 67 | jmp .Print_Device_Name |
68 | ;-------------------------------------- |
||
69 | .FindCD: |
||
2288 | clevermous | 70 | call DeviceReset |
71 | cmp [DevErrorCode], 0 |
||
4700 | mario79 | 72 | jne .end |
2288 | clevermous | 73 | call ReadCD_ID |
74 | cmp [DevErrorCode], 0 |
||
4700 | mario79 | 75 | jne .end |
6842 | pathoswith | 76 | pop ebx |
77 | inc byte [ebx+DRIVE_DATA] |
||
4700 | mario79 | 78 | ;-------------------------------------- |
6464 | pathoswith | 79 | .Print_Device_Name: |
6842 | pathoswith | 80 | inc byte [ebx+DRIVE_DATA] |
81 | pop ecx |
||
3711 | clevermous | 82 | pushad |
6464 | pathoswith | 83 | movzx ebx, [ChannelNumber] |
4772 | mario79 | 84 | dec ebx |
85 | shl ebx, 1 |
||
86 | add bl, [DiskNumber] |
||
87 | shl ebx, 1 |
||
88 | call calculate_IDE_device_values_storage |
||
89 | ;-------------------------------------- |
||
90 | .copy_dev_name: |
||
3711 | clevermous | 91 | mov esi, Sector512+27*2 |
92 | mov edi, dev_name |
||
93 | mov ecx, 20 |
||
94 | cld |
||
4772 | mario79 | 95 | ;-------------------------------------- |
3702 | mario79 | 96 | @@: |
3711 | clevermous | 97 | lodsw |
98 | xchg ah, al |
||
99 | stosw |
||
100 | loop @b |
||
3702 | mario79 | 101 | DEBUGF 1, "K : Dev: %s \n", dev_name |
3881 | mario79 | 102 | xor eax, eax |
103 | mov ax, [Sector512+64*2] |
||
4772 | mario79 | 104 | DEBUGF 1, "K : PIO possible modes %x\n", al |
4624 | mario79 | 105 | mov ax, [Sector512+51*2] |
106 | mov al, ah |
||
107 | call convert_Sector512_value |
||
4772 | mario79 | 108 | DEBUGF 1, "K : PIO set mode %x\n", ah |
3881 | mario79 | 109 | mov ax, [Sector512+63*2] |
4624 | mario79 | 110 | DEBUGF 1, "K : Multiword DMA possible modes %x\n", al |
111 | mov al, ah |
||
112 | call convert_Sector512_value |
||
113 | DEBUGF 1, "K : Multiword DMA set mode %x\n", ah |
||
3881 | mario79 | 114 | mov ax, [Sector512+88*2] |
4624 | mario79 | 115 | DEBUGF 1, "K : Ultra DMA possible modes %x\n", al |
4772 | mario79 | 116 | mov [ebx+IDE_DEVICE.UDMA_possible_modes], al |
4624 | mario79 | 117 | mov al, ah |
118 | call convert_Sector512_value |
||
119 | DEBUGF 1, "K : Ultra DMA set mode %x\n", ah |
||
4772 | mario79 | 120 | mov [ebx+IDE_DEVICE.UDMA_set_mode], ah |
4700 | mario79 | 121 | popad |
2288 | clevermous | 122 | ret |
6842 | pathoswith | 123 | |
4700 | mario79 | 124 | .end: |
125 | DEBUGF 1, "K : Device not found\n" |
||
6842 | pathoswith | 126 | pop ebx ecx |
2288 | clevermous | 127 | ret |
4624 | mario79 | 128 | ;----------------------------------------------------------------------------- |
4772 | mario79 | 129 | calculate_IDE_device_values_storage: |
130 | cmp ecx, IDE_controller_1 |
||
131 | jne @f |
||
132 | |||
133 | add ebx, IDE_device_1 |
||
134 | jmp .exit |
||
135 | ;-------------------------------------- |
||
136 | @@: |
||
137 | cmp ecx, IDE_controller_2 |
||
138 | jne @f |
||
139 | |||
140 | add ebx, IDE_device_2 |
||
141 | jmp .exit |
||
142 | ;-------------------------------------- |
||
143 | @@: |
||
144 | add ebx, IDE_device_3 |
||
145 | ;-------------------------------------- |
||
146 | .exit: |
||
147 | ret |
||
148 | ;----------------------------------------------------------------------------- |
||
4624 | mario79 | 149 | convert_Sector512_value: |
150 | mov ecx, 8 |
||
151 | xor ah, ah |
||
4772 | mario79 | 152 | ;-------------------------------------- |
4624 | mario79 | 153 | @@: |
154 | test al, 1b |
||
155 | jnz .end |
||
2288 | clevermous | 156 | |
4624 | mario79 | 157 | shr al, 1 |
158 | inc ah |
||
159 | loop @b |
||
160 | |||
161 | xor ah, ah |
||
4772 | mario79 | 162 | ;-------------------------------------- |
4624 | mario79 | 163 | .end: |
164 | ret |
||
165 | ;----------------------------------------------------------------------------- |
||
8051 | rgimad | 166 | ; Address of reading sector in LBA mode |
2288 | clevermous | 167 | uglobal |
4700 | mario79 | 168 | SectorAddress dd ? |
3702 | mario79 | 169 | dev_name: |
3711 | clevermous | 170 | rb 41 |
2288 | clevermous | 171 | endg |
4700 | mario79 | 172 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 173 | ;************************************************* |
8051 | rgimad | 174 | ;* READING THE HARD DISK IDENTIFIER * |
175 | ;* Input parameters are passed through the global* |
||
176 | ;* variables: * |
||
177 | ;* ChannelNumber - channel number (1 or 2); * |
||
178 | ;* DiskNumber - disk number on channel (0 or 1) * |
||
179 | ;* Block of identificational data is reading * |
||
180 | ;* to Sector512 array. * |
||
2288 | clevermous | 181 | ;************************************************* |
182 | ReadHDD_ID: |
||
8051 | rgimad | 183 | ; set up CHS mode |
2288 | clevermous | 184 | mov [ATAAddressMode], 0 |
8051 | rgimad | 185 | ; send device identification command |
2288 | clevermous | 186 | mov [ATAFeatures], 0 |
187 | mov [ATAHead], 0 |
||
4700 | mario79 | 188 | mov [ATACommand], 0xEC |
2288 | clevermous | 189 | call SendCommandToHDD |
8051 | rgimad | 190 | cmp [DevErrorCode], 0 ; check the error code |
191 | jne @@End ; finish, saving the error code |
||
4700 | mario79 | 192 | |
193 | mov dx, [ATABasePortAddr] |
||
8051 | rgimad | 194 | add dx, 7 ; address of state register |
2288 | clevermous | 195 | mov ecx, 0xffff |
196 | @@WaitCompleet: |
||
8051 | rgimad | 197 | ; Check command execution time |
2288 | clevermous | 198 | dec ecx |
8051 | rgimad | 199 | jz @@Error1 ; timeout error |
200 | ; Check if ready or not |
||
4700 | mario79 | 201 | in al, dx |
8051 | rgimad | 202 | test al, 80h ; BSY signal state |
2288 | clevermous | 203 | jnz @@WaitCompleet |
4700 | mario79 | 204 | |
8051 | rgimad | 205 | test al, 1 ; ERR signal state |
2288 | clevermous | 206 | jnz @@Error6 |
4700 | mario79 | 207 | |
8051 | rgimad | 208 | test al, 08h ; DRQ signal state |
2288 | clevermous | 209 | jz @@WaitCompleet |
8051 | rgimad | 210 | ; Receive data block from controller |
4700 | mario79 | 211 | mov edi, Sector512 |
8051 | rgimad | 212 | mov dx, [ATABasePortAddr]; data register |
213 | mov cx, 256 ; number of word to receive |
||
214 | rep insw ; receive data block |
||
2288 | clevermous | 215 | ret |
8051 | rgimad | 216 | ; write the error code |
2288 | clevermous | 217 | @@Error1: |
218 | mov [DevErrorCode], 1 |
||
219 | ret |
||
220 | @@Error6: |
||
221 | mov [DevErrorCode], 6 |
||
222 | @@End: |
||
223 | ret |
||
4700 | mario79 | 224 | ;----------------------------------------------------------------------------- |
225 | uglobal |
||
8051 | rgimad | 226 | ; Standart base addresses of channels 1 or 2 |
4700 | mario79 | 227 | StandardATABases dw ?, ? ; 1F0h, 170h |
8051 | rgimad | 228 | ; Channel number |
6464 | pathoswith | 229 | ChannelNumber db ? |
8051 | rgimad | 230 | ; Disk number |
4700 | mario79 | 231 | DiskNumber db ? |
5852 | pathoswith | 232 | DeviceNumber db ? |
8051 | rgimad | 233 | ; Base address of ATA controller's port group |
4700 | mario79 | 234 | ATABasePortAddr dw ? |
8051 | rgimad | 235 | ; ATA-command parameters |
236 | ATAFeatures db ? ; features |
||
237 | ATASectorCount db ? ; count of processing sectors |
||
238 | ATASectorNumber db ? ; initial sector number |
||
239 | ATACylinder dw ? ; initial cylinder number |
||
240 | ATAHead db ? ; initial head number |
||
241 | ATAAddressMode db ? ; addressing mode (0 - CHS, 1 - LBA) |
||
242 | ATACommand db ? ; executing command number |
||
243 | ; Error code (0 - no errors, 1 - waiting time limit exceed |
||
244 | ; 2 - incorrect code of addressing mode, |
||
245 | ; 3 - incorrect channel number, 4 - incorrect disk number, |
||
246 | ; 5 - incorrect head number, 6 - command execution error, |
||
247 | ; 7 - time out when choosing channel) |
||
2288 | clevermous | 248 | DevErrorCode dd ? |
249 | endg |
||
4700 | mario79 | 250 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 251 | ;**************************************************** |
8051 | rgimad | 252 | ;* SEND COMMAND TO GIVEN DISK * |
253 | ;* Input parameters are passed through the global * |
||
254 | ;* variables: * |
||
255 | ;* ChannelNumber - channel number (1 or 2); * |
||
256 | ;* DiskNumber - disk number (0 or 1); * |
||
257 | ;* ATAFeatures - "features"; * |
||
258 | ;* ATASectorCount - sector count; * |
||
259 | ;* ATASectorNumber - initial sector number; * |
||
260 | ;* ATACylinder - initial cylinder number; * |
||
261 | ;* ATAHead - initial head number; * |
||
262 | ;* ATAAddressMode - addressing mode (0-CHS, 1-LBA); * |
||
263 | ;* ATACommand - command code. * |
||
264 | ;* If the function finished successfully: * |
||
265 | ;* in ATABasePortAddr - base address of HDD; * |
||
266 | ;* in DevErrorCode - zero. * |
||
267 | ;* If error has occured then in DevErrorCode will * |
||
268 | ;* be the error code. * |
||
2288 | clevermous | 269 | ;**************************************************** |
270 | SendCommandToHDD: |
||
8051 | rgimad | 271 | ; Check the addressing mode code |
2288 | clevermous | 272 | cmp [ATAAddressMode], 1 |
273 | ja @@Err2 |
||
8051 | rgimad | 274 | ; Check the channel number correctness |
6464 | pathoswith | 275 | movzx ebx, [ChannelNumber] |
276 | dec ebx |
||
277 | cmp ebx, 1 |
||
2288 | clevermous | 278 | ja @@Err3 |
8051 | rgimad | 279 | ; Set the base address |
6464 | pathoswith | 280 | shl ebx, 1 |
4700 | mario79 | 281 | mov ax, [ebx+StandardATABases] |
282 | mov [ATABasePortAddr], ax |
||
8051 | rgimad | 283 | ; Waiting for HDD ready to receive a command |
284 | ; Choose desired disk |
||
4700 | mario79 | 285 | mov dx, [ATABasePortAddr] |
8051 | rgimad | 286 | add dx, 6 ; address of the heads register |
4700 | mario79 | 287 | mov al, [DiskNumber] |
8051 | rgimad | 288 | cmp al, 1 ; check the disk number |
2288 | clevermous | 289 | ja @@Err4 |
4700 | mario79 | 290 | |
291 | shl al, 4 |
||
292 | or al, 10100000b |
||
293 | out dx, al |
||
8051 | rgimad | 294 | ; Waiting for disk ready |
4700 | mario79 | 295 | inc dx |
2288 | clevermous | 296 | mov ecx, 0xfff |
297 | @@WaitHDReady: |
||
8051 | rgimad | 298 | ; Check waiting time |
2288 | clevermous | 299 | dec ecx |
300 | jz @@Err1 |
||
8051 | rgimad | 301 | ; Read the state register |
4700 | mario79 | 302 | in al, dx |
8051 | rgimad | 303 | ; Check the state of BSY signal |
4700 | mario79 | 304 | test al, 80h |
2288 | clevermous | 305 | jnz @@WaitHDReady |
8051 | rgimad | 306 | ; Check the state of DRQ signal |
4700 | mario79 | 307 | test al, 08h |
2288 | clevermous | 308 | jnz @@WaitHDReady |
8051 | rgimad | 309 | ; load command to controller's registers |
2288 | clevermous | 310 | cli |
4700 | mario79 | 311 | mov dx, [ATABasePortAddr] |
8051 | rgimad | 312 | inc dx ; "features" register |
4700 | mario79 | 313 | mov al, [ATAFeatures] |
314 | out dx, AL |
||
8051 | rgimad | 315 | inc dx ; sector counter |
4700 | mario79 | 316 | mov al, [ATASectorCount] |
317 | out dx, AL |
||
8051 | rgimad | 318 | inc dx ; sector number register |
4700 | mario79 | 319 | mov al, [ATASectorNumber] |
320 | out dx, AL |
||
8051 | rgimad | 321 | inc dx ; cylinder number (low byte) |
4700 | mario79 | 322 | mov ax, [ATACylinder] |
323 | out dx, AL |
||
8051 | rgimad | 324 | inc dx ; cylinder number (high byte) |
4700 | mario79 | 325 | mov al, AH |
326 | out dx, AL |
||
8051 | rgimad | 327 | inc dx ; head number / disk number |
4700 | mario79 | 328 | mov al, [DiskNumber] |
329 | shl al, 4 |
||
8051 | rgimad | 330 | cmp [ATAHead], 0xF ; check head number |
2288 | clevermous | 331 | ja @@Err5 |
4700 | mario79 | 332 | |
333 | or al, [ATAHead] |
||
334 | or al, 10100000b |
||
335 | mov ah, [ATAAddressMode] |
||
336 | shl ah, 6 |
||
337 | or al, ah |
||
338 | out dx, al |
||
8051 | rgimad | 339 | ; Send command |
4700 | mario79 | 340 | mov al, [ATACommand] |
8051 | rgimad | 341 | inc dx ; command register |
4700 | mario79 | 342 | out dx, al |
2288 | clevermous | 343 | sti |
8051 | rgimad | 344 | ; reset the error sign |
2288 | clevermous | 345 | mov [DevErrorCode], 0 |
346 | ret |
||
8051 | rgimad | 347 | ; write error code |
2288 | clevermous | 348 | @@Err1: |
5030 | clevermous | 349 | mov [DevErrorCode], 7 |
2288 | clevermous | 350 | ret |
351 | @@Err2: |
||
352 | mov [DevErrorCode], 2 |
||
353 | ret |
||
354 | @@Err3: |
||
355 | mov [DevErrorCode], 3 |
||
356 | ret |
||
357 | @@Err4: |
||
358 | mov [DevErrorCode], 4 |
||
359 | ret |
||
360 | @@Err5: |
||
361 | mov [DevErrorCode], 5 |
||
8051 | rgimad | 362 | ; finish work |
2288 | clevermous | 363 | ret |
4700 | mario79 | 364 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 365 | ;************************************************* |
8051 | rgimad | 366 | ;* READ ATAPI DEVICE IDENTIFIER * |
367 | ;* Input parameters are passed through the global* |
||
368 | ;* variables: * |
||
369 | ;* ChannelNumber - channel number; * |
||
370 | ;* DiskNumber - disk number on channel. * |
||
371 | ;* Block of identificational data is reading * |
||
372 | ;* to Sector512 array. * * |
||
2288 | clevermous | 373 | ;************************************************* |
374 | ReadCD_ID: |
||
8051 | rgimad | 375 | ; Set CHS mode |
2288 | clevermous | 376 | mov [ATAAddressMode], 0 |
8051 | rgimad | 377 | ; Send command for device identification |
2288 | clevermous | 378 | mov [ATAFeatures], 0 |
379 | mov [ATASectorCount], 0 |
||
380 | mov [ATASectorNumber], 0 |
||
381 | mov [ATACylinder], 0 |
||
382 | mov [ATAHead], 0 |
||
4700 | mario79 | 383 | mov [ATACommand], 0xA1 |
2288 | clevermous | 384 | call SendCommandToHDD |
8051 | rgimad | 385 | cmp [DevErrorCode], 0 ; check the error code |
386 | jne @@End_1 ; finish, saving the error code |
||
387 | ; Wait for HDD data ready |
||
4700 | mario79 | 388 | mov dx, [ATABasePortAddr] |
8051 | rgimad | 389 | add dx, 7 ; port 1х7h |
2288 | clevermous | 390 | mov ecx, 0xffff |
391 | @@WaitCompleet_1: |
||
8051 | rgimad | 392 | ; Check time |
2288 | clevermous | 393 | dec ecx |
8051 | rgimad | 394 | jz @@Error1_1 ; time out error |
395 | ; Check readyness |
||
4700 | mario79 | 396 | in al, dx |
8051 | rgimad | 397 | test al, 80h ; BSY signal state |
2288 | clevermous | 398 | jnz @@WaitCompleet_1 |
4700 | mario79 | 399 | |
8051 | rgimad | 400 | test al, 1 ; ERR signal state |
2288 | clevermous | 401 | jnz @@Error6_1 |
4700 | mario79 | 402 | |
8051 | rgimad | 403 | test al, 08h ; DRQ signal state |
2288 | clevermous | 404 | jz @@WaitCompleet_1 |
8051 | rgimad | 405 | ; Receive data block from controller |
406 | mov edi, Sector512 ; offset Sector512 |
||
407 | mov dx, [ATABasePortAddr] ; port 1x0h |
||
408 | mov cx, 256 ; words read count |
||
2288 | clevermous | 409 | rep insw |
410 | ret |
||
8051 | rgimad | 411 | ; write the error code |
2288 | clevermous | 412 | @@Error1_1: |
413 | mov [DevErrorCode], 1 |
||
414 | ret |
||
415 | @@Error6_1: |
||
416 | mov [DevErrorCode], 6 |
||
417 | @@End_1: |
||
418 | ret |
||
4700 | mario79 | 419 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 420 | ;************************************************* |
8051 | rgimad | 421 | ;* DEVICE RESET * |
422 | ;* Input parameters are passed through the global* |
||
423 | ;* variables: * |
||
424 | ;* ChannelNumber - channel number (1 or 2); * |
||
425 | ;* DiskNumber - disk number (0 or 1). * |
||
2288 | clevermous | 426 | ;************************************************* |
427 | DeviceReset: |
||
8051 | rgimad | 428 | ; Check the channel number correctness |
6464 | pathoswith | 429 | movzx ebx, [ChannelNumber] |
430 | dec ebx |
||
431 | cmp ebx, 1 |
||
2288 | clevermous | 432 | ja @@Err3_2 |
8051 | rgimad | 433 | ; Set base address |
6464 | pathoswith | 434 | shl ebx, 1 |
4700 | mario79 | 435 | mov dx, [ebx+StandardATABases] |
436 | mov [ATABasePortAddr], dx |
||
8051 | rgimad | 437 | ; Choose desired disk |
438 | add dx, 6 ; address of heads register |
||
4700 | mario79 | 439 | mov al, [DiskNumber] |
8051 | rgimad | 440 | cmp al, 1 ; check disk number |
2288 | clevermous | 441 | ja @@Err4_2 |
4700 | mario79 | 442 | |
443 | shl al, 4 |
||
444 | or al, 10100000b |
||
445 | out dx, al |
||
8051 | rgimad | 446 | ; Send the "Reset" command |
4700 | mario79 | 447 | mov al, 0x8 |
8051 | rgimad | 448 | inc dx ; command register |
4700 | mario79 | 449 | out dx, al |
2288 | clevermous | 450 | mov ecx, 0x80000 |
451 | @@WaitHDReady_1: |
||
8051 | rgimad | 452 | ; Check waiting time |
2288 | clevermous | 453 | dec ecx |
8051 | rgimad | 454 | je @@Err1_2 ; time out error |
455 | ; read the state register |
||
4700 | mario79 | 456 | in al, dx |
8051 | rgimad | 457 | ; Check the state of BSY signal |
4700 | mario79 | 458 | test al, 80h |
2288 | clevermous | 459 | jnz @@WaitHDReady_1 |
8051 | rgimad | 460 | ; reset the error sign |
2288 | clevermous | 461 | mov [DevErrorCode], 0 |
462 | ret |
||
8051 | rgimad | 463 | ; error processing |
2288 | clevermous | 464 | @@Err1_2: |
465 | mov [DevErrorCode], 1 |
||
466 | ret |
||
467 | @@Err3_2: |
||
468 | mov [DevErrorCode], 3 |
||
469 | ret |
||
470 | @@Err4_2: |
||
471 | mov [DevErrorCode], 4 |
||
8051 | rgimad | 472 | ; write error code |
2288 | clevermous | 473 | ret |
4700 | mario79 | 474 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 475 | EndFindHDD: |