summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/nest/p9_l2_flush.H
blob: ae8488e201f0ad07c7a72fb63238fc949b7142de (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/nest/p9_l2_flush.H $       */
/*                                                                        */
/* OpenPOWER sbe Project                                                  */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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                                                     */

///
/// @file p9_l2_flush.H
/// @brief Flush the P9 L2 cache (FAPI)
///
/// *HWP HWP Owner   : Benjamin Gass <bgass@us.ibm.com>
/// *HWP FW Owner    : Thi Tran <thi@us.ibm.com>
/// *HWP Team        : Quad
/// *HWP Consumed by : FSP and SBE
/// *HWP Level       : 3
///
///  Procedure Additional Comments:
///
///  High-level procedure flow:
///    o Poll Purge Engine Command Register to confirm that purge engine
///      is idle before starting (fail if self-imposed timeout occurs)
///    o Write Purge Engine Command Register to kick off complete/requested
///      cache flush operation
///    o Poll Purge Engine Command Register to wait for completion of
///      flush (fail if self-imposed timeout occurs) & check for errors
///
///  Successful operations assumes that:
///    o System clocks are running
///    o While not strictly required, to guarantee a completely empty cache
///      at the end of the procedure execution, instructions should be
///      stopped on the core underneath the L2 being flushed before the flush
///      is executed
///

#ifndef _P9_L2_FLUSH_H_
#define _P9_L2_FLUSH_H_

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------

#include <fapi2.H>

//------------------------------------------------------------------------------
// Structure definitions
//------------------------------------------------------------------------------
namespace p9core
{

// This structure specifies the data needed in case when there
// is request for specific L2 purges
struct purgeData_t
{
    uint8_t iv_cmdType: 4;
    uint8_t iv_cmdMem: 3;
    uint8_t iv_cmdBank: 1;
    uint8_t iv_cmdCGC: 8;

    purgeData_t(): iv_cmdType(0),
        iv_cmdMem(0),
        iv_cmdBank(0),
        iv_cmdCGC(0) {}
};

} // end of p9core namespace

//------------------------------------------------------------------------------
// Function prototypes
//------------------------------------------------------------------------------
typedef fapi2::ReturnCode (*p9_l2_flush_FP_t)
(const fapi2::Target < fapi2::TARGET_TYPE_EX >& i_target,
 const p9core::purgeData_t& i_purgeData);

extern "C"
{

///-----------------------------------------------------------------------------
///
/// @brief  Check if any purge is in progress before issuing a new one.
///
/// @param[in]  i_target          => EX chiplet target
/// @param[in]  i_busyCount       => Max busy count waiting for idle
/// @param[out] o_prdPurgeCmdReg  => EX_PRD_PURGE_CMD_REG value.
///
/// @return FAPI2_RC_SUCCESS if engine status returns as idle (with no errors)
///         before maximum number of polls has been reached
///         else, return error.
    fapi2::ReturnCode purgeReadyCheck(
        const fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
        const uint64_t i_busyCount,
        fapi2::buffer<uint64_t>& o_prdPurgeCmdReg);

///-----------------------------------------------------------------------------
///
/// @brief  Utility function to check for a purge operation to be completed.
///         This function polls the EX_PRD_PURGE_CMD_REG_BUSY bit of
///         EX_PRD_PURGE_CMD_REG.
///           - If this bit is clear before the input loop threshold is
///             reached, it returns FAPi2_RC_SUCCESS.
///           - Otherwise, it returns an error code.
///
/// @param[in]  i_target          => EX chiplet target
/// @param[in]  i_busyCount       => Max busy count waiting for PURGE to complete.
/// @param[out] o_prdPurgeCmdReg  => EX_PRD_PURGE_CMD_REG value.
///
/// @return FAPI2_RC_SUCCESS if engine status returns as idle (with no errors)
///         before maximum number of polls has been reached
///         else, return error.
    fapi2::ReturnCode purgeCompleteCheck(
        const fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
        const uint64_t i_busyCount,
        fapi2::buffer<uint64_t>& o_prdPurgeCmdReg);

///-----------------------------------------------------------------------------
/// @brief Utility subroutine to setup and trigger a PRD PURGE based
///        on input purge data specification.
///
/// @param[in]  i_target          EX target
/// @param[in]  i_purgeData       Structure having values for MEM, CGC, BANK
///                               passed by the user
/// @param[in]  i_prdPurgeCmdReg  EX_PRD_PURGE_CMD_REG value.
///
/// @return  FAPI2_RC_SUCCESS if purge operation was started,
///          else error code.
///-----------------------------------------------------------------------------
    fapi2::ReturnCode setupAndTriggerPrdPurge(
        const fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
        const p9core::purgeData_t& i_purgeData,
        fapi2::buffer<uint64_t>& i_prdPurgeCmdReg);

///
/// @brief Flush entire content of L2 cache via purge engine
/// @param[in] i_target EX target
/// @param[in] i_purgeData Specifies a particular purge type
/// @return: FAPI2_RC_SUCCESS if purge operation completes successfully,
///          P9_L2_FLUSH_PURGE_REQ_OUTSTANDING
///              if called when existing L2 purge is in progress,
///          RC_P9_PURGE_COMPLETE_TIMEOUT
///              if purge operation does not complete in expected time,
///          RC_P9_PURGE_CMD_REG_ERR
///              if purge operation reports error,
///          else FAPI getscom/putscom return code for failing operation
///
    fapi2::ReturnCode p9_l2_flush(
        const fapi2::Target < fapi2::TARGET_TYPE_EX >&   i_target,
        const p9core::purgeData_t& i_purgeData);

} // end of extern C

#endif // _P9_L2_FLUSH_H_
OpenPOWER on IntegriCloud