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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [libdbg64g/] [services/] [debug/] [serial_dbglink.h] - Rev 5

Compare with Previous | Blame | View Log

/*
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
 
#ifndef __DEBUGGER_SERIAL_DBGLINK_SERVICE_H__
#define __DEBUGGER_SERIAL_DBGLINK_SERVICE_H__
 
#include "iclass.h"
#include "iservice.h"
#include "coreservices/itap.h"
#include "coreservices/iserial.h"
#include "coreservices/irawlistener.h"
 
namespace debugger {
 
#define MAGIC_ID 0x31
static const int UART_REQ_HEADER_SZ = 10;
static const int UART_MST_BURST_MAX = 64;
 
#pragma pack(1)
struct UartMstPacketType {
    uint8_t magic;
    uint8_t cmd;
    uint64_t addr;
    uint32_t data[UART_MST_BURST_MAX];
};
#pragma pack()
 
union PacketType {
    UartMstPacketType fields;
    char buf[1];
};
 
class SerialDbgService : public IService,
                         public ITap,
                         public IRawListener {
public:
    SerialDbgService(const char *name);
    ~SerialDbgService();
 
    /** IService interface */
    virtual void postinitService();
    virtual void predeleteService();
 
    /** ITap interface */
    virtual int read(uint64_t addr, int bytes, uint8_t *obuf);
    virtual int write(uint64_t addr, int bytes, uint8_t *ibuf);
 
    /** IRawListener interface */
    virtual void updateData(const char *buf, int buflen);
 
private:
    AttributeType timeout_;
    AttributeType port_;
 
    ISerial *iserial_;
    event_def event_block_;
    PacketType pkt_;
    int rd_count_;
    int req_count_;
    int wait_bytes_;
    Reg64Type rxbuf_[UART_MST_BURST_MAX];
};
 
DECLARE_CLASS(SerialDbgService)
 
}  // namespace debugger
 
#endif  // __DEBUGGER_SERIAL_DBGLINK_SERVICE_H__
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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