blob: 131376c5b51e029e5084c6cbb242b263937f557b [file] [log] [blame]
Matt Spinler0c0eeff2017-02-28 10:06:56 -06001#pragma once
2
Matt Spinler0c0eeff2017-02-28 10:06:56 -06003#include "targeting.hpp"
4
Patrick Venturef78d9042018-11-01 15:39:53 -07005#include <memory>
6
Matt Spinler0c0eeff2017-02-28 10:06:56 -06007namespace openpower
8{
9namespace cfam
10{
11namespace access
12{
13
14using cfam_address_t = uint16_t;
15using cfam_data_t = uint32_t;
16using cfam_mask_t = uint32_t;
17
18/**
19 * @brief Writes a CFAM (Common FRU Access Macro) register in a P9.
20 *
21 * Throws an exception on error.
22 *
23 * @param[in] target - The Target to perform the operation on
24 * @param[in] address - The register address to write to
25 * @param[in] data - The data to write
26 */
27void writeReg(const std::unique_ptr<openpower::targeting::Target>& target,
Patrick Venturef78d9042018-11-01 15:39:53 -070028 cfam_address_t address, cfam_data_t data);
Matt Spinler0c0eeff2017-02-28 10:06:56 -060029
30/**
31 * @brief Reads a CFAM (Common FRU Access Macro) register in a P9.
32 *
33 * Throws an exception on error.
34 *
35 * @param[in] target - The Target to perform the operation on
36 * @param[in] address - The register address to read
37 * @return - The register data
38 */
Patrick Venturef78d9042018-11-01 15:39:53 -070039cfam_data_t readReg(const std::unique_ptr<openpower::targeting::Target>& target,
40 cfam_address_t address);
Matt Spinler0c0eeff2017-02-28 10:06:56 -060041
42/**
43 * @brief Writes a CFAM (Common FRU Access Macro) register in a P9
44 * using a mask to specify the bits the modify.
45 *
46 * Only bits that are set in the mask parameter will be modified.
47 *
48 * Throws an exception on error.
49 *
50 * @param[in] target - The Target to perform the operation on
51 * @param[in] address - The register address to write to
52 * @param[in] data - The data to write
53 * @param[in] mask - The mask
54 */
55void writeRegWithMask(
56 const std::unique_ptr<openpower::targeting::Target>& target,
Patrick Venturef78d9042018-11-01 15:39:53 -070057 cfam_address_t address, cfam_data_t data, cfam_mask_t mask);
58} // namespace access
59} // namespace cfam
60} // namespace openpower