blob: faf8cccd890b44677f921948910cfd13dcd2fe28 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
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 Diaz1486f3b2018-06-26 10:30:10 +010019#include "cactus_def.h"
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020020#include "cactus_tests.h"
21
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020022/* Host machine information injected by the build system in the ELF file. */
23extern const char build_message[];
24extern const char version_string[];
25
Antonio Nino Diaz1486f3b2018-06-26 10:30:10 +010026static void cactus_print_memory_layout(void)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020027{
28 NOTICE("Secure Partition memory layout:\n");
29
Antonio Nino Diaz1486f3b2018-06-26 10:30:10 +010030 NOTICE(" Image regions\n");
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020031 NOTICE(" Text region : %p - %p\n",
Antonio Nino Diaz1486f3b2018-06-26 10:30:10 +010032 (void *)CACTUS_TEXT_START, (void *)CACTUS_TEXT_END);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020033 NOTICE(" Read-only data region : %p - %p\n",
Antonio Nino Diaz1486f3b2018-06-26 10:30:10 +010034 (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 Bailleux3cd87d72018-10-09 11:12:55 +020053}
54
Antonio Nino Diaz1486f3b2018-06-26 10:30:10 +010055void __dead2 cactus_main(void)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020056{
Antonio Nino Diaz99f4fd22018-07-03 20:25:16 +010057 console_init(PL011_UART2_BASE,
58 PL011_UART2_CLK_IN_HZ,
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020059 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 Diaz1486f3b2018-06-26 10:30:10 +010066 cactus_print_memory_layout();
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020067
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 Diaz1486f3b2018-06-26 10:30:10 +010076 mem_attr_changes_tests();
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020077
78 /*
79 * Handle secure service requests.
80 */
81 secure_services_loop();
82}