1 /*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdarg.h>
11 #include "nsi_cpu_es_if.h"
12
13 /*
14 * This file provides the interfaces the POSIX architecture and soc_inf
15 * expect from all boards that use them
16 */
17
posix_exit(int exit_code)18 void posix_exit(int exit_code)
19 {
20 nsi_exit(exit_code);
21 }
22
posix_vprint_error_and_exit(const char * format,va_list vargs)23 void posix_vprint_error_and_exit(const char *format, va_list vargs)
24 {
25 nsi_vprint_error_and_exit(format, vargs);
26 }
27
posix_vprint_warning(const char * format,va_list vargs)28 void posix_vprint_warning(const char *format, va_list vargs)
29 {
30 nsi_vprint_warning(format, vargs);
31 }
32
posix_vprint_trace(const char * format,va_list vargs)33 void posix_vprint_trace(const char *format, va_list vargs)
34 {
35 nsi_vprint_trace(format, vargs);
36 }
37
posix_print_error_and_exit(const char * format,...)38 void posix_print_error_and_exit(const char *format, ...)
39 {
40 va_list variable_args;
41
42 va_start(variable_args, format);
43 nsi_vprint_error_and_exit(format, variable_args);
44 va_end(variable_args);
45 }
46
posix_print_warning(const char * format,...)47 void posix_print_warning(const char *format, ...)
48 {
49 va_list variable_args;
50
51 va_start(variable_args, format);
52 nsi_vprint_warning(format, variable_args);
53 va_end(variable_args);
54 }
55
posix_print_trace(const char * format,...)56 void posix_print_trace(const char *format, ...)
57 {
58 va_list variable_args;
59
60 va_start(variable_args, format);
61 nsi_vprint_trace(format, variable_args);
62 va_end(variable_args);
63 }
64
posix_trace_over_tty(int file_number)65 int posix_trace_over_tty(int file_number)
66 {
67 return nsi_trace_over_tty(file_number);
68 }
69
posix_get_hw_cycle(void)70 uint64_t posix_get_hw_cycle(void)
71 {
72 return nsi_hws_get_time();
73 }
74