Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chipset reporting (fixes #151) #152

Merged
merged 4 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plc/PLCNetworkInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ signed PLCNetworkInfo (struct plc * plc)

{
signed status;
uint32_t ident;
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);

Expand Down Expand Up @@ -123,7 +124,7 @@ signed PLCNetworkInfo (struct plc * plc)
Failure (plc, "Device will not start");
return (-1);
}
chipset (confirm);
chipset (confirm, & ident);
if ((plc->hardwareID = confirm->MDEVICEID) < CHIPSET_AR7400)
{
status = NetInfo1 (plc);
Expand Down
3 changes: 2 additions & 1 deletion plc/PLCPhyRates.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ signed PLCPhyRates (struct plc * plc)

{
signed status;
uint32_t ident;
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);

Expand Down Expand Up @@ -123,7 +124,7 @@ signed PLCPhyRates (struct plc * plc)
Failure (plc, "Device will not start");
return (-1);
}
chipset (confirm);
chipset (confirm, & ident);
if ((plc->hardwareID = confirm->MDEVICEID) < CHIPSET_AR7400)
{
status = PhyRates1 (plc);
Expand Down
5 changes: 3 additions & 2 deletions plc/PLCTopology.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ static signed PLCPlatform (struct channel * channel, struct plcstation * plcstat
{
if (!UnwantedMessage (&message, packetsize, 0, (VS_SW_VER | MMTYPE_CNF)))
{
chipset (confirm);
strncpy (plcstation->hardware, chipsetname (confirm->MDEVICE), sizeof (plcstation->hardware));
uint32_t ident;
chipset (confirm, & ident);
strncpy (plcstation->hardware, chipsetname_by_ident (ident, confirm->MDEVICE), sizeof (plcstation->hardware));
strncpy (plcstation->firmware, confirm->MSTRING, sizeof (plcstation->firmware));
return (0);
}
Expand Down
5 changes: 3 additions & 2 deletions plc/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ signed Platform (struct channel * channel, const uint8_t device [])
{
if (!UnwantedMessage (&message, packetsize, 0, (VS_SW_VER | MMTYPE_CNF)))
{
chipset (confirm);
printf (" %s", chipsetname (confirm->MDEVICEID));
uint32_t ident;
chipset (confirm, & ident);
printf (" %s", chipsetname_by_ident (ident, confirm->MDEVICEID));
printf (" %s", confirm->MVERSION);
return (0);
}
Expand Down
5 changes: 3 additions & 2 deletions plc/VersionInfo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ signed VersionInfo1 (struct plc * plc)
}
while (ReadMME (plc, 0, (VS_SW_VER | MMTYPE_CNF)) > 0)
{
uint32_t ident;
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
chipset (confirm);
Display (plc, "%s %s", chipsetname (confirm->MDEVICEID), confirm->MVERSION);
chipset (confirm, & ident);
Display (plc, "%s %s", chipsetname_by_ident (ident, confirm->MDEVICEID), confirm->MVERSION);
}
return (0);
}
Expand Down
5 changes: 3 additions & 2 deletions plc/VersionInfo2.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ signed VersionInfo2 (struct plc * plc)
}
while (ReadMME (plc, 0, (VS_SW_VER | MMTYPE_CNF)) > 0)
{
uint32_t ident;

#if 0

Expand All @@ -135,8 +136,8 @@ signed VersionInfo2 (struct plc * plc)
Failure (plc, PLC_WONTDOIT);
continue;
}
chipset (confirm);
Display (plc, "%s %s", chipsetname (confirm->MDEVICE_CLASS), confirm->MVERSION);
chipset (confirm, & ident);
Display (plc, "%s %s", chipsetname_by_ident (ident, confirm->MDEVICE_CLASS), confirm->MVERSION);
}
return (0);
}
Expand Down
3 changes: 2 additions & 1 deletion plc/WaitForStart.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ signed WaitForStart (struct plc * plc, char string [], size_t length)
}
if (plc->packetsize)
{
chipset (confirm);
uint32_t ident;
chipset (confirm, & ident);
plc->hardwareID = confirm->MDEVICEID;
memcpy (channel->peer, request->ethernet.OSA, sizeof (channel->peer));
if (confirm->MVERLENGTH > length)
Expand Down
65 changes: 62 additions & 3 deletions plc/chipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,56 @@ char const * chipsetname (uint8_t MDEVICE_CLASS)

/*====================================================================*
*
* void chipset (void const * memory);
* char const * chipsetname_by_ident (uint32_t ident, uint8_t chipset)
*
* Chipset.h
* chipset.h
*
* return the ASCII name string associated with the IDENT (aka STRAP)
* field in the VS_SW_VER.CNF message;
* in case of unknown value, fallback using chipsetname function
*
*--------------------------------------------------------------------*/

char const * chipsetname_by_ident (uint32_t ident, uint8_t chipset)
{
static const struct _type_ chipname [] =
{
{ 0x00000042, "INT6000" },
{ 0x00006300, "INT6300" },
#if 0
/* don't list these two here since we would need MDEVICE_CLASS
* (aka our chipset parameter) to differentiate; instead we rely
* on older chipsetname function to handle it during fallback...
*/
{ 0x00006400, " AR6405" },
{ 0x00006400, "INT6400" },
#endif
{ 0x00007400, " AR7400" },
{ 0x001B587C, "QCA7005" },
{ 0x001B589C, "QCA7000" },
{ 0x001B58BC, "QCA6411" },
{ 0x001B58DC, "QCA7000" },
{ 0x001B58EC, "QCA6410" },
{ 0x001CFC00, "QCA7420" },
{ 0x001CFCFC, "QCA7420" },
{ 0x001D4C00, "QCA7500" },
{ 0x001D4C0F, "QCA7500" },
{ 0x0E001D1A, "QCA7451" },
{ 0x0F001D1A, "QCA7450" },
};
return (typename (chipname, SIZEOF (chipname), ident, chipsetname (chipset)));
}

/*====================================================================*
*
* void chipset (void const * memory, uint32_t * ident);
*
* chipset.h
*
* replace VS_SW_VER message MDEVICE_CLASS field with correct value;
* the MDEVICE_CLASS field was named MDEVICEID at one time;
* while at save the ident field to given (since the offset varies,
* it can be used by caller later more easily);
*
* Atheros chipsets are identified by code in the VS_SW_VER vendor
* specific management message; the chipset [] vector translates a
Expand Down Expand Up @@ -171,7 +215,7 @@ char const * chipsetname (uint8_t MDEVICE_CLASS)
*
*--------------------------------------------------------------------*/

void chipset (void const * memory)
void chipset (void const * memory, uint32_t * ident)

{

Expand Down Expand Up @@ -323,11 +367,21 @@ void chipset (void const * memory)
0x20,
CHIPSET_QCA7451A0
},
{
0x001CFC00,
0x20,
CHIPSET_QCA7420A0
},
{
0x001CFCFC,
0x20,
CHIPSET_QCA7420A0
},
{
0x001B587C,
0x22,
CHIPSET_QCA7005A0
},
{
0x001B58EC,
0x21,
Expand Down Expand Up @@ -368,6 +422,7 @@ void chipset (void const * memory)
continue;
}
confirm->MDEVICE_CLASS = bootrom [chip].DEVICE;
* ident = LE32TOH (chipinfo->STRAP);
return;
}
}
Expand All @@ -382,24 +437,28 @@ void chipset (void const * memory)
if (firmware [chip].STRAP < CHIPSET_PANTHER_LYNX)
{
confirm->MDEVICE_CLASS = firmware [chip].DEVICE;
* ident = LE32TOH (chipinfo->STRAP);
return;
}
chipinfo = (struct chipinfo *) (& confirm->MVERSION [64]);
if (firmware [chip].STRAP == LE32TOH (chipinfo->STRAP))
{
confirm->MDEVICE_CLASS = firmware [chip].DEVICE;
* ident = LE32TOH (chipinfo->STRAP);
return;
}
chipinfo = (struct chipinfo *) (& confirm->MVERSION [128]);
if (firmware [chip].STRAP == LE32TOH (chipinfo->STRAP))
{
confirm->MDEVICE_CLASS = firmware [chip].DEVICE;
* ident = LE32TOH (chipinfo->STRAP);
return;
}
chipinfo = (struct chipinfo *) (& confirm->MVERSION [253]);
if (firmware [chip].STRAP == LE32TOH (chipinfo->STRAP))
{
confirm->MDEVICE_CLASS = firmware [chip].DEVICE;
* ident = LE32TOH (chipinfo->STRAP);
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion plc/chipset.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
*--------------------------------------------------------------------*/

char const * chipsetname (uint8_t chipset);
void chipset (void const * memory);
char const * chipsetname_by_ident (uint32_t ident, uint8_t chipset);
void chipset (void const * memory, uint32_t * ident);

/*====================================================================*
*
Expand Down
2 changes: 1 addition & 1 deletion plc/plc.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ PLC;
* fixer-upper functions that compensate for errors and omissions;
*--------------------------------------------------------------------*/

void chipset (void const * memory);
void chipset (void const * memory, uint32_t * ident);
char const * chipsetname (uint8_t chipset);

/*====================================================================*
Expand Down