1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 */ 5 6 #include <gen-asm-defines.h> 7 #include <kernel/thread.h> 8 #include <sm/pm.h> 9 #include <sm/sm.h> 10 #include <types_ext.h> 11 #include "thread_private.h" 12 13 DEFINES 14 { 15 #ifdef ARM32 16 DEFINE(SM_NSEC_CTX_R0, offsetof(struct sm_nsec_ctx, r0)); 17 DEFINE(SM_NSEC_CTX_R8, offsetof(struct sm_nsec_ctx, r8)); 18 DEFINE(SM_SEC_CTX_R0, offsetof(struct sm_sec_ctx, r0)); 19 DEFINE(SM_SEC_CTX_MON_LR, offsetof(struct sm_sec_ctx, mon_lr)); 20 DEFINE(SM_CTX_SIZE, sizeof(struct sm_ctx)); 21 DEFINE(SM_CTX_NSEC, offsetof(struct sm_ctx, nsec)); 22 DEFINE(SM_CTX_SEC, offsetof(struct sm_ctx, sec)); 23 24 DEFINE(THREAD_VECTOR_TABLE_FIQ_ENTRY, 25 offsetof(struct thread_vector_table, fiq_entry)); 26 27 DEFINE(THREAD_SVC_REG_R0, offsetof(struct thread_svc_regs, r0)); 28 DEFINE(THREAD_SVC_REG_R5, offsetof(struct thread_svc_regs, r5)); 29 DEFINE(THREAD_SVC_REG_R6, offsetof(struct thread_svc_regs, r6)); 30 31 /* struct thread_core_local */ 32 DEFINE(THREAD_CORE_LOCAL_R0, offsetof(struct thread_core_local, r[0])); 33 DEFINE(THREAD_CORE_LOCAL_SM_PM_CTX_PHYS, 34 offsetof(struct thread_core_local, sm_pm_ctx_phys)); 35 DEFINE(THREAD_CORE_LOCAL_SIZE, sizeof(struct thread_core_local)); 36 37 DEFINE(SM_PM_CTX_SIZE, sizeof(struct sm_pm_ctx)); 38 #endif /*ARM32*/ 39 40 #ifdef ARM64 41 DEFINE(THREAD_SMC_ARGS_X0, offsetof(struct thread_smc_args, a0)); 42 DEFINE(THREAD_SMC_ARGS_SIZE, sizeof(struct thread_smc_args)); 43 44 DEFINE(THREAD_SVC_REG_X0, offsetof(struct thread_svc_regs, x0)); 45 DEFINE(THREAD_SVC_REG_X2, offsetof(struct thread_svc_regs, x2)); 46 DEFINE(THREAD_SVC_REG_X5, offsetof(struct thread_svc_regs, x5)); 47 DEFINE(THREAD_SVC_REG_X6, offsetof(struct thread_svc_regs, x6)); 48 DEFINE(THREAD_SVC_REG_X30, offsetof(struct thread_svc_regs, x30)); 49 DEFINE(THREAD_SVC_REG_ELR, offsetof(struct thread_svc_regs, elr)); 50 DEFINE(THREAD_SVC_REG_SPSR, offsetof(struct thread_svc_regs, spsr)); 51 DEFINE(THREAD_SVC_REG_SP_EL0, offsetof(struct thread_svc_regs, sp_el0)); 52 DEFINE(THREAD_SVC_REG_SIZE, sizeof(struct thread_svc_regs)); 53 54 /* struct thread_abort_regs */ 55 DEFINE(THREAD_ABT_REG_X0, offsetof(struct thread_abort_regs, x0)); 56 DEFINE(THREAD_ABT_REG_X2, offsetof(struct thread_abort_regs, x2)); 57 DEFINE(THREAD_ABT_REG_X30, offsetof(struct thread_abort_regs, x30)); 58 DEFINE(THREAD_ABT_REG_SPSR, offsetof(struct thread_abort_regs, spsr)); 59 DEFINE(THREAD_ABT_REGS_SIZE, sizeof(struct thread_abort_regs)); 60 61 /* struct thread_ctx */ 62 DEFINE(THREAD_CTX_KERN_SP, offsetof(struct thread_ctx, kern_sp)); 63 DEFINE(THREAD_CTX_SIZE, sizeof(struct thread_ctx)); 64 65 /* struct thread_ctx_regs */ 66 DEFINE(THREAD_CTX_REGS_SP, offsetof(struct thread_ctx_regs, sp)); 67 DEFINE(THREAD_CTX_REGS_X0, offsetof(struct thread_ctx_regs, x[0])); 68 DEFINE(THREAD_CTX_REGS_X1, offsetof(struct thread_ctx_regs, x[1])); 69 DEFINE(THREAD_CTX_REGS_X4, offsetof(struct thread_ctx_regs, x[4])); 70 DEFINE(THREAD_CTX_REGS_X19, offsetof(struct thread_ctx_regs, x[19])); 71 72 /* struct thread_user_mode_rec */ 73 DEFINE(THREAD_USER_MODE_REC_EXIT_STATUS0_PTR, 74 offsetof(struct thread_user_mode_rec, exit_status0_ptr)); 75 DEFINE(THREAD_USER_MODE_REC_X19, 76 offsetof(struct thread_user_mode_rec, x[0])); 77 DEFINE(THREAD_USER_MODE_REC_SIZE, sizeof(struct thread_user_mode_rec)); 78 79 /* struct thread_core_local */ 80 DEFINE(THREAD_CORE_LOCAL_X0, offsetof(struct thread_core_local, x[0])); 81 DEFINE(THREAD_CORE_LOCAL_X2, offsetof(struct thread_core_local, x[2])); 82 #endif /*ARM64*/ 83 84 /* struct thread_core_local */ 85 DEFINE(THREAD_CORE_LOCAL_TMP_STACK_VA_END, 86 offsetof(struct thread_core_local, tmp_stack_va_end)); 87 DEFINE(THREAD_CORE_LOCAL_CURR_THREAD, 88 offsetof(struct thread_core_local, curr_thread)); 89 DEFINE(THREAD_CORE_LOCAL_FLAGS, 90 offsetof(struct thread_core_local, flags)); 91 DEFINE(THREAD_CORE_LOCAL_ABT_STACK_VA_END, 92 offsetof(struct thread_core_local, abt_stack_va_end)); 93 94 } 95