Documentation\arm\firmware

本文详细介绍了ARM平台下固件特定操作的注册和调用接口,包括CPU空闲模式进入、物理CPU启动地址设置、CPU启动、L2缓存初始化等操作。通过struct firmware_ops结构体定义操作,使用register_firmware_ops函数注册接口,以及call_firmware_op宏调用操作。示例代码展示了如何在主板文件中注册和使用这些操作。

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);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值