Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $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'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 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 |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 44 | * |
| 45 | */ |
| 46 | |
| 47 | #ifndef _PCIEUTILLIB_H_ |
| 48 | #define _PCIEUTILLIB_H_ |
| 49 | |
| 50 | /// Core lanes |
| 51 | typedef 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 |
| 60 | typedef enum { |
| 61 | DdiAllLanes, ///< All DDI Lanes |
| 62 | DdiActiveLanes ///< Active DDI Lanes |
| 63 | } DDI_LANES; |
| 64 | |
| 65 | BOOLEAN |
| 66 | PcieUtilSearchArray ( |
| 67 | IN UINT8 *Buf1, |
| 68 | IN UINTN Buf1Length, |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 69 | CONST IN UINT8 *Buf2, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 70 | IN UINTN Buf2Length |
| 71 | ); |
| 72 | |
| 73 | VOID |
| 74 | PcieUtilGetLinkHwStateHistory ( |
| 75 | IN PCIe_ENGINE_CONFIG *Engine, |
| 76 | OUT UINT8 *History, |
| 77 | IN UINT8 Length, |
| 78 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 79 | ); |
| 80 | |
| 81 | |
| 82 | BOOLEAN |
| 83 | PcieUtilIsLinkReversed ( |
| 84 | IN BOOLEAN HwLinkState, |
| 85 | IN PCIe_ENGINE_CONFIG *Engine, |
| 86 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 87 | ); |
| 88 | |
| 89 | |
| 90 | UINT8 |
| 91 | PcieUtilGetLinkWidth ( |
| 92 | IN PCIe_ENGINE_CONFIG *Engine, |
| 93 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 94 | ); |
| 95 | |
| 96 | |
| 97 | UINT32 |
| 98 | PcieUtilGetEngineLaneBitMap ( |
| 99 | IN UINT32 IncludeLaneType, |
| 100 | IN UINT32 ExcludeLaneType, |
| 101 | IN PCIe_ENGINE_CONFIG *Engine, |
| 102 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 103 | ); |
| 104 | |
| 105 | UINT32 |
| 106 | PcieUtilGetWrapperLaneBitMap ( |
| 107 | IN UINT32 IncludeLaneType, |
| 108 | IN UINT32 ExcludeLaneType, |
| 109 | IN PCIe_WRAPPER_CONFIG *Wrapper, |
| 110 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 111 | ); |
| 112 | |
| 113 | VOID |
| 114 | PciePortProgramRegisterTable ( |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 115 | CONST IN PCIE_PORT_REGISTER_ENTRY *Table, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 116 | IN UINTN Length, |
| 117 | IN PCIe_ENGINE_CONFIG *Engine, |
| 118 | IN BOOLEAN S3Save, |
| 119 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 120 | ); |
| 121 | |
| 122 | VOID |
| 123 | PcieLockRegisters ( |
| 124 | IN PCIe_WRAPPER_CONFIG *Wrapper, |
| 125 | IN PCIe_PLATFORM_CONFIG *Pcie |
| 126 | ); |
| 127 | |
| 128 | #endif |