1 /*
2  * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "uart_stdout.h"
9 #include "stdarg.h"
10 #include "string.h"
11 
12 /* Log level = debug */
13 int CC_PAL_logLevel = 3;
14 #define CC_PAL_MAX_LOG_LEVEL 3
15 
16 #include "cc_pal_log.h"
17 
18 
19 #define CC312_LOG_BUF_SIZE 64
20 
21 uint32_t CC_PAL_logMask = 0xFFFFFFFF;
22 
CC_PalLogInit(void)23 void CC_PalLogInit(void){}
24 
CC_PalLog(int level,const char * format,...)25 void CC_PalLog(int level, const char* format, ...)
26 {
27     (void) level;
28 
29     char buf[CC312_LOG_BUF_SIZE] = {0};
30     va_list args;
31     size_t format_len = strlen(format);
32 
33     if (format_len + 2 > CC312_LOG_BUF_SIZE) {
34         printf("CC312 logging error: Message too long\r\n");
35         return;
36     }
37 
38     va_start(args, format);
39 
40     /* CC312 lib doesn't insert CR characters, so it's done here */
41     strcpy(buf, format);
42     buf[format_len] = '\r';
43 
44     // TODO: replace with print function that works at higher isolation levels
45     vprintf(buf, args);
46 }
47