Changeset bb0eab1 in mainline for uspace/srv/bd/ata_bd/ata_bd.c
- Timestamp:
- 2011-02-01T07:27:32Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aa893e0
- Parents:
- 0d247f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
r0d247f5 rbb0eab1 56 56 #include <as.h> 57 57 #include <fibril_synch.h> 58 #include <stdint.h> 58 59 #include <str.h> 59 60 #include <devmap.h> … … 62 63 #include <errno.h> 63 64 #include <bool.h> 65 #include <byteorder.h> 64 66 #include <task.h> 65 67 #include <macros.h> … … 368 370 identify_data_t idata; 369 371 uint8_t model[40]; 370 uint8_t inq_buf[36];372 ata_inquiry_data_t inq_data; 371 373 uint16_t w; 372 374 uint8_t c; … … 471 473 if (d->dev_type == ata_pkt_dev) { 472 474 /* Send inquiry. */ 473 rc = ata_pcmd_inquiry(0, inq_buf, 36);475 rc = ata_pcmd_inquiry(0, &inq_data, sizeof(inq_data)); 474 476 if (rc != EOK) { 475 477 printf("Device inquiry failed.\n"); … … 479 481 480 482 /* Check device type. */ 481 if ( (inq_buf[0] & 0x1f) != 0x05)483 if (INQUIRY_PDEV_TYPE(inq_data.pdev_type) != PDEV_TYPE_CDROM) 482 484 printf("Warning: Peripheral device type is not CD-ROM.\n"); 483 484 /* XXX Test some reading */485 uint8_t rdbuf[4096];486 rc = ata_pcmd_read_12(0, 0, 1, rdbuf, 4096);487 if (rc != EOK) {488 printf("read(12) failed\n");489 } else {490 printf("read(12) succeeded\n");491 }492 485 493 486 /* Assume 2k block size for now. */ … … 714 707 data_size = (uint16_t) pio_read_8(&cmd->cylinder_low) + 715 708 ((uint16_t) pio_read_8(&cmd->cylinder_high) << 8); 716 printf("data_size = %u\n", data_size);717 709 718 710 /* Check whether data fits into output buffer. */ … … 749 741 static int ata_pcmd_inquiry(int dev_idx, void *obuf, size_t obuf_size) 750 742 { 751 uint8_t cp[12];743 ata_pcmd_inquiry_t cp; 752 744 int rc; 753 745 754 memset(cp, 0, 12); 755 cp[0] = 0x12; /* Inquiry */ 756 cp[4] = min(obuf_size, 0xff); /* Allocation length */ 757 758 rc = ata_cmd_packet(0, cp, 12, obuf, obuf_size); 746 memset(&cp, 0, sizeof(cp)); 747 748 cp.opcode = PCMD_INQUIRY; 749 cp.alloc_len = min(obuf_size, 0xff); /* Allocation length */ 750 751 rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size); 759 752 if (rc != EOK) 760 753 return rc; … … 766 759 void *obuf, size_t obuf_size) 767 760 { 768 uint8_t cp[12];761 ata_pcmd_read_12_t cp; 769 762 int rc; 770 763 771 if (ba > 0xffffffff)764 if (ba > UINT32_MAX) 772 765 return EINVAL; 773 766 774 memset(cp, 0, 12); 775 cp[0] = 0xa8; /* Read(12) */ 776 cp[2] = (ba >> 24) & 0xff; 777 cp[3] = (ba >> 16) & 0xff; 778 cp[4] = (ba >> 8) & 0xff; 779 cp[5] = ba & 0xff; 780 781 cp[6] = (cnt >> 24) & 0xff; 782 cp[7] = (cnt >> 16) & 0xff; 783 cp[8] = (cnt >> 8) & 0xff; 784 cp[9] = cnt & 0xff; 785 786 rc = ata_cmd_packet(0, cp, 12, obuf, obuf_size); 767 memset(&cp, 0, sizeof(cp)); 768 769 cp.opcode = PCMD_READ_12; 770 cp.ba = host2uint32_t_be(ba); 771 cp.nblocks = host2uint32_t_be(cnt); 772 773 rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size); 787 774 if (rc != EOK) 788 775 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.