Skip to content

Commit

Permalink
Fixing Gentoo MUSL build. (#412)
Browse files Browse the repository at this point in the history
* Added workflow for Genoot MUSL tests.

* Fixed workflow.

* Fixed memory issue with GD77 codeplug. Fixes #410.
  • Loading branch information
hmatuschek authored Nov 20, 2023
1 parent 2489bcc commit c557f84
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 16 deletions.
11 changes: 5 additions & 6 deletions lib/gd77_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
#define ADDR_CONTACTS 0x017620
#define CONTACT_SIZE 0x000018

#define NUM_GROUP_LISTS 76
#define NUM_GROUP_LISTS 64
#define ADDR_GROUP_LIST_BANK 0x01d620
#define GROUPLIST_SIZE 0x000050
#define GROUP_LIST_BANK_SIZE 0x001840


Expand Down Expand Up @@ -223,7 +222,7 @@ GD77Codeplug::GroupListElement::GroupListElement(uint8_t *ptr, unsigned size)
}

GD77Codeplug::GroupListElement::GroupListElement(uint8_t *ptr)
: RadioddityCodeplug::GroupListElement(ptr, 0x0050)
: RadioddityCodeplug::GroupListElement(ptr, size())
{
// pass...
}
Expand All @@ -239,14 +238,14 @@ GD77Codeplug::GroupListBankElement::GroupListBankElement(uint8_t *ptr, unsigned
}

GD77Codeplug::GroupListBankElement::GroupListBankElement(uint8_t *ptr)
: RadioddityCodeplug::GroupListBankElement(ptr, 0x1840)
: RadioddityCodeplug::GroupListBankElement(ptr, size())
{
// pass...
}

uint8_t *
GD77Codeplug::GroupListBankElement::get(unsigned n) const {
return _data + 0x80 + n*GROUPLIST_SIZE;
return _data + Offset::groupLists() + n*GroupListElement::size();
}


Expand All @@ -258,7 +257,7 @@ GD77Codeplug::GD77Codeplug(QObject *parent)
{
addImage("Radioddity GD77 Codeplug");
image(0).addElement(0x00080, 0x07b80);
image(0).addElement(0x08000, 0x16300);
image(0).addElement(0x08000, 0x16b00);
}

void
Expand Down
17 changes: 15 additions & 2 deletions lib/gd77_codeplug.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
* <tr><td>0x0af10</td> <td>0x0b1b0</td> <td>0x02a0</td> <td>??? Unknown ???</td></tr>
* <tr><td>0x0b1b0</td> <td>0x17620</td> <td>0xc470</td> <td>Remaining 896 channels (bank 1-7), see @c RadioddityCodeplug::ChannelBankElement, @c GD77Codeplug::ChannelElement.</td></tr>
* <tr><td>0x17620</td> <td>0x1d620</td> <td>0x6000</td> <td>1024 contacts, see @c GD77Codeplug::ContactElement.</td></tr>
* <tr><td>0x1d620</td> <td>0x1e2a0</td> <td>0x0c80</td> <td>64 RX group lists, see @c GD77Codeplug::GroupListBankElement, @c GD77Codeplug::GroupListElement.</td></tr>
* <tr><td>0x1e2a0</td> <td>0x1e300</td> <td>0x0060</td> <td>??? Unknown ???</td></tr>
* <tr><td>0x1d620</td> <td>0x1eaa0</td> <td>0x1480</td> <td>64 RX group lists, see @c GD77Codeplug::GroupListBankElement, @c GD77Codeplug::GroupListElement.</td></tr>
* <tr><td>0x1eaa0</td> <td>0x1eb00</td> <td>0x0060</td> <td>??? Unknown ???</td></tr>
* </table>
* @ingroup gd77 */
class GD77Codeplug: public RadioddityCodeplug
Expand Down Expand Up @@ -174,6 +174,16 @@ public:
public:
/** Constructor. */
GroupListElement(uint8_t *ptr);

/** Size of the group list element. */
static constexpr unsigned int size() { return 0x0050; }

public:
/** Limits of the element. */
struct Limit: public RadioddityCodeplug::GroupListElement::Limit {
/** Maximum member count. */
static constexpr unsigned int memberCount() { return 32; }
};
};

/** Table of RX group lists.
Expand All @@ -195,6 +205,9 @@ public:
/** Constructor. */
GroupListBankElement(uint8_t *ptr);

/** Size of the element. */
static constexpr unsigned int size() { return 0x1480; }

uint8_t *get(unsigned n) const;
};

Expand Down
18 changes: 10 additions & 8 deletions lib/radioddity_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ RadioddityCodeplug::GroupListElement::GroupListElement(uint8_t *ptr, unsigned si
}

