OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [api_utils.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15
 */
16
 
17
#ifndef __DEBUGGER_API_UTILS_H__
18
#define __DEBUGGER_API_UTILS_H__
19
 
20
#include <stdarg.h>
21
#include <api_types.h>
22
#include <attribute.h>
23
 
24
namespace debugger {
25
 
26
#define LOG_ERROR     1
27
#define LOG_IMPORTANT 2   // can be used for the autotest messages
28
#define LOG_INFO      3
29
#define LOG_DEBUG     4
30
 
31
#ifdef __cplusplus
32
extern "C" {
33
#endif
34
 
35
/** Generate unique string. */
36
void RISCV_generate_name(AttributeType *name);
37
 
38
/** Redirect output to specified console. */
39
void RISCV_add_default_output(void *iout);
40
void RISCV_remove_default_output(void *iout);
41
 
42
/**
43
 * @brief Write output to logfile.
44
 * @return 0 on success, 1 when failed
45
 */
46
int RISCV_enable_log(const char *filename);
47
 
48
void RISCV_disable_log();
49
 
50
/** Format output to string. */
51
int RISCV_sprintf(char *s, size_t len, const char *fmt, ...);
52
 
53
/** Format output to the default stream. */
54
int RISCV_printf(void *iface, int level, const char *fmt, ...);
55
 
56
/** Output always */
57
#define RISCV_printf0(fmt, ...) \
58
    RISCV_printf(getInterface(IFACE_SERVICE), 0, fmt, __VA_ARGS__)
59
 
60
/** Output with the maximal logging level */
61
#define RISCV_error(fmt, ...) \
62
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_ERROR, "%s:%d " fmt, \
63
                 __FILE__, __LINE__, __VA_ARGS__)
64
 
65
/** Output with the information logging level */
66
#define RISCV_important(fmt, ...) \
67
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_IMPORTANT, fmt, __VA_ARGS__)
68
 
69
/** Output with the information logging level */
70
#define RISCV_info(fmt, ...) \
71
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_INFO, fmt, __VA_ARGS__)
72
 
73
/** Output with the lower logging level */
74
#define RISCV_debug(fmt, ...) \
75
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_DEBUG, fmt, __VA_ARGS__)
76
 
77
/** Suspend thread on certain number of milliseconds */
78
void RISCV_sleep_ms(int ms);
79
 
80
/** Get current time in milliseconds. */
81
uint64_t RISCV_get_time_ms();
82
 
83
/** Get process ID. */
84
int RISCV_get_pid();
85
 
86
/** Memory barrier */
87
void RISCV_memory_barrier();
88
 
89
void RISCV_thread_create(void *data);
90
uint64_t RISCV_thread_id();
91
 
92
int RISCV_mutex_init(mutex_def *mutex);
93
int RISCV_mutex_lock(mutex_def *mutex);
94
int RISCV_mutex_unlock(mutex_def *mutex);
95
int RISCV_mutex_destroy(mutex_def *mutex);
96
void RISCV_thread_join(thread_def th, int ms);
97
 
98
void RISCV_event_create(event_def *ev, const char *name);
99
void RISCV_event_close(event_def *ev);
100
void RISCV_event_set(event_def *ev);
101
int RISCV_event_is_set(event_def *ev);
102
void RISCV_event_clear(event_def *ev);
103
void RISCV_event_wait(event_def *ev);
104
int RISCV_event_wait_ms(event_def *ev, int ms);
105
 
106
sharemem_def RISCV_memshare_create(const char *name, int sz);
107
void* RISCV_memshare_map(sharemem_def h, int sz);
108
void RISCV_memshare_unmap(void *buf);
109
void RISCV_memshare_delete(sharemem_def h);
110
 
111
/** Memory allocator/de-allocator */
112
void *RISCV_malloc(uint64_t sz);
113
void RISCV_free(void *p);
114
 
115
/** Get absolute directory where core library is placed. */
116
int RISCV_get_core_folder(char *out, int sz);
117
 
118
/** Set $(pwd) directory equals to executable location */
119
void RISCV_set_current_dir();
120
 
121
/** Reading configuration from JSON formatted file. */
122
int RISCV_read_json_file(const char *filename, void *outattr);
123
 
124
/** Write configuration string to JSON formatted file. */
125
void RISCV_write_json_file(const char *filename, const char *s);
126
 
127
#ifdef __cplusplus
128
}
129
#endif
130
 
131
}  // namespace debugger
132
 
133
#endif  // __DEBUGGER_API_UTILS_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.