20 #include "modules/drivers/common/scsi/ScsiCommands.h" 21 #include "pedigree/kernel/utilities/utility.h" 23 ScsiCommand::ScsiCommand() =
default;
24 ScsiCommand::~ScsiCommand() =
default;
29 uint16_t len,
bool enableVitalData, uint8_t pageCode, uint8_t ctl)
31 ByteSet(&command, 0,
sizeof(command));
32 command.opcode = 0x12;
33 command.epvd = enableVitalData;
35 command.pageCode = pageCode;
36 command.len = HOST_TO_BIG16(len);
37 command.control = ctl;
40 size_t Inquiry::serialise(uintptr_t &addr)
42 addr =
reinterpret_cast<uintptr_t
>(&command);
43 return sizeof(command);
46 UnitReady::UnitReady(uint8_t ctl)
48 ByteSet(&command, 0,
sizeof(command));
50 command.control = ctl;
53 size_t UnitReady::serialise(uintptr_t &addr)
55 addr =
reinterpret_cast<uintptr_t
>(&command);
56 return sizeof(command);
59 ReadSense::ReadSense(uint8_t desc, uint8_t len, uint8_t ctl)
61 ByteSet(&command, 0,
sizeof(command));
62 command.opcode = 0x03;
65 command.control = ctl;
68 size_t ReadSense::serialise(uintptr_t &addr)
70 addr =
reinterpret_cast<uintptr_t
>(&command);
71 return sizeof(command);
75 bool imm, uint8_t newpower,
bool eject_load,
bool start, uint8_t ctl)
77 ByteSet(&command, 0,
sizeof(command));
78 command.opcode = 0x1b;
79 command.imm = imm ? 1 : 0;
81 (start ? 1 : 0) | ((eject_load ? 1 : 0) << 1) | (newpower << 4);
82 command.control = ctl;
85 size_t StartStop::serialise(uintptr_t &addr)
87 addr =
reinterpret_cast<uintptr_t
>(&command);
88 return sizeof(command);
91 SendDiagnostic::SendDiagnostic(
92 bool selfTest, uint8_t selfTestCode, uintptr_t params,
size_t paramLen,
93 bool deviceOffline,
bool unitOffline, uint8_t ctl)
95 ByteSet(&command, 0,
sizeof(command));
96 command.opcode = 0x1d;
97 command.unitOffline = unitOffline;
98 command.devOffline = deviceOffline;
99 command.selfTest = selfTest;
101 command.selfTestCode = selfTestCode;
102 command.paramListLen = HOST_TO_BIG16(paramLen);
103 command.control = ctl;
106 size_t SendDiagnostic::serialise(uintptr_t &addr)
108 addr =
reinterpret_cast<uintptr_t
>(&command);
109 return sizeof(command);
112 ReadTocCommand::ReadTocCommand(uint16_t nativeBlockSize, uint8_t ctl)
114 ByteSet(&command, 0,
sizeof(command));
115 command.opcode = 0x43;
116 command.len = HOST_TO_BIG16(nativeBlockSize);
119 size_t ReadTocCommand::serialise(uintptr_t &addr)
121 addr =
reinterpret_cast<uintptr_t
>(&command);
122 return sizeof(command);
125 ReadCapacity10::ReadCapacity10(uint8_t ctl)
127 ByteSet(&command, 0,
sizeof(command));
128 command.opcode = 0x25;
129 command.control = ctl;
132 size_t ReadCapacity10::serialise(uintptr_t &addr)
134 addr =
reinterpret_cast<uintptr_t
>(&command);
135 return sizeof(command);
138 Read10::Read10(uint32_t nLba, uint32_t nSectors)
140 ByteSet(&command, 0,
sizeof(command));
141 command.nOpCode = 0x28;
142 command.nLba = HOST_TO_BIG32(nLba);
143 command.nSectors = HOST_TO_BIG16(nSectors);
146 size_t Read10::serialise(uintptr_t &addr)
148 addr =
reinterpret_cast<uintptr_t
>(&command);
149 return sizeof(command);
152 Read12::Read12(uint32_t nLba, uint32_t nSectors)
154 ByteSet(&command, 0,
sizeof(command));
155 command.nOpCode = 0xa8;
156 command.nLba = HOST_TO_BIG32(nLba);
157 command.nSectors = HOST_TO_BIG32(nSectors);
160 size_t Read12::serialise(uintptr_t &addr)
162 addr =
reinterpret_cast<uintptr_t
>(&command);
163 return sizeof(command);
166 Read16::Read16(uint32_t nLba, uint32_t nSectors)
168 ByteSet(&command, 0,
sizeof(command));
169 command.nOpCode = 0x88;
170 command.nLba = HOST_TO_BIG64(nLba);
171 command.nSectors = HOST_TO_BIG32(nSectors);
174 size_t Read16::serialise(uintptr_t &addr)
176 addr =
reinterpret_cast<uintptr_t
>(&command);
177 return sizeof(command);
180 Write10::Write10(uint32_t nLba, uint32_t nSectors)
182 ByteSet(&command, 0,
sizeof(command));
183 command.nOpCode = 0x2A;
184 command.nLba = HOST_TO_BIG32(nLba);
185 command.nSectors = HOST_TO_BIG16(nSectors);
188 size_t Write10::serialise(uintptr_t &addr)
190 addr =
reinterpret_cast<uintptr_t
>(&command);
191 return sizeof(command);
194 Write12::Write12(uint32_t nLba, uint32_t nSectors)
196 ByteSet(&command, 0,
sizeof(command));
197 command.nOpCode = 0xAA;
198 command.nLba = HOST_TO_BIG32(nLba);
199 command.nSectors = HOST_TO_BIG32(nSectors);
202 size_t Write12::serialise(uintptr_t &addr)
204 addr =
reinterpret_cast<uintptr_t
>(&command);
205 return sizeof(command);
208 Write16::Write16(uint32_t nLba, uint32_t nSectors)
210 ByteSet(&command, 0,
sizeof(command));
211 command.nOpCode = 0x8A;
212 command.nLba = HOST_TO_BIG64(nLba);
213 command.nSectors = HOST_TO_BIG32(nSectors);
216 size_t Write16::serialise(uintptr_t &addr)
218 addr =
reinterpret_cast<uintptr_t
>(&command);
219 return sizeof(command);
222 Synchronise10::Synchronise10(uint32_t nLba, uint32_t nSectors)
224 ByteSet(&command, 0,
sizeof(command));
225 command.nOpCode = 0x35;
226 command.nLba = HOST_TO_BIG32(nLba);
227 command.nBlocks = HOST_TO_BIG16(nSectors);
230 size_t Synchronise10::serialise(uintptr_t &addr)
232 addr =
reinterpret_cast<uintptr_t
>(&command);
233 return sizeof(command);
236 Synchronise16::Synchronise16(uint32_t nLba, uint32_t nSectors)
238 ByteSet(&command, 0,
sizeof(command));
239 command.nOpCode = 0x91;
240 command.nLba = HOST_TO_BIG64(nLba);
241 command.nBlocks = HOST_TO_BIG32(nSectors);
244 size_t Synchronise16::serialise(uintptr_t &addr)
246 addr =
reinterpret_cast<uintptr_t
>(&command);
247 return sizeof(command);