diff options
Diffstat (limited to 'kernel/drivers/disk')
-rw-r--r-- | kernel/drivers/disk/sata.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/kernel/drivers/disk/sata.c b/kernel/drivers/disk/sata.c index aa3ff41..0a083b4 100644 --- a/kernel/drivers/disk/sata.c +++ b/kernel/drivers/disk/sata.c @@ -488,7 +488,25 @@ void sata_init() long sata_read_block(blockdev_t *bdev, char *buf, blocknum_t block, size_t block_count) { - NOT_YET_IMPLEMENTED("DRIVERS: sata_read_block"); + // NOT_YET_IMPLEMENTED("DRIVERS: sata_read_block"); + + // convert block to sector + ssize_t lba = block * SATA_SECTORS_PER_BLOCK; + ssize_t count = block_count * SATA_SECTORS_PER_BLOCK; + + // get the disk + ata_disk_t *disk = bdev_to_ata_disk(bdev); + if (disk == NULL) + { + dbg(DBG_DISK, "sata_read_block: disk is NULL\n"); + return -1; + } + + // call ahci_do_operation + long ret = ahci_do_operation(disk->port, lba, count, buf, + 0 // 0 for read + ); + return -1; } @@ -507,6 +525,24 @@ long sata_read_block(blockdev_t *bdev, char *buf, blocknum_t block, long sata_write_block(blockdev_t *bdev, const char *buf, blocknum_t block, size_t block_count) { - NOT_YET_IMPLEMENTED("DRIVERS: sata_write_block"); + // NOT_YET_IMPLEMENTED("DRIVERS: sata_write_block"); + + // convert block to sector + ssize_t lba = block * SATA_SECTORS_PER_BLOCK; + ssize_t count = block_count * SATA_SECTORS_PER_BLOCK; + + // get the disk + ata_disk_t *disk = bdev_to_ata_disk(bdev); + if (disk == NULL) + { + dbg(DBG_DISK, "sata_write_block: disk is NULL\n"); + return -1; + } + + // call ahci_do_operation + long ret = ahci_do_operation(disk->port, lba, count, (void *)buf, + 1 // 1 for write + ); + return -1; } |