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 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      Common library types definition.
6
 */
7
 
8
#ifndef __DEBUGGER_API_TYPES_H__
9
#define __DEBUGGER_API_TYPES_H__
10
 
11
#include <inttypes.h>
12
#if defined(_WIN32) || defined(__CYGWIN__)
13
#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
14
#define _WINSOCK_DEPRECATED_NO_WARNINGS
15
#include <windows.h>
16
#include <ws2tcpip.h>
17
#include <process.h>
18
#include <conio.h>  // console input/output
19
#else /* Linux */
20
#include <netinet/in.h>
21
#include <netinet/tcp.h>
22
#include <arpa/inet.h>
23
#include <stdio.h>
24
#include <unistd.h>
25
#include <sys/types.h>
26
#include <sys/time.h>
27
#include <sys/socket.h>
28
#include <sys/ioctl.h>
29
#include <netdb.h>
30
#define __STDC_FORMAT_MACROS
31
#include <inttypes.h>
32
#include <pthread.h>
33
#include <fcntl.h>
34
#include <termios.h>  // work with console
35
#endif
36
 
37
namespace debugger {
38
 
39
#if defined(_WIN32) || defined(__CYGWIN__)
40
    typedef SOCKET socket_def;
41
    typedef int addr_size_t;
42
 
43
    typedef CRITICAL_SECTION mutex_def;
44
    typedef void *thread_def; // HANDLE = void*
45
    typedef struct event_def {
46
        void *cond; // HANDLE = void*
47
        bool state;
48
    } event_def;
49
    typedef unsigned thread_return_t;
50
    typedef thread_return_t (__stdcall* lib_thread_func)(void *args);
51
 
52
    #define RV_PRI64 "I64"
53
#else /* Linux */
54
    typedef int socket_def;
55
    typedef unsigned int addr_size_t;
56
    typedef pthread_t thread_def;
57
    typedef pthread_mutex_t mutex_def;
58
    typedef struct event_def {
59
        pthread_mutex_t mut;
60
        pthread_cond_t cond;
61
        bool state;
62
    } event_def;
63
    typedef void *thread_return_t;
64
    typedef thread_return_t (*lib_thread_func)(void *args);
65
 
66
    # if defined(__WORDSIZE) && (__WORDSIZE == 64)
67
    #  define RV_PRI64 "l"
68
    # else
69
    #  define RV_PRI64 "ll"
70
    # endif
71
#endif
72
 
73
typedef struct LibThreadType
74
{
75
    lib_thread_func func;
76
    void *args;
77
    thread_def Handle;
78
} LibThreadType;
79
 
80
union Reg64Type {
81
    uint8_t buf[8];
82
    uint16_t buf16[4];
83
    uint32_t buf32[2];
84
    uint64_t val;
85
};
86
 
87
}  // namespace debugger
88
 
89
#endif  // __DEBUGGER_API_TYPES_H__

powered by: WebSVN 2.1.0

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