RadioddityCodeplug::GroupListElement::GroupListElement(uint8_t *ptr)
: Element(ptr, 0x0030)
: Element(ptr, size())
{
// pass...
}
Expand All @@ -939,29 +939,31 @@ RadioddityCodeplug::GroupListElement::~GroupListElement() {
void
RadioddityCodeplug::GroupListElement::clear() {
setName("");
memset(_data+0x0010, 0, 2*16);
memset(_data+Offset::members(), 0, Offset::betweenMembers()*Limit::memberCount());
}

QString
RadioddityCodeplug::GroupListElement::name() const {
return readASCII(0x0000, 16, 0xff);
return readASCII(Offset::name(), Limit::nameLength(), 0xff);
}
void
RadioddityCodeplug::GroupListElement::setName(const QString &name) {
writeASCII(0x0000, name, 16, 0xff);
writeASCII(Offset::name(), name, Limit::nameLength(), 0xff);
}

bool
RadioddityCodeplug::GroupListElement::hasMember(unsigned n) const {
if (n >= Limit::memberCount())
return false;
return 0 != member(n);
}
unsigned
RadioddityCodeplug::GroupListElement::member(unsigned n) const {
return getUInt16_le(0x0010 + 2*n);
return getUInt16_le(Offset::members() + n*Offset::betweenMembers());
}
void
RadioddityCodeplug::GroupListElement::setMember(unsigned n, unsigned idx) {
return setUInt16_le(0x0010 + 2*n, idx);
return setUInt16_le(Offset::members() + n*Offset::betweenMembers(), idx);
}
void
RadioddityCodeplug::GroupListElement::clearMember(unsigned n) {
Expand Down Expand Up @@ -1021,7 +1023,7 @@ RadioddityCodeplug::GroupListBankElement::GroupListBankElement(uint8_t *ptr, uns
}

RadioddityCodeplug::GroupListBankElement::GroupListBankElement(uint8_t *ptr)
: Element(ptr, 0x0c80)
: Element(ptr, size())
{
// pass...
}
Expand Down Expand Up @@ -1054,7 +1056,7 @@ RadioddityCodeplug::GroupListBankElement::disable(unsigned n) {

uint8_t *
RadioddityCodeplug::GroupListBankElement::get(unsigned n) const {
return _data + 0x80 + n*0x30;
return _data + Offset::groupLists() + n*GroupListElement::size();
}


Expand Down
42 changes: 42 additions & 0 deletions lib/radioddity_codeplug.hh
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ public:
/** Destructor. */
virtual ~GroupListElement();

/** Size of the element. */
static constexpr unsigned int size() { return 0x0030; }

/** Resets the group list. */
void clear();

Expand All @@ -508,6 +511,25 @@ public:
virtual bool linkRXGroupListObj(int ncnt, RXGroupList *lst, Context &ctx, const ErrorStack &err=ErrorStack()) const;
/** Reset this codeplug representation from a @c RXGroupList object. */
virtual void fromRXGroupListObj(const RXGroupList *lst, Context &ctx, const ErrorStack &err=ErrorStack());

public:
/** Some limits for the group list. */
struct Limit {
/** Maximum name length. */
static constexpr unsigned int nameLength() { return 16; }
/** Maximum member count. */
static constexpr unsigned int memberCount() { return 16; }
};

protected:
/** Some internal offsets within the element. */
struct Offset {
/// @cond DO_NOT_DOCUMENT
static constexpr unsigned int name() { return 0x0000; }
static constexpr unsigned int members() { return 0x0010; }
static constexpr unsigned int betweenMembers() { return 0x0002; }
/// @endcond
};
};

/** Implements a base class of group list memory banks for all Radioddity codeplugs.
Expand All @@ -527,6 +549,9 @@ public:
/** Destructor. */
virtual ~GroupListBankElement();

/** Returns the size of the element. */
static constexpr unsigned int size() { return 0x0c80; }

/** Resets the bank. */
void clear();

Expand All @@ -542,6 +567,23 @@ public:

/** Returns a pointer to the n-th group list. */
virtual uint8_t *get(unsigned n) const;

public:
/** Some limits for the group list bank. */
struct Limit {
/** Maximum number of members. */
static constexpr unsigned int memberCount() { return 64; }
};

protected:
/** Internal used offset within the element. */
struct Offset {
/// @cond DO_NOT_DOCUMENT
static constexpr unsigned int contactCount() { return 0x0000; }
static constexpr unsigned int betweenContactCounts() { return 0x0000; }
static constexpr unsigned int groupLists() { return 0x0080; }
/// @endcond
};
};

/** Implements the base class for scan lists of all Radioddity codeplugs.
Expand Down

0 comments on commit c557f84

Please sign in to comment.