Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 1 | /* |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <common/bl_common.h> |
| 8 | #include <common/debug.h> |
| 9 | #include <drivers/arm/pl011.h> |
| 10 | #include <drivers/console.h> |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 11 | #include <services/rmm_core_manifest.h> |
| 12 | #include <services/rmmd_svc.h> |
| 13 | #include <services/trp/platform_trp.h> |
| 14 | #include <trp_helpers.h> |
| 15 | |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 16 | #include <plat/arm/common/plat_arm.h> |
| 17 | #include <platform_def.h> |
| 18 | |
| 19 | /******************************************************************************* |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 20 | * Received from boot manifest and populated here |
| 21 | ******************************************************************************/ |
| 22 | extern uint32_t trp_boot_manifest_version; |
| 23 | |
| 24 | /******************************************************************************* |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 25 | * Initialize the UART |
| 26 | ******************************************************************************/ |
| 27 | static console_t arm_trp_runtime_console; |
| 28 | |
AlexeiFedorov | 8e754f9 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 29 | static int arm_trp_process_manifest(struct rmm_manifest *manifest) |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 30 | { |
Javier Almansa Sobrino | 04a6f2f | 2022-12-01 17:20:45 +0000 | [diff] [blame] | 31 | /* padding field on the manifest must be RES0 */ |
| 32 | assert(manifest->padding == 0U); |
| 33 | |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 34 | /* Verify the Boot Manifest Version. Only the Major is considered */ |
| 35 | if (RMMD_MANIFEST_VERSION_MAJOR != |
| 36 | RMMD_GET_MANIFEST_VERSION_MAJOR(manifest->version)) { |
| 37 | return E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED; |
| 38 | } |
| 39 | |
| 40 | trp_boot_manifest_version = manifest->version; |
AlexeiFedorov | 8e754f9 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 41 | flush_dcache_range((uintptr_t)manifest, sizeof(struct rmm_manifest)); |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
AlexeiFedorov | 8e754f9 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 46 | void arm_trp_early_platform_setup(struct rmm_manifest *manifest) |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 47 | { |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 48 | int rc; |
| 49 | |
| 50 | rc = arm_trp_process_manifest(manifest); |
| 51 | if (rc != 0) { |
| 52 | trp_boot_abort(rc); |
| 53 | } |
| 54 | |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 55 | /* |
| 56 | * Initialize a different console than already in use to display |
| 57 | * messages from trp |
| 58 | */ |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 59 | rc = console_pl011_register(PLAT_ARM_TRP_UART_BASE, |
| 60 | PLAT_ARM_TRP_UART_CLK_IN_HZ, |
| 61 | ARM_CONSOLE_BAUDRATE, |
| 62 | &arm_trp_runtime_console); |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 63 | if (rc == 0) { |
| 64 | panic(); |
| 65 | } |
| 66 | |
| 67 | console_set_scope(&arm_trp_runtime_console, |
| 68 | CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME); |
| 69 | } |
| 70 | |
AlexeiFedorov | 8e754f9 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 71 | void trp_early_platform_setup(struct rmm_manifest *manifest) |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 72 | { |
Javier Almansa Sobrino | 4165e84 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 73 | arm_trp_early_platform_setup(manifest); |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 74 | } |