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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [api_types.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_COMMON_API_TYPES_H__
18
#define __DEBUGGER_COMMON_API_TYPES_H__
19
 
20
#include <inttypes.h>
21
#if defined(_WIN32) || defined(__CYGWIN__)
22
// Exclude rarely-used stuff from Windows headers
23
#define WIN32_LEAN_AND_MEAN
24
#define _WINSOCK_DEPRECATED_NO_WARNINGS
25
#include <windows.h>
26
#include <ws2tcpip.h>
27
#include <process.h>
28
#include <conio.h>  // console input/output
29
#else /* Linux */
30
#include <netinet/in.h>
31
#include <netinet/tcp.h>
32
#include <arpa/inet.h>
33
#include <stdio.h>
34
#include <unistd.h>
35
#include <sys/types.h>
36
#include <sys/time.h>
37
#include <sys/socket.h>
38
#include <sys/ioctl.h>
39
#include <netdb.h>
40
#define __STDC_FORMAT_MACROS
41
#include <pthread.h>
42
#include <fcntl.h>
43
#include <termios.h>  // work with console
44
#include <errno.h>
45
#endif
46
 
47
namespace debugger {
48
 
49
#if defined(_WIN32) || defined(__CYGWIN__)
50
    typedef SOCKET socket_def;
51
    typedef int addr_size_t;
52
 
53
    typedef CRITICAL_SECTION mutex_def;
54
    typedef void *thread_def;   // HANDLE = void*
55
    typedef struct event_def {
56
        void *cond;             // HANDLE = void*
57
        bool state;
58
    } event_def;
59
    typedef unsigned thread_return_t;
60
    typedef thread_return_t (__stdcall* lib_thread_func)(void *args);
61
    typedef void *sharemem_def;   // HANDLE = void*
62
 
63
    #define RV_PRI64 "I64"
64
#else /* Linux */
65
    typedef int socket_def;
66
    typedef unsigned int addr_size_t;
67
    typedef pthread_t thread_def;
68
    typedef pthread_mutex_t mutex_def;
69
    typedef struct event_def {
70
        pthread_mutex_t mut;
71
        pthread_cond_t cond;
72
        bool state;
73
    } event_def;
74
    typedef void *thread_return_t;
75
    typedef thread_return_t (*lib_thread_func)(void *args);
76
    typedef int sharemem_def;
77
 
78
    # if defined(__WORDSIZE) && (__WORDSIZE == 64)
79
    #  define RV_PRI64 "l"
80
    # else
81
    #  define RV_PRI64 "ll"
82
    # endif
83
#endif
84
 
85
typedef struct LibThreadType {
86
    lib_thread_func func;
87
    void *args;
88
    thread_def Handle;
89
} LibThreadType;
90
 
91
union Reg8Type {
92
    uint8_t byte;
93
    int8_t sbyte;
94
    struct bits_type {
95
        uint8_t b0 : 1;
96
        uint8_t b1 : 1;
97
        uint8_t b2 : 1;
98
        uint8_t b3 : 1;
99
        uint8_t b4 : 1;
100
        uint8_t b5 : 1;
101
        uint8_t b6 : 1;
102
        uint8_t b7 : 1;
103
    } bits;
104
};
105
 
106
union Reg16Type {
107
    uint8_t buf[2];
108
    uint16_t word;
109
    Reg8Type r8[2];
110
    struct bits_type {
111
        uint16_t b0 : 1;
112
        uint16_t b1 : 1;
113
        uint16_t b2 : 1;
114
        uint16_t b3 : 1;
115
        uint16_t b4 : 1;
116
        uint16_t b5 : 1;
117
        uint16_t b6 : 1;
118
        uint16_t b7 : 1;
119
        uint16_t b8 : 1;
120
        uint16_t b9 : 1;
121
        uint16_t b10 : 1;
122
        uint16_t b11 : 1;
123
        uint16_t b12 : 1;
124
        uint16_t b13 : 1;
125
        uint16_t b14 : 1;
126
        uint16_t b15 : 1;
127
    } bits;
128
};
129
 
130
union Reg64Type {
131
    uint8_t buf[8];
132
    uint16_t buf16[4];
133
    uint32_t buf32[2];
134
    uint64_t val;
135
    Reg8Type r8[8];
136
    Reg16Type r16[4];
137
    struct bits_type {
138
        uint64_t b0 : 1;
139
        uint64_t b1 : 1;
140
        uint64_t b2 : 1;
141
        uint64_t b3 : 1;
142
        uint64_t b4 : 1;
143
        uint64_t b5 : 1;
144
        uint64_t b6 : 1;
145
        uint64_t b7 : 1;
146
        uint64_t b8 : 1;
147
        uint64_t b9 : 1;
148
        uint64_t b10 : 1;
149
        uint64_t b11 : 1;
150
        uint64_t b12 : 1;
151
        uint64_t b13 : 1;
152
        uint64_t b14 : 1;
153
        uint64_t b15 : 1;
154
        uint64_t b16 : 1;
155
        uint64_t b17 : 1;
156
        uint64_t b18 : 1;
157
        uint64_t b19 : 1;
158
        uint64_t b20 : 1;
159
        uint64_t b21 : 1;
160
        uint64_t b22 : 1;
161
        uint64_t b23 : 1;
162
        uint64_t b24 : 1;
163
        uint64_t b25 : 1;
164
        uint64_t b26 : 1;
165
        uint64_t b27 : 1;
166
        uint64_t b28 : 1;
167
        uint64_t b29 : 1;
168
        uint64_t b30 : 1;
169
        uint64_t b31 : 1;
170
    } bits;
171
};
172
 
173
}  // namespace debugger
174
 
175
#endif  // __DEBUGGER_COMMON_API_TYPES_H__

powered by: WebSVN 2.1.0

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