blob: ac87c2217212480ab4613727fe0a91804078ecd3 (
plain)
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
50
51
52
53
54
55
56
57
58
|
#pragma once
#include "internal/sys.hpp"
#include "window_hw_interface.hpp"
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace ipmi_flash
{
class LpcMapperAspeed : public HardwareMapperInterface
{
public:
static std::unique_ptr<HardwareMapperInterface>
createAspeedMapper(std::uint32_t regionAddress, std::size_t regionSize);
/* NOTE: This object is created and then never destroyed (unless ipmid
* stops/crashes, etc)
*/
LpcMapperAspeed(std::uint32_t regionAddress, std::size_t regionSize,
const internal::Sys* sys = &internal::sys_impl) :
regionAddress(regionAddress),
regionSize(regionSize), sys(sys){};
LpcMapperAspeed(const LpcMapperAspeed&) = delete;
LpcMapperAspeed& operator=(const LpcMapperAspeed&) = delete;
LpcMapperAspeed(LpcMapperAspeed&&) = default;
LpcMapperAspeed& operator=(LpcMapperAspeed&&) = default;
/* throws MapperException */
MemorySet open() override;
void close() override;
WindowMapResult mapWindow(std::uint32_t address,
std::uint32_t length) override;
/**
* Attempt to mmap the region.
*
* @return true on success, false otherwise.
*/
bool mapRegion();
private:
static const std::string lpcControlPath;
int mappedFd = -1;
std::uint8_t* mappedRegion = nullptr;
std::uint32_t regionAddress;
std::size_t regionSize;
const internal::Sys* sys;
};
} // namespace ipmi_flash
|