summaryrefslogtreecommitdiffstats
path: root/src/ssx/pgp/pgp.h
blob: fb99e4f50263ca25f9b0df09075a862acae5db31 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#ifndef __PGP_H__
#define __PGP_H__

// $Id: pgp.h,v 1.1.1.1 2013/12/11 21:03:22 bcbrock Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ssx/pgp/pgp.h,v $
//-----------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2013
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//-----------------------------------------------------------------------------

/// \file pgp.h
/// \brief The PgP environment for SSX.

// This is a 'circular' reference in SSX, but included here to simplify PGAS
// programming. 

#ifndef CHIP_PGP
#define CHIP_PGP
#include "ppc405.h"
#endif  

// Can't include this here due to ordering issues.  It's included in
// ppc405_irq.h.
// #include "pgp_irq.h"

// Required for MMU Map declarations
#include "ppc405_mmu.h"

#include "pgp_common.h"
#include "pgp_core.h"
#include "pgp_trace.h"
#include "pgp_ocb.h"
#include "pgp_pba.h"
#include "pgp_pore.h"
#include "pgp_pmc.h"
#include "pgp_sramctl.h"
#include "pgp_vrm.h"
#include "pgp_id.h"
#include "pgp_centaur.h"

#include "pcbs_register_addresses.h"
#include "pcbs_firmware_registers.h"

#include "tod_register_addresses.h"
#include "tod_firmware_registers.h"

#include "plb_arbiter_register_addresses.h"
#include "plb_arbiter_firmware_registers.h"

#include "mcs_register_addresses.h"
#include "mcs_firmware_registers.h"

#include "centaur_firmware_registers.h"
#include "centaur_register_addresses.h"

#include "tpc_register_addresses.h"
#include "tpc_firmware_registers.h"

#include "oha_register_addresses.h"
#include "oha_firmware_registers.h"


// Include other driver headers

#include "pgp_async.h"

/// \defgroup memory_map Real-mode memory map setup for SRAM-resident applications
///
/// Below are the interpretations of the default settings of the real-mode
/// memory control registers.  All of the settings can be overridden as
/// compile switches for special test purposes.
///
/// The final 128MB of memory (the SRAM) is mapped both I- and
/// D-cacheable. The other 7 high-memory regions aliased by the SRAM remain
/// uncacheable, however SRAM alias region 29 is marked write-through.
/// 
/// Low memory addresses (direct-map Mainstore via PBA) are I-cacheable
/// but not D-cacheable to improve predicatability of execution times.
/// However, we should not execute from mainstore after initialization.
///
/// OCI register space (Segment '0b01') is marked guarded and non-cacheable.
///
/// All memory is big-endian.
///
/// @{

#ifndef PPC405_ICCR_INITIAL
#define PPC405_ICCR_INITIAL 0xff000001
#endif

#ifndef PPC405_DCCR_INITIAL
#define PPC405_DCCR_INITIAL 0x00000001
#endif

#ifndef PPC405_DCWR_INITIAL
#define PPC405_DCWR_INITIAL 0x00000004
#endif

#ifndef PPC405_SGR_INITIAL
#define PPC405_SGR_INITIAL  0x00ff0000
#endif

#ifndef PPC405_SU0R_INITIAL
#define PPC405_SU0R_INITIAL 0x00000000
#endif

#ifndef PPC405_SLER_INITIAL
#define PPC405_SLER_INITIAL 0x00000000
#endif

/// @}


/// PgP always runs from a memory image

#define SSX_RUN_FROM_MEMORY 1

/// This is the initial value of Cache Control Register 0 (CCR0) for PgP.
/// This definition can be overridden by the application.
///
/// The default setting:
///
/// - Enables parity checking in the caches and TLBs.  The parity mode is not
///   modified and defaults to 'imprecise'.
///
/// - Enables ICU prefetching for cacheable regions (Subject to final
///   performance evaluation).  Non-cacheable regions are not prefetched.
///
/// - Gives highest PLB priority to ICU fetches.  This setting can be
///   overriden by scan-only dials in the PgP design which force a fixed
///   priority on the ICU.
///
/// - Sets priority bit 1 to '1' for DCU operations.  The DCU sets priority
///   bit 0 automatically.  This setting can also be overridden by scan-only
///   dials that force a fixed priority on the DCU
///
/// Other options can be set at run time with the API \c ppc405_ccr0_modify().

