ducky.hdt module¶
Hardware Description Table structures.
-
class
ducky.hdt.HDT(logger, config=None)[source]¶ Bases:
objectRoot of HDT. Provides methods for creating HDT for a given machine configuration.
Parameters: - logger (logging.Logger) – logger instance used for logging.
- config (ducky.config.MachineConfig) – configuration file HDT should reflect.
-
klasses= [<class 'ducky.hdt.HDTEntry_Memory'>, <class 'ducky.hdt.HDTEntry_CPU'>, <class 'ducky.hdt.HDTEntry_Argument'>]¶ These HDT entries are added automatically.
-
class
ducky.hdt.HDTEntry(entry_type, length)[source]¶ Bases:
ducky.hdt.HDTStructureBase class of all HDT entries.
Each entry has at least two fields, type and length. Other fields depend on type of entry, and follow immediately after length field.
Parameters: - type (u16_t) – type of entry. See
ducky.hdt.HDTEntryTypes. - length (u16_t) – length of entry, in bytes.
-
ENTRY_HEADER= [('type', <class 'ctypes.c_ushort'>), ('length', <class 'ctypes.c_ushort'>)]¶
- type (u16_t) – type of entry. See
-
class
ducky.hdt.HDTEntryTypes[source]¶ Bases:
enum.IntEnumTypes of different HDT entries.
-
ARGUMENT= 3¶
-
CPU= 1¶
-
DEVICE= 4¶
-
MEMORY= 2¶
-
UNDEFINED= 0¶
-
_member_map_= OrderedDict([('UNDEFINED', <HDTEntryTypes.UNDEFINED: 0>), ('CPU', <HDTEntryTypes.CPU: 1>), ('MEMORY', <HDTEntryTypes.MEMORY: 2>), ('ARGUMENT', <HDTEntryTypes.ARGUMENT: 3>), ('DEVICE', <HDTEntryTypes.DEVICE: 4>)])¶
-
_member_names_= ['UNDEFINED', 'CPU', 'MEMORY', 'ARGUMENT', 'DEVICE']¶
-
_member_type_¶ alias of
int
-
_value2member_map_= {0: <HDTEntryTypes.UNDEFINED: 0>, 1: <HDTEntryTypes.CPU: 1>, 2: <HDTEntryTypes.MEMORY: 2>, 3: <HDTEntryTypes.ARGUMENT: 3>, 4: <HDTEntryTypes.DEVICE: 4>}¶
-
-
class
ducky.hdt.HDTEntry_Argument(arg_name, arg_type, arg_value)[source]¶ Bases:
ducky.hdt.HDTEntry-
MAX_NAME_LENGTH= 13¶
-
_fields_= [('type', <class 'ctypes.c_ushort'>), ('length', <class 'ctypes.c_ushort'>), ('name_length', <class 'ctypes.c_ubyte'>), ('value_length', <class 'ctypes.c_ubyte'>), ('name', <class 'ducky.hdt.c_ubyte_Array_13'>), ('value', <class 'ducky.hdt.c_ubyte_Array_13'>)]¶
-
length¶ Structure/Union member
-
name¶ Structure/Union member
-
name_length¶ Structure/Union member
-
type¶ Structure/Union member
-
value¶ Structure/Union member
-
value_length¶ Structure/Union member
-
-
class
ducky.hdt.HDTEntry_CPU(logger, config)[source]¶ Bases:
ducky.hdt.HDTEntryHDT entry describing CPU configuration.
Parameters: - nr_cpus (u16_t) – number of CPUs.
- nr_cores (u16_t) – number of cores per CPU.
-
_fields_= [('type', <class 'ctypes.c_ushort'>), ('length', <class 'ctypes.c_ushort'>), ('nr_cpus', <class 'ctypes.c_ushort'>), ('nr_cores', <class 'ctypes.c_ushort'>)]¶
-
length¶ Structure/Union member
-
nr_cores¶ Structure/Union member
-
nr_cpus¶ Structure/Union member
-
type¶ Structure/Union member
-
class
ducky.hdt.HDTEntry_Device(logger, name, ident)[source]¶ Bases:
ducky.hdt.HDTEntry-
ENTRY_HEADER= [('type', <class 'ctypes.c_ushort'>), ('length', <class 'ctypes.c_ushort'>), ('name_length', <class 'ctypes.c_ubyte'>), ('flags', <class 'ctypes.c_ubyte'>), ('name', <class 'ducky.hdt.c_ubyte_Array_10'>), ('ident', <class 'ducky.hdt.c_ubyte_Array_32'>)]¶
-
MAX_IDENT_LENGTH= 32¶
-
MAX_NAME_LENGTH= 10¶
-
-
class
ducky.hdt.HDTEntry_Memory(logger, config)[source]¶ Bases:
ducky.hdt.HDTEntryHDT entry describing memory configuration.
Parameters: size (u32_t) – size of memory, in bytes. -
_fields_= [('type', <class 'ctypes.c_ushort'>), ('length', <class 'ctypes.c_ushort'>), ('size', <class 'ctypes.c_uint'>)]¶
-
length¶ Structure/Union member
-
size¶ Structure/Union member
-
type¶ Structure/Union member
-
-
class
ducky.hdt.HDTHeader[source]¶ Bases:
ducky.hdt.HDTStructureHDT header. Contains magic number, number of HDT entries that immediately follow header.
-
_fields_= [('magic', <class 'ctypes.c_uint'>), ('entries', <class 'ctypes.c_uint'>), ('length', <class 'ctypes.c_uint'>)]¶
-
entries¶ Structure/Union member
-
length¶ Structure/Union member
-
magic¶ Structure/Union member
-
-
class
ducky.hdt.HDTStructure[source]¶ Bases:
_ctypes.StructureBase class of all HDT structures.
-
_pack_= 0¶
-
-
ducky.hdt.HDT_MAGIC= 1298034544¶ Magic number present in HDT header
-
ducky.hdt.encode_string(struct, field, s, max_length)[source]¶ Store string in a structure’s field, and set the corresponding length field properly.
Parameters: - struct (HDTStructure) – structure to modify.
- field (str) – name of field the string should be stored in.
- s (str) – string to encode.
- max_length (int) – maximal number of bytes that can fit into the field.