AMBaseboard: Convert union ICCommand into struct

This commit is contained in:
Sepalani
2026-02-04 19:38:53 -06:00
committed by Jordan Woyak
parent bbf0e96603
commit 5fbb25eca1
2 changed files with 15 additions and 17 deletions
@@ -174,11 +174,12 @@ void CSIDevice_AMBaseboard::ICCardSendReply(ICCommand* iccommand, u8* buffer, u3
{
iccommand->status = Common::swap16(iccommand->status);
const u8 crc = CheckSumXOR(iccommand->data + 2, iccommand->pktlen - 1);
const auto iccommand_data = reinterpret_cast<const u8*>(iccommand);
const u8 crc = CheckSumXOR(iccommand_data + 2, iccommand->pktlen - 1);
for (u32 i = 0; i < iccommand->pktlen + 1; ++i)
{
buffer[(*length)++] = iccommand->data[i];
buffer[(*length)++] = iccommand_data[i];
}
buffer[(*length)++] = crc;
+12 -15
View File
@@ -239,23 +239,20 @@ private:
ProgramVersion = 0x76,
};
union ICCommand
// NOTE: Used to be an union with `u8 data[81 + 4 + 4 + 4]`
// TODO: Should the struct be packed?
struct ICCommand
{
u8 data[81 + 4 + 4 + 4] = {};
u32 pktcmd : 8;
u32 pktlen : 8;
u32 fixed : 8;
u32 command : 8;
u32 flag : 8;
u32 length : 8;
u32 status : 16;
struct
{
u32 pktcmd : 8;
u32 pktlen : 8;
u32 fixed : 8;
u32 command : 8;
u32 flag : 8;
u32 length : 8;
u32 status : 16;
u8 extdata[81];
u32 extlen;
};
u8 extdata[81];
u32 extlen;
};
u8 m_last[2][0x80] = {};