148bfb88eSYatharth Kochar /* 2*d158d425SBoyan Karatotev * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. 348bfb88eSYatharth Kochar * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 548bfb88eSYatharth Kochar */ 648bfb88eSYatharth Kochar 7c3cf06f1SAntonio Nino Diaz #ifndef BL1_H 8c3cf06f1SAntonio Nino Diaz #define BL1_H 948bfb88eSYatharth Kochar 1009d40e0eSAntonio Nino Diaz #include <common/bl_common.h> 1148bfb88eSYatharth Kochar 1248bfb88eSYatharth Kochar /* 1348bfb88eSYatharth Kochar * Defines for BL1 SMC function ids. 1448bfb88eSYatharth Kochar */ 1548bfb88eSYatharth Kochar #define BL1_SMC_CALL_COUNT 0x0 1648bfb88eSYatharth Kochar #define BL1_SMC_UID 0x1 1748bfb88eSYatharth Kochar /* SMC #0x2 reserved */ 1848bfb88eSYatharth Kochar #define BL1_SMC_VERSION 0x3 1948bfb88eSYatharth Kochar 2048bfb88eSYatharth Kochar /* 2148bfb88eSYatharth Kochar * Corresponds to the function ID of the SMC that 2248bfb88eSYatharth Kochar * the BL1 exception handler service to execute BL31. 2348bfb88eSYatharth Kochar */ 2448bfb88eSYatharth Kochar #define BL1_SMC_RUN_IMAGE 0x4 2548bfb88eSYatharth Kochar 2648bfb88eSYatharth Kochar /* 2748bfb88eSYatharth Kochar * BL1 SMC version 2848bfb88eSYatharth Kochar */ 29e1d5be56SJimmy Brisson #define BL1_SMC_MAJOR_VER UL(0x0) 30e1d5be56SJimmy Brisson #define BL1_SMC_MINOR_VER UL(0x1) 3148bfb88eSYatharth Kochar 3248bfb88eSYatharth Kochar /* 3348bfb88eSYatharth Kochar * Defines for FWU SMC function ids. 3448bfb88eSYatharth Kochar */ 3548bfb88eSYatharth Kochar 3648bfb88eSYatharth Kochar #define FWU_SMC_IMAGE_COPY 0x10 3748bfb88eSYatharth Kochar #define FWU_SMC_IMAGE_AUTH 0x11 3848bfb88eSYatharth Kochar #define FWU_SMC_IMAGE_EXECUTE 0x12 3948bfb88eSYatharth Kochar #define FWU_SMC_IMAGE_RESUME 0x13 4048bfb88eSYatharth Kochar #define FWU_SMC_SEC_IMAGE_DONE 0x14 4148bfb88eSYatharth Kochar #define FWU_SMC_UPDATE_DONE 0x15 429d6fc3c3SAntonio Nino Diaz #define FWU_SMC_IMAGE_RESET 0x16 4348bfb88eSYatharth Kochar 4448bfb88eSYatharth Kochar /* 4548bfb88eSYatharth Kochar * Number of FWU calls (above) implemented 4648bfb88eSYatharth Kochar */ 479d6fc3c3SAntonio Nino Diaz #define FWU_NUM_SMC_CALLS 7 4848bfb88eSYatharth Kochar 4948bfb88eSYatharth Kochar #if TRUSTED_BOARD_BOOT 5048bfb88eSYatharth Kochar # define BL1_NUM_SMC_CALLS (FWU_NUM_SMC_CALLS + 4) 5148bfb88eSYatharth Kochar #else 5248bfb88eSYatharth Kochar # define BL1_NUM_SMC_CALLS 4 5348bfb88eSYatharth Kochar #endif 5448bfb88eSYatharth Kochar 5548bfb88eSYatharth Kochar /* 5648bfb88eSYatharth Kochar * The macros below are used to identify FWU 5748bfb88eSYatharth Kochar * calls from the SMC function ID 5848bfb88eSYatharth Kochar */ 5948bfb88eSYatharth Kochar #define FWU_SMC_FID_START FWU_SMC_IMAGE_COPY 609d6fc3c3SAntonio Nino Diaz #define FWU_SMC_FID_END FWU_SMC_IMAGE_RESET 6148bfb88eSYatharth Kochar #define is_fwu_fid(_fid) \ 6248bfb88eSYatharth Kochar ((_fid >= FWU_SMC_FID_START) && (_fid <= FWU_SMC_FID_END)) 6348bfb88eSYatharth Kochar 64d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__ 6509d40e0eSAntonio Nino Diaz 6609d40e0eSAntonio Nino Diaz #include <lib/cassert.h> 6748bfb88eSYatharth Kochar 687fabe1a8SRoberto Vargas struct entry_point_info; 697fabe1a8SRoberto Vargas 702fe75a2dSZelalem u_register_t bl1_smc_wrapper(uint32_t smc_fid, 717fabe1a8SRoberto Vargas void *cookie, 727fabe1a8SRoberto Vargas void *handle, 737fabe1a8SRoberto Vargas unsigned int flags); 747fabe1a8SRoberto Vargas 752fe75a2dSZelalem u_register_t bl1_smc_handler(unsigned int smc_fid, 762fe75a2dSZelalem u_register_t x1, 772fe75a2dSZelalem u_register_t x2, 782fe75a2dSZelalem u_register_t x3, 792fe75a2dSZelalem u_register_t x4, 807fabe1a8SRoberto Vargas void *cookie, 817fabe1a8SRoberto Vargas void *handle, 827fabe1a8SRoberto Vargas unsigned int flags); 837fabe1a8SRoberto Vargas 847fabe1a8SRoberto Vargas void bl1_print_next_bl_ep_info(const struct entry_point_info *bl_ep_info); 857fabe1a8SRoberto Vargas 867fabe1a8SRoberto Vargas void bl1_main(void); 871af540efSRoberto Vargas void bl1_plat_prepare_exit(entry_point_info_t *ep_info); 887fabe1a8SRoberto Vargas 8948bfb88eSYatharth Kochar /* 9048bfb88eSYatharth Kochar * Check if the total number of FWU SMC calls are as expected. 9148bfb88eSYatharth Kochar */ 929a90d720SElyes Haouas CASSERT(FWU_NUM_SMC_CALLS == 939a90d720SElyes Haouas (FWU_SMC_FID_END - FWU_SMC_FID_START + 1), 9448bfb88eSYatharth Kochar assert_FWU_NUM_SMC_CALLS_mismatch); 9548bfb88eSYatharth Kochar 96d5dfdeb6SJulius Werner #endif /* __ASSEMBLER__ */ 97c3cf06f1SAntonio Nino Diaz #endif /* BL1_H */ 98