blob: f10a6af80b4d76cc32425ebb871f41368514ba91 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD CPU Execution Cache Allocation functions.
6 *
7 * Contains code for doing Execution Cache Allocation for ROM space
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: CPU
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*
16 ******************************************************************************
17 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080018 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
19 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080020 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080021 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
zbao7d94cf92012-07-02 14:19:14 +080031 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080042 ******************************************************************************
43 */
44
45#ifndef _CPU_CACHE_INIT_H_
46#define _CPU_CACHE_INIT_H_
47
48/*----------------------------------------------------------------------------
49 * Mixed (DEFINITIONS AND MACROS / TYPEDEFS, STRUCTURES, ENUMS)
50 *
51 *----------------------------------------------------------------------------
52 */
53
54/*-----------------------------------------------------------------------------
55 * DEFINITIONS AND MACROS
56 *
57 *-----------------------------------------------------------------------------
58 */
59#define BSP_STACK_SIZE_64K 65536
60#define BSP_STACK_SIZE_32K 32768
61
62#define CORE0_STACK_SIZE 16384
63#define CORE1_STACK_SIZE 4096
64
65#define AMD_MTRR_FIX4K_BASE 0x268
66#define AMD_MTRR_VARIABLE_BASE6 0x20C
67#define AMD_MTRR_VARIABLE_BASE7 0x20E
68
69#define WP_IO 0x0505050505050505ull
70
71#define AGESA_CACHE_SIZE_REDUCED 1
72#define AGESA_CACHE_REGIONS_ACROSS_1MB 2
73#define AGESA_CACHE_REGIONS_ACROSS_4GB 3
74#define AGESA_REGION_NOT_ALIGNED_ON_BOUNDARY 4
75#define AGESA_CACHE_START_ADDRESS_LESS_D0000 5
76#define AGESA_THREE_CACHE_REGIONS_ABOVE_1MB 6
77#define AGESA_DEALLOCATE_CACHE_REGIONS 7
78
79/*----------------------------------------------------------------------------
80 * TYPEDEFS, STRUCTURES, ENUMS
81 *
82 *----------------------------------------------------------------------------
83 */
84/// Cache-As-Ram Executable region allocation modes
85typedef enum {
86 LimitedByL2Size, ///< Execution space must be allocated from L2
87 InfiniteExe, ///< Family can support unlimited Execution space
88 MaxCarExeMode ///< Used as limit or bounds check
89} CAR_EXE_MODE;
90
91/// Cache Information
92typedef struct {
93 IN UINT32 BspStackSize; ///< Stack size of BSP
94 IN UINT32 Core0StackSize; ///< Stack size of primary cores
95 IN UINT32 Core1StackSize; ///< Stack size of all non primary cores
96 IN UINT32 MemTrainingBufferSize; ///< Memory training buffer size
97 IN UINT32 SharedMemSize; ///< Shared memory size
98 IN UINT64 VariableMtrrMask; ///< Mask to apply before variable MTRR writes
99 IN UINT64 VariableMtrrHeapMask; ///< Mask to apply before variable MTRR writes for use in heap init.
100 IN UINT64 HeapBaseMask; ///< Mask used for the heap MTRR settings
101 IN CAR_EXE_MODE CarExeType; ///< Indicates which algorithm to use when allocating EXE space
102} CACHE_INFO;
103
104/// Merged memory region overlap type
105typedef enum {
106 EmptySet, ///< One of the regions is zero length
107 Disjoint, ///< The two regions do not touch
108 Adjacent, ///< one region is next to the other, no gap
109 CommonEnd, ///< regions overlap with a common end point
110 Extending, ///< the 2nd region is extending the size of the 1st
111 Contained, ///< the 2nd region is wholely contained inside the 1st
112 CommonStartContained, ///< the 2nd region is contained in the 1st with a common start
113 Identity, ///< the two regions are the same
114 CommonStartExtending, ///< the 2nd region has same start as 1st, but is larger size
115 NotCombinable ///< the combined regions do not follow the cache block rules
116} OVERLAP_TYPE;
117
118/// Result of merging two memory regions for cache coverage
119typedef struct {
120 IN OUT UINT32 MergedStartAddr; ///< Start address of the merged regions
121 IN OUT UINT32 MergedSize; ///< Size of the merged regions
122 OUT UINT32 OverlapAmount; ///< the size of the overlapping section
123 OUT OVERLAP_TYPE OverlapType; ///< indicates how the two regions overlap
124} MERGED_CACHE_REGION;
125
126/*----------------------------------------------------------------------------
127 * FUNCTIONS PROTOTYPE
128 *
129 *----------------------------------------------------------------------------
130 */
131AGESA_STATUS
132AllocateExecutionCache (
133 IN AMD_CONFIG_PARAMS *StdHeader,
134 IN EXECUTION_CACHE_REGION *AmdExeAddrMapPtr
135 );
136
137#endif // _CPU_CACHE_INIT_H_
138