1 #include <common/debug.h>
2 #include <smccc_helpers.h>
3 #include <services/ffa_svc.h>
4 #include <services/logical_sp.h>
5
6 #define LP_PARTITION_ID 0xC000
7 #define LP_UUID {0x0, 0x0, 0x0, 0x12}
8
sp_init(void)9 static int64_t sp_init(void) {
10 // TODO: Do some initialisation.
11 INFO("LSP: Init function called.\n");
12 return 0;
13 }
14
handle_ffa_direct_request(uint32_t smc_fid,bool secure_origin,uint64_t x1,uint64_t x2,uint64_t x3,uint64_t x4,void * cookie,void * handle,uint64_t flags)15 static uint64_t handle_ffa_direct_request(uint32_t smc_fid, bool secure_origin, uint64_t x1, uint64_t x2,
16 uint64_t x3, uint64_t x4, void *cookie, void *handle, uint64_t flags) {
17 uint64_t ret;
18
19 /* Determine if we have a 64 or 32 direct request. */
20 if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC32) {
21 ret = FFA_MSG_SEND_DIRECT_RESP_SMC32;
22 } else if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC64) {
23 ret = FFA_MSG_SEND_DIRECT_RESP_SMC64;
24 }
25 else {
26 panic(); // Unknown SMC
27 }
28 /* TODO: Do something with the request. - Echo only*/
29 INFO("Logical Partition: Received Direct Request from %s world!\n", secure_origin ? "Secure" : "Normal");
30
31 /* SP's must always respond to their calls so we can populate our response directly. */
32 SMC_RET8(handle, ret, 0, 0, x4, 0, 0, 0, 0);
33 }
34
35 /* Register logical partition */
36 DECLARE_LOGICAL_PARTITION(
37 my_logical_partition,
38 sp_init, // Init Function
39 LP_PARTITION_ID, // FFA Partition ID
40 LP_UUID, // UUID
41 0x1, // Partition Properties. Can only receive direct messages.
42 handle_ffa_direct_request // Callback for direct requests.
43 );
44