forked from len0rd/rockbox
soc_desc: add default constructors to most structures
After being caught by several bugs of the type "let's forgot to initialize a field to default value", I'm finally fixing this. Change-Id: I01c33e0611d4f697f767db66465e4fb30858cdab
This commit is contained in:
parent
45a02dcf81
commit
56dc54d38a
1 changed files with 24 additions and 0 deletions
|
@ -39,6 +39,9 @@ typedef uint32_t soc_addr_t;
|
||||||
typedef uint32_t soc_word_t;
|
typedef uint32_t soc_word_t;
|
||||||
typedef int soc_id_t;
|
typedef int soc_id_t;
|
||||||
|
|
||||||
|
/** Default value for IDs */
|
||||||
|
const soc_id_t DEFAULT_ID = 0xcafebabe;
|
||||||
|
|
||||||
/** Error class */
|
/** Error class */
|
||||||
class error_t
|
class error_t
|
||||||
{
|
{
|
||||||
|
@ -81,6 +84,9 @@ struct enum_t
|
||||||
std::string name; /** Name (must be unique among field enums) */
|
std::string name; /** Name (must be unique among field enums) */
|
||||||
std::string desc; /** Optional description of the meaning of this value */
|
std::string desc; /** Optional description of the meaning of this value */
|
||||||
soc_word_t value; /** Value of the field */
|
soc_word_t value; /** Value of the field */
|
||||||
|
|
||||||
|
/** Default constructor: default ID and value is 0 */
|
||||||
|
enum_t():id(DEFAULT_ID), value(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Register field information */
|
/** Register field information */
|
||||||
|
@ -93,6 +99,9 @@ struct field_t
|
||||||
size_t width; /** Width of the field in bits */
|
size_t width; /** Width of the field in bits */
|
||||||
std::vector< enum_t > enum_; /** List of special values */
|
std::vector< enum_t > enum_; /** List of special values */
|
||||||
|
|
||||||
|
/** Default constructor: default ID, position is 0, width is 1 */
|
||||||
|
field_t():id(DEFAULT_ID), pos(0), width(1) {}
|
||||||
|
|
||||||
/** Returns the bit mask of the field within the register */
|
/** Returns the bit mask of the field within the register */
|
||||||
soc_word_t bitmask() const
|
soc_word_t bitmask() const
|
||||||
{
|
{
|
||||||
|
@ -140,6 +149,9 @@ struct variant_t
|
||||||
soc_id_t id; /** ID (must be unique among register variants) */
|
soc_id_t id; /** ID (must be unique among register variants) */
|
||||||
std::string type; /** type of the variant */
|
std::string type; /** type of the variant */
|
||||||
soc_addr_t offset; /** offset of the variant */
|
soc_addr_t offset; /** offset of the variant */
|
||||||
|
|
||||||
|
/** Default constructor: default ID, offset is 0 */
|
||||||
|
variant_t():id(DEFAULT_ID), offset(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Register information */
|
/** Register information */
|
||||||
|
@ -149,6 +161,9 @@ struct register_t
|
||||||
std::string desc; /** Optional description of the register */
|
std::string desc; /** Optional description of the register */
|
||||||
std::vector< field_t > field; /** List of fields */
|
std::vector< field_t > field; /** List of fields */
|
||||||
std::vector< variant_t > variant; /** List of variants */
|
std::vector< variant_t > variant; /** List of variants */
|
||||||
|
|
||||||
|
/** Default constructor: width is 32 */
|
||||||
|
register_t():width(32) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Node address range information */
|
/** Node address range information */
|
||||||
|
@ -170,6 +185,9 @@ struct range_t
|
||||||
std::string variable; /** Formula variable name (for FORMULA) */
|
std::string variable; /** Formula variable name (for FORMULA) */
|
||||||
std::vector< soc_word_t > list; /** Address list (for LIST) */
|
std::vector< soc_word_t > list; /** Address list (for LIST) */
|
||||||
|
|
||||||
|
/** Default constructor: empty stride */
|
||||||
|
range_t():type(STRIDE), first(0), count(0), base(0), stride(0) {}
|
||||||
|
|
||||||
/** Return the number of indexes (based on count or list) */
|
/** Return the number of indexes (based on count or list) */
|
||||||
size_t size()
|
size_t size()
|
||||||
{
|
{
|
||||||
|
@ -193,6 +211,9 @@ struct instance_t
|
||||||
type_t type; /** Instance type */
|
type_t type; /** Instance type */
|
||||||
soc_word_t addr; /** Address (for SINGLE) */
|
soc_word_t addr; /** Address (for SINGLE) */
|
||||||
range_t range; /** Range (for RANGE) */
|
range_t range; /** Range (for RANGE) */
|
||||||
|
|
||||||
|
/** Default constructor: single instance at 0 */
|
||||||
|
instance_t():id(DEFAULT_ID), type(SINGLE), addr(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Node information */
|
/** Node information */
|
||||||
|
@ -205,6 +226,9 @@ struct node_t
|
||||||
std::vector< register_t> register_; /** Optional register */
|
std::vector< register_t> register_; /** Optional register */
|
||||||
std::vector< instance_t> instance; /** List of instances */
|
std::vector< instance_t> instance; /** List of instances */
|
||||||
std::vector< node_t > node; /** List of sub-nodes */
|
std::vector< node_t > node; /** List of sub-nodes */
|
||||||
|
|
||||||
|
/** Default constructor: default ID */
|
||||||
|
node_t():id(DEFAULT_ID) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** System-on-chip information */
|
/** System-on-chip information */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue