Chinese translated version of Documentation\arm\firmware
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 金丽丽 819153113@qq.com
---------------------------------------------------------------------
Documentation\arm\firmware的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 金丽丽 819153113@qq.com
中文版翻译者: 金丽丽 819153113@qq.com
中文版校译者: 潘丽卡 774945605@qq.com
以下为正文
---------------------------------------------------------------------
Interface for registering and calling firmware-specific operations for ARM.
ARM的接口注册和固件特定操作的调用
----
Written by Tomasz Figa <t.figa@samsung.com>
作者:Tomasz Figa <t.figa@samsung.com>
Some boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
一些主板要在安全固件上运行,而安全固件运行在TrustZone安全环境中——TrustZone安全环境可以改变一些事物初始化的方式。
This makes a need to provide an interface for such platforms to specify available firmware operations and call them when needed.
这使得需要这样的平台提供了一个接口指定可用的固件操作,并在需要时调用它们。
Firmware operations can be specified using struct firmware_ops:
利用struct firmware_ops可以指定固件操作:
struct firmware_ops {
/*
* Enters CPU idle mode
CPU进入空闲状态
*/
int (*do_idle)(void);
/*
* Sets boot address of specified physical CPU
设置指定的物理CPU的启动地址
*/
int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
/*
* Boots specified physical CPU
启动指定的物理CPU
*/
int (*cpu_boot)(int cpu);
/*
* Initializes L2 cache
初始化L2缓存
*/
int (*l2x0_init)(void);
};
and then registered with register_firmware_ops function void register_firmware_ops(const struct firmware_ops *ops) the ops pointer must be non-NULL.
然后注册register_firmware_ops函数:void register_firmware_ops(const struct firmware_ops *ops) ops指针必须非空。
There is a default, empty set of operations provided, so there is no need to set anything if platform does not require firmware operations.
register_firmware_ops函数包含了一个默认的空的集合,所以如果这个平台不要求固件操作,则就没有必要设置什么了。
To call a firmware operation, a helper macro is provided:
为了调用固件操作,需要包含一个宏定义:
#define call_firmware_op(op, ...)
((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
the macro checks if the operation is provided and calls it or otherwise returns -ENOSYS to signal that given operation is not available (for example, to allow fallback to legacy operation).
若包含宏并调用它,则可进行宏检验或者返回-ENOSYS信号以表明该操作不可行(例如:允许返回legacy操作)。
Example of registering firmware operations:
/* board file */
主板文件
static int platformX_do_idle(void) {
/* tell platformX firmware to enter idle */
告诉platformX固件进入空闲状态
return 0; }
static int platformX_cpu_boot(int i) {
/* tell platformX firmware to boot CPU i */
告诉platformX固件去启动CPU i
return 0; }
static const struct firmware_ops platformX_firmware_ops = {
.do_idle = exynos_do_idle, .cpu_boot = exynos_cpu_boot;
/* other operations not available on platformX */ };
其他操作在platformX上不可行
/* init_early callback of machine descriptor */
init_early的回调机理描述
static void __init board_init_early(void) {
register_firmware_ops(&platformX_firmware_ops); }
Example of using a firmware operation:
利用固件操作的例子:
/* some platform code, e.g. SMP initialization */
一些平台的代码,例如SMP初始化
__raw_writel(virt_to_phys(exynos4_secondary_startup),CPU1_BOOT_REG);
/* Call Exynos specific smc call */
调用Exynos specific smc call
if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
cpu_boot_legacy(...);
/* Try legacy way */
尝试legacy方式
gic_raise_softirq(cpumask_of(cpu), 1);