GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
fpga_dma-proxy.h
Go to the documentation of this file.
1/*!
2 * \file fpga_dma-proxy.h
3 * \brief FPGA DMA control. This code is based in the Xilinx DMA proxy test application:
4 * https://github.com/Xilinx-Wiki-Projects/software-prototypes/tree/master/linux-user-space-dma/Software
5 * \author Marc Majoral, mmajoral(at)cttc.es
6 *
7 * -----------------------------------------------------------------------------
8 *
9 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10 * This file is part of GNSS-SDR.
11 *
12 * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)
13 * SPDX-License-Identifier: GPL-3.0-or-later
14 *
15 * -----------------------------------------------------------------------------
16 */
17
18#ifndef GNSS_SDR_FPGA_DMA_PROXY_H
19#define GNSS_SDR_FPGA_DMA_PROXY_H
20
21#include <cstdint> // for std::int8_t
22
23/*!
24 * \brief Class that controls the switch DMA in the FPGA
25 */
27{
28public:
29 /*!
30 * \brief Default constructor.
31 */
32 Fpga_DMA() = default;
33
34 /*!
35 * \brief Default destructor.
36 */
37 ~Fpga_DMA() = default;
38
39 /*!
40 * \brief Open the DMA device driver.
41 */
42 int DMA_open(void);
43
44 /*!
45 * \brief Obtain DMA buffer address.
46 */
47 int8_t *get_buffer_address(void); // NOLINT(readability-make-member-function-const)
48
49 /*!
50 * \brief Transfer DMA data
51 */
52 int DMA_write(int nbytes) const;
53
54 /*!
55 * \brief Close the DMA device driver
56 */
57 int DMA_close(void) const;
58
59private:
60 static const uint32_t DMA_MAX_BUFFER_SIZE = (128 * 1024); /* must match driver exactly */
61 static const uint32_t TX_BUFFER_COUNT = 1;
62
63 // channel buffer structure
64 struct channel_buffer
65 {
66 int8_t buffer[DMA_MAX_BUFFER_SIZE];
67 enum proxy_status
68 {
69 PROXY_NO_ERROR = 0,
70 PROXY_BUSY = 1,
71 PROXY_TIMEOUT = 2,
72 PROXY_ERROR = 3
73 } status;
74 unsigned int length;
75 } __attribute__((aligned(1024))); /* 64 byte alignment required for DMA, but 1024 handy for viewing memory */
76
77 // internal DMA channel data structure
78 struct channel
79 {
80 struct channel_buffer *buf_ptr;
81 int fd;
82 };
83
84 channel tx_channel;
85};
86#endif // GNSS_SDR_FPGA_DMA_PROXY_H
int8_t * get_buffer_address(void)
Obtain DMA buffer address.
Fpga_DMA()=default
Default constructor.
~Fpga_DMA()=default
Default destructor.
int DMA_write(int nbytes) const
Transfer DMA data.
int DMA_open(void)
Open the DMA device driver.
int DMA_close(void) const
Close the DMA device driver.