1 /* IBM_PROLOG_BEGIN_TAG                                                   */
2 /* This is an automatically generated prolog.                             */
3 /*                                                                        */
4 /* $Source: src/import/chips/p9/procedures/hwp/lib/p9_hcd_header_defs.H $ */
5 /*                                                                        */
6 /* OpenPOWER HostBoot Project                                             */
7 /*                                                                        */
8 /* Contributors Listed Below - COPYRIGHT 2016,2017                        */
9 /* [+] International Business Machines Corp.                              */
10 /*                                                                        */
11 /*                                                                        */
12 /* Licensed under the Apache License, Version 2.0 (the "License");        */
13 /* you may not use this file except in compliance with the License.       */
14 /* You may obtain a copy of the License at                                */
15 /*                                                                        */
16 /*     http://www.apache.org/licenses/LICENSE-2.0                         */
17 /*                                                                        */
18 /* Unless required by applicable law or agreed to in writing, software    */
19 /* distributed under the License is distributed on an "AS IS" BASIS,      */
20 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
21 /* implied. See the License for the specific language governing           */
22 /* permissions and limitations under the License.                         */
23 /*                                                                        */
24 /* IBM_PROLOG_END_TAG                                                     */
25 ///
26 /// @file  p9_hcd_header_defs.H
27 /// @brief defines header constants based on file types
28 ///
29 /// This header contains those cpp manifest constants required for processing
30 /// the linker scripts used to generate OCC code images.  As these are used
31 /// by linker scripts as well as by C++ code, these cannot be solely be put
32 /// into a namespace. Prefixing these with the region name is the attempt
33 /// to make these globally unique when this header is included in C++ code.
34 ///
35 //  *HWP HWP Owner:        David Du   <daviddu@us.ibm.com>
36 //  *HWP Backup HWP Owner: Greg Still <stillgs@us.ibm.com>
37 //  *HWP FW Owner:         Prem Jha <premjha2@in.ibm.com>
38 //  *HWP Team:             PM
39 //  *HWP Level:            2
40 //  *HWP Consumed by:      PM
41 //
42 
43 #ifndef __HCD_HEADER_DEFS_H__
44 #define __HCD_HEADER_DEFS_H__
45 
46 /// Macros for generating an Hcode header section
47 ///
48 /// The CPP macros HCD_HDR_UINTxx generate equivalent code depending on
49 /// whether they are being called from assembler (where they actually
50 /// create the header section data) or from C (where they specifiy a
51 /// C-structure form of the contents of the header section.
52 ///
53 /// In assembler each invocation also creates space in the header section
54 
55 #ifdef __ASSEMBLER__
56 
57 // *INDENT-OFF*
58     .macro  hcd_header_uint64, symbol:req, value = 0
59     .global \symbol
60 \symbol\():
61     .quad (\value)
62     .endm
63 
64     .macro  hcd_header_uint32, symbol:req, value = 0
65     .global \symbol
66     \symbol\():
67     .long (\value)
68     .endm
69 
70     .macro  hcd_header_uint16, symbol:req, value = 0
71     .global \symbol
72 \symbol\():
73     .short (\value)
74     .endm
75 
76     .macro  hcd_header_uint8, symbol:req, value = 0
77     .global \symbol
78 \symbol\():
79     .byte (\value)
80     .endm
81 
82     .macro  hcd_header_uint8_vec, symbol:req, number:req, value = 0
83     .global \symbol
84 \symbol\():
85     .rept (\number)
86     .byte (\value)
87     .endr
88     .endm
89 
90     .macro  hcd_header_attn, symbol:req, number = 1
91     .global \symbol
92 \symbol\():
93     .rept (\number)
94     .long 0x00000200
95     .endr
96     .endm
97 
98     .macro  hcd_header_attn_pad, align:req
99     .balignl (\align), 0x00000200
100     .endm
101 
102      .macro  hcd_header_pad, align:req
103      .balignl (\align), 0
104      .endm
105 // *INDENT-ON*
106 
107 #define ULL(x) x
108 #define HCD_CONST(name, expr)   .set name, expr;
109 #define HCD_CONST64(name, expr) .set name, expr;
110 
111 #define HCD_HDR_UINT64(symbol, value) hcd_header_uint64 symbol value
112 #define HCD_HDR_UINT32(symbol, value) hcd_header_uint32 symbol value
113 #define HCD_HDR_UINT16(symbol, value) hcd_header_uint16 symbol value
114 #define HCD_HDR_UINT8(symbol, value)  hcd_header_uint8  symbol value
115 #define HCD_HDR_UINT8_VEC(symbol, number, value)  hcd_header_uint8_vec  symbol number value
116 #define HCD_HDR_ATTN(symbol, number)  hcd_header_attn symbol number
117 #define HCD_HDR_ATTN_PAD(align)       hcd_header_attn_pad align
118 #define HCD_HDR_PAD(align)            hcd_header_pad      align
119 
120 #else // NOT __ASSEMBLER__
121 
122 #ifdef __LINKERSCRIPT__
123 
124     #define ULL(x) x
125     #define POUND_DEFINE #define
126     #define HCD_CONST(name, expr)   POUND_DEFINE name expr
127     #define HCD_CONST64(name, expr) POUND_DEFINE name expr
128 
129 #else
130 
131     #define ULL(x) x##ull
132     #define HCD_CONST(name, expr)   enum { name = expr };
133     #define HCD_CONST64(name, expr) enum { name = expr };
134 
135     #define HCD_HDR_UINT64(symbol, value) uint64_t symbol
136     #define HCD_HDR_UINT32(symbol, value) uint32_t symbol
137     #define HCD_HDR_UINT16(symbol, value) uint16_t symbol
138     #define HCD_HDR_UINT8(symbol, value)  uint8_t  symbol
139     #define HCD_HDR_UINT8_VEC(symbol, number, value) uint8_t  symbol[number]
140     #define HCD_HDR_ATTN(symbol, number)  uint32_t symbol[number]
141     #define HCD_HDR_ATTN_PAD(align)
142     #define HCD_HDR_PAD(align)
143 
144 #endif // __LINKERSCRIPT__
145 #endif // __ASSEMBLER__
146 
147 // Stringification
148 
149 #define STR_HELPER(x) #x
150 #define STR(x) STR_HELPER(x)
151 
152 #endif // __HCD_HEADER_DEFS_H__
153