Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 1 | /* |
Daniel Boulby | 459eace | 2021-06-11 13:40:56 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 8 | #include <debug.h> |
Antonio Nino Diaz | 09a00ef | 2019-01-11 13:12:58 +0000 | [diff] [blame] | 9 | #include <drivers/console.h> |
| 10 | #include <drivers/arm/pl011.h> |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 11 | #include <errno.h> |
| 12 | #include <ivy_def.h> |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 13 | #include <plat_arm.h> |
| 14 | #include <platform_def.h> |
Antonio Nino Diaz | 2ac6f8f | 2018-07-02 09:04:07 +0100 | [diff] [blame] | 15 | #include <sp_helpers.h> |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 16 | |
| 17 | #include "ivy.h" |
| 18 | #include "ivy_def.h" |
| 19 | |
| 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 | |
| 24 | static void ivy_print_memory_layout(void) |
| 25 | { |
| 26 | NOTICE("Secure Partition memory layout:\n"); |
| 27 | |
| 28 | NOTICE(" Image regions\n"); |
| 29 | NOTICE(" Text region : %p - %p\n", |
| 30 | (void *)IVY_TEXT_START, (void *)IVY_TEXT_END); |
| 31 | NOTICE(" Read-only data region : %p - %p\n", |
| 32 | (void *)IVY_RODATA_START, (void *)IVY_RODATA_END); |
| 33 | NOTICE(" Data region : %p - %p\n", |
| 34 | (void *)IVY_DATA_START, (void *)IVY_DATA_END); |
| 35 | NOTICE(" BSS region : %p - %p\n", |
| 36 | (void *)IVY_BSS_START, (void *)IVY_BSS_END); |
| 37 | NOTICE(" Total image memory : %p - %p\n", |
| 38 | (void *)IVY_IMAGE_BASE, |
| 39 | (void *)(IVY_IMAGE_BASE + IVY_IMAGE_SIZE)); |
| 40 | NOTICE(" SPM regions\n"); |
| 41 | NOTICE(" SPM <-> SP buffer : %p - %p\n", |
| 42 | (void *)IVY_SPM_BUF_BASE, |
| 43 | (void *)(IVY_SPM_BUF_BASE + IVY_SPM_BUF_SIZE)); |
| 44 | NOTICE(" NS <-> SP buffer : %p - %p\n", |
| 45 | (void *)IVY_NS_BUF_BASE, |
| 46 | (void *)(IVY_NS_BUF_BASE + IVY_NS_BUF_SIZE)); |
| 47 | } |
| 48 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 49 | void __dead2 ivy_main(void) |
| 50 | { |
Daniel Boulby | 459eace | 2021-06-11 13:40:56 +0100 | [diff] [blame^] | 51 | u_register_t ret; |
| 52 | svc_args args; |
| 53 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 54 | console_init(PL011_UART3_BASE, |
| 55 | PL011_UART3_CLK_IN_HZ, |
| 56 | PL011_BAUDRATE); |
| 57 | |
| 58 | NOTICE("Booting test Secure Partition Ivy\n"); |
| 59 | NOTICE("%s\n", build_message); |
| 60 | NOTICE("%s\n", version_string); |
| 61 | NOTICE("Running at S-EL0\n"); |
| 62 | |
| 63 | ivy_print_memory_layout(); |
| 64 | |
Daniel Boulby | 459eace | 2021-06-11 13:40:56 +0100 | [diff] [blame^] | 65 | init: |
| 66 | args = (svc_args){.fid = FFA_MSG_WAIT}; |
| 67 | ret = sp_svc(&args); |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 68 | while (1) { |
Daniel Boulby | 459eace | 2021-06-11 13:40:56 +0100 | [diff] [blame^] | 69 | if (ret != FFA_MSG_SEND_DIRECT_REQ_SMC32) { |
| 70 | ERROR("unknown FF-A request %lx\n", ret); |
| 71 | goto init; |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 72 | } |
Daniel Boulby | 459eace | 2021-06-11 13:40:56 +0100 | [diff] [blame^] | 73 | VERBOSE("Received request: %lx\n", args.arg3); |
| 74 | args.fid = FFA_MSG_SEND_DIRECT_RESP_SMC32; |
| 75 | args.arg1 = 0x80020000; |
| 76 | args.arg2 = 0; |
| 77 | args.arg3 = 0; |
| 78 | ret = sp_svc(&args); |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 79 | } |
| 80 | } |