用於註冊和呼叫 ARM 的韌體特定操作的介面¶
由 Tomasz Figa <t.figa@samsung.com> 編寫
有些板子執行著在 TrustZone 安全世界中執行的安全韌體,這改變了一些事情的初始化方式。 這使得需要為這些平臺提供一個介面來指定可用的韌體操作,並在需要時呼叫它們。
可以透過填寫一個帶有適當回撥的 struct firmware_ops 結構體,然後使用 register_firmware_ops() 函式註冊它來指定韌體操作。
void register_firmware_ops(const struct firmware_ops *ops)
ops 指標必須是非 NULL 的。 有關 struct firmware_ops 及其成員的更多資訊,請參見 arch/arm/include/asm/firmware.h 標頭檔案。
提供了一組預設的空操作,因此如果平臺不需要韌體操作,則無需設定任何內容。
為了呼叫韌體操作,提供了一個輔助宏
#define call_firmware_op(op, ...) \
((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
該宏檢查是否提供了該操作並呼叫它,否則返回 -ENOSYS 以指示給定操作不可用(例如,允許回退到舊操作)。
註冊韌體操作的示例
/* board file */
static int platformX_do_idle(void)
{
/* tell platformX firmware to enter idle */
return 0;
}
static int platformX_cpu_boot(int i)
{
/* tell platformX firmware to boot 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 */
};
/* init_early callback of machine descriptor */
static void __init board_init_early(void)
{
register_firmware_ops(&platformX_firmware_ops);
}
使用韌體操作的示例
/* some platform code, e.g. SMP initialization */
__raw_writel(__pa_symbol(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);