diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2014-10-15 16:56:03 +0100 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2014-10-21 10:16:44 +0100 |
commit | 2902b1ddf6101cd4c3cffc0443326bdea3bda0a6 (patch) | |
tree | 23b5dbde95529a519668c248198984d2d42f4308 /lib/power_management/suspend/tftf_suspend.c | |
parent | 99565ab9d814d9c5844fbe2a4daba74848a95cc3 (diff) |
Restructure framework's directory hierarchy
This is a first, rough attempt at cleaning the framework's directory
hierarchy.
Basically, almost everything is moved to individual directories
under lib/. What's left under framework/ are the core features of
the framework, i.e. things that test cases won't ever need.
This patch also introduces some cleanups.
The following functions are removed:
- tftf_platform_get_time()
We'll need such a function in the future to measure tests execution
time but there's no reason for it to be platform-specific, we can
use the Generic Timer instead when we get to it.
Tracked by GENFW-506.
- tftf_platform_reset()
We'll need a function to reset the platform in the future but at
the moment it is not used.
Tracked by GENFW-500.
- tftf_platform_core_whoami()
Not needed. A CPU can just call read_mpidr_el1() to get its MPID,
then platform_get_core_pos() to get the corresponding linear ID.
See GENFW-483.
- tftf_is_core_enabled()
Superseded by plat_get_aff_state().
- tftf_core_participates_in_testcase()
Superseded by the platform API to query the platform topology.
Move the following defintions out of framework/helpers.c:
- Move mp_printf() in lib/utils/mp_printf.c
- Move MMU functions into plat_common.c as default implementations
of these platform functions.
What's left in helpers.c then are helper functions to write test
results into NVM so rename the file into nvm_results_helpers.c.
Remove bl_common.h as it contains only Trusted Firmware specific
definitions.
Rename tests_api.h into tftf_lib.h. Also move some of its
declarations into new header files: irq.h, systimer.h, sgi.h.
Remove tftf_common.h and move its declarations to tftf_lib.h.
Rename rt_services/ into runtime_services/.
The test cases' directory hierarchy needs to be restructured as well,
this will come in a subsequent patch.
Change-Id: I143c4c888586301594f6b6339d6e48cbbd817570
Diffstat (limited to 'lib/power_management/suspend/tftf_suspend.c')
-rw-r--r-- | lib/power_management/suspend/tftf_suspend.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/power_management/suspend/tftf_suspend.c b/lib/power_management/suspend/tftf_suspend.c new file mode 100644 index 0000000..8853451 --- /dev/null +++ b/lib/power_management/suspend/tftf_suspend.c @@ -0,0 +1,79 @@ +/** @file +* +* Copyright (c) 2014, ARM Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include <arch_helpers.h> +#include <arm_gic.h> +#include <platform.h> +#include <power_management.h> +#include <psci.h> +#include <stdint.h> +#include <tftf_lib.h> +#include "suspend_private.h" + +unsigned int tftf_enter_suspend(uint32_t power_state, + tftf_cpu_suspend_ctx_t *ctx) +{ + smc64_args args = { + PSCI_CPU_SUSPEND_AARCH64, + power_state, + (uint64_t)__tftf_cpu_resume_ep, + (uint64_t)ctx + }; + smc64_ret_values rc; + + /* + * Save the CPU context. It will be restored in resume path in + * __tftf_cpu_resume_ep(). + */ + __tftf_save_arch_context(ctx); + + /* + * Flush the context that must be retrieved with MMU off + */ + flush_dcache_range((uint64_t)ctx, sizeof(*ctx)); + + rc = tftf_smc64(&args); + + /* + * If execution reaches this point, The above SMC call was an invalid + * call or a suspend to standby call. In both cases the CPU does not + * power down so there is no need to restore the context. + */ + return rc.ret0; +} + +unsigned int tftf_cpu_suspend(uint32_t power_state) +{ + unsigned int rc; + uint64_t flags; + + flags = read_daif(); + + rc = __tftf_cpu_suspend(power_state); + + /* + * HACK: ARM TF is disabling Group 1 interrupts while entering suspend + * but does not restore it + */ + arm_gic_cpuif_setup(); + + /* + * DAIF flags should be restored last because it could be an issue + * to unmask exceptions before that point, e.g. if GIC must be + * reconfigured upon resume from suspend. + */ + write_daif(flags); + + return rc; +} |