summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/pm/p9_check_proc_config.H
blob: 1696eeb52f53cfd745d1180dc684355f62d76d0d (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_check_proc_config.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2017                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* 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                                                     */
#ifndef __CHECK_PROC_CONFIG_
#define __CHECK_PROC_CONFIG_


///
/// @file   p9_check_proc_config.H
/// @brief  describes interface for a HWP that generates a bit vector corresponding to P9 chip config.
///
/// *HWP HWP Owner:      Greg Still <stillgs@us.ibm.com>
/// *HWP FW Owner:       Prem S Jha <premjha2@in.ibm.com>
/// *HWP Team:           PM
/// *HWP Level:          3
/// *HWP Consumed by:    Hostboot:Phyp
//

//--------------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------------
#include <fapi2.H>
#include <stdint.h>
#include <map>


extern "C"
{
    typedef  const fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP > CONST_FAPI2_PROC;

//------------------------------------------------------------------------------

/// @brief    builds a STOP image using a refrence image as input.
/// @param[in]   i_procTgt        fapi2 target for processor chip.
/// @param[in]   i_pHomerImage    pointer to the beginning of the HOMER image buffer
/// @return   fapi2 return code
//
    fapi2::ReturnCode p9_check_proc_config( CONST_FAPI2_PROC& i_procTgt, void* i_pHomerImage );

//------------------------------------------------------------------------------

    typedef fapi2::ReturnCode( *p9_check_proc_config_FP_t ) ( CONST_FAPI2_PROC& i_procTgt,
            void* i_pHomerImage );

} // extern C

#ifndef __HOSTBOOT_MODULE
    extern     std::map< fapi2::TargetType, std::string > g_targetTypeMap;
#endif

/// @brief   checks proc configuration for a given chiplet type
/// @param[in]      i_procTgt          fapi2 target for processor chip.
/// @param[in]      i_type             target type
/// @param[inout]   io_configVector  fapi2 buffer
/// @param[in]      i_chipletStartPos  start position for given chiplet type in  config vector
/// @return   fapi2 return code
//
template< fapi2::TargetType K >
fapi2::ReturnCode checkChiplet( CONST_FAPI2_PROC& i_procTgt, fapi2::TargetType  i_type,
                                uint64_t& io_configVector, uint8_t i_chipletStartPos )
{
    auto l_childVector =
        i_procTgt.getChildren < K > ( fapi2::TARGET_STATE_PRESENT );

    uint64_t l_tempVector = 0;

    for( auto itv : l_childVector )
    {
        uint8_t l_chipletPos = 0;
        FAPI_TRY( FAPI_ATTR_GET( fapi2::ATTR_CHIP_UNIT_POS, itv, l_chipletPos ),
                  "Failed to get chiplet position " );

        if( itv.isFunctional() )
        {
            l_tempVector = 0x8000000000000000ull;
            uint8_t l_configPos = i_chipletStartPos + l_chipletPos;

            io_configVector |= (l_tempVector >> l_configPos);

#ifndef __HOSTBOOT_MODULE

            FAPI_INF( "Chiplet Type %s", g_targetTypeMap[i_type].c_str() );

#endif

            FAPI_INF( "Chiplet Pos 0x%08x Bit Pos 0x%02x UAV 0x%016lx",
                      l_chipletPos, l_configPos, io_configVector );
        }
    }

fapi_try_exit:

    FAPI_INF( "<< p9_check_proc_config" );
    return fapi2::current_err;
}

#endif //__CHECK_PROC_CONFIG_
OpenPOWER on IntegriCloud