#ifndef PPC405_CCR0_INITIAL
#define PPC405_CCR0_INITIAL                     \
    (CCR0_DPE | CCR0_IPE | CCR0_TPE |           \
     CCR0_PFC |                                 \
     CCR0_IPP0 | CCR0_IPP1 |                    \
     CCR0_DPP1)
#endif


#ifndef __ASSEMBLER__

/// \page noncacheable_support Non-cacheable modes for PgP
///
/// In order to support evaluation of cache management strategies on
/// performance, DMA buffers read/written by DMA devices can be declared as
/// NONCACHEABLE or NONCACHEABLE_RO, and DMA buffers read by DMA devices can
/// be declared as WRITETHROUGH.  However the code still does an explicit
/// FLUSH of these buffers before activating DMA devices. The configuration
/// option NONCACHEABLE_SUPPORT determines how NONCACHEABLE, NONCACAHEABLE_RO,
/// WRITETHROUGH and FLUSH are defined.
///
/// When noncacheable support is configured, the linker will link the
/// noncacheable and writethrough sections at a fixed offset from cacheable
/// address, depending on where SSX is loaded. Non-cacheable read-only
/// sections are enforced only if PPC405_MMU_SUPPORT is also configured.
/// Writethrogh sections are assumed to be read-write.
///
/// PGP_HIGH_MEMORY_LOAD
///
///     cacheable    : 0xfff8000 - 0xffffffff
///     noncacheable : 0xf7f8000 - 0xf7ffffff [cacheable - 128MB]
///     writethrough : 0xeff8000 - 0xefffffff [cacheable - 256MB]


#ifndef NONCACHEABLE_SUPPORT
#define NONCACHEABLE_SUPPORT 0
#endif


/// Declare an aligned data structure in a noncacheable RO section
///
/// This macro declares an aligned data structure in a noncacheable read-only
/// section.  The linker requires that data allocated in non-default sections
/// be initialized - so an initialization declaration for at least one element
/// of the data structure is required.  Use a value of 8 as the default
/// alignment.
///
/// See \ref noncacheable_support

#if NONCACHEABLE_SUPPORT

#define NONCACHEABLE_RO(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((section (".noncacheable_ro"), aligned (alignment))) = initialization

#else

#define NONCACHEABLE_RO(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((aligned (alignment))) = initialization

#endif  /* NONCACHEABLE_SUPPORT */


/// Declare an aligned data structure in a noncacheable RW section
///
/// This macro declares an aligned data structure in a noncacheable read-write
/// section.  The linker requires that data allocated in non-default sections
/// be initialized - so an initialization declaration for at least one element
/// of the data structure is required.  Use a value of 8 as the default
/// alignment.
///
/// See \ref noncacheable_support

#if NONCACHEABLE_SUPPORT

#define NONCACHEABLE(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((section (".noncacheable"), aligned (alignment))) = initialization

#else

#define NONCACHEABLE(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((aligned (alignment))) = initialization

#endif  /* NONCACHEABLE_SUPPORT */


/// Declare an aligned data structure in a write-through section
///
/// This macro declares an aligned data structure in a write-throgh section.
/// The linker requires that data allocated in non-default sections be
/// initialized - so an initialization declaration for at least one element of
/// the data structure is required.  Use a value of 8 as the default
/// alignment.
///
/// See \ref noncacheable_support

#if NONCACHEABLE_SUPPORT

#define WRITETHROUGH(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((section (".writethrough"), aligned (alignment))) = initialization

#else

#define WRITETHROUGH(declaration, alignment, initialization) \
    declaration __attribute__ \
    ((aligned (alignment))) = initialization

