Changes in uspace/srv/bd/ata_bd/ata_bd.c [aa893e0:029b13c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
raa893e0 r029b13c 51 51 #include <libarch/ddi.h> 52 52 #include <ddi.h> 53 #include <ipc/ipc.h>54 53 #include <ipc/bd.h> 55 54 #include <async.h> … … 282 281 sysarg_t method; 283 282 devmap_handle_t dh; 284 int flags;283 unsigned int flags; 285 284 int retval; 286 285 uint64_t ba; … … 298 297 299 298 if (disk_id < 0 || disk[disk_id].present == false) { 300 ipc_answer_0(iid, EINVAL);299 async_answer_0(iid, EINVAL); 301 300 return; 302 301 } 303 302 304 303 /* Answer the IPC_M_CONNECT_ME_TO call. */ 305 ipc_answer_0(iid, EOK);304 async_answer_0(iid, EOK); 306 305 307 306 if (!async_share_out_receive(&callid, &comm_size, &flags)) { 308 ipc_answer_0(callid, EHANGUP);307 async_answer_0(callid, EHANGUP); 309 308 return; 310 309 } … … 312 311 fs_va = as_get_mappable_page(comm_size); 313 312 if (fs_va == NULL) { 314 ipc_answer_0(callid, EHANGUP);313 async_answer_0(callid, EHANGUP); 315 314 return; 316 315 } … … 324 323 case IPC_M_PHONE_HUNGUP: 325 324 /* The other side has hung up. */ 326 ipc_answer_0(callid, EOK);325 async_answer_0(callid, EOK); 327 326 return; 328 327 case BD_READ_BLOCKS: … … 347 346 break; 348 347 case BD_GET_BLOCK_SIZE: 349 ipc_answer_1(callid, EOK, disk[disk_id].block_size);348 async_answer_1(callid, EOK, disk[disk_id].block_size); 350 349 continue; 351 350 case BD_GET_NUM_BLOCKS: 352 ipc_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks),351 async_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks), 353 352 UPPER32(disk[disk_id].blocks)); 354 353 continue; … … 357 356 break; 358 357 } 359 ipc_answer_0(callid, retval);358 async_answer_0(callid, retval); 360 359 } 361 360 } … … 373 372 uint16_t w; 374 373 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. 391 * It could be a packet device. 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. 392 398 */ 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; 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 } 397 410 } else { 398 411 /* Nope. Something's there, but not recognized. */ … … 404 417 } 405 418 406 printf("device caps: 0x%04x\n", idata.caps);407 419 if (d->dev_type == ata_pkt_dev) { 408 420 /* Packet device */ … … 567 579 568 580 /* 569 * This is where we would most likely expect a non-existing device to 570 * show up by not setting SR_DRDY. 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. 571 584 */ 572 if (wait_status( SR_DRDY, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)585 if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK) 573 586 return ETIMEOUT; 574 587 … … 578 591 return ETIMEOUT; 579 592 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 */ 597 if ((status & SR_ERR) != 0) { 598 return EIO; 599 } 600 601 if (wait_status(SR_DRQ, ~SR_BSY, &status, TIMEOUT_PROBE) != EOK) 602 return ETIMEOUT; 603 580 604 /* Read data from the disk buffer. */ 581 605 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 589 if ((status & SR_ERR) != 0) { 590 return EIO; 606 for (i = 0; i < identify_data_size / 2; i++) { 607 data = pio_read_16(&cmd->data_port); 608 ((uint16_t *) buf)[i] = data; 591 609 } 592 610
Note:
See TracChangeset
for help on using the changeset viewer.