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