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