[U-Boot] [PATCH 13/15] ARM: PSCI: Add helper functions to access per-CPU target PC storage
Chen-Yu Tsai
wens at csie.org
Sat Jul 2 11:08:45 CEST 2016
On Fri, Jul 1, 2016 at 6:54 PM, Hongbo Zhang <macro.wave.z at gmail.com> wrote:
> On Sun, Jun 19, 2016 at 12:38 PM, Chen-Yu Tsai <wens at csie.org> wrote:
>> Now that we have a data section, add helper functions to save and fetch
>> per-CPU target PC.
>>
>> Signed-off-by: Chen-Yu Tsai <wens at csie.org>
>> ---
>> arch/arm/cpu/armv7/Makefile | 1 +
>> arch/arm/cpu/armv7/psci-common.c | 39 +++++++++++++++++++++++++++++++++++++++
>> arch/arm/include/asm/psci.h | 4 ++++
>> 3 files changed, 44 insertions(+)
>> create mode 100644 arch/arm/cpu/armv7/psci-common.c
>>
>> diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
>> index 328c4b10e976..730b59986a01 100644
>> --- a/arch/arm/cpu/armv7/Makefile
>> +++ b/arch/arm/cpu/armv7/Makefile
>> @@ -26,6 +26,7 @@ endif
>>
>> ifneq ($(CONFIG_ARMV7_PSCI),)
>> obj-y += psci.o
>> +obj-y += psci-common.o
>> endif
>>
>> obj-$(CONFIG_IPROC) += iproc-common/
>> diff --git a/arch/arm/cpu/armv7/psci-common.c b/arch/arm/cpu/armv7/psci-common.c
>> new file mode 100644
>> index 000000000000..d14b6937473f
>> --- /dev/null
>> +++ b/arch/arm/cpu/armv7/psci-common.c
>> @@ -0,0 +1,39 @@
>> +/*
>> + * Common PSCI functions
>> + *
>> + * Copyright (C) 2016 Chen-Yu Tsai
>> + * Author: Chen-Yu Tsai <wens at csie.org>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include <config.h>
>> +#include <asm/armv7.h>
>> +#include <asm/macro.h>
>> +#include <asm/psci.h>
>> +#include <asm/secure.h>
>> +#include <linux/linkage.h>
>> +
>> +static u32 psci_target_pc[CONFIG_ARMV7_PSCI_NR_CPUS] __secure_data = { 0 };
>> +
>> +void __secure psci_save_target_pc(int cpu, u32 pc)
>> +{
>> + psci_target_pc[cpu] = pc;
>> + DSB;
>> +}
>> +
>> +u32 __secure psci_get_target_pc(int cpu)
>> +{
>> + return psci_target_pc[cpu];
>> +}
>> +
>> diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
>> index dab576997654..a0da02300700 100644
>> --- a/arch/arm/include/asm/psci.h
>> +++ b/arch/arm/include/asm/psci.h
>> @@ -54,6 +54,10 @@
>> #ifndef __ASSEMBLY__
>> #include <asm/types.h>
>>
>> +/* These 2 helper functions assume cpu < CONFIG_ARMV7_PSCI_NR_CPUS */
>
> Only depends on this comment here? why not check parameter 'cpu'
> inside these functions?
That's doable. But if you're passing a bad cpu index,
chances are it's going to break elsewhere as well.
I was mostly concerned with keeping the helpers as simple
as possible. They can't be static inlines in the header
though, as some assembly code might use them.
ChenYu
>> +u32 psci_get_target_pc(int cpu);
>> +void psci_save_target_pc(int cpu, u32 pc);
>> +
>> void psci_cpu_entry(void);
>> u32 psci_get_cpu_id(void);
>> u32 psci_get_cpu_stack_top(int cpu);
>> --
>> 2.8.1
>>
More information about the U-Boot
mailing list