Home | History | Annotate | Download | only in IoInitDxe
      1 /** @file
      2 *
      3 *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
      4 *  Copyright (c) 2015, Linaro Limited. All rights reserved.
      5 *
      6 *  This program and the accompanying materials
      7 *  are licensed and made available under the terms and conditions of the BSD License
      8 *  which accompanies this distribution.  The full text of the license may be found at
      9 *  http://opensource.org/licenses/bsd-license.php
     10 *
     11 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 *
     14 **/
     15 
     16 #include <Uefi.h>
     17 #include <Library/DebugLib.h>
     18 #include <Library/UefiBootServicesTableLib.h>
     19 
     20 #include <Library/PlatformSysCtrlLib.h>
     21 #include <Library/SerdesLib.h>
     22 
     23 #include "Smmu.h"
     24 
     25 SMMU_DEVICE mSpecialSmmu[] = {
     26   {FixedPcdGet64 (PcdM3SmmuBaseAddress), 0},
     27   {FixedPcdGet64 (PcdPcieSmmuBaseAddress), 0},
     28 };
     29 
     30 VOID
     31 SpecialSmmuConfig (VOID)
     32 {
     33   UINTN Index;
     34 
     35   for (Index = 0; Index < sizeof (mSpecialSmmu) / sizeof (mSpecialSmmu[0]); Index++) {
     36     (VOID) SmmuConfigSwitch (&mSpecialSmmu[Index]);
     37   }
     38 }
     39 
     40 VOID
     41 SpecialSmmuEnable (VOID)
     42 {
     43   UINTN Index;
     44 
     45   for (Index = 0; Index < sizeof (mSpecialSmmu) / sizeof (mSpecialSmmu[0]); Index++) {
     46     (VOID) SmmuEnableTable (&mSpecialSmmu[Index]);
     47   }
     48 }
     49 
     50 VOID
     51 EFIAPI
     52 ExitBootServicesEventSmmu (
     53   IN EFI_EVENT  Event,
     54   IN VOID       *Context
     55   )
     56 {
     57   SmmuConfigForOS ();
     58   SpecialSmmuEnable ();
     59   DEBUG((EFI_D_ERROR,"SMMU ExitBootServicesEvent\n"));
     60 }
     61 
     62 
     63 EFI_STATUS
     64 EFIAPI
     65 IoInitDxeEntry (
     66   IN EFI_HANDLE         ImageHandle,
     67   IN EFI_SYSTEM_TABLE  *SystemTable)
     68 {
     69   EFI_STATUS Status;
     70   EFI_EVENT  Event = NULL;
     71 
     72   (VOID) EfiSerdesInitWrap ();
     73 
     74   SmmuConfigForBios ();
     75 
     76   SpecialSmmuConfig ();
     77 
     78   Status = gBS->CreateEvent (
     79       EVT_SIGNAL_EXIT_BOOT_SERVICES,
     80       TPL_CALLBACK,
     81       ExitBootServicesEventSmmu,
     82       NULL,
     83       &Event
     84       );
     85 
     86   if (EFI_ERROR(Status))
     87   {
     88     DEBUG ((EFI_D_ERROR, "[%a:%d] - CreateEvent failed: %r\n", __FUNCTION__,
     89         __LINE__, Status));
     90   }
     91 
     92   return Status;
     93 }
     94 
     95