AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / CPU / Feature / cpuCacheInit.h
1 /* $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: 50472 $   @e \$Date: 2011-04-11 01:57:56 -0600 (Mon, 11 Apr 2011) $
13  *
14  */
15 /*
16  ******************************************************************************
17  *
18  * Copyright (C) 2012 Advanced Micro Devices, Inc.
19  * All rights reserved.
20  *
21  * 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.
31  *
32  * 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.
42  *
43  ******************************************************************************
44  */
45
46 #ifndef _CPU_CACHE_INIT_H_
47 #define _CPU_CACHE_INIT_H_
48
49 /*----------------------------------------------------------------------------
50  *   Mixed (DEFINITIONS AND MACROS / TYPEDEFS, STRUCTURES, ENUMS)
51  *
52  *----------------------------------------------------------------------------
53  */
54
55 /*-----------------------------------------------------------------------------
56  *                         DEFINITIONS AND MACROS
57  *
58  *-----------------------------------------------------------------------------
59  */
60 #define BSP_STACK_SIZE_64K        65536
61 #define BSP_STACK_SIZE_32K        32768
62
63 #define CORE0_STACK_SIZE          16384
64 #define CORE1_STACK_SIZE          4096
65
66 #define AMD_MTRR_FIX4K_BASE     0x268
67 #define AMD_MTRR_VARIABLE_BASE6 0x20C
68 #define AMD_MTRR_VARIABLE_BASE7 0x20E
69
70 #define WP_IO 0x0505050505050505
71
72 #define AGESA_CACHE_SIZE_REDUCED              1
73 #define AGESA_CACHE_REGIONS_ACROSS_1MB        2
74 #define AGESA_CACHE_REGIONS_ACROSS_4GB        3
75 #define AGESA_REGION_NOT_ALIGNED_ON_BOUNDARY  4
76 #define AGESA_CACHE_START_ADDRESS_LESS_D0000  5
77 #define AGESA_THREE_CACHE_REGIONS_ABOVE_1MB   6
78 #define AGESA_DEALLOCATE_CACHE_REGIONS        7
79
80 /*----------------------------------------------------------------------------
81  *                         TYPEDEFS, STRUCTURES, ENUMS
82  *
83  *----------------------------------------------------------------------------
84  */
85 /// Cache-As-Ram Executable region allocation modes
86 typedef enum {
87   LimitedByL2Size,                            ///< Execution space must be allocated from L2
88   InfiniteExe,                                ///< Family can support unlimited Execution space
89   MaxCarExeMode                               ///< Used as limit or bounds check
90 } CAR_EXE_MODE;
91
92 /// Cache Information
93 typedef struct {
94   IN       UINT32  BspStackSize;              ///< Stack size of BSP
95   IN       UINT32  Core0StackSize;            ///< Stack size of primary cores
96   IN       UINT32  Core1StackSize;            ///< Stack size of all non primary cores
97   IN       UINT32  MemTrainingBufferSize;     ///< Memory training buffer size
98   IN       UINT32  SharedMemSize;             ///< Shared memory size
99   IN       UINT64  VariableMtrrMask;          ///< Mask to apply before variable MTRR writes
100   IN       UINT64  VariableMtrrHeapMask;      ///< Mask to apply before variable MTRR writes for use in heap init.
101   IN       UINT64  HeapBaseMask;              ///< Mask used for the heap MTRR settings
102   IN CAR_EXE_MODE  CarExeType;                ///< Indicates which algorithm to use when allocating EXE space
103 } CACHE_INFO;
104
105 /// Merged memory region overlap type
106 typedef enum {
107   EmptySet,                                   ///< One of the regions is zero length
108   Disjoint,                                   ///< The two regions do not touch
109   Adjacent,                                   ///< one region is next to the other, no gap
110   CommonEnd,                                  ///< regions overlap with a common end point
111   Extending,                                  ///< the 2nd region is extending the size of the 1st
112   Contained,                                  ///< the 2nd region is wholely contained inside the 1st
113   CommonStartContained,                       ///< the 2nd region is contained in the 1st with a common start
114   Identity,                                   ///< the two regions are the same
115   CommonStartExtending,                       ///< the 2nd region has same start as 1st, but is larger size
116   NotCombinable                               ///< the combined regions do not follow the cache block rules
117 } OVERLAP_TYPE;
118
119 /// Result of merging two memory regions for cache coverage
120 typedef struct {
121   IN OUT  UINT32        MergedStartAddr;      ///< Start address of the merged regions
122   IN OUT  UINT32        MergedSize;           ///< Size of the merged regions
123      OUT  UINT32        OverlapAmount;        ///< the size of the overlapping section
124      OUT  OVERLAP_TYPE  OverlapType;          ///< indicates how the two regions overlap
125 } MERGED_CACHE_REGION;
126
127 /*----------------------------------------------------------------------------
128  *                           FUNCTIONS PROTOTYPE
129  *
130  *----------------------------------------------------------------------------
131  */
132 AGESA_STATUS
133 AllocateExecutionCache (
134   IN AMD_CONFIG_PARAMS *StdHeader,
135   IN EXECUTION_CACHE_REGION *AmdExeAddrMapPtr
136   );
137
138 #endif  // _CPU_CACHE_INIT_H_
139