-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[RFC] arm32: introduce suspend/resume common functions #1729
Changes from all commits
9275937
732fc43
3ddbb7f
b73bb8e
8ca9edc
8af2207
382e20e
45998b6
27009ca
5a4b957
8e34262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2017 NXP | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. header guards There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix in V2 |
||
#ifndef SM_PM_H | ||
#define SM_PM_H | ||
#include <stdint.h> | ||
#include <types_ext.h> | ||
|
||
struct sm_pm_ctx { | ||
uint32_t sp; | ||
paddr_t cpu_resume_addr; | ||
uint32_t suspend_regs[16]; | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a "sm_pm_" prefix to the functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. Will add them in next version patch |
||
/* suspend/resume core functions */ | ||
void sm_pm_cpu_suspend_save(struct sm_pm_ctx *ptr, uint32_t sp); | ||
void sm_pm_cpu_do_suspend(uint32_t *ptr); | ||
void sm_pm_cpu_do_resume(void); | ||
|
||
/* | ||
* Exported to platform suspend, arg will be passed to fn as r0 | ||
* Return value: 0 - cpu resumed from suspended state. | ||
* -1 - cpu not suspended. | ||
*/ | ||
int sm_pm_cpu_suspend(uint32_t arg, int (*fn)(uint32_t)); | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ | |
|
||
struct thread_ctx threads[CFG_NUM_THREADS]; | ||
|
||
static struct thread_core_local thread_core_local[CFG_TEE_CORE_NB_CORE]; | ||
struct thread_core_local thread_core_local[CFG_TEE_CORE_NB_CORE]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should go into the "core: arm: kernel: make thread_core_local public" commit |
||
|
||
#ifdef CFG_WITH_STACK_CANARIES | ||
#ifdef ARM32 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,33 +117,6 @@ struct thread_ctx { | |
struct mutex_head mutexes; | ||
struct thread_specific_data tsd; | ||
}; | ||
|
||
#ifdef ARM64 | ||
/* | ||
* struct thread_core_local need to have alignment suitable for a stack | ||
* pointer since SP_EL1 points to this | ||
*/ | ||
#define THREAD_CORE_LOCAL_ALIGNED __aligned(16) | ||
#else | ||
#define THREAD_CORE_LOCAL_ALIGNED | ||
#endif | ||
|
||
struct thread_core_local { | ||
vaddr_t tmp_stack_va_end; | ||
int curr_thread; | ||
uint32_t flags; | ||
vaddr_t abt_stack_va_end; | ||
#ifdef ARM32 | ||
uint32_t r[2]; | ||
#endif | ||
#ifdef ARM64 | ||
uint64_t x[4]; | ||
#endif | ||
#ifdef CFG_TEE_CORE_DEBUG | ||
unsigned int locked_count; /* Number of spinlocks held */ | ||
#endif | ||
} THREAD_CORE_LOCAL_ALIGNED; | ||
|
||
#endif /*ASM*/ | ||
|
||
#ifdef ARM64 | ||
|
@@ -190,8 +163,6 @@ void thread_init_vbar(void); | |
/* Handles a stdcall, r0-r7 holds the parameters */ | ||
void thread_std_smc_entry(void); | ||
|
||
struct thread_core_local *thread_get_core_local(void); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should go into the "core: arm: kernel: make thread_core_local public" commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @jenswi-linaro. I'll fix this, then add your tags. |
||
|
||
/* | ||
* Resumes execution of currently active thread by restoring context and | ||
* jumping to the instruction where to continue execution. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should go into the "core: arm: kernel: make thread_core_local public" commit