blob: 4e011ee10ef7038839c006eba92eaa915ac9d5fa [file] [log] [blame]
Andrew F. Davis3a543a82019-04-12 12:54:45 -04001// SPDX-License-Identifier: GPL-2.0
2/*
3 * K3: Security functions
4 *
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 * Andrew F. Davis <afd@ti.com>
7 */
8
9#include <common.h>
10#include <dm.h>
11#include <linux/soc/ti/ti_sci_protocol.h>
12#include <mach/spl.h>
13#include <spl.h>
Lokesh Vutla78e51212019-09-09 12:47:38 +053014#include <asm/arch/sys_proto.h>
Andrew F. Davis3a543a82019-04-12 12:54:45 -040015
16void board_fit_image_post_process(void **p_image, size_t *p_size)
17{
Lokesh Vutla78e51212019-09-09 12:47:38 +053018 struct ti_sci_handle *ti_sci = get_ti_sci_handle();
19 struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops;
Andrew F. Davis3a543a82019-04-12 12:54:45 -040020 u64 image_addr;
21 u32 image_size;
22 int ret;
23
Andrew F. Davis3a543a82019-04-12 12:54:45 -040024 image_addr = (uintptr_t)*p_image;
25
26 debug("Authenticating image at address 0x%016llx\n", image_addr);
27
28 /* Authenticate image */
29 ret = proc_ops->proc_auth_boot_image(ti_sci, &image_addr, &image_size);
30 if (ret) {
31 printf("Authentication failed!\n");
32 hang();
33 }
34
35 /*
36 * The image_size returned may be 0 when the authentication process has
37 * moved the image. When this happens no further processing on the
38 * image is needed or often even possible as it may have also been
39 * placed behind a firewall when moved.
40 */
41 *p_size = image_size;
42
43 /*
44 * Output notification of successful authentication to re-assure the
45 * user that the secure code is being processed as expected. However
46 * suppress any such log output in case of building for SPL and booting
47 * via YMODEM. This is done to avoid disturbing the YMODEM serial
48 * protocol transactions.
49 */
50 if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
51 IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
52 spl_boot_device() == BOOT_DEVICE_UART))
53 printf("Authentication passed\n");
54}