1ed7fb7aeSJayanth Othayoth /**
2ed7fb7aeSJayanth Othayoth  * Copyright © 2022 IBM Corporation
3ed7fb7aeSJayanth Othayoth  *
4ed7fb7aeSJayanth Othayoth  * Licensed under the Apache License, Version 2.0 (the "License");
5ed7fb7aeSJayanth Othayoth  * you may not use this file except in compliance with the License.
6ed7fb7aeSJayanth Othayoth  * You may obtain a copy of the License at
7ed7fb7aeSJayanth Othayoth  *
8ed7fb7aeSJayanth Othayoth  *     http://www.apache.org/licenses/LICENSE-2.0
9ed7fb7aeSJayanth Othayoth  *
10ed7fb7aeSJayanth Othayoth  * Unless required by applicable law or agreed to in writing, software
11ed7fb7aeSJayanth Othayoth  * distributed under the License is distributed on an "AS IS" BASIS,
12ed7fb7aeSJayanth Othayoth  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ed7fb7aeSJayanth Othayoth  * See the License for the specific language governing permissions and
14ed7fb7aeSJayanth Othayoth  * limitations under the License.
15ed7fb7aeSJayanth Othayoth  */
16ed7fb7aeSJayanth Othayoth #pragma once
17ed7fb7aeSJayanth Othayoth 
18ed7fb7aeSJayanth Othayoth #include "extensions/phal/create_pel.hpp"
19ed7fb7aeSJayanth Othayoth 
20ed7fb7aeSJayanth Othayoth #include <sdeventplus/utility/timer.hpp>
21ed7fb7aeSJayanth Othayoth 
22ed7fb7aeSJayanth Othayoth #include <chrono>
23ed7fb7aeSJayanth Othayoth 
24ed7fb7aeSJayanth Othayoth namespace openpower::phal::clock
25ed7fb7aeSJayanth Othayoth {
26ed7fb7aeSJayanth Othayoth 
27ed7fb7aeSJayanth Othayoth /* Dbus event timer */
28ed7fb7aeSJayanth Othayoth using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
29ed7fb7aeSJayanth Othayoth 
30ed7fb7aeSJayanth Othayoth /**
31ed7fb7aeSJayanth Othayoth  * @class Manager - Represents the clock daily management functions
32ed7fb7aeSJayanth Othayoth  *
33ed7fb7aeSJayanth Othayoth  */
34ed7fb7aeSJayanth Othayoth class Manager
35ed7fb7aeSJayanth Othayoth {
36ed7fb7aeSJayanth Othayoth   public:
37ed7fb7aeSJayanth Othayoth     Manager() = delete;
38ed7fb7aeSJayanth Othayoth     Manager(const Manager&) = delete;
39ed7fb7aeSJayanth Othayoth     Manager(Manager&&) = delete;
40ed7fb7aeSJayanth Othayoth     Manager& operator=(const Manager&) = delete;
41ed7fb7aeSJayanth Othayoth     Manager& operator=(Manager&&) = delete;
42ed7fb7aeSJayanth Othayoth     ~Manager() = default;
43ed7fb7aeSJayanth Othayoth 
44ed7fb7aeSJayanth Othayoth     /**
45ed7fb7aeSJayanth Othayoth      * Constructor
46ed7fb7aeSJayanth Othayoth      * Starts the functions required to capture clock daily logger data.
47ed7fb7aeSJayanth Othayoth      *
48ed7fb7aeSJayanth Othayoth      * @param[in] event - sdeventplus event loop
49ed7fb7aeSJayanth Othayoth      */
50ed7fb7aeSJayanth Othayoth     Manager(const sdeventplus::Event& event);
51ed7fb7aeSJayanth Othayoth 
52ed7fb7aeSJayanth Othayoth     /**
53ed7fb7aeSJayanth Othayoth      * @brief Add a dbus timer
54ed7fb7aeSJayanth Othayoth      */
55ed7fb7aeSJayanth Othayoth     void addTimer();
56ed7fb7aeSJayanth Othayoth 
57ed7fb7aeSJayanth Othayoth     /**
58ed7fb7aeSJayanth Othayoth      * @brief Callback when a timer expires
59ed7fb7aeSJayanth Othayoth      */
60ed7fb7aeSJayanth Othayoth     void timerExpired();
61ed7fb7aeSJayanth Othayoth 
62ed7fb7aeSJayanth Othayoth     /**
63ed7fb7aeSJayanth Othayoth      * @brief utility function to create clock data log
64ed7fb7aeSJayanth Othayoth      */
65ed7fb7aeSJayanth Othayoth     void createClockDataLog();
66ed7fb7aeSJayanth Othayoth 
6791bf93e0SJayanth Othayoth     /**
6891bf93e0SJayanth Othayoth      * @brief Add processor specific CFAM data to daily logger.
6991bf93e0SJayanth Othayoth      *
7091bf93e0SJayanth Othayoth      * @param[in] proc - pdbg processor target
7191bf93e0SJayanth Othayoth      * @param[out] ffdcData - reference to clock data log
7291bf93e0SJayanth Othayoth      */
7391bf93e0SJayanth Othayoth     void addCFAMData(struct pdbg_target* proc,
7491bf93e0SJayanth Othayoth                      openpower::pel::FFDCData& clockDataLog);
7591bf93e0SJayanth Othayoth 
76*5ffe7fb7SJayanth Othayoth     /**
77*5ffe7fb7SJayanth Othayoth      * @brief Add clock specific register data to daily logger.
78*5ffe7fb7SJayanth Othayoth      *
79*5ffe7fb7SJayanth Othayoth      * @param[out] ffdcData - reference to clock data log
80*5ffe7fb7SJayanth Othayoth      */
81*5ffe7fb7SJayanth Othayoth     void addClockRegData(openpower::pel::FFDCData& clockDataLog);
82*5ffe7fb7SJayanth Othayoth 
83ed7fb7aeSJayanth Othayoth   private:
84ed7fb7aeSJayanth Othayoth     /* The sdeventplus even loop to use */
85ed7fb7aeSJayanth Othayoth     sdeventplus::Event _event;
86ed7fb7aeSJayanth Othayoth 
87ed7fb7aeSJayanth Othayoth     /** @brief Timer used for LEDs lamp test period */
88ed7fb7aeSJayanth Othayoth     sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
89ed7fb7aeSJayanth Othayoth };
90ed7fb7aeSJayanth Othayoth 
91ed7fb7aeSJayanth Othayoth } // namespace openpower::phal::clock
92