本文整理汇总了C++中Header::board_name方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::board_name方法的具体用法?C++ Header::board_name怎么用?C++ Header::board_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::board_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(BootImgHeaderTest, CheckDefaultValues)
{
Header header;
ASSERT_EQ(header.supported_fields(), ALL_FIELDS);
ASSERT_FALSE(header.board_name());
ASSERT_FALSE(header.kernel_cmdline());
ASSERT_FALSE(header.page_size());
ASSERT_FALSE(header.kernel_address());
ASSERT_FALSE(header.ramdisk_address());
ASSERT_FALSE(header.secondboot_address());
ASSERT_FALSE(header.kernel_tags_address());
ASSERT_FALSE(header.sony_ipl_address());
ASSERT_FALSE(header.sony_rpm_address());
ASSERT_FALSE(header.sony_appsbl_address());
ASSERT_FALSE(header.entrypoint_address());
}
示例2: success
oc::result<void> MtkFormatWriter::write_header(File &file, const Header &header)
{
// Construct header
m_hdr = {};
memcpy(m_hdr.magic, android::BOOT_MAGIC, android::BOOT_MAGIC_SIZE);
if (auto address = header.kernel_address()) {
m_hdr.kernel_addr = *address;
}
if (auto address = header.ramdisk_address()) {
m_hdr.ramdisk_addr = *address;
}
if (auto address = header.secondboot_address()) {
m_hdr.second_addr = *address;
}
if (auto address = header.kernel_tags_address()) {
m_hdr.tags_addr = *address;
}
if (auto page_size = header.page_size()) {
switch (*page_size) {
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
m_hdr.page_size = *page_size;
break;
default:
//DEBUG("Invalid page size: %" PRIu32, *page_size);
return android::AndroidError::InvalidPageSize;
}
} else {
return android::AndroidError::MissingPageSize;
}
if (auto board_name = header.board_name()) {
if (board_name->size() >= sizeof(m_hdr.name)) {
return android::AndroidError::BoardNameTooLong;
}
strncpy(reinterpret_cast<char *>(m_hdr.name), board_name->c_str(),
sizeof(m_hdr.name) - 1);
m_hdr.name[sizeof(m_hdr.name) - 1] = '\0';
}
if (auto cmdline = header.kernel_cmdline()) {
if (cmdline->size() >= sizeof(m_hdr.cmdline)) {
return android::AndroidError::KernelCmdlineTooLong;
}
strncpy(reinterpret_cast<char *>(m_hdr.cmdline), cmdline->c_str(),
sizeof(m_hdr.cmdline) - 1);
m_hdr.cmdline[sizeof(m_hdr.cmdline) - 1] = '\0';
}
// TODO: UNUSED
// TODO: ID
std::vector<SegmentWriterEntry> entries;
entries.push_back({ ENTRY_TYPE_MTK_KERNEL_HEADER, 0, {}, 0 });
entries.push_back({ ENTRY_TYPE_KERNEL, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_MTK_RAMDISK_HEADER, 0, {}, 0 });
entries.push_back({ ENTRY_TYPE_RAMDISK, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_SECONDBOOT, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_DEVICE_TREE, 0, {}, m_hdr.page_size });
OUTCOME_TRYV(m_seg->set_entries(std::move(entries)));
// Start writing after first page
auto seek_ret = file.seek(m_hdr.page_size, SEEK_SET);
if (!seek_ret) {
if (file.is_fatal()) { m_writer.set_fatal(); }
return seek_ret.as_failure();
}
return oc::success();
}