summaryrefslogtreecommitdiffstats
path: root/src/usr/pnor/pnor_common.H
blob: e8b6bd4f8e8e4f4d4981906e2be9a74630175db5 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/pnor/pnor_common.H $                                  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2016                        */
/* [+] 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 PNOR_COMMON_H
#define PNOR_COMMON_H

#include <pnor/pnorif.H>
#include "pnor_utils.H"
#include "ffs.h"
#include <secureboot/service.H>

/************************************************************
*   Provides common functions for Hostboot IPL and runtime
*   code access to PNOR
************************************************************/
namespace PNOR {
    /**
     * @brief parse the TOC read from memory and store section
     *        information if the TOC is valid
     * @param[in] i_tocBuffer      Pointer to buffer containing a TOC
     * @param[out] o_TOC            sectionInformation of the TOC used
     * @return Error
     */
    errlHndl_t parseTOC(uint8_t* i_tocBuffer, PNOR::SectionData_t * o_TOC);

    /**
     *  @brief: determine the physical offset of ffs entry
     *          (to be used before readTOC is called)
     *  @param[in] i_tocAddress - ffs hdr pointing to a valid TOC
     *  @param[in] i_entryName  - Name of the ffs entry to find the offset of
     *  @param[out] o_offset    - physical offset of the ffs entry
     */
    void findPhysicalOffset(ffs_hdr* i_tocAddress,
                                  const char* i_entryName,
                                  uint64_t & o_offset);

    /**
     * @brief used to translate mmio offset stored in mbox scratch 2
     *        to physical offset of HBB Image
     * @param[out] o_hbbAddress Physical Offset of HB Base Image
     *                          associated with the current boot
     * @return Error
     */
    errlHndl_t mmioToPhysicalOffset(uint64_t& o_hbbAddress);


    /**
     * @brief used to translate HBB Address to MMIO offset
     * @param[in] i_hbbAddress  - Physical Offset of the HB Base image
     * @param[out] o_mmioOffest - MMIO Offset of the HB Base image
     */
     void physicalToMmioOffset(uint64_t  i_hbbAddress,
                               uint64_t& o_mmioOffset);

    /**
     * @brief Reads version header of section, hashes it, and extends to tpm
     *        buffer list.
     *
     * @parm i_addr  Offset into flash to read
     * @parm i_size  Number of bytes to read
     * @parm i_name  Name of PNOR section
     *
     * @return Error from operation
     */
    errlHndl_t extendHash(uint64_t i_addr, size_t i_size, const char* i_name);

}

#endif
OpenPOWER on IntegriCloud