Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 1 | /* |
Harrison Mutai | faf3ac3 | 2024-01-04 16:18:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef BL1_H |
| 8 | #define BL1_H |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/bl_common.h> |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 11 | |
| 12 | /* |
| 13 | * Defines for BL1 SMC function ids. |
| 14 | */ |
| 15 | #define BL1_SMC_CALL_COUNT 0x0 |
| 16 | #define BL1_SMC_UID 0x1 |
| 17 | /* SMC #0x2 reserved */ |
| 18 | #define BL1_SMC_VERSION 0x3 |
| 19 | |
| 20 | /* |
| 21 | * Corresponds to the function ID of the SMC that |
| 22 | * the BL1 exception handler service to execute BL31. |
| 23 | */ |
| 24 | #define BL1_SMC_RUN_IMAGE 0x4 |
| 25 | |
| 26 | /* |
| 27 | * BL1 SMC version |
| 28 | */ |
Jimmy Brisson | a5f70aa | 2020-08-05 15:33:40 -0500 | [diff] [blame] | 29 | #define BL1_SMC_MAJOR_VER UL(0x0) |
| 30 | #define BL1_SMC_MINOR_VER UL(0x1) |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 31 | |
| 32 | /* |
| 33 | * Defines for FWU SMC function ids. |
| 34 | */ |
| 35 | |
| 36 | #define FWU_SMC_IMAGE_COPY 0x10 |
| 37 | #define FWU_SMC_IMAGE_AUTH 0x11 |
| 38 | #define FWU_SMC_IMAGE_EXECUTE 0x12 |
| 39 | #define FWU_SMC_IMAGE_RESUME 0x13 |
| 40 | #define FWU_SMC_SEC_IMAGE_DONE 0x14 |
| 41 | #define FWU_SMC_UPDATE_DONE 0x15 |
Antonio Nino Diaz | 0e8e720 | 2017-05-12 16:51:59 +0100 | [diff] [blame] | 42 | #define FWU_SMC_IMAGE_RESET 0x16 |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * Number of FWU calls (above) implemented |
| 46 | */ |
Antonio Nino Diaz | 0e8e720 | 2017-05-12 16:51:59 +0100 | [diff] [blame] | 47 | #define FWU_NUM_SMC_CALLS 7 |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 48 | |
| 49 | #if TRUSTED_BOARD_BOOT |
| 50 | # define BL1_NUM_SMC_CALLS (FWU_NUM_SMC_CALLS + 4) |
| 51 | #else |
| 52 | # define BL1_NUM_SMC_CALLS 4 |
| 53 | #endif |
| 54 | |
| 55 | /* |
| 56 | * The macros below are used to identify FWU |
| 57 | * calls from the SMC function ID |
| 58 | */ |
| 59 | #define FWU_SMC_FID_START FWU_SMC_IMAGE_COPY |
Antonio Nino Diaz | 0e8e720 | 2017-05-12 16:51:59 +0100 | [diff] [blame] | 60 | #define FWU_SMC_FID_END FWU_SMC_IMAGE_RESET |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 61 | #define is_fwu_fid(_fid) \ |
| 62 | ((_fid >= FWU_SMC_FID_START) && (_fid <= FWU_SMC_FID_END)) |
| 63 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 64 | #ifndef __ASSEMBLER__ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 65 | |
| 66 | #include <lib/cassert.h> |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 67 | |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 68 | struct entry_point_info; |
| 69 | |
Zelalem | 91d8061 | 2020-02-12 10:37:03 -0600 | [diff] [blame] | 70 | u_register_t bl1_smc_wrapper(uint32_t smc_fid, |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 71 | void *cookie, |
| 72 | void *handle, |
| 73 | unsigned int flags); |
| 74 | |
Zelalem | 91d8061 | 2020-02-12 10:37:03 -0600 | [diff] [blame] | 75 | u_register_t bl1_smc_handler(unsigned int smc_fid, |
| 76 | u_register_t x1, |
| 77 | u_register_t x2, |
| 78 | u_register_t x3, |
| 79 | u_register_t x4, |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 80 | void *cookie, |
| 81 | void *handle, |
| 82 | unsigned int flags); |
| 83 | |
| 84 | void bl1_print_next_bl_ep_info(const struct entry_point_info *bl_ep_info); |
| 85 | |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 86 | void bl1_setup(void); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 87 | void bl1_main(void); |
Roberto Vargas | 2ca18d9 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 88 | void bl1_plat_prepare_exit(entry_point_info_t *ep_info); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 89 | |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 90 | /* |
| 91 | * Check if the total number of FWU SMC calls are as expected. |
| 92 | */ |
Elyes Haouas | 183638f | 2023-02-13 10:05:41 +0100 | [diff] [blame] | 93 | CASSERT(FWU_NUM_SMC_CALLS == |
| 94 | (FWU_SMC_FID_END - FWU_SMC_FID_START + 1), |
Yatharth Kochar | 71c9a5e | 2015-10-10 19:06:53 +0100 | [diff] [blame] | 95 | assert_FWU_NUM_SMC_CALLS_mismatch); |
| 96 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 97 | #endif /* __ASSEMBLER__ */ |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 98 | #endif /* BL1_H */ |