Skip to content

Commit

Permalink
#0: .text.end
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-TT committed Oct 23, 2024
1 parent f307141 commit 15e4dd8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
8 changes: 3 additions & 5 deletions tt_metal/hw/firmware/src/brisck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
#include "tools/profiler/kernel_profiler.hpp"
#include <kernel_includes.hpp>

extern uint32_t __kernel_init_local_l1_base[];
extern uint32_t __fw_export_end_text[];

void kernel_launch(uint32_t kernel_base_addr) {
void kernel_launch(uint32_t) {

#if defined(DEBUG_NULL_KERNELS) && !defined(DISPATCH_KERNEL)
#ifdef KERNEL_RUN_TIME
uint64_t end_time = c_tensix_core::read_wall_clock() + KERNEL_RUN_TIME;
while (c_tensix_core::read_wall_clock() < end_time);
#endif
#else
firmware_kernel_common_init((void tt_l1_ptr *)(kernel_base_addr + (uint32_t) __kernel_init_local_l1_base - (uint32_t)__fw_export_end_text));
extern uint32_t __kernel_data_lma[];
firmware_kernel_common_init((void tt_l1_ptr *)&__kernel_data_lma);

if constexpr (NOC_MODE == DM_DEDICATED_NOC) {
noc_local_state_init(NOC_INDEX);
Expand Down
8 changes: 3 additions & 5 deletions tt_metal/hw/firmware/src/idle_erisck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@

#include <kernel_includes.hpp>

extern uint32_t __kernel_init_local_l1_base[];
extern uint32_t __fw_export_end_text[];

void kernel_launch(uint32_t kernel_base_addr) {
void kernel_launch(uint32_t) {
DeviceZoneScopedMainChildN("ERISC-KERNEL");

firmware_kernel_common_init((void tt_l1_ptr *)(kernel_base_addr + (uint32_t) __kernel_init_local_l1_base - (uint32_t)__fw_export_end_text));
extern uint32_t __kernel_data_lma[];
firmware_kernel_common_init((void tt_l1_ptr *)&__kernel_data_lma);

noc_local_state_init(NOC_INDEX);

Expand Down
9 changes: 3 additions & 6 deletions tt_metal/hw/firmware/src/ncrisck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ uint32_t noc_nonposted_writes_acked[NUM_NOCS];
uint32_t noc_nonposted_atomics_acked[NUM_NOCS];
uint32_t noc_posted_writes_num_issued[NUM_NOCS];

extern uint32_t __kernel_init_local_l1_base[];
extern uint32_t __fw_export_end_text[];

void kernel_launch(uint32_t kernel_base_addr) {
void kernel_launch(uint32_t) {

DeviceZoneScopedMainChildN("NCRISC-KERNEL");
#if defined(DEBUG_NULL_KERNELS) && !defined(DISPATCH_KERNEL)
Expand All @@ -38,8 +35,8 @@ void kernel_launch(uint32_t kernel_base_addr) {
while (c_tensix_core::read_wall_clock() < KERNEL_RUN_TIME);
#endif
#else

firmware_kernel_common_init((void tt_l1_ptr *)(kernel_base_addr + (uint32_t) __kernel_init_local_l1_base - (uint32_t)__fw_export_end_text));
extern uint32_t __kernel_data_lma[];
firmware_kernel_common_init((void tt_l1_ptr *)&__kernel_data_lma);

if constexpr (NOC_MODE == DM_DEDICATED_NOC) {
noc_local_state_init(NOC_INDEX);
Expand Down
8 changes: 3 additions & 5 deletions tt_metal/hw/firmware/src/trisck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ volatile tt_reg_ptr uint * mailbox_base[4] = {
};
}

extern uint32_t __kernel_init_local_l1_base[];
extern uint32_t __fw_export_end_text[];

void kernel_launch(uint32_t kernel_base_addr)
void kernel_launch(uint32_t)
{
DeviceZoneScopedMainChildN("TRISC-KERNEL");
#if defined(DEBUG_NULL_KERNELS) && !defined(DISPATCH_KERNEL)
#ifdef KERNEL_RUN_TIME
ckernel::wait(KERNEL_RUN_TIME);
#endif
#else
firmware_kernel_common_init((void tt_l1_ptr *)(kernel_base_addr + (uint32_t) __kernel_init_local_l1_base - (uint32_t)__fw_export_end_text));
extern uint32_t __kernel_data_lma[];
firmware_kernel_common_init((void tt_l1_ptr *)&__kernel_data_lma);

#if defined(UCK_CHLKC_UNPACK)
// Make sure DBG_FEATURE_DISABLE register is cleared before every kernel is executed
Expand Down
16 changes: 11 additions & 5 deletions tt_metal/hw/toolchain/sections.ld
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,24 @@ SECTIONS
*(l1_data_test_only)
} > REGION_CODE

. = ALIGN(. + MEM_PAD, MEM_ALIGN);

.text.end :
{
/* Place in a text-segment section so that these symbols are recognized
as text-based, which is important for XIP. */
. = ALIGN(. + MEM_PAD, MEM_ALIGN);
#if defined(TYPE_FIRMWARE)
__fw_export_end_text = .;
/* Kernels will start their text at this point. */
__fw_export_end_text = .;
#if defined(TARGET_NCRISC)
PROVIDE (KERNEL_ENTRY_SYMBOL = __fw_export_end_text);
PROVIDE (KERNEL_ENTRY_SYMBOL = __fw_export_end_text);
#endif
#endif

#if defined(TYPE_KERNEL)
__kernel_init_local_l1_base = .;
/* Kernel's initalized data image will start at this point -- abutting the kernel's text. */
__kernel_data_lma = .;
#endif
} > REGION_CODE

PROVIDE(__global_pointer$ = ORIGIN(REGION_DATA) + 0x7f0);
.data DATA_START :
Expand Down

0 comments on commit 15e4dd8

Please sign in to comment.