2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Full C support initialization
|
|
|
|
*
|
2015-10-20 09:42:33 -07:00
|
|
|
*
|
|
|
|
* Initialization of full C support: zero the .bss, copy the .data if XIP,
|
2019-03-08 14:19:05 -07:00
|
|
|
* call z_cstart().
|
2015-10-20 09:42:33 -07:00
|
|
|
*
|
|
|
|
* Stack is available in this module, but not the global data/bss until their
|
|
|
|
* initialization is performed.
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 10:32:08 -05:00
|
|
|
#include <zephyr/types.h>
|
2022-05-06 10:49:15 +02:00
|
|
|
#include <zephyr/toolchain.h>
|
|
|
|
#include <zephyr/linker/linker-defs.h>
|
|
|
|
#include <zephyr/arch/arc/v2/aux_regs.h>
|
|
|
|
#include <zephyr/kernel_structs.h>
|
2018-01-31 10:11:47 +05:30
|
|
|
#include <kernel_internal.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-05-09 14:26:28 -07:00
|
|
|
|
2016-11-29 17:09:31 -05:00
|
|
|
/* XXX - keep for future use in full-featured cache APIs */
|
|
|
|
#if 0
|
2016-05-23 13:30:55 -07:00
|
|
|
/**
|
|
|
|
* @brief Disable the i-cache if present
|
|
|
|
*
|
|
|
|
* For those ARC CPUs that have a i-cache present,
|
|
|
|
* invalidate the i-cache and then disable it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void disable_icache(void)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
val = z_arc_v2_aux_reg_read(_ARC_V2_I_CACHE_BUILD);
|
2016-05-23 13:30:55 -07:00
|
|
|
val &= 0xff; /* version field */
|
|
|
|
if (val == 0) {
|
|
|
|
return; /* skip if i-cache is not present */
|
|
|
|
}
|
2019-03-08 14:19:05 -07:00
|
|
|
z_arc_v2_aux_reg_write(_ARC_V2_IC_IVIC, 0);
|
2020-07-20 18:14:58 +03:00
|
|
|
__builtin_arc_nop();
|
2019-03-08 14:19:05 -07:00
|
|
|
z_arc_v2_aux_reg_write(_ARC_V2_IC_CTRL, 1);
|
2016-05-23 13:30:55 -07:00
|
|
|
}
|
|
|
|
|
2016-05-09 14:26:28 -07:00
|
|
|
/**
|
|
|
|
* @brief Invalidate the data cache if present
|
|
|
|
*
|
|
|
|
* For those ARC CPUs that have a data cache present,
|
|
|
|
* invalidate the data cache.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void invalidate_dcache(void)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
val = z_arc_v2_aux_reg_read(_ARC_V2_D_CACHE_BUILD);
|
2016-05-09 14:26:28 -07:00
|
|
|
val &= 0xff; /* version field */
|
|
|
|
if (val == 0) {
|
|
|
|
return; /* skip if d-cache is not present */
|
|
|
|
}
|
2019-03-08 14:19:05 -07:00
|
|
|
z_arc_v2_aux_reg_write(_ARC_V2_DC_IVDC, 1);
|
2016-05-09 14:26:28 -07:00
|
|
|
}
|
2016-11-29 17:09:31 -05:00
|
|
|
#endif
|
2016-05-09 14:26:28 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
extern FUNC_NORETURN void z_cstart(void);
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Prepare to and run C code
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
* This routine prepares for the execution of and runs C code.
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
void _PrepC(void)
|
|
|
|
{
|
2019-03-08 14:19:05 -07:00
|
|
|
z_bss_zero();
|
|
|
|
z_data_copy();
|
|
|
|
z_cstart();
|
2015-04-10 16:44:37 -07:00
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|