blob: 5fa4a89f92eda75329aec87c725f5e66874e8c18 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $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: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
14 *
15 */
16/*
17 ******************************************************************************
18 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080019 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
20 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080021 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080022 * 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.
zbao7d94cf92012-07-02 14:19:14 +080032 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080033 * 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.
zbao7d94cf92012-07-02 14:19:14 +080043 ******************************************************************************
44 */
45
46#ifndef _GENERAL_SERVICES_H_
47#define _GENERAL_SERVICES_H_
48
49/*----------------------------------------------------------------------------------------
50 * M I X E D (Definitions And Macros / Typedefs, Structures, Enums)
51 *----------------------------------------------------------------------------------------
52 */
53
54/*----------------------------------------------------------------------------------------
55 * D E F I N I T I O N S A N D M A C R O S
56 *----------------------------------------------------------------------------------------
57 */
58#define NUMBER_OF_EVENT_DATA_PARAMS 4
59
60/**
61 * AMD Device id for MMIO check.
62 */
63#define AMD_DEV_VEN_ID 0x1022
64#define AMD_DEV_VEN_ID_ADDRESS 0
65
66/*----------------------------------------------------------------------------------------
67 * T Y P E D E F S, S T R U C T U R E S, E N U M S
68 *----------------------------------------------------------------------------------------
69 */
70
71/**
72 * An AGESA Event Log entry.
73 */
74typedef struct {
75 AGESA_STATUS EventClass; ///< The severity of the event, its associated AGESA_STATUS.
76 UINT32 EventInfo; ///< Uniquely identifies the event.
77 UINT32 DataParam1; ///< Event specific additional data
78 UINT32 DataParam2; ///< Event specific additional data
79 UINT32 DataParam3; ///< Event specific additional data
80 UINT32 DataParam4; ///< Event specific additional data
81} AGESA_EVENT;
82
83/*----------------------------------------------------------------------------------------
84 * F U N C T I O N P R O T O T Y P E
85 *----------------------------------------------------------------------------------------
86 */
87
88/**
89 * Get a specified Core's APIC ID.
90 *
91 * @param[in] StdHeader Header for library and services.
92 * @param[in] Socket The Core's Socket.
93 * @param[in] Core The Core id.
94 * @param[out] ApicAddress The Core's APIC ID.
95 * @param[out] AgesaStatus Aggregates AGESA_STATUS for external interface, Always Succeeds.
96 *
97 * @retval TRUE The core is present, APIC Id valid
98 * @retval FALSE The core is not present, APIC Id not valid.
99 */
100BOOLEAN
101GetApicId (
102 IN AMD_CONFIG_PARAMS *StdHeader,
103 IN UINT32 Socket,
104 IN UINT32 Core,
105 OUT UINT8 *ApicAddress,
106 OUT AGESA_STATUS *AgesaStatus
107);
108
109/**
110 * Get Processor Module's PCI Config Space address.
111 *
112 * @param[in] StdHeader Header for library and services.
113 * @param[in] Socket The Core's Socket.
114 * @param[in] Module The Module in that Processor
115 * @param[out] PciAddress The Processor's PCI Config Space address (Function 0, Register 0)
116 * @param[out] AgesaStatus Aggregates AGESA_STATUS for external interface, Always Succeeds.
117 *
118 * @retval TRUE The core is present, PCI Address valid
119 * @retval FALSE The core is not present, PCI Address not valid.
120 */
121BOOLEAN
122GetPciAddress (
123 IN AMD_CONFIG_PARAMS *StdHeader,
124 IN UINT32 Socket,
125 IN UINT32 Module,
126 OUT PCI_ADDR *PciAddress,
127 OUT AGESA_STATUS *AgesaStatus
128);
129
130/**
131 * "Who am I" for the current running core.
132 *
133 * @param[in] StdHeader Header for library and services.
134 * @param[out] Socket The current Core's Socket
135 * @param[out] Module The current Core's Processor Module
136 * @param[out] Core The current Core's core id.
137 * @param[out] AgesaStatus Aggregates AGESA_STATUS for external interface, Always Succeeds.
138 *
139 */
140VOID
141IdentifyCore (
142 IN AMD_CONFIG_PARAMS *StdHeader,
143 OUT UINT32 *Socket,
144 OUT UINT32 *Module,
145 OUT UINT32 *Core,
146 OUT AGESA_STATUS *AgesaStatus
147);
148
149/**
150 * A boolean function determine executed CPU is BSP core.
151 */
152BOOLEAN
153IsBsp (
154 IN OUT AMD_CONFIG_PARAMS *StdHeader,
155 OUT AGESA_STATUS *AgesaStatus
156 );
157
158/**
159 * This function logs AGESA events into the event log.
160 */
161VOID
162PutEventLog (
163 IN AGESA_STATUS EventClass,
164 IN UINT32 EventInfo,
165 IN UINT32 DataParam1,
166 IN UINT32 DataParam2,
167 IN UINT32 DataParam3,
168 IN UINT32 DataParam4,
169 IN AMD_CONFIG_PARAMS *StdHeader
170 );
171
172/**
173 * This function gets event logs from the circular buffer.
174 */
175AGESA_STATUS
176GetEventLog (
177 OUT AGESA_EVENT *EventRecord,
178 IN AMD_CONFIG_PARAMS *StdHeader
179 );
180
181/**
182 * This function gets event logs from the circular buffer without flushing the entry.
183 */
184BOOLEAN
185PeekEventLog (
186 OUT AGESA_EVENT *EventRecord,
187 IN UINT16 Index,
188 IN AMD_CONFIG_PARAMS *StdHeader
189 );
190
191/*---------------------------------------------------------------------------------------*/
192/**
193 * This routine programs the registers necessary to get the PCI MMIO mechanism
194 * up and functioning.
195 */
196VOID
197InitializePciMmio (
198 IN AMD_CONFIG_PARAMS *StdHeader
199 );
200
201#endif // _GENERAL_SERVICES_H_