X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/01a605198da7bc5883a3dfa96b38f4f7c04f67f9..202a8b1f31fa458e96ad7f20ae056d200b31b029:/lunaix-os/hal/ahci/atapi.c diff --git a/lunaix-os/hal/ahci/atapi.c b/lunaix-os/hal/ahci/atapi.c new file mode 100644 index 0000000..193f8f3 --- /dev/null +++ b/lunaix-os/hal/ahci/atapi.c @@ -0,0 +1,39 @@ +#include +#include +#include + +#include +#include + +void +scsi_create_packet12(struct scsi_cdb12* cdb, + uint8_t opcode, + uint32_t lba, + uint32_t alloc_size) +{ + memset(cdb, 0, sizeof(*cdb)); + cdb->opcode = opcode; + cdb->lba_be = SCSI_FLIP(lba); + cdb->length = alloc_size; +} + +void +scsi_create_packet16(struct scsi_cdb16* cdb, + uint8_t opcode, + uint32_t lba_hi, + uint32_t lba_lo, + uint32_t alloc_size) +{ + memset(cdb, 0, sizeof(*cdb)); + cdb->opcode = opcode; + cdb->lba_be_hi = SCSI_FLIP(lba_hi); + cdb->lba_be_lo = SCSI_FLIP(lba_lo); + cdb->length = alloc_size; +} + +void +scsi_parse_capacity(struct hba_device* device, uint32_t* parameter) +{ + device->max_lba = SCSI_FLIP(*(parameter + 1)); + device->block_size = SCSI_FLIP(*(parameter + 2)); +} \ No newline at end of file