package com.github.mjdev.libaums.driver.scsi.commands;

import com.github.mjdev.libaums.driver.scsi.commands.CommandBlockWrapper;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/* JADX INFO: loaded from: classes.dex */
public class ScsiRead10 extends CommandBlockWrapper {
    private static final byte LENGTH = 16;
    private static final byte OPCODE = 40;
    private int blockAddress;
    private int blockSize;
    private short transferBlocks;
    private int transferBytes;

    public ScsiRead10() {
        super(0, CommandBlockWrapper.Direction.IN, (byte) 0, (byte) 16);
    }

    public ScsiRead10(int i, int i2, int i3) {
        super(i2, CommandBlockWrapper.Direction.IN, (byte) 0, (byte) 16);
        init(i, i2, i3);
    }

    public void init(int i, int i2, int i3) {
        this.dCbwDataTransferLength = i2;
        this.blockAddress = i;
        this.transferBytes = i2;
        this.blockSize = i3;
        short s = (short) (i2 / i3);
        if (i2 % i3 != 0) {
            throw new IllegalArgumentException("transfer bytes is not a multiple of block size");
        }
        this.transferBlocks = s;
    }

    @Override // com.github.mjdev.libaums.driver.scsi.commands.CommandBlockWrapper
    public void serialize(ByteBuffer byteBuffer) {
        super.serialize(byteBuffer);
        byteBuffer.order(ByteOrder.BIG_ENDIAN);
        byteBuffer.put((byte) 40);
        byteBuffer.put((byte) 0);
        byteBuffer.putInt(this.blockAddress);
        byteBuffer.put((byte) 0);
        byteBuffer.putShort(this.transferBlocks);
    }

    public String toString() {
        return "ScsiRead10 [blockAddress=" + this.blockAddress + ", transferBytes=" + this.transferBytes + ", blockSize=" + this.blockSize + ", transferBlocks=" + ((int) this.transferBlocks) + ", getdCbwDataTransferLength()=" + getdCbwDataTransferLength() + "]";
    }
}
