]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformDxe/SlotConfig.c
f9b53ead95312bd158c286cac37832fb266a87c2
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformDxe / SlotConfig.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 Module Name:
10
11 SlotConfig.c
12
13 Abstract:
14
15 Sets platform/SKU specific expansion slot information.
16
17
18
19 --*/
20 #include "SlotConfig.h"
21
22 //
23 // Implementation
24 //
25 VOID
26 InitializeSlotInfo (
27 )
28 {
29 UINT16 BusSaveState;
30 UINT16 Vendor;
31 UINT8 CurrentBus;
32 UINTN i;
33 UINTN j;
34 EFI_HANDLE Handle;
35 EFI_STATUS Status;
36 BOOLEAN RunNext;
37
38 //
39 // Loop through the slot table and see if any slots have cards in them
40 //
41 for (i = 0; i < mSlotBridgeTableSize; i++) {
42 //
43 // Initialize variable
44 //
45 RunNext = FALSE;
46
47 //
48 // Hide mini PCIe slots per SKU
49 //
50 for (j = 0; j < mSlotInformation.NumberOfEntries; j++) {
51 if (mSlotInformation.SlotEntries[j].SmbiosSlotId == mSlotBridgeTable[i].SmbiosSlotId) {
52 if ((mSlotInformation.SlotEntries[j].SmbiosSlotId == 0x02) &&
53 (mBoardFeatures & B_BOARD_FEATURES_NO_MINIPCIE)
54 ) {
55 mSlotInformation.SlotEntries[j].Disabled = TRUE;
56 RunNext = TRUE;
57 }
58 break;
59 }
60 }
61
62 if (RunNext) {
63 //
64 // Skip slot device detection since the slot is disabled.
65 //
66 continue;
67 }
68
69 //
70 // Check to see if the bridge has a bus number and assign one if not
71 //
72 BusSaveState = MmPci16 (
73 0,
74 mSlotBridgeTable[i].Bus,
75 mSlotBridgeTable[i].Dev,
76 mSlotBridgeTable[i].Function,
77 PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET
78 );
79 if (BusSaveState == 0) {
80 //
81 // Assign temp bus number
82 //
83 MmPci16 (
84 0,
85 mSlotBridgeTable[i].Bus,
86 mSlotBridgeTable[i].Dev,
87 mSlotBridgeTable[i].Function,
88 PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET
89 ) = DEF_BUS_CONFIG;
90 CurrentBus = DEF_BUS;
91 } else if (BusSaveState == 0xFFFF) {
92 //
93 // Bridge is disabled so continue with next entry in the table
94 //
95 continue;
96 } else {
97 //
98 // Use existing bus number
99 //
100 CurrentBus = (UINT8) BusSaveState & 0xFF;
101 }
102
103 //
104 // Check to see if a device is behind the bridge
105 //
106 Vendor = MmPci16 (
107 0,
108 CurrentBus,
109 mSlotBridgeTable[i].TargetDevice,
110 0,
111 0
112 );
113 if (Vendor != 0xFFFF) {
114 //
115 // Device found so make sure the slot is marked that way
116 //
117 for (j = 0; j < mSlotInformation.NumberOfEntries; j++) {
118 if (mSlotInformation.SlotEntries[j].SmbiosSlotId == mSlotBridgeTable[i].SmbiosSlotId) {
119 mSlotInformation.SlotEntries[j].InUse = TRUE;
120 break;
121 }
122 }
123 }
124
125 //
126 // Restore previous bus information
127 //
128 if (BusSaveState == 0) {
129 MmPci16 (
130 0,
131 mSlotBridgeTable[i].Bus,
132 mSlotBridgeTable[i].Dev,
133 mSlotBridgeTable[i].Function,
134 PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET
135 ) = 0;
136 }
137 }
138
139 Handle = NULL;
140 Status = gBS->InstallProtocolInterface (
141 &Handle,
142 &gEfiSmbiosSlotPopulationGuid,
143 EFI_NATIVE_INTERFACE,
144 &mSlotInformation
145 );
146 ASSERT_EFI_ERROR(Status);
147
148 }