Summer Qin | 596f555 | 2022-01-27 18:04:06 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include "compiler_ext_defs.h" |
| 9 | #include "runtime_defs.h" |
| 10 | #include "sprt_partition_metadata_indicator.h" |
| 11 | #include "sprt_main.h" |
| 12 | |
| 13 | #if defined(__ICCARM__) |
| 14 | #pragma required = meta_init_c |
| 15 | #endif |
| 16 | |
Kevin Peng | 43160d5 | 2022-02-11 13:35:56 +0800 | [diff] [blame] | 17 | extern void common_sfn_thread(void); |
| 18 | |
Summer Qin | 596f555 | 2022-01-27 18:04:06 +0800 | [diff] [blame] | 19 | __used static uintptr_t runtime_init_c(void) |
| 20 | { |
Kevin Peng | 43160d5 | 2022-02-11 13:35:56 +0800 | [diff] [blame] | 21 | struct runtime_metadata_t *p_rt_meta; |
| 22 | |
| 23 | p_rt_meta = PART_METADATA(); |
| 24 | |
| 25 | if (p_rt_meta->n_sfn == 0) { |
| 26 | /* IPC Partition */ |
| 27 | return p_rt_meta->entry; |
| 28 | } else { |
| 29 | /* SFN Partition */ |
| 30 | return (uintptr_t)common_sfn_thread; |
| 31 | } |
Summer Qin | 596f555 | 2022-01-27 18:04:06 +0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | __naked void sprt_main(void) |
| 35 | { |
| 36 | __asm volatile( |
| 37 | #if !defined(__ICCARM__) |
| 38 | ".syntax unified \n" |
| 39 | #endif |
| 40 | "bl runtime_init_c \n" |
| 41 | "bx r0 \n" |
| 42 | ); |
| 43 | } |