summaryrefslogtreecommitdiffstats
path: root/occ_bus.hpp
blob: bdb4fa468fc44511c14a259484813a354aa17b94 (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
#pragma once

#include <string>
#include <experimental/filesystem>

namespace open_power
{
namespace occ
{

namespace fs = std::experimental::filesystem;

/** @class Bus
 *  @brief Manages the bus on which the OCC device exists
 */
class Bus
{
    public:
        Bus() = delete;
        ~Bus() = default;
        Bus(const Bus&) = delete;
        Bus& operator=(const Bus&) = delete;
        Bus(Bus&&) = default;
        Bus& operator=(Bus&&) = default;

        /** @brief Constructs the Bus object
         *
         *  @param[in] instance - OCC device index
         */
        explicit Bus(int instance) :
            config("0" + std::to_string(instance) + ":0" +
                std::to_string(instance) + ":00:06")
        {
            // Nothing to do here
        }

        void reset() const;

    private:
        /** @brief Config value to be used to do bind and unbind */
        const std::string config;

        /**  @brief To bind the device to the OCC's bus driver, do:
         *
         *    Write 0x:0x:00:06 to: /sys/bus/fsi/drivers/sbefifo/bind
         */
        static fs::path bindPath;

        /**  @brief To un-bind the dvice from the OCC's bus driver, do:
         *    Write 0x:0x:00:06 to: /sys/bus/fsi/drivers/sbefifo/unbind
         */
        static fs::path unBindPath;
};

} // namespace occ
} // namespace open_power
OpenPOWER on IntegriCloud