2 * K2HK: secure kernel command file
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
14 asm(".arch_extension sec\n\t");
16 int mon_install(u32 addr, u32 dpsc, u32 freq)
20 __asm__ __volatile__ (
28 : "r" (addr), "r" (dpsc), "r" (freq)
29 : "cc", "r0", "r1", "r2", "memory");
33 int mon_power_on(int core_id, void *ep)
45 : "r" (core_id), "r" (ep)
46 : "cc", "r0", "r1", "r2", "memory");
50 int mon_power_off(int core_id)
62 : "cc", "r0", "r1", "memory");
66 #ifdef CONFIG_TI_SECURE_DEVICE
67 #define KS2_HS_SEC_HEADER_LEN 0x60
68 #define KS2_HS_SEC_TAG_OFFSET 0x34
69 #define KS2_AUTH_CMD 130
72 * k2_hs_bm_auth() - Invokes security functions using a
73 * proprietary TI interface. This binary and source for
74 * this is available in the secure development package or
75 * SECDEV. For details on how to access this please refer
76 * doc/README.ti-secure
78 * @cmd: Secure monitor command
79 * @arg1: Argument for command
81 * returns non-zero value on success, zero on error
83 static int k2_hs_bm_auth(int cmd, void *arg1)
88 "stmfd r13!, {r4-r12, lr}\n"
92 "ldmfd r13!, {r4-r12, lr}\n"
94 : "r" (cmd), "r" (arg1)
95 : "cc", "r0", "r1", "memory");
100 void board_fit_image_post_process(void **p_image, size_t *p_size)
103 void *image = *p_image;
105 if (strncmp(image + KS2_HS_SEC_TAG_OFFSET, "KEYS", 4)) {
106 printf("No signature found in image!\n");
110 result = k2_hs_bm_auth(KS2_AUTH_CMD, image);
112 printf("Authentication failed!\n");
117 * Overwrite the image headers after authentication
118 * and decryption. Update size to reflect removal
121 memcpy(image, image + KS2_HS_SEC_HEADER_LEN, *p_size);
122 *p_size -= KS2_HS_SEC_HEADER_LEN;
125 * Output notification of successful authentication to re-assure the
126 * user that the secure code is being processed as expected. However
127 * suppress any such log output in case of building for SPL and booting
128 * via YMODEM. This is done to avoid disturbing the YMODEM serial
129 * protocol transactions.
131 if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
132 IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
133 spl_boot_device() == BOOT_DEVICE_UART))
134 printf("Authentication passed\n");