1 /* IBM_PROLOG_BEGIN_TAG                                                   */
2 /* This is an automatically generated prolog.                             */
3 /*                                                                        */
4 /* $Source: src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_image_help_base.H $ */
5 /*                                                                        */
6 /* OpenPOWER HostBoot Project                                             */
7 /*                                                                        */
8 /* COPYRIGHT International Business Machines Corp. 2012,2014              */
9 /*                                                                        */
10 /* Licensed under the Apache License, Version 2.0 (the "License");        */
11 /* you may not use this file except in compliance with the License.       */
12 /* You may obtain a copy of the License at                                */
13 /*                                                                        */
14 /*     http://www.apache.org/licenses/LICENSE-2.0                         */
15 /*                                                                        */
16 /* Unless required by applicable law or agreed to in writing, software    */
17 /* distributed under the License is distributed on an "AS IS" BASIS,      */
18 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
19 /* implied. See the License for the specific language governing           */
20 /* permissions and limitations under the License.                         */
21 /*                                                                        */
22 /* IBM_PROLOG_END_TAG                                                     */
23 // $Id: p8_image_help_base.H,v 1.18 2013/06/10 22:08:20 jeshua Exp $
24 //------------------------------------------------------------------------------
25 //  Title:  p8_image_help_base.H
26 //  Description:  Contains the most basic structures and defines needed for
27 //                image building and interpretation.
28 //------------------------------------------------------------------------------
29 #ifndef _P8_IMAGE_HELP_BASE_H_
30 #define _P8_IMAGE_HELP_BASE_H_
31 
32 #include <sbe_xip_image.h>
33 
34 //
35 // Various image/ring buffer sizes. Must be used by all users (VBU, FSP, HB, HBI, Cronus)
36 //
37 const uint32_t  MAX_REF_IMAGE_SIZE      =   5000000; // Max reference image size.
38 const uint32_t  FIXED_SEEPROM_WORK_SPACE=  128*1024; // Max work space for Seeprom img.
39 const uint32_t  MAX_SEEPROM_IMAGE_SIZE  =   56*1024; // Max Seeprom image size.
40 // Fixed SLW image size (Ensure 128-byte alignment.)
41 const uint32_t  FIXED_SLW_IMAGE_SIZE    = 1024*1024; // Fixed SLW image size for _fixed.
42 const uint32_t  FIXED_RING_BUF_SIZE     =     60000; // Fixed ring buf size for _fixed.
43 
44 const uint8_t   MAX_VPD_TYPES           =   2;   // #G and #R, so far.
45 #define         CHIPLET_ID_MIN            0x00
46 #define         CHIPLET_ID_MAX            0x1F
47 #define         CHIPLET_ID_EX_MIN         0x10
48 #define         CHIPLET_ID_EX_MAX         0x1F
49 const uint8_t   MAX_CHIPLETS            = CHIPLET_ID_MAX-CHIPLET_ID_MIN+1;
50 const uint32_t  ASM_RS4_LAUNCH_BUF_SIZE =  24; // Byte size of RS4 launch buffer.
51 const uint32_t  WF_ENCAP_SIZE           = 400; // Byte size of WF encapsulation.
52                                                // (Actually, only 304B but may change.)
53 const uint32_t  WF_WORST_CASE_SIZE_FAC  =   4; // WC WF size = 3x ring length.
54                                                // (Assumes 12B per write.)
55                                                // (4x w/waits instructions.)
56 const uint32_t  LISTING_STRING_SIZE     = 256;
57 const uint64_t  MAX_UINT64_T            = (uint64_t)0xFFFFFFFF<<32 | (uint64_t)0xFFFFFFFF;
58 
59 const uint8_t RING_SECTION_ID[] = {
60   SBE_XIP_SECTION_RINGS,
61   SBE_XIP_SECTION_DCRINGS,
62 };
63 const uint8_t RING_SECTION_ID_SIZE = sizeof(RING_SECTION_ID) / sizeof(RING_SECTION_ID[0]);
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 // Base (shared) ring layout for both RS4 and Wiggle-flip layouts.
70 typedef struct {
71   uint64_t entryOffset;
72   uint64_t backItemPtr;
73   uint32_t sizeOfThis;
74   uint32_t sizeOfMeta; // Exact size of meta data. Arbitrary size. Not null terminated.
75 } BaseRingLayout;
76 
77 // RS4 specific layout.
78 typedef struct {
79   uint64_t entryOffset;
80   uint64_t backItemPtr;
81   uint32_t sizeOfThis;
82   uint32_t sizeOfMeta; // Exact size of meta data. Arbitrary size. Not null terminated.
83   uint32_t ddLevel;
84   uint8_t  sysPhase;
85   uint8_t  override;
86   uint8_t  reserved1;
87   uint8_t  reserved2;
88 } Rs4RingLayout;
89 
90 // PairingInfo is used for pairing, or matching, a back pointer address of a
91 // ring block with its corresponding TOC name.
92 typedef struct {
93     uint64_t address;     // (in) Holds PORE backPtr addr of the ring
94     uint8_t  vectorpos;   // (in) Vector position of fwdPtr [0;31]
95                           //      max=0  for most VPD rings
96                           //      max=1  for all non-VPD rings
97                           //      max=1  for perv_ VPD rings
98                           //      max=15 for most VPD ex_ rings
99                           //      max=31 for 16 ex_ chiplets with override
100     char     *name;       // (out) TOC name
101     uint8_t  isvpd;       // (out) 0: Non-VPD ring  1: VPD ring
102     uint8_t  overridable; // (out) 0: No (most VPD rings)  1: Yes (all non-VPD rings)
103     uint8_t  override;    // (out) 0: base  1: override
104 } PairingInfo;
105 
106 
107 ///
108 /// ****************************************************************************
109 /// Function declares.
110 /// ****************************************************************************
111 ///
112 int over_write_ring_data_in_image(  void            *io_image,
113                                     const char      *i_ringName,
114                                     const void      *i_ringData,    // WF or RS4
115                                     const uint32_t  i_sizeRingData, // Byte size
116                                     const uint8_t   i_idxVector,
117                                     const uint8_t   i_override,
118                                     const uint8_t   i_overridable );
119 
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif //_P8_IMAGE_HELP_BASE_H_
126