summaryrefslogtreecommitdiffstats
path: root/src/include/usr/runtime/populate_hbruntime.H
blob: 329f0ccebac66780ad8c33f4423d428e01c6cb2a (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/runtime/populate_hbruntime.H $                */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017,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                                                     */
#ifndef POPULATE_HBRUNTIME_H
#define POPULATE_HBRUNTIME_H
#include <hdat/hdat.H>
#include <vector>
#include <utility>
#include <errl/errlentry.H>
#include <pnor/pnorif.H>

namespace RUNTIME
{

extern const uint64_t HB_RES_MEM_UPPER_LIMIT;
extern const uint64_t HB_RES_MEM_LOWER_LIMIT;

/**
 *  @brief Get the next Reserved HB memory range and set all member variables
 *         of struct. Additionally trace out relevant parts of the struct
 * @param[in] i_type, HDAT Range type
 * @param[in] i_rangeId, HDAT Range ID [Frequently node ID, see hdatMsVpdRhbAddrRange_t]
 * @param[in] i_startAddr, Range Starting Address
 * @param[in] i_size, Size of address space to reserve
 * @param[in] i_label, Label String Ptr
 * @param[in] i_permission, HDAT permission type [default read/write]
 * @param[in] i_checkMemoryLimit, check if we overflow the limit for hb reserved
 *            memory. False for PHYP component
 *
 * @return errlHndl_t, nullptr on success; otherwise errlog
 */
errlHndl_t setNextHbRsvMemEntry(HDAT::hdatMsVpdRhbAddrRangeType i_type,
                                uint16_t i_rangeId,
                                uint64_t i_startAddr,
                                uint64_t i_size,
                                const char* i_label,
                                HDAT::hdatRhbPermType i_permission =
                                                           HDAT::RHB_READ_WRITE,
                                bool i_checkMemoryLimit = true
                                );

/**
 *  @brief Map physical address to virtual
 *  @param[in]  i_addr Physical address
 *  @param[in]  i_size Size of block to be mapped, in bytes.
 *  @param[out] o_addr Virtual address
 *  @return Error handle if error
 */
errlHndl_t mapPhysAddr(uint64_t i_addr, size_t i_size, uint64_t& o_addr);

/**
 *  @brief Unmap virtual address block
 *  @param[in]  i_addr Virtual address
 *  @return Error handle if error
 */
errlHndl_t unmapVirtAddr(uint64_t i_addr);

/**
 *  @brief Pre verify Pnor sections and load into HB reserved memory
 *
 *  @param[in] i_sec - pnor section to pre-verify and load
 *  @param[in] i_secHdrExpected - Indicates if pnor section is expected to have
 *                                a secure header.
 *                              e.g. RINGOVD currently never has a secure header
 *
 *  @return Error handle if error
 */
errlHndl_t hbResvLoadSecureSection (PNOR::SectionId i_sec,
                                    bool i_secHdrExpected);

/**
 * @brief Check whether the given addr falls withing allowed hb reserved memory
 *        range.
 * @param[in] i_addr - phys address to check
 * @param[in] i_size - the size of the section starting with i_addr (needed to
 *                   verify the end limit of the section)
 * @return Error handle if error
 */
errlHndl_t checkHbResMemLimit(uint64_t i_addr,
                              uint64_t i_size);

} // End of Namespace
#endif

OpenPOWER on IntegriCloud