2. PSCIとは
PSCIは、POWER STATE COORDINATION INTERFACE の略
ARMv8(ARM64)では、多くのSoCがPSCIをサポートしている
参考資料
"Power State Coordination Interface System Software on ARM processors"
http://infocenter.arm.com/help/topic/com.arm.doc.den0022c/
LinuxのDevice Tree Binding
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/psci.txt
3. cpuノードのenable-methodプロパティ
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/arm/cpus.txt
- enable-method
Value type: <stringlist>
Usage and definition depend on ARM architecture version.
# On ARM v8 64-bit this property is required and must
be one of:
"psci"
"spin-table"
- cpu-release-addr
Usage: required for systems that have an "enable-method"
property value of "spin-table".
Value type: <prop-encoded-array>
Definition:
# On ARM v8 64-bit systems must be a two cell
property identifying a 64-bit zero-initialised memory location.
7. enable-methodプロパティのチェック
http://lxr.free-electrons.com/source/arch/arm64/kernel/cpu_ops.c
static const char *__init cpu_read_enable_method(int cpu)
{
struct device_node *dn = of_get_cpu_node(cpu, NULL);
enable_method = of_get_property(dn, "enable-method", NULL);
if (!enable_method) {
/* The boot CPU may not have an enable method (e.g.
* when spin-table is used for secondaries).
* Don't warn spuriously. */
if (cpu != 0)
pr_err("%s: missing enable-method propertyn", dn->full_name);
}
}
13. drivers/firmware/psci.c (Linux 4.3〜
static int psci_system_suspend(unsigned long unused)
{
return invoke_psci_fn(
PSCI_FN_NATIVE(1_0,
SYSTEM_SUSPEND),
virt_to_phys(cpu_resume), 0, 0);
}
static int psci_system_suspend_enter(suspend_state_t state)
{
return cpu_suspend(0, psci_system_suspend);
}
14. drivers/firmware/psci.c (Linux 4.3〜
static int get_set_conduit_method(struct device_node *np)
{
if (of_property_read_string(np, "method", &method)) {
pr_warn("missing "method" propertyn");
return -ENXIO;
}
if (!strcmp("hvc", method)) {
invoke_psci_fn = __invoke_psci_fn_hvc;
} else if (!strcmp("smc", method)) {
invoke_psci_fn = __invoke_psci_fn_smc;
}
15. drivers/firmware/psci.c (Linux 4.3〜
static unsigned long __invoke_psci_fn_smc(
unsigned long function_id,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2)
{
struct arm_smccc_res res;
arm_smccc_smc(function_id, arg0, arg1, arg2,
0, 0, 0, 0, &res);
return res.a0;
}
16. arch/arm64/kernel/smccc-call.S
/*
* void arm_smccc_smc(unsigned long a0, unsigned long a1,
unsigned long a2, unsigned long a3,
unsigned long a4, unsigned long a5,
unsigned long a6, unsigned long a7,
struct arm_smccc_res *res)
*/
ENTRY(arm_smccc_smc)
SMCCC smc
ENDPROC(arm_smccc_smc)
18. LinuxからATFへはどのように伝える?
http://lxr.free-electrons.com/source/arch/arm64/kernel/smccc-call.S
・SMC (Secure Monitor Call) を使う
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204ij/Cjaeeged.html
/*
* void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
* unsigned long a3, unsigned long a4, unsigned long a5,
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res)
*/
ENTRY(arm_smccc_smc)
SMCCC smc /* SMCCC は、このファイル(smccc-call.S内でマクロ定義されてい
る)*/
ENDPROC(arm_smccc_smc)
19. EL3 Runtime Service
https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/rt-svc-writers-guide.
md
Software executing in the normal world and in the trusted world at exception levels lower
than EL3 will request runtime services using the Secure Monitor Call (SMC) instruction.
These requests will follow the convention described in the SMC Calling Convention PDD
(SMCCC). The SMCCC assigns function identifiers to each SMC request and describes how
arguments are passed and results are returned.
・Standard Service calls => 標準サービスの提供 ( PSCI )
・SiP Service calls => 各社独自サービス用