blob: 1f86ea6ba2d8c01cb43bd64f6f14683561eb9190 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * PCIe utility. Various supporting functions.
6 *
7 *
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: GNB
12 * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
13 *
14 */
15/*
16 *****************************************************************************
17 *
18 * Copyright (c) 2011, Advanced Micro Devices, Inc.
19 * All rights reserved.
Edward O'Callaghane963b382014-07-06 19:27:14 +100020 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000021 * 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.
Edward O'Callaghane963b382014-07-06 19:27:14 +100028 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
Frank Vibrans2b4c8312011-02-14 18:30:54 +000030 * from this software without specific prior written permission.
Edward O'Callaghane963b382014-07-06 19:27:14 +100031 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000032 * 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.
Edward O'Callaghane963b382014-07-06 19:27:14 +100042 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000043 * ***************************************************************************
44 *
45 */
46
47#ifndef _PCIEUTILLIB_H_
48#define _PCIEUTILLIB_H_
49
50/// Core lanes
51typedef enum {
52 AllCoreLanes, ///< All core lanes
53 AllocatedCoreLanes, ///< Allocated core lanes
54 ActiveCoreLanes, ///< Active core lanes
55 HotplugCoreLanes, ///< Hot plug core lanes
56 SbCoreLanes, ///< South bridge core lanes
57} CORE_LANES;
58
59/// DDI lanes
60typedef enum {
61 DdiAllLanes, ///< All DDI Lanes
62 DdiActiveLanes ///< Active DDI Lanes
63} DDI_LANES;
64
65BOOLEAN
66PcieUtilSearchArray (
67 IN UINT8 *Buf1,
68 IN UINTN Buf1Length,
Arthur Heymans704ccaf2022-05-16 14:55:46 +020069 CONST IN UINT8 *Buf2,
Frank Vibrans2b4c8312011-02-14 18:30:54 +000070 IN UINTN Buf2Length
71 );
72
73VOID
74PcieUtilGetLinkHwStateHistory (
75 IN PCIe_ENGINE_CONFIG *Engine,
76 OUT UINT8 *History,
77 IN UINT8 Length,
78 IN PCIe_PLATFORM_CONFIG *Pcie
79 );
80
81
82BOOLEAN
83PcieUtilIsLinkReversed (
84 IN BOOLEAN HwLinkState,
85 IN PCIe_ENGINE_CONFIG *Engine,
86 IN PCIe_PLATFORM_CONFIG *Pcie
87 );
88
89
90UINT8
91PcieUtilGetLinkWidth (
92 IN PCIe_ENGINE_CONFIG *Engine,
93 IN PCIe_PLATFORM_CONFIG *Pcie
94 );
95
96
97UINT32
98PcieUtilGetEngineLaneBitMap (
99 IN UINT32 IncludeLaneType,
100 IN UINT32 ExcludeLaneType,
101 IN PCIe_ENGINE_CONFIG *Engine,
102 IN PCIe_PLATFORM_CONFIG *Pcie
103 );
104
105UINT32
106PcieUtilGetWrapperLaneBitMap (
107 IN UINT32 IncludeLaneType,
108 IN UINT32 ExcludeLaneType,
109 IN PCIe_WRAPPER_CONFIG *Wrapper,
110 IN PCIe_PLATFORM_CONFIG *Pcie
111 );
112
113VOID
114PciePortProgramRegisterTable (
Arthur Heymans704ccaf2022-05-16 14:55:46 +0200115 CONST IN PCIE_PORT_REGISTER_ENTRY *Table,
Frank Vibrans2b4c8312011-02-14 18:30:54 +0000116 IN UINTN Length,
117 IN PCIe_ENGINE_CONFIG *Engine,
118 IN BOOLEAN S3Save,
119 IN PCIe_PLATFORM_CONFIG *Pcie
120 );
121
122VOID
123PcieLockRegisters (
124 IN PCIe_WRAPPER_CONFIG *Wrapper,
125 IN PCIe_PLATFORM_CONFIG *Pcie
126 );
127
128#endif