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 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Core API utils methods declaration.
6
 */
7
 
8
#ifndef __DEBUGGER_API_UTILS_H__
9
#define __DEBUGGER_API_UTILS_H__
10
 
11
#include <stdarg.h>
12
#include "api_types.h"
13
#include "attribute.h"
14
 
15
namespace debugger {
16
 
17
#define LOG_ERROR 1
18
#define LOG_INFO  3
19
#define LOG_DEBUG 4
20
 
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
 
25
/** Generate unique string. */
26
void RISCV_generate_name(AttributeType *name);
27
 
28
/** Redirect output to specified console. */
29
void RISCV_add_default_output(void *iout);
30
void RISCV_remove_default_output(void *iout);
31
 
32
/**
33
 * @brief Write output to logfile.
34
 * @return 0 on success, 1 when failed
35
 */
36
int RISCV_enable_log(const char *filename);
37
 
38
void RISCV_disable_log();
39
 
40
/** Format output to string. */
41
int RISCV_sprintf(char *s, size_t len, const char *fmt, ...);
42
 
43
/** Format output to the default stream. */
44
int RISCV_printf(void *iface, int level, const char *fmt, ...);
45
 
46
/** Output always */
47
#define RISCV_printf0(fmt, ...) \
48
    RISCV_printf(getInterface(IFACE_SERVICE), 0, fmt, __VA_ARGS__)
49
 
50
/** Output with the maximal logging level */
51
#define RISCV_error(fmt, ...) \
52
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_ERROR, "%s:%d " fmt, \
53
                 __FILE__, __LINE__, __VA_ARGS__)
54
 
55
/** Output with the information logging level */
56
#define RISCV_info(fmt, ...) \
57
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_INFO, fmt, __VA_ARGS__)
58
 
59
/** Output with the lower logging level */
60
#define RISCV_debug(fmt, ...) \
61
    RISCV_printf(getInterface(IFACE_SERVICE), LOG_DEBUG, fmt, __VA_ARGS__)
62
 
63
/** Suspend thread on certain number of milliseconds */
64
void RISCV_sleep_ms(int ms);
65
 
66
/** Get current time in milliseconds. */
67
uint64_t RISCV_get_time_ms();
68
 
69
/** Get process ID. */
70
int RISCV_get_pid();
71
 
72
void RISCV_thread_create(void *data);
73
uint64_t RISCV_thread_id();
74
 
75
int RISCV_mutex_init(mutex_def *mutex);
76
int RISCV_mutex_lock(mutex_def *mutex);
77
int RISCV_mutex_unlock(mutex_def *mutex);
78
int RISCV_mutex_destroy(mutex_def *mutex);
79
void RISCV_thread_join(thread_def th, int ms);
80
 
81
void RISCV_event_create(event_def *ev, const char *name);
82
void RISCV_event_close(event_def *ev);
83
void RISCV_event_set(event_def *ev);
84
int RISCV_event_is_set(event_def *ev);
85
void RISCV_event_clear(event_def *ev);
86
void RISCV_event_wait(event_def *ev);
87
int RISCV_event_wait_ms(event_def *ev, int ms);
88
 
89
/** Memory allocator/de-allocator */
90
void *RISCV_malloc(uint64_t sz);
91
void RISCV_free(void *p);
92
 
93
/** Get absolute directory where core library is placed. */
94
int RISCV_get_core_folder(char *out, int sz);
95
 
96
/** Set $(pwd) directory equals to executable location */
97
void RISCV_set_current_dir();
98
 
99
/** Reading configuration from JSON formatted file. */
100
int RISCV_read_json_file(const char *filename, void *outattr);
101
 
102
/** Write configuration string to JSON formatted file. */
103
void RISCV_write_json_file(const char *filename, const char *s);
104
 
105
#ifdef __cplusplus
106
}
107
#endif
108
 
109
}  // namespace debugger
110
 
111
#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.