summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/bus_training/pbusLinkSvc.H
blob: 141c1007fe76106e481ed9372b41bc5121daa3e5 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/bus_training/pbusLinkSvc.H $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/**
 *  @file pbusLinkSvc.H
 *
 *  Singleton service to provide validation of pbus connections and
 *  return validated valid connections
 *
 */

#ifndef __PBUSLINKSVC_H
#define __PBUSLINKSVC_H

#include    <stdint.h>
#include    <util/singleton.H>
#include    <map>

#include    <errl/errlentry.H>

//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>
#include    <targeting/common/trace.H>

//  fapi support
#include    <fapi.H>

namespace   EDI_EI_INITIALIZATION
{

using   namespace   TARGETING;
using   namespace   fapi;

typedef std::map<const TARGETING::Target*,
                 const TARGETING::Target*> TargetPairs_t;

class PbusLinkSvc
{

public:

    /**
     * @brief Get singleton instance of this class.
     *
     *  @return the (one and only) instance of PbusLinkSvc
     */
    static PbusLinkSvc& getTheInstance();

    /**
     * @brief getPbusConnections() will collect all pbus connections of
     *        the specified bus type. If this is the first time collection,
     *        it will perform the collection and save them into the vectors
     *        within the singleton. Then, it will make a copy into the
     *        caller's map whose reference is passed to this function.
     *  
     * @parm[out] o_PbusConnections, reference of a map for getting a copy
     *            of the map of specified bus connections
     * @parm[in]  i_busType, type of bus connection, TYPE_XBUS or TYPE_ABUS
     * @parm[in]  i_noDuplicate, set to true to eliminate duplicates, i.e.
     *            only (endpoint1,endpoint2) or (endpoint2,endpoint1) will
     *            be in the present in the map
     * @return    errlHndl_t if encountering an error, or NULL (no error)
     *  
     */

    errlHndl_t getPbusConnections( TargetPairs_t & o_PbusConnections,
                             TYPE i_busType,  bool i_noDuplicate = true );

protected:
    /**
     * @brief Constructor for the PbusLinkSvc object.
     */
    PbusLinkSvc();

    /**
     * @brief Destructor for the PbusLinkSvc object.
     */
    ~PbusLinkSvc();

private:
    /**
     * @note   Disable copy constructor and assignment operator
     */
    PbusLinkSvc(const PbusLinkSvc& i_right);
    PbusLinkSvc& operator=(const PbusLinkSvc& i_right);

    TargetPairs_t iv_abusUniqueConnections;
    TargetPairs_t iv_abusConnections;
    TargetPairs_t iv_xbusUniqueConnections;
    TargetPairs_t iv_xbusConnections;

    // Mutex serializing changes to the above four maps
    mutex_t iv_mutex;

    /**
     * @brief collectPbusConections() will collect all pbus connections of
     *        the specified bus type. It checks for mixed-type connection,
     *        conflicting connection, and invalid-same-chip connection.
     *        The connections are saved within the singleton.
     *  
     * @parm[in]  i_busType, type of bus connection, TYPE_XBUS or TYPE_ABUS
     * @return    errlHndl_t if encountering an error, or NULL (no error)
     *
     */
    errlHndl_t collectPbusConections( TYPE i_busType );

};

}

#endif
OpenPOWER on IntegriCloud