def handle_structures_table(self, table, tpm_alg_ids): # handle TPMS_EMPTY structure if "TPMS_EMPTY" in table.short_name: self.tpm_types_h_file_content += "typedef BYTE TPMS_EMPTY;\n\n" self.marshaller.handle_structures_table_empty_structure(table) return # SELECTOR STARTBLOCK START selector = utils.find_alg_dep(table.short_name) if selector: self.tpm_types_h_file_content += "#ifdef TPM_ALG_" + selector + "\n" # SELECTOR STARTBLOCK END typedef_name = utils.find_tpm_type_name(table.short_name) if "Structure" in table.short_name: if "TPM2B" in table.short_name: # TPM2B TYPEDEF UNION STRUCT self.handle_typedef_union_struct(table, typedef_name) else: # TYPEDEF STRUCT self.handle_typedef_struct(table, typedef_name) if "Union" in table.short_name: # TYPEDEF UNION self.handle_typedef_union(table, typedef_name, tpm_alg_ids) # SELECTOR ENDBLOCK START if selector: self.tpm_types_h_file_content += "#endif // TPM_ALG_" + selector + "\n"
def handle_simple_constants(self, table): self.create_header_comment(table) base_type = utils.find_tpm_base_type_name(table.short_name) current_type = utils.find_tpm_type_name(table.short_name) alg_dep = utils.find_alg_dep(table.short_name) size = utils.find_base_type_size(base_type) if not size: return if alg_dep: self.content += tpm2_partx_marshal_templates.IFDEF_ALG.format( alg_dep) self.content_fp += tpm2_partx_marshal_templates.IFDEF_ALG.format( alg_dep) already_marshaled = base_type in tpm2_partx_type_mapping.dictionary.keys( ) if already_marshaled: self.content += tpm2_partx_marshal_templates.COMMENT_TYPE_Unmarshal_defined.format( current_type) self.content += tpm2_partx_marshal_templates.COMMENT_TYPE_Marshal_defined.format( current_type) self.content_fp += self.simple_marshaller.create_unmarshal_fp_define( current_type, base_type) self.content_fp += self.simple_marshaller.create_marshal_fp_define( current_type, base_type) else: self.content += self.simple_marshaller.create_unmarshal_code( current_type, int(size) / 8) self.content += self.simple_marshaller.create_marshal_code( current_type, int(size) / 8) self.content_fp += self.simple_marshaller.create_unmarshal_fp( current_type) self.content_fp += self.simple_marshaller.create_marshal_fp( current_type) tpm2_partx_type_mapping.dictionary[current_type] = [ base_type, table.number ] if alg_dep: self.content += tpm2_partx_marshal_templates.ENDIF_ALG.format( alg_dep) self.content_fp += tpm2_partx_marshal_templates.ENDIF_ALG.format( alg_dep)
def handle_simple_constants(self, table): self.create_header_comment(table) base_type = utils.find_tpm_base_type_name(table.short_name) current_type = utils.find_tpm_type_name(table.short_name) alg_dep = utils.find_alg_dep(table.short_name) size = utils.find_base_type_size(base_type) if not size: return if alg_dep: self.content += tpm2_partx_marshal_templates.IFDEF_ALG.format(alg_dep) self.content_fp += tpm2_partx_marshal_templates.IFDEF_ALG.format(alg_dep) already_marshaled = base_type in tpm2_partx_type_mapping.dictionary.keys() if already_marshaled: self.content += tpm2_partx_marshal_templates.COMMENT_TYPE_Unmarshal_defined.format(current_type) self.content += tpm2_partx_marshal_templates.COMMENT_TYPE_Marshal_defined.format(current_type) self.content_fp += self.simple_marshaller.create_unmarshal_fp_define(current_type, base_type) self.content_fp += self.simple_marshaller.create_marshal_fp_define(current_type, base_type) else: self.content += self.simple_marshaller.create_unmarshal_code(current_type, int(size)/8) self.content += self.simple_marshaller.create_marshal_code(current_type, int(size)/8) self.content_fp += self.simple_marshaller.create_unmarshal_fp(current_type) self.content_fp += self.simple_marshaller.create_marshal_fp(current_type) tpm2_partx_type_mapping.dictionary[current_type] = [base_type, table.number] if alg_dep: self.content += tpm2_partx_marshal_templates.ENDIF_ALG.format(alg_dep) self.content_fp += tpm2_partx_marshal_templates.ENDIF_ALG.format(alg_dep)