Changeset 4abe919 in mainline
- Timestamp:
- 2014-08-28T10:52:08Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a7db87
- Parents:
- 4236b18
- Location:
- uspace/drv/block/ata_bd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ata_bd/ata_bd.c
r4236b18 r4abe919 97 97 static int ata_bd_get_block_size(bd_srv_t *, size_t *); 98 98 static int ata_bd_get_num_blocks(bd_srv_t *, aoff64_t *); 99 static int ata_bd_sync_cache(bd_srv_t *, aoff64_t, size_t); 99 100 100 101 static int ata_rcmd_read(disk_t *disk, uint64_t ba, size_t cnt, … … 102 103 static int ata_rcmd_write(disk_t *disk, uint64_t ba, size_t cnt, 103 104 const void *buf); 105 static int ata_rcmd_flush_cache(disk_t *disk); 104 106 static int disk_init(ata_ctrl_t *ctrl, disk_t *d, int disk_id); 105 107 static int ata_identify_dev(disk_t *disk, void *buf); … … 129 131 .write_blocks = ata_bd_write_blocks, 130 132 .get_block_size = ata_bd_get_block_size, 131 .get_num_blocks = ata_bd_get_num_blocks 133 .get_num_blocks = ata_bd_get_num_blocks, 134 .sync_cache = ata_bd_sync_cache 132 135 }; 133 136 … … 586 589 } 587 590 591 /** Flush cache. */ 592 static int ata_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt) 593 { 594 disk_t *disk = bd_srv_disk(bd); 595 596 /* ATA cannot flush just some blocks, we just flush everything. */ 597 (void)ba; 598 (void)cnt; 599 600 return ata_rcmd_flush_cache(disk); 601 } 602 588 603 /** PIO data-in command protocol. */ 589 604 static int ata_pio_data_in(disk_t *disk, void *obuf, size_t obuf_size, … … 639 654 } 640 655 } 656 657 if (status & SR_ERR) 658 return EIO; 659 660 return EOK; 661 } 662 663 /** PIO non-data command protocol. */ 664 static int ata_pio_nondata(disk_t *disk) 665 { 666 ata_ctrl_t *ctrl = disk->ctrl; 667 uint8_t status; 668 669 if (wait_status(ctrl, 0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK) 670 return EIO; 641 671 642 672 if (status & SR_ERR) … … 1076 1106 rc = ata_pio_data_out(disk, buf, cnt * disk->block_size, 1077 1107 disk->block_size, cnt); 1108 1109 fibril_mutex_unlock(&ctrl->lock); 1110 return rc; 1111 } 1112 1113 /** Flush cached data to nonvolatile storage. 1114 * 1115 * @param disk Disk 1116 * 1117 * @return EOK on success, EIO on error. 1118 */ 1119 static int ata_rcmd_flush_cache(disk_t *disk) 1120 { 1121 ata_ctrl_t *ctrl = disk->ctrl; 1122 uint8_t drv_head; 1123 int rc; 1124 1125 /* New value for Drive/Head register */ 1126 drv_head = 1127 (disk_dev_idx(disk) != 0) ? DHR_DRV : 0; 1128 1129 fibril_mutex_lock(&ctrl->lock); 1130 1131 /* Program a Flush Cache operation. */ 1132 1133 if (wait_status(ctrl, 0, ~SR_BSY, NULL, TIMEOUT_BSY) != EOK) { 1134 fibril_mutex_unlock(&ctrl->lock); 1135 return EIO; 1136 } 1137 1138 pio_write_8(&ctrl->cmd->drive_head, drv_head); 1139 1140 if (wait_status(ctrl, SR_DRDY, ~SR_BSY, NULL, TIMEOUT_DRDY) != EOK) { 1141 fibril_mutex_unlock(&ctrl->lock); 1142 return EIO; 1143 } 1144 1145 pio_write_8(&ctrl->cmd->command, CMD_FLUSH_CACHE); 1146 1147 rc = ata_pio_nondata(disk); 1078 1148 1079 1149 fibril_mutex_unlock(&ctrl->lock); -
uspace/drv/block/ata_bd/ata_hw.h
r4236b18 r4abe919 136 136 CMD_PACKET = 0xA0, 137 137 CMD_IDENTIFY_PKT_DEV = 0xA1, 138 CMD_IDENTIFY_DRIVE = 0xEC 138 CMD_IDENTIFY_DRIVE = 0xEC, 139 CMD_FLUSH_CACHE = 0xE7 139 140 }; 140 141
Note:
See TracChangeset
for help on using the changeset viewer.