summaryrefslogtreecommitdiffstats
path: root/src/include/usr/util/utilmbox_scratch.H
blob: 0849c8c8fc86ea834d26866cc9c67b542859a0f4 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/util/utilmbox_scratch.H $                     */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,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 UTILMBOX_SCRATCH_H
#define UTILMBOX_SCRATCH_H

/**
 * @file utilmbox_scratch.H
 *
 * @brief Utilies to manipulate mbox scratch debug communication
 *
 * Used for creating and manipulating memory streams
 *
 */

/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <initservice/mboxRegs.H>

// Utility Includes

/*****************************************************************************/
// Forwards
/*****************************************************************************/

//*****************************************************************************/
// C o n s t a n t s
/*****************************************************************************/
namespace Util
{
    enum
    {
        MSG_TYPE_MASK           =       0xE0000000,
        MSG_COUNT_MASK          =       0x1F000000,
        MSG_USAGE_MASK          =       MSG_TYPE_MASK | MSG_COUNT_MASK,
        MSG_USAGE_SHIFT         =       24,
        MSG_DATA_SIZE_MASK      =        ~MSG_USAGE_MASK,

        MSG_TYPE_TRACE          =       0x00,
        MSG_TYPE_ATTRDUMP       =       0x01,
        MSG_TYPE_ATTROVERRIDE   =       0x02,
        MSG_TYPE_ATTRGET        =       0x03,

        //ATTR GET control words
        DEBUG_ATTRGET_FAPI_TYPE =       0x0,
        DEBUG_ATTRGET_FAPI_POS  =       0x1,
        DEBUG_ATTRGET_HASH      =       0x2,
    };

    /**
     * @brief This places the address and buffer size for the debug tool
     * into the mailbox scratch regs in a synchronous fashion.  It will also
     * wait for the tool to ack the reciept of data before returning
     *
     * @param[in] i_usage       1 byte of "usage" data.  Caller defined
     * @param[in] i_addr        Physical real address of buffer
     * @param[in] i_size        Size of data in bytes
     *
     * @return none
     */
    void writeDebugCommRegs(uint8_t i_usage, uint32_t i_addr, uint32_t i_size);

    /**
     * @brief This function writes data to mailbox scratch reg
     *  These scom addresses are always accessible and any errors are commited
     *  internally
     * @param[in] i_addr        Scom address of mailbox reg to write
     * @param[in] i_data        Data to write to mailbox
     *
     * @return none
     */
    void writeScratchReg(uint64_t i_addr, uint32_t i_data);

    /**
     * @brief This function reads data to mailbox scratch reg
     *  These scom addresses are always accessible and any errors are commited
     *  internally
     * @param[in] i_addr        Scom address of mailbox reg to read
     *
     * @return Data in mailbox scratch reg
     */
    uint32_t readScratchReg(uint64_t i_addr);

    /**
     * @brief This uses the stashed away mbox scratch regs to
     *         determine the frequency the SBE booted the nest
     *         at
     *
     * @return uint32_t -- Nest freq SBE booted with
     */
    uint32_t getBootNestFreq( void);

};

#endif //UTILMEM_H
OpenPOWER on IntegriCloud