Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | #include <console.h> |
| 9 | #include <debug.h> |
| 10 | #include <pl011.h> |
| 11 | #include <plat_arm.h> |
| 12 | #include <platform_def.h> |
| 13 | #include <secure_partition.h> |
| 14 | #include <sp_helpers.h> |
| 15 | #include <spm_svc.h> |
| 16 | #include <std_svc.h> |
| 17 | |
| 18 | #include "cactus.h" |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 19 | #include "cactus_def.h" |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 20 | #include "cactus_tests.h" |
| 21 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 22 | /* Host machine information injected by the build system in the ELF file. */ |
| 23 | extern const char build_message[]; |
| 24 | extern const char version_string[]; |
| 25 | |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 26 | static void cactus_print_memory_layout(void) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 27 | { |
| 28 | NOTICE("Secure Partition memory layout:\n"); |
| 29 | |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 30 | NOTICE(" Image regions\n"); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 31 | NOTICE(" Text region : %p - %p\n", |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 32 | (void *)CACTUS_TEXT_START, (void *)CACTUS_TEXT_END); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 33 | NOTICE(" Read-only data region : %p - %p\n", |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 34 | (void *)CACTUS_RODATA_START, (void *)CACTUS_RODATA_END); |
| 35 | NOTICE(" Data region : %p - %p\n", |
| 36 | (void *)CACTUS_DATA_START, (void *)CACTUS_DATA_END); |
| 37 | NOTICE(" BSS region : %p - %p\n", |
| 38 | (void *)CACTUS_BSS_START, (void *)CACTUS_BSS_END); |
| 39 | NOTICE(" Total image memory : %p - %p\n", |
| 40 | (void *)CACTUS_IMAGE_BASE, |
| 41 | (void *)(CACTUS_IMAGE_BASE + CACTUS_IMAGE_SIZE)); |
| 42 | NOTICE(" SPM regions\n"); |
| 43 | NOTICE(" SPM <-> SP buffer : %p - %p\n", |
| 44 | (void *)CACTUS_SPM_BUF_BASE, |
| 45 | (void *)(CACTUS_SPM_BUF_BASE + CACTUS_SPM_BUF_SIZE)); |
| 46 | NOTICE(" NS <-> SP buffer : %p - %p\n", |
| 47 | (void *)CACTUS_NS_BUF_BASE, |
| 48 | (void *)(CACTUS_NS_BUF_BASE + CACTUS_NS_BUF_SIZE)); |
| 49 | NOTICE(" Test regions\n"); |
| 50 | NOTICE(" Test region : %p - %p\n", |
| 51 | (void *)CACTUS_TEST_MEM_BASE, |
| 52 | (void *)(CACTUS_TEST_MEM_BASE + CACTUS_TEST_MEM_SIZE)); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 53 | } |
| 54 | |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 55 | void __dead2 cactus_main(void) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 56 | { |
Antonio Nino Diaz | 99f4fd2 | 2018-07-03 20:25:16 +0100 | [diff] [blame] | 57 | console_init(PL011_UART2_BASE, |
| 58 | PL011_UART2_CLK_IN_HZ, |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 59 | PL011_BAUDRATE); |
| 60 | |
| 61 | NOTICE("Booting test Secure Partition Cactus\n"); |
| 62 | NOTICE("%s\n", build_message); |
| 63 | NOTICE("%s\n", version_string); |
| 64 | NOTICE("Running at S-EL0\n"); |
| 65 | |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 66 | cactus_print_memory_layout(); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * Run some initial tests. |
| 70 | * |
| 71 | * These are executed when the system is still booting, just after SPM |
| 72 | * has handed over to Cactus. |
| 73 | */ |
| 74 | misc_tests(); |
| 75 | system_setup_tests(); |
Antonio Nino Diaz | 1486f3b | 2018-06-26 10:30:10 +0100 | [diff] [blame^] | 76 | mem_attr_changes_tests(); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * Handle secure service requests. |
| 80 | */ |
| 81 | secure_services_loop(); |
| 82 | } |