148bfb88eSYatharth Kochar /* 2101d01e2SSoby Mathew * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 348bfb88eSYatharth Kochar * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 548bfb88eSYatharth Kochar */ 648bfb88eSYatharth Kochar 748bfb88eSYatharth Kochar #ifndef __BL1_FWU_H__ 848bfb88eSYatharth Kochar #define __BL1_FWU_H__ 948bfb88eSYatharth Kochar 1048bfb88eSYatharth Kochar #include <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 */ 2948bfb88eSYatharth Kochar #define BL1_SMC_MAJOR_VER 0x0 3048bfb88eSYatharth Kochar #define BL1_SMC_MINOR_VER 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 6448bfb88eSYatharth Kochar #ifndef __ASSEMBLY__ 6548bfb88eSYatharth Kochar #include <cassert.h> 6648bfb88eSYatharth Kochar 67*7fabe1a8SRoberto Vargas struct entry_point_info; 68*7fabe1a8SRoberto Vargas 69*7fabe1a8SRoberto Vargas register_t bl1_smc_wrapper(uint32_t smc_fid, 70*7fabe1a8SRoberto Vargas void *cookie, 71*7fabe1a8SRoberto Vargas void *handle, 72*7fabe1a8SRoberto Vargas unsigned int flags); 73*7fabe1a8SRoberto Vargas 74*7fabe1a8SRoberto Vargas register_t bl1_smc_handler(unsigned int smc_fid, 75*7fabe1a8SRoberto Vargas register_t x1, 76*7fabe1a8SRoberto Vargas register_t x2, 77*7fabe1a8SRoberto Vargas register_t x3, 78*7fabe1a8SRoberto Vargas register_t x4, 79*7fabe1a8SRoberto Vargas void *cookie, 80*7fabe1a8SRoberto Vargas void *handle, 81*7fabe1a8SRoberto Vargas unsigned int flags); 82*7fabe1a8SRoberto Vargas 83*7fabe1a8SRoberto Vargas void bl1_print_next_bl_ep_info(const struct entry_point_info *bl_ep_info); 84*7fabe1a8SRoberto Vargas 85*7fabe1a8SRoberto Vargas void bl1_main(void); 86*7fabe1a8SRoberto Vargas 8748bfb88eSYatharth Kochar /* 8848bfb88eSYatharth Kochar * Check if the total number of FWU SMC calls are as expected. 8948bfb88eSYatharth Kochar */ 9048bfb88eSYatharth Kochar CASSERT(FWU_NUM_SMC_CALLS == \ 9148bfb88eSYatharth Kochar (FWU_SMC_FID_END - FWU_SMC_FID_START + 1),\ 9248bfb88eSYatharth Kochar assert_FWU_NUM_SMC_CALLS_mismatch); 9348bfb88eSYatharth Kochar 94101d01e2SSoby Mathew /* Utility functions */ 95101d01e2SSoby Mathew void bl1_calc_bl2_mem_layout(const meminfo_t *bl1_mem_layout, 96101d01e2SSoby Mathew meminfo_t *bl2_mem_layout); 97101d01e2SSoby Mathew 9848bfb88eSYatharth Kochar #endif /* __ASSEMBLY__ */ 9948bfb88eSYatharth Kochar #endif /* __BL1_FWU_H__ */ 100