AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Include / GeneralServices.h
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * General Services
6  *
7  * Provides Services similar to the external General Services API, except
8  * suited to use within AGESA components.  Socket, Core and PCI identification.
9  *
10  * @xrefitem bom "File Content Label" "Release Content"
11  * @e project:      AGESA
12  * @e sub-project:  Common
13  * @e \$Revision: 44324 $   @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
14  *
15  */
16 /*
17  ******************************************************************************
18  *
19  * Copyright (C) 2012 Advanced Micro Devices, Inc.
20  * All rights reserved.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions are met:
24  *     * Redistributions of source code must retain the above copyright
25  *       notice, this list of conditions and the following disclaimer.
26  *     * Redistributions in binary form must reproduce the above copyright
27  *       notice, this list of conditions and the following disclaimer in the
28  *       documentation and/or other materials provided with the distribution.
29  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
30  *       its contributors may be used to endorse or promote products derived
31  *       from this software without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
37  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  *
44  ******************************************************************************
45  */
46
47 #ifndef _GENERAL_SERVICES_H_
48 #define _GENERAL_SERVICES_H_
49
50 /*----------------------------------------------------------------------------------------
51  *          M I X E D   (Definitions And Macros / Typedefs, Structures, Enums)
52  *----------------------------------------------------------------------------------------
53  */
54
55 /*----------------------------------------------------------------------------------------
56  *                 D E F I N I T I O N S     A N D     M A C R O S
57  *----------------------------------------------------------------------------------------
58  */
59 #define NUMBER_OF_EVENT_DATA_PARAMS 4
60
61 /**
62  * AMD Device id for MMIO check.
63  */
64 #define AMD_DEV_VEN_ID 0x1022
65 #define AMD_DEV_VEN_ID_ADDRESS 0
66
67 /*----------------------------------------------------------------------------------------
68  *               T Y P E D E F S,   S T R U C T U R E S,    E N U M S
69  *----------------------------------------------------------------------------------------
70  */
71
72 /**
73  * An AGESA Event Log entry.
74  */
75 typedef struct {
76   AGESA_STATUS EventClass;   ///< The severity of the event, its associated AGESA_STATUS.
77   UINT32   EventInfo;        ///< Uniquely identifies the event.
78   UINT32   DataParam1;       ///< Event specific additional data
79   UINT32   DataParam2;       ///< Event specific additional data
80   UINT32   DataParam3;       ///< Event specific additional data
81   UINT32   DataParam4;       ///< Event specific additional data
82 } AGESA_EVENT;
83
84 /*----------------------------------------------------------------------------------------
85  *                        F U N C T I O N    P R O T O T Y P E
86  *----------------------------------------------------------------------------------------
87  */
88
89 /**
90  * Get a specified Core's APIC ID.
91  *
92  * @param[in]    StdHeader    Header for library and services.
93  * @param[in]    Socket       The Core's Socket.
94  * @param[in]    Core         The Core id.
95  * @param[out]   ApicAddress  The Core's APIC ID.
96  * @param[out]   AgesaStatus  Aggregates AGESA_STATUS for external interface, Always Succeeds.
97  *
98  * @retval       TRUE         The core is present, APIC Id valid
99  * @retval       FALSE        The core is not present, APIC Id not valid.
100  */
101 BOOLEAN
102 GetApicId (
103   IN       AMD_CONFIG_PARAMS *StdHeader,
104   IN       UINT32            Socket,
105   IN       UINT32            Core,
106      OUT   UINT8             *ApicAddress,
107      OUT   AGESA_STATUS      *AgesaStatus
108 );
109
110 /**
111  * Get Processor Module's PCI Config Space address.
112  *
113  * @param[in]    StdHeader    Header for library and services.
114  * @param[in]    Socket       The Core's Socket.
115  * @param[in]    Module       The Module in that Processor
116  * @param[out]   PciAddress   The Processor's PCI Config Space address (Function 0, Register 0)
117  * @param[out]   AgesaStatus  Aggregates AGESA_STATUS for external interface, Always Succeeds.
118  *
119  * @retval       TRUE         The core is present, PCI Address valid
120  * @retval       FALSE        The core is not present, PCI Address not valid.
121  */
122 BOOLEAN
123 GetPciAddress (
124   IN       AMD_CONFIG_PARAMS *StdHeader,
125   IN       UINT32            Socket,
126   IN       UINT32            Module,
127      OUT   PCI_ADDR          *PciAddress,
128      OUT   AGESA_STATUS      *AgesaStatus
129 );
130
131 /**
132  * "Who am I" for the current running core.
133  *
134  * @param[in]    StdHeader    Header for library and services.
135  * @param[out]   Socket       The current Core's Socket
136  * @param[out]   Module       The current Core's Processor Module
137  * @param[out]   Core         The current Core's core id.
138  * @param[out]   AgesaStatus  Aggregates AGESA_STATUS for external interface, Always Succeeds.
139  *
140  */
141 VOID
142 IdentifyCore (
143   IN       AMD_CONFIG_PARAMS *StdHeader,
144      OUT   UINT32            *Socket,
145      OUT   UINT32            *Module,
146      OUT   UINT32            *Core,
147      OUT   AGESA_STATUS      *AgesaStatus
148 );
149
150 /**
151  *  A boolean function determine executed CPU is BSP core.
152  */
153 BOOLEAN
154 IsBsp (
155   IN OUT   AMD_CONFIG_PARAMS *StdHeader,
156      OUT   AGESA_STATUS      *AgesaStatus
157   );
158
159 /**
160  * This function logs AGESA events into the event log.
161  */
162 VOID
163 PutEventLog (
164   IN       AGESA_STATUS EventClass,
165   IN       UINT32 EventInfo,
166   IN       UINT32 DataParam1,
167   IN       UINT32 DataParam2,
168   IN       UINT32 DataParam3,
169   IN       UINT32 DataParam4,
170   IN       AMD_CONFIG_PARAMS *StdHeader
171   );
172
173 /**
174  * This function gets event logs from the circular buffer.
175  */
176 AGESA_STATUS
177 GetEventLog (
178      OUT   AGESA_EVENT *EventRecord,
179   IN       AMD_CONFIG_PARAMS *StdHeader
180   );
181
182 /**
183  * This function gets event logs from the circular buffer without flushing the entry.
184  */
185 BOOLEAN
186 PeekEventLog (
187      OUT   AGESA_EVENT *EventRecord,
188   IN       UINT16 Index,
189   IN       AMD_CONFIG_PARAMS *StdHeader
190   );
191
192 /*---------------------------------------------------------------------------------------*/
193 /**
194  * This routine programs the registers necessary to get the PCI MMIO mechanism
195  * up and functioning.
196  */
197 VOID
198 InitializePciMmio (
199   IN       AMD_CONFIG_PARAMS *StdHeader
200   );
201
202 #endif  // _GENERAL_SERVICES_H_