forked from Sepanta/pcie-driver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1010 B
42 lines
1010 B
#ifndef SONOPCIEDEVICE_H
|
|
#define SONOPCIEDEVICE_H
|
|
|
|
#include <iostream>
|
|
|
|
#include "SonoException.h"
|
|
#include "Buffer.h"
|
|
|
|
#define KB * 1024
|
|
#define MB KB KB
|
|
#define TOTAL_BAR_NUM 3
|
|
#define TOTAL_DMA_BUFFER_NUM 16
|
|
#define DMA_SIZE 4 MB
|
|
|
|
class SonoPcieDevice
|
|
{
|
|
private:
|
|
Buffer_t bars[TOTAL_BAR_NUM];
|
|
Buffer_t dmaBuffers[TOTAL_DMA_BUFFER_NUM];
|
|
|
|
void initBars();
|
|
void initDmaBuffers();
|
|
|
|
public:
|
|
SonoPcieDevice();
|
|
|
|
void init();
|
|
|
|
void writeByte(uint32_t bar, uint32_t offset, uint8_t data);
|
|
void writeShort(uint32_t bar, uint32_t offset, uint16_t data);
|
|
void writeWord(uint32_t bar, uint32_t offset, uint32_t data);
|
|
void writeLong(uint32_t bar, uint32_t offset, uint64_t data);
|
|
|
|
uint8_t readByte(uint32_t bar, uint32_t offset);
|
|
uint16_t readShort(uint32_t bar, uint32_t offset);
|
|
uint32_t readWord(uint32_t bar, uint32_t offset);
|
|
uint64_t readLong(uint32_t bar, uint32_t offset);
|
|
|
|
uint8_t* getBufferPtr(uint32_t buffer);
|
|
};
|
|
|
|
#endif
|