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