-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathudmabuf.h
50 lines (39 loc) · 1.03 KB
/
udmabuf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <string>
#include <string_view>
#include <fstream>
class udmabuf
{
public:
udmabuf();
explicit udmabuf(std::string_view name);
~udmabuf();
udmabuf(udmabuf&&) = default;
udmabuf(const udmabuf&) = delete;
udmabuf& operator=(udmabuf&&) = default;
void operator=(const udmabuf&) = delete;
std::ifstream get_prop(std::string_view name) const
{
std::string path = (m_class_path + "/").append(name);
return std::ifstream(path);
}
std::ofstream set_prop(std::string_view name) const
{
std::string path = (m_class_path + "/").append(name);
return std::ofstream(path);
}
void sync_for_cpu(unsigned long offset, unsigned long length) const;
const void *get() const;
void* get();
size_t size() const;
private:
void map();
private:
int m_fd = -1;
std::string m_name;
std::string m_dev_name;
std::string m_class_path;
size_t m_phys_addr = 0;
size_t m_size = 0;
void* m_ptr = nullptr;
};