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 Reset handler
|
|
|
|
*
|
|
|
|
* Reset handler that prepares the system for running C code.
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#include <toolchain.h>
|
2017-06-17 11:30:47 -04:00
|
|
|
#include <linker/sections.h>
|
2015-05-28 10:56:47 -07:00
|
|
|
#include <arch/cpu.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-11-20 11:49:07 -05:00
|
|
|
GDATA(_interrupt_stack)
|
2016-11-21 12:31:18 -05:00
|
|
|
GDATA(_main_stack)
|
2016-11-20 11:49:07 -05:00
|
|
|
|
|
|
|
/* use one of the available interrupt stacks during init */
|
|
|
|
|
2017-07-11 10:39:54 +08:00
|
|
|
|
|
|
|
#define INIT_STACK _interrupt_stack
|
|
|
|
#define INIT_STACK_SIZE CONFIG_ISR_STACK_SIZE
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
GTEXT(__reset)
|
arc: Set __start entry point to be same as __reset
There is a BUG here in that the alias for __start was
aliased to the start of the vector table. Yet, on ARC CPUs,
the vector table CANNOT be the entry point, because there
is no code in a vector table. Only addresses appear in each vector.
Thus, the reset vector, at offset 0 in this table, is a raw address.
The top Makefile in zephyr sets the lable __start to be the entry point
like this: -e __start. Debuggers, for example, use this entry point
to know where the first line of code is.
Also, in KConfig, there were duplicate NSIM blocks. One has been
removed.
Change-Id: I480be7d338a8b45b8ea6ef3f55ac2e6c43829452
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-04 17:46:27 -07:00
|
|
|
GTEXT(__start)
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
|
|
|
*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Reset vector
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
* Ran when the system comes out of reset. The processor is at supervisor level.
|
|
|
|
*
|
|
|
|
* Locking interrupts prevents anything from interrupting the CPU.
|
|
|
|
*
|
|
|
|
* When these steps are completed, jump to _PrepC(), which will finish setting
|
|
|
|
* up the system for running C code.
|
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return N/A
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
SECTION_FUNC(TEXT,__reset)
|
arc: Set __start entry point to be same as __reset
There is a BUG here in that the alias for __start was
aliased to the start of the vector table. Yet, on ARC CPUs,
the vector table CANNOT be the entry point, because there
is no code in a vector table. Only addresses appear in each vector.
Thus, the reset vector, at offset 0 in this table, is a raw address.
The top Makefile in zephyr sets the lable __start to be the entry point
like this: -e __start. Debuggers, for example, use this entry point
to know where the first line of code is.
Also, in KConfig, there were duplicate NSIM blocks. One has been
removed.
Change-Id: I480be7d338a8b45b8ea6ef3f55ac2e6c43829452
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-04 17:46:27 -07:00
|
|
|
SECTION_FUNC(TEXT,__start)
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2018-06-07 17:43:14 +08:00
|
|
|
/* lock interrupts: will get unlocked when switch to main task
|
|
|
|
* also make sure the processor in the correct status
|
|
|
|
*/
|
|
|
|
mov r0, 0
|
|
|
|
kflag r0
|
|
|
|
|
|
|
|
/* interrupt related init */
|
|
|
|
sr r0, [_ARC_V2_AUX_IRQ_ACT]
|
|
|
|
sr r0, [_ARC_V2_AUX_IRQ_CTRL]
|
|
|
|
sr r0, [_ARC_V2_AUX_IRQ_HINT]
|
|
|
|
|
|
|
|
/* \todo: MPU init, gp for small data? */
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2018-02-02 14:18:35 +08:00
|
|
|
#if CONFIG_USERSPACE
|
|
|
|
lr r0, [_ARC_V2_STATUS32]
|
|
|
|
bset r0, r0, _ARC_V2_STATUS32_US_BIT
|
|
|
|
kflag r0
|
|
|
|
#endif
|
2016-11-29 17:09:31 -05:00
|
|
|
mov r1, 1
|
|
|
|
|
|
|
|
invalidate_and_disable_icache:
|
|
|
|
|
|
|
|
lr r0, [_ARC_V2_I_CACHE_BUILD]
|
|
|
|
and.f r0, r0, 0xff
|
|
|
|
bz.nd invalidate_dcache
|
|
|
|
|
|
|
|
mov_s r2, 0
|
|
|
|
sr r2, [_ARC_V2_IC_IVIC]
|
|
|
|
/* writing to IC_IVIC needs 3 NOPs */
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
sr r1, [_ARC_V2_IC_CTRL]
|
|
|
|
|
|
|
|
invalidate_dcache:
|
|
|
|
|
|
|
|
lr r3, [_ARC_V2_D_CACHE_BUILD]
|
|
|
|
and.f r3, r3, 0xff
|
|
|
|
bz.nd done_cache_invalidate
|
|
|
|
|
|
|
|
sr r1, [_ARC_V2_DC_IVDC]
|
|
|
|
|
|
|
|
done_cache_invalidate:
|
|
|
|
|
2016-11-01 13:07:34 +00:00
|
|
|
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP) && \
|
|
|
|
!defined(CONFIG_BOOTLOADER_CONTEXT_RESTORE)
|
2018-12-08 14:10:58 -05:00
|
|
|
jl @sys_resume_from_deep_sleep
|
2016-11-01 13:07:34 +00:00
|
|
|
#endif
|
|
|
|
|
2016-11-21 12:31:18 -05:00
|
|
|
#ifdef CONFIG_INIT_STACKS
|
|
|
|
/*
|
|
|
|
* use the main stack to call memset on the interrupt stack and the
|
|
|
|
* FIRQ stack when CONFIG_INIT_STACKS is enabled before switching to
|
|
|
|
* one of them for the rest of the early boot
|
|
|
|
*/
|
|
|
|
mov sp, _main_stack
|
|
|
|
add sp, sp, CONFIG_MAIN_STACK_SIZE
|
|
|
|
|
|
|
|
mov_s r0, _interrupt_stack
|
|
|
|
mov_s r1, 0xaa
|
|
|
|
mov_s r2, CONFIG_ISR_STACK_SIZE
|
|
|
|
jl memset
|
|
|
|
|
2016-11-24 10:04:05 -05:00
|
|
|
#endif /* CONFIG_INIT_STACKS */
|
|
|
|
|
2016-11-20 11:49:07 -05:00
|
|
|
mov sp, INIT_STACK
|
|
|
|
add sp, sp, INIT_STACK_SIZE
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
j @_PrepC
|