1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2022, Linaro Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Description:
8 * Interface SCP-firmware console module with OP-TEE console resources.
9 */
10
11 #include <fwk_assert.h>
12 #include <fwk_attributes.h>
13 #include <fwk_event.h>
14 #include <fwk_log.h>
15 #include <fwk_mm.h>
16 #include <fwk_module.h>
17 #include <fwk_module_idx.h>
18 #include <fwk_status.h>
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <console.h>
23
mod_console_init(fwk_id_t module_id,unsigned int element_count,const void * data)24 static int mod_console_init(
25 fwk_id_t module_id,
26 unsigned int element_count,
27 const void *data)
28 {
29 return FWK_SUCCESS;
30 }
31
mod_console_element_init(fwk_id_t element_id,unsigned int unused,const void * data)32 static int mod_console_element_init(
33 fwk_id_t element_id,
34 unsigned int unused,
35 const void *data)
36 {
37 return FWK_SUCCESS;
38 }
39
40
mod_console_io_open(const struct fwk_io_stream * stream)41 static int mod_console_io_open(const struct fwk_io_stream *stream)
42 {
43 return FWK_SUCCESS;
44 }
45
mod_console_io_getch(const struct fwk_io_stream * restrict stream,char * restrict ch)46 static int mod_console_io_getch(
47 const struct fwk_io_stream *restrict stream,
48 char *restrict ch)
49 {
50 *ch = 'A';
51
52 return FWK_SUCCESS;
53 }
54
mod_console_io_putch(const struct fwk_io_stream * stream,char ch)55 static int mod_console_io_putch(const struct fwk_io_stream *stream, char ch)
56 {
57 console_putc(ch);
58 return FWK_SUCCESS;
59 }
60
mod_console_close(const struct fwk_io_stream * stream)61 static int mod_console_close(const struct fwk_io_stream *stream)
62 {
63 return FWK_SUCCESS;
64 }
65
66 const struct fwk_module module_optee_console = {
67 .type = FWK_MODULE_TYPE_DRIVER,
68
69 .init = mod_console_init,
70 .element_init = mod_console_element_init,
71
72 .adapter =
73 (struct fwk_io_adapter){
74 .open = mod_console_io_open,
75 .getch = mod_console_io_getch,
76 .putch = mod_console_io_putch,
77 .close = mod_console_close,
78 },
79 };
80
81 struct fwk_module_config config_optee_console = {
82 .elements = FWK_MODULE_STATIC_ELEMENTS({
83 [0] = {
84 .name = "printf",
85 .data = (void *)1
86 },
87 [1] = { 0 },
88 }),
89 };
90