Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elfloader changes for shim patching for aie4 #8355

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/runtime_src/core/common/api/xrt_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct patcher
scalar_32bit_kind = 3,
control_packet_48 = 4, // patching scheme needed by firmware to patch control packet
shim_dma_48 = 5, // patching scheme needed by firmware to patch instruction buffer
shim_dma_aie4_base_addr_symbol_kind = 6, // patching scheme needed by AIE4 firmware
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the ELF spce accordingly.

unknown_symbol_kind = 8
};

Expand Down Expand Up @@ -182,6 +183,18 @@ struct patcher
bd_data_ptr[8] = (bd_data_ptr[8] & 0xFFFFFE00) | ((base_address >> 48) & 0x1FF); // NOLINT
}

void
patch57_aie4(uint32_t* bd_data_ptr, uint64_t patch)
{
uint64_t base_address =
((static_cast<uint64_t>(bd_data_ptr[0]) & 0x1FFFFFF) << 32) | // NOLINT
bd_data_ptr[1];

base_address += patch;
bd_data_ptr[1] = (uint32_t)(base_address & 0xFFFFFFFF); // NOLINT
bd_data_ptr[0] = (bd_data_ptr[0] & 0xFE000000) | ((base_address >> 32) & 0x1FFFFFF);// NOLINT
}

void
patch_ctrl48(uint32_t* bd_data_ptr, uint64_t patch)
{
Expand Down Expand Up @@ -226,6 +239,10 @@ struct patcher
// new_value is a bo address
patch57(bd_data_ptr, new_value + item.offset_to_base_bo_addr);
break;
case symbol_type::shim_dma_aie4_base_addr_symbol_kind:
// new_value is a bo address
patch57_aie4(bd_data_ptr, new_value + item.offset_to_base_bo_addr);
break;
case symbol_type::control_packet_48:
// new_value is a bo address
patch_ctrl48(bd_data_ptr, new_value + item.offset_to_base_bo_addr);
Expand Down
Loading