#endif  /* NONCACHEABLE_SUPPORT */


/// Flush/invalidate a region of memory

#if NONCACHEABLE_SUPPORT
#define FLUSH(p, n) do {} while (0)
#define INVALIDATE(p, n) do {} while (0)
#else
#define FLUSH(p, n) do {dcache_flush((p), (n));} while (0)
#define INVALIDATE(p, n) do {dcache_invalidate((p), (n));} while (0)
#endif  /* NONCACHEABLE_SUPPORT */


/// The type of linker symbols
///
/// C++ and current GCC versions do not allow us to declare (C++) or take the
/// address of (C) a symbol of type void, which was an acceptable way to
/// declare linker symbols in earlier versions of GCC.  However if we declare
/// them of type 'char' or another integral type, the compiler will try to
/// make references to this 'data' appear to be in the small data areas (since
/// we're compiling with the PPC EABI), which causes the link to fail since
/// the symbols are actually defined in many different sections. The solution
/// is to declare them to be external references of a bogus type,
/// SsxLinkerSymbol, which is too large (9 bytes) to be stored in the small
/// data area.
///
/// This type definition is considered a required definition for a port of
/// SSX.

typedef struct {
    char bogus[9];
} SsxLinkerSymbol;

// Symbols defined by linkssx.cmd, used during MMU setup, byte-pool setup, and
// other purposes.

extern SsxLinkerSymbol _MEMORY_ORIGIN;
extern SsxLinkerSymbol _MEMORY_SIZE;
extern SsxLinkerSymbol _TEXT0_SECTION_BASE;
extern SsxLinkerSymbol _TEXT0_SECTION_SIZE;
extern SsxLinkerSymbol _TEXT1_SECTION_BASE;
extern SsxLinkerSymbol _TEXT1_SECTION_SIZE;
extern SsxLinkerSymbol _RODATA_SECTION_BASE;
extern SsxLinkerSymbol _RODATA_SECTION_SIZE;
extern SsxLinkerSymbol _NONCACHEABLE_RO_SECTION_BASE;
extern SsxLinkerSymbol _NONCACHEABLE_RO_SECTION_SIZE;
extern SsxLinkerSymbol _NONCACHEABLE_SECTION_BASE;
extern SsxLinkerSymbol _NONCACHEABLE_SECTION_SIZE;
extern SsxLinkerSymbol _WRITETHROUGH_SECTION_BASE;
extern SsxLinkerSymbol _WRITETHROUGH_SECTION_SIZE;
extern SsxLinkerSymbol _DATA_SECTION_BASE;
extern SsxLinkerSymbol _DATA_SECTION_SIZE;
extern SsxLinkerSymbol _EX_FREE_SECTION_BASE;
extern SsxLinkerSymbol _EX_FREE_SECTION_SIZE;
extern SsxLinkerSymbol _APPLET0_SECTION_BASE;
extern SsxLinkerSymbol _APPLET0_SECTION_SIZE;
extern SsxLinkerSymbol _APPLET1_SECTION_BASE;
extern SsxLinkerSymbol _APPLET1_SECTION_SIZE;
extern SsxLinkerSymbol _SSX_FREE_START;
extern SsxLinkerSymbol _SSX_FREE_END;

// Global MMU maps to allow remapping certain regions

extern Ppc405MmuMap G_ex_free_mmu_map;
extern Ppc405MmuMap G_applet0_mmu_map;
extern Ppc405MmuMap G_applet1_mmu_map;

#endif  /* __ASSEMBLER__ */

// PgP defines a private version of dcache_flush_all() that uses the undefined
// OCI space at 0x80000000; See dcache_flush_all() in pgp_cache.S.

#define USE_GENERIC_DCACHE_FLUSH_ALL 0
#define PGP_FLUSH_ZERO_ADDRESS       0x80000000
#define PGP_FLUSH_ZERO_DCCR          0x00008000

#endif  /* __PGP_H__ */
OpenPOWER on IntegriCloud