2019-11-10 16:17:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Full C support initialization
|
|
|
|
*
|
|
|
|
* Initialization of full C support: zero the .bss and call z_cstart().
|
|
|
|
*
|
|
|
|
* Stack is available in this module, but not the global data/bss until their
|
|
|
|
* initialization is performed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kernel_internal.h>
|
2021-01-14 21:28:55 +01:00
|
|
|
#include <linker/linker-defs.h>
|
2019-11-10 16:17:19 +00:00
|
|
|
|
2021-06-28 17:14:34 +08:00
|
|
|
__weak void z_arm64_mm_init(bool is_primary_core) { }
|
|
|
|
|
2019-11-10 16:17:19 +00:00
|
|
|
extern FUNC_NORETURN void z_cstart(void);
|
2021-01-14 21:28:55 +01:00
|
|
|
|
2021-06-28 17:14:34 +08:00
|
|
|
extern void z_arm64_mm_init(bool is_primary_core);
|
2021-02-15 10:26:21 -05:00
|
|
|
|
2021-01-14 21:28:55 +01:00
|
|
|
static inline void z_arm64_bss_zero(void)
|
|
|
|
{
|
|
|
|
uint64_t *p = (uint64_t *)__bss_start;
|
|
|
|
uint64_t *end = (uint64_t *)__bss_end;
|
|
|
|
|
|
|
|
while (p < end) {
|
2021-04-02 22:52:42 -07:00
|
|
|
*p++ = 0U;
|
2021-01-14 21:28:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-10 16:17:19 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Prepare to and run C code
|
|
|
|
*
|
|
|
|
* This routine prepares for the execution of and runs C code.
|
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
|
|
|
void z_arm64_prep_c(void)
|
|
|
|
{
|
2021-04-09 23:01:18 -04:00
|
|
|
/* Initialize tpidrro_el0 with our struct _cpu instance address */
|
|
|
|
write_tpidrro_el0((uintptr_t)&_kernel.cpus[0]);
|
|
|
|
|
2021-01-14 21:28:55 +01:00
|
|
|
z_arm64_bss_zero();
|
2020-12-16 14:11:55 +01:00
|
|
|
#ifdef CONFIG_XIP
|
|
|
|
z_data_copy();
|
|
|
|
#endif
|
2021-06-28 17:14:34 +08:00
|
|
|
z_arm64_mm_init(true);
|
2020-02-11 18:08:28 +09:00
|
|
|
z_arm64_interrupt_init();
|
2019-11-10 16:17:19 +00:00
|
|
|
z_cstart();
|
|
|
|
|
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|
2020-11-09 15:58:15 +08:00
|
|
|
|
|
|
|
#if CONFIG_MP_NUM_CPUS > 1
|
|
|
|
extern FUNC_NORETURN void z_arm64_secondary_start(void);
|
|
|
|
void z_arm64_secondary_prep_c(void)
|
|
|
|
{
|
|
|
|
z_arm64_secondary_start();
|
|
|
|
|
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|
|
|
|
#endif
|