blob: 17c4f4b1a120b8964e2482c57cad6e5c2f0800c4 [file] [log] [blame]
Mate Toth-Pal57fadaf2025-02-06 10:21:30 +01001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <app.h>
7#include <app_common.h>
8#include <app_services.h>
9#include <assert.h>
10#include <console.h>
11
12typedef uint64_t (*app_service_func)(struct app_data_cfg *app_data,
13 unsigned long arg0,
14 unsigned long arg1,
15 unsigned long arg2,
16 unsigned long arg3);
17
18static uint64_t app_service_print(struct app_data_cfg *app_data,
19 unsigned long arg0,
20 unsigned long arg1,
21 unsigned long arg2,
22 unsigned long arg3)
23{
24 size_t len = arg0;
25 size_t i;
26 size_t offset = 0;
27 char print_buf[4];
28
29 (void)arg1;
30 (void)arg2;
31 (void)arg3;
32
33 while (len > 0U) {
34 char *shared_page;
35 size_t to_print = len;
36
37 if (to_print > sizeof(print_buf)) {
38 to_print = sizeof(print_buf);
39 }
40 shared_page = app_data->el2_shared_page;
41 assert(shared_page != NULL);
42 (void)memcpy(print_buf, &shared_page[offset], to_print);
43 for (i = 0; i < to_print; ++i) {
44 (void)console_putc((int)print_buf[i]);
45 }
46 offset += to_print;
47 len -= to_print;
48 }
49 return 0;
50}
51
52static app_service_func service_functions[APP_SERVICE_COUNT] = {
53 [APP_SERVICE_PRINT] = app_service_print};
54
55uint64_t call_app_service(unsigned long service_id,
56 struct app_data_cfg *app_data,
57 unsigned long arg0,
58 unsigned long arg1,
59 unsigned long arg2,
60 unsigned long arg3)
61{
62 (void)arg0;
63 (void)arg1;
64 (void)arg2;
65 (void)arg3;
66
67 assert(service_id < APP_SERVICE_COUNT);
68 assert(service_functions[service_id] != NULL);
69
70 return service_functions[service_id](app_data, arg0, arg1, arg2, arg3);
71}
72