summaryrefslogtreecommitdiffstats
path: root/bmc/window_hw_interface.hpp
blob: 7d15521e468d11dfeeb5d7f5fe5840f15612738c (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
59
60
61
62
63
#pragma once

#include <cstdint>
#include <utility>
#include <vector>

namespace ipmi_flash
{

struct MemorySet
{
    int mappedFd = -1;
    std::uint8_t* mapped = nullptr;
};

/** The result from the mapWindow command. */
struct WindowMapResult
{
    /* The response can validly be 0, or EFBIG.  If it's EFBIG that means the
     * region available is within the requested region. If the value is anything
     * else, it's a complete failure.
     */
    std::uint8_t response;
    std::uint32_t windowOffset;
    std::uint32_t windowSize;
};

/**
 * Different LPC (or P2a) memory map implementations may require different
 * mechanisms for specific tasks such as mapping the memory window or copying
 * out data.
 */
class HardwareMapperInterface
{
  public:
    virtual ~HardwareMapperInterface() = default;

    /**
     * Open the driver or whatever and map the region.
     */
    virtual MemorySet open() = 0;

    /**
     * Close the mapper.  This could mean, send an ioctl to turn off the region,
     * or unmap anything mmapped.
     */
    virtual void close() = 0;

    /**
     * Returns a windowOffset and windowSize if the requested window was mapped.
     *
     * TODO: If the length requested is too large, windowSize will be written
     * with the max size that the BMC can map and returns false.
     *
     * @param[in] address - The address for mapping (passed to LPC window)
     * @param[in] length - The length of the region
     * @return WindowMapResult - the result of the call
     */
    virtual WindowMapResult mapWindow(std::uint32_t address,
                                      std::uint32_t length) = 0;
};

} // namespace ipmi_flash
OpenPOWER on IntegriCloud