AMBaseboard: Convert union ICCommand into struct

This commit is contained in:
Sepalani 2026-01-21 19:04:43 +04:00 committed by Jordan Woyak
parent 85707891cf
commit fcb4d27f1a
2 changed files with 15 additions and 17 deletions

View File

@ -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;

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] = {};