Documentation\arm\firmware

来源:互联网 发布:linux 小数比较 编辑:程序博客网 时间:2024/04/28 03:39

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: biyu tang<tangbiyu17@qq.com>
---------------------------------------------------------------------
DocumentationDocumentation\arm\firmware的中文翻译


如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。


中文版维护者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版翻译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版校译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>

 

 

 

 


以下为正文
---------------------------------------------------------------------

Interface for registering and calling firmware-specific operations for ARM.
----
Written by Tomasz Figa <t.figa@samsung.com>

ARM中注册和调用firmware-specific操作的接口。
----
由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. This makes
a need to provide an interface for such platforms to specify available firmware
operations and call them when needed.

有些主板在TrustZone的安全世界中伴随着安全固件运行,这改变了有些事物初始化的方式。
这需要为这样的平台提供一个接口来指定可用的固件操作,并在需要的时候调用他们。

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.

有一个默认的空集的操作设置,所以没有必要设置任何东西,如果平台不要求固件操作。

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的信号那么给定的操作不可用(例如,从而使
退回到传统的操作)。

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 */
 if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
  cpu_boot_legacy(...); /* Try legacy way */

 gic_raise_softirq(cpumask_of(cpu), 1);

原创粉丝点击