Changes in uspace/srv/bd/ata_bd/ata_bd.c [029b13c:aa893e0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
r029b13c raa893e0 51 51 #include <libarch/ddi.h> 52 52 #include <ddi.h> 53 #include <ipc/ipc.h> 53 54 #include <ipc/bd.h> 54 55 #include <async.h> … … 281 282 sysarg_t method; 282 283 devmap_handle_t dh; 283 unsignedint flags;284 int flags; 284 285 int retval; 285 286 uint64_t ba; … … 297 298 298 299 if (disk_id < 0 || disk[disk_id].present == false) { 299 async_answer_0(iid, EINVAL);300 ipc_answer_0(iid, EINVAL); 300 301 return; 301 302 } 302 303 303 304 /* Answer the IPC_M_CONNECT_ME_TO call. */ 304 async_answer_0(iid, EOK);305 ipc_answer_0(iid, EOK); 305 306 306 307 if (!async_share_out_receive(&callid, &comm_size, &flags)) { 307 async_answer_0(callid, EHANGUP);308 ipc_answer_0(callid, EHANGUP); 308 309 return; 309 310 } … … 311 312 fs_va = as_get_mappable_page(comm_size); 312 313 if (fs_va == NULL) { 313 async_answer_0(callid, EHANGUP);314 ipc_answer_0(callid, EHANGUP); 314 315 return; 315 316 } … … 323 324 case IPC_M_PHONE_HUNGUP: 324 325 /* The other side has hung up. */ 325 async_answer_0(callid, EOK);326 ipc_answer_0(callid, EOK); 326 327 return; 327 328 case BD_READ_BLOCKS: … … 346 347 break; 347 348 case BD_GET_BLOCK_SIZE: 348 async_answer_1(callid, EOK, disk[disk_id].block_size);349 ipc_answer_1(callid, EOK, disk[disk_id].block_size); 349 350 continue; 350 351 case BD_GET_NUM_BLOCKS: 351 async_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks),352 ipc_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks), 352 353 UPPER32(disk[disk_id].blocks)); 353 354 continue; … … 356 357 break; 357 358 } 358 async_answer_0(callid, retval);359 ipc_answer_0(callid, retval); 359 360 } 360 361 } … … 372 373 uint16_t w; 373 374 uint8_t c; 374 uint16_t bc;375 375 size_t pos, len; 376 376 int rc; … … 388 388 } else if (rc == EIO) { 389 389 /* 390 * There is something, but not a register device. Check to see 391 * whether the IDENTIFY command left the packet signature in 392 * the registers in case this is a packet device. 393 * 394 * According to the ATA specification, the LBA low and 395 * interrupt reason registers should be set to 0x01. However, 396 * there are many devices that do not follow this and only set 397 * the byte count registers. So, only check these. 390 * There is something, but not a register device. 391 * It could be a packet device. 398 392 */ 399 bc = ((uint16_t)pio_read_8(&cmd->cylinder_high) << 8) | 400 pio_read_8(&cmd->cylinder_low); 401 402 if (bc == PDEV_SIGNATURE_BC) { 403 rc = identify_pkt_dev(disk_id, &idata); 404 if (rc == EOK) { 405 /* We have a packet device. */ 406 d->dev_type = ata_pkt_dev; 407 } else { 408 return EIO; 409 } 393 rc = identify_pkt_dev(disk_id, &idata); 394 if (rc == EOK) { 395 /* We have a packet device. */ 396 d->dev_type = ata_pkt_dev; 410 397 } else { 411 398 /* Nope. Something's there, but not recognized. */ … … 417 404 } 418 405 406 printf("device caps: 0x%04x\n", idata.caps); 419 407 if (d->dev_type == ata_pkt_dev) { 420 408 /* Packet device */ … … 579 567 580 568 /* 581 * Do not wait for DRDY to be set in case this is a packet device. 582 * We determine whether the device is present by waiting for DRQ to be 583 * set after issuing the command. 569 * This is where we would most likely expect a non-existing device to 570 * show up by not setting SR_DRDY. 584 571 */ 585 if (wait_status( 0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)572 if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK) 586 573 return ETIMEOUT; 587 574 … … 591 578 return ETIMEOUT; 592 579 593 /* 594 * If ERR is set, this may be a packet device, so return EIO to cause 595 * the caller to check for one. 596 */ 580 /* Read data from the disk buffer. */ 581 582 if ((status & SR_DRQ) != 0) { 583 for (i = 0; i < identify_data_size / 2; i++) { 584 data = pio_read_16(&cmd->data_port); 585 ((uint16_t *) buf)[i] = data; 586 } 587 } 588 597 589 if ((status & SR_ERR) != 0) { 598 590 return EIO; 599 }600 601 if (wait_status(SR_DRQ, ~SR_BSY, &status, TIMEOUT_PROBE) != EOK)602 return ETIMEOUT;603 604 /* Read data from the disk buffer. */605 606 for (i = 0; i < identify_data_size / 2; i++) {607 data = pio_read_16(&cmd->data_port);608 ((uint16_t *) buf)[i] = data;609 591 } 610 592
Note:
See TracChangeset
for help on using the changeset viewer.