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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [socsim_plugin/] [uartmst.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 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_SOCSIM_PLUGIN_UARTMST_H__
18
#define __DEBUGGER_SOCSIM_PLUGIN_UARTMST_H__
19
 
20
#include "iclass.h"
21
#include "iservice.h"
22
#include "coreservices/ithread.h"
23
#include "coreservices/imemop.h"
24
#include "coreservices/iserial.h"
25
#include "coreservices/iwire.h"
26
#include "coreservices/irawlistener.h"
27
#include "coreservices/imemop.h"
28
#include <string>
29
 
30
namespace debugger {
31
 
32
static const int UART_MST_BURST_MAX = 64;
33
 
34
#pragma pack(1)
35
struct UartMstPacketType {
36
    uint8_t cmd;
37
    Reg64Type addr;
38
    Reg64Type data[UART_MST_BURST_MAX];
39
};
40
#pragma pack()
41
 
42
class UartMst : public IService,
43
                public IThread,
44
                public IAxi4NbResponse,
45
                public ISerial {
46
public:
47
    UartMst(const char *name);
48
    ~UartMst();
49
 
50
    /** IService interface */
51
    virtual void postinitService();
52
 
53
    /** ISerial */
54
    virtual int writeData(const char *buf, int sz);
55
    virtual void registerRawListener(IFace *listener);
56
    virtual void unregisterRawListener(IFace *listener);
57
    virtual void getListOfPorts(AttributeType *list);
58
    virtual int openPort(const char *port, AttributeType settings);
59
    virtual void closePort();
60
 
61
    /** IAxi4NbResponse */
62
    virtual void nb_response(Axi4TransactionType *trans);
63
 
64
protected:
65
    /** IThread interface */
66
    virtual void busyLoop();
67
 
68
private:
69
    AttributeType listeners_;  // non-registering attribute
70
    AttributeType bus_;
71
 
72
    IMemoryOperation *ibus_;
73
    ISerial *itransport_;
74
 
75
    Axi4TransactionType trans_;
76
 
77
    mutex_def mutexListeners_;
78
    event_def event_request_;
79
    event_def event_accept_;
80
    event_def event_tap_;
81
 
82
    union TxBufferType {
83
        UartMstPacketType packet;
84
        uint8_t buf[sizeof(UartMstPacketType)];
85
    } txbuf_;
86
    int txbuf_sz_;
87
    bool baudrate_detect_;
88
 
89
    struct uart_map {
90
        volatile uint32_t status;
91
        volatile uint32_t scaler;
92
        uint32_t rsrv[2];
93
        volatile uint32_t data;
94
    } regs_;
95
};
96
 
97
DECLARE_CLASS(UartMst)
98
 
99
}  // namespace debugger
100
 
101
#endif  // __DEBUGGER_SOCSIM_PLUGIN_UARTMST_H__

powered by: WebSVN 2.1.0

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