Lines Matching refs:header

108 	// we need some pieces of the header down below
112 // write plaintext header
114 // write header
119 // update CBC-MAC over image header
139 // write header for this section
329 void EncoreBootImage::prepareImageHeader(boot_image_header_t & header)
339 // fill in header fields
340 header.m_signature[0] = 'S';
341 header.m_signature[1] = 'T';
342 header.m_signature[2] = 'M';
343 header.m_signature[3] = 'P';
344 header.m_majorVersion = ROM_BOOT_IMAGE_MAJOR_VERSION;
345 header.m_minorVersion = ROM_BOOT_IMAGE_MINOR_VERSION;
346 header.m_flags = ENDIAN_HOST_TO_LITTLE_U16(m_headerFlags);
347 header.m_imageBlocks = ENDIAN_HOST_TO_LITTLE_U32(getImageSize());
348 header.m_firstBootableSectionID = ENDIAN_HOST_TO_LITTLE_U32(firstBootSectionID);
349 header.m_keyCount = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)m_keys.size());
350 header.m_headerBlocks = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)numberOfCipherBlocks(sizeof(header)));
351 header.m_sectionCount = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)m_sections.size());
352 header.m_sectionHeaderSize = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)numberOfCipherBlocks(sizeof(section_header_t)));
353 header.m_signature2[0] = 's';
354 header.m_signature2[1] = 'g';
355 header.m_signature2[2] = 't';
356 header.m_signature2[3] = 'l';
357 header.m_timestamp = ENDIAN_HOST_TO_LITTLE_U64(getTimestamp());
358 header.m_driveTag = m_driveTag;
361 header.m_productVersion = m_productVersion;
362 header.m_componentVersion = m_componentVersion;
363 header.m_productVersion.fixByteOrder();
364 header.m_componentVersion.fixByteOrder();
367 header.m_keyDictionaryBlock = ENDIAN_HOST_TO_LITTLE_U16(header.m_headerBlocks + header.m_sectionCount * header.m_sectionHeaderSize);
368 header.m_firstBootTagBlock = ENDIAN_HOST_TO_LITTLE_U32(header.m_keyDictionaryBlock + header.m_keyCount * 2);
372 rng.generateBlock(header.m_padding0, sizeof(header.m_padding0));
373 rng.generateBlock(header.m_padding1, sizeof(header.m_padding1));
375 // compute SHA-1 digest over the image header
376 uint8_t * message = reinterpret_cast<uint8_t *>(&header.m_signature);
377 uint32_t length = static_cast<uint32_t>(sizeof(header) - sizeof(header.m_digest)); // include padding
383 hash.GetHash(header.m_digest);
431 uint32_t offset = numberOfCipherBlocks(sizeof(boot_image_header_t)); // header
536 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
539 switch (header->m_tag)
573 uint8_t EncoreBootImage::BootCommand::calculateChecksum(const boot_command_t & header)
575 const uint8_t * bytes = reinterpret_cast<const uint8_t *>(&header);
580 for (i = 1; i < sizeof(header); ++i)
619 // handle the command header block separately
624 boot_command_t header;
625 fillCommandHeader(header);
626 memcpy(data, &header, sizeof(header));
641 //! \param modelHeader The baseline header to compare against. Only those fields that
643 //! \param testHeader The actual command header which is being validated.
645 //! header are compared. Possible values are:
689 //! Since the NOP command has no data, this method just validates the command header.
698 //! \exception std::runtime_error Thrown if header fields are invalid.
702 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
703 validateHeader(&model, header, CMD_TAG_FIELD | CMD_FLAGS_FIELD | CMD_ADDRESS_FIELD | CMD_COUNT_FIELD | CMD_DATA_FIELD);
708 //! All fields of the boot command header structure are set to 0, except
712 void EncoreBootImage::NopCommand::fillCommandHeader(boot_command_t & header)
714 header.m_tag = getTag();
715 header.m_flags = 0;
716 header.m_address = 0;
717 header.m_count = 0;
718 header.m_data = 0;
719 header.m_checksum = calculateChecksum(header); // do this last
744 //! \exception std::runtime_error Thrown if header fields are invalid.
748 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
749 validateHeader(&model, header, CMD_TAG_FIELD);
751 // read fields from header
752 m_isLast = (ENDIAN_LITTLE_TO_HOST_U16(header->m_flags) & ROM_LAST_TAG) != 0;
753 m_sectionIdentifier = ENDIAN_LITTLE_TO_HOST_U32(header->m_address);
754 m_sectionLength = ENDIAN_LITTLE_TO_HOST_U32(header->m_count);
755 m_sectionFlags = ENDIAN_LITTLE_TO_HOST_U32(header->m_data);
762 void EncoreBootImage::TagCommand::fillCommandHeader(boot_command_t & header)
764 header.m_tag = getTag();
765 header.m_flags = ENDIAN_HOST_TO_LITTLE_U16(m_isLast ? ROM_LAST_TAG : 0);
766 header.m_address = ENDIAN_HOST_TO_LITTLE_U32(m_sectionIdentifier);
767 header.m_count = ENDIAN_HOST_TO_LITTLE_U32(m_sectionLength);
768 header.m_data = ENDIAN_HOST_TO_LITTLE_U32(m_sectionFlags);
769 header.m_checksum = calculateChecksum(header); // do this last
799 //! data does not match the CRC stored in the command header. Also thrown if the
801 //! specified in the command header or if header fields are invalid.
806 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
807 validateHeader(&model, header, CMD_TAG_FIELD);
809 // read fields from header
810 m_address = ENDIAN_LITTLE_TO_HOST_U32(header->m_address);
811 m_length = ENDIAN_LITTLE_TO_HOST_U32(header->m_count);
812 unsigned crc = ENDIAN_LITTLE_TO_HOST_U32(header->m_data);
815 m_loadDCD = (ENDIAN_LITTLE_TO_HOST_U16(header->m_flags) & ROM_LOAD_DCD) != 0;
843 //! The only thing unique in the load command header is the
846 void EncoreBootImage::LoadCommand::fillCommandHeader(boot_command_t & header)
848 header.m_tag = getTag();
849 header.m_flags = ENDIAN_HOST_TO_LITTLE_U16(m_loadDCD ? ROM_LOAD_DCD : 0);
850 header.m_address = ENDIAN_HOST_TO_LITTLE_U32(m_address);
851 header.m_count = ENDIAN_HOST_TO_LITTLE_U32(m_length);
852 header.m_data = ENDIAN_HOST_TO_LITTLE_U32(calculateCRC());
855 header.m_checksum = calculateChecksum(header);
995 //! \exception std::runtime_error Thrown if header fields are invalid.
1000 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
1001 validateHeader(&model, header, CMD_TAG_FIELD | CMD_FLAGS_FIELD);
1003 // read fields from header
1004 m_address = ENDIAN_LITTLE_TO_HOST_U32(header->m_address);
1005 m_count = ENDIAN_LITTLE_TO_HOST_U32(header->m_count);
1006 m_pattern = ENDIAN_LITTLE_TO_HOST_U32(header->m_data);
1011 void EncoreBootImage::FillCommand::fillCommandHeader(boot_command_t & header)
1013 header.m_tag = getTag();
1014 header.m_flags = 0;
1015 header.m_address = ENDIAN_HOST_TO_LITTLE_U32(m_address);
1016 header.m_count = ENDIAN_HOST_TO_LITTLE_U32(m_count);
1017 header.m_data = ENDIAN_HOST_TO_LITTLE_U32(m_pattern);
1018 header.m_checksum = calculateChecksum(header); // do this last
1051 //! \exception std::runtime_error Thrown if header fields are invalid.
1056 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
1057 validateHeader(&model, header, CMD_TAG_FIELD | CMD_FLAGS_FIELD | CMD_ADDRESS_FIELD | CMD_COUNT_FIELD);
1059 // read fields from header
1060 m_mode = ENDIAN_LITTLE_TO_HOST_U32(header->m_data);
1065 void EncoreBootImage::ModeCommand::fillCommandHeader(boot_command_t & header)
1067 header.m_tag = getTag();
1068 header.m_flags = 0;
1069 header.m_address = 0;
1070 header.m_count = 0;
1071 header.m_data = ENDIAN_HOST_TO_LITTLE_U32(m_mode);
1072 header.m_checksum = calculateChecksum(header); // do this last
1086 //! \exception std::runtime_error Thrown if header fields are invalid.
1091 const boot_command_t * header = reinterpret_cast<const boot_command_t *>(blocks);
1092 validateHeader(&model, header, CMD_TAG_FIELD | CMD_COUNT_FIELD);
1094 // read fields from header
1095 m_address = ENDIAN_LITTLE_TO_HOST_U32(header->m_address);
1096 m_argument = ENDIAN_LITTLE_TO_HOST_U32(header->m_data);
1097 m_isHAB = (ENDIAN_LITTLE_TO_HOST_U16(header->m_flags) & ROM_HAB_EXEC) != 0;
1102 void EncoreBootImage::JumpCommand::fillCommandHeader(boot_command_t & header)
1104 header.m_tag = getTag();
1105 header.m_flags = ENDIAN_HOST_TO_LITTLE_U16(m_isHAB ? ROM_HAB_EXEC : 0);
1106 header.m_address = ENDIAN_HOST_TO_LITTLE_U32(m_address);
1107 header.m_count = 0;
1108 header.m_data = ENDIAN_HOST_TO_LITTLE_U32(m_argument);
1109 header.m_checksum = calculateChecksum(header); // do this last
1125 void EncoreBootImage::Section::fillSectionHeader(section_header_t & header)
1127 header.m_tag = getIdentifier();
1128 header.m_offset = 0;
1129 header.m_length = ENDIAN_HOST_TO_LITTLE_U32(getBlockCount());
1130 header.m_flags = ENDIAN_HOST_TO_LITTLE_U32(getFlags());
1135 header.m_offset = ENDIAN_HOST_TO_LITTLE_U32(m_image->getSectionOffset(this));