Home | History | Annotate | Download | only in LegacyRegionDxe
      1 /** @file
      2   Produces the Legacy Region Protocol.
      3 
      4   This generic implementation of the Legacy Region Protocol does not actually
      5   perform any lock/unlock operations.  This module may be used on platforms
      6   that do not provide HW locking of the legacy memory regions.  It can also
      7   be used as a template driver for implementing the Legacy Region Protocol on
      8   a platform that does support HW locking of the legacy memory regions.
      9 
     10 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
     11 This program and the accompanying materials
     12 are licensed and made available under the terms and conditions of the BSD License
     13 which accompanies this distribution.  The full text of the license may be found at
     14 http://opensource.org/licenses/bsd-license.php
     15 
     16 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.
     18 
     19 **/
     20 
     21 #include <PiDxe.h>
     22 #include <Protocol/LegacyRegion.h>
     23 #include <Library/DebugLib.h>
     24 #include <Library/UefiBootServicesTableLib.h>
     25 
     26 /**
     27   Sets hardware to decode or not decode a region.
     28 
     29   @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance
     30   @param  Start                 Start of region to decode.
     31   @param  Length                Size in bytes of the region.
     32   @param  On                    Decode/nondecode flag.
     33 
     34   @retval EFI_SUCCESS           Decode range successfully changed.
     35 
     36 **/
     37 EFI_STATUS
     38 EFIAPI
     39 LegacyRegionDecode (
     40   IN EFI_LEGACY_REGION_PROTOCOL  *This,
     41   IN UINT32                      Start,
     42   IN UINT32                      Length,
     43   IN BOOLEAN                     *On
     44   )
     45 {
     46   return EFI_SUCCESS;
     47 }
     48 
     49 /**
     50   Sets a region to read only.
     51 
     52   @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance
     53   @param  Start                 Start of region to lock.
     54   @param  Length                Size in bytes of the region.
     55   @param  Granularity           Lock attribute affects this granularity in bytes.
     56 
     57   @retval EFI_SUCCESS           The region was made read only.
     58 
     59 **/
     60 EFI_STATUS
     61 EFIAPI
     62 LegacyRegionLock (
     63   IN  EFI_LEGACY_REGION_PROTOCOL  *This,
     64   IN  UINT32                      Start,
     65   IN  UINT32                      Length,
     66   OUT UINT32                      *Granularity OPTIONAL
     67   )
     68 {
     69   return EFI_SUCCESS;
     70 }
     71 
     72 /**
     73   Sets a region to read only and ensures that flash is locked from being
     74   inadvertently modified.
     75 
     76   @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance
     77   @param  Start                 Start of region to lock.
     78   @param  Length                Size in bytes of the region.
     79   @param  Granularity           Lock attribute affects this granularity in bytes.
     80 
     81   @retval EFI_SUCCESS           The region was made read only and flash is locked.
     82 
     83 **/
     84 EFI_STATUS
     85 EFIAPI
     86 LegacyRegionBootLock (
     87   IN  EFI_LEGACY_REGION_PROTOCOL  *This,
     88   IN  UINT32                      Start,
     89   IN  UINT32                      Length,
     90   OUT UINT32                      *Granularity OPTIONAL
     91   )
     92 {
     93   return EFI_SUCCESS;
     94 }
     95 
     96 /**
     97   Sets a region to read-write.
     98 
     99   @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance
    100   @param  Start                 Start of region to lock.
    101   @param  Length                Size in bytes of the region.
    102   @param  Granularity           Lock attribute affects this granularity in bytes.
    103 
    104   @retval EFI_SUCCESS           The region was successfully made read-write.
    105 
    106 **/
    107 EFI_STATUS
    108 EFIAPI
    109 LegacyRegionUnlock (
    110   IN  EFI_LEGACY_REGION_PROTOCOL  *This,
    111   IN  UINT32                      Start,
    112   IN  UINT32                      Length,
    113   OUT UINT32                      *Granularity OPTIONAL
    114   )
    115 {
    116   return EFI_SUCCESS;
    117 }
    118 
    119 //
    120 // Module global for the handle the Legacy Region Protocol is installed
    121 //
    122 EFI_HANDLE                  mLegacyRegionHandle = NULL;
    123 
    124 //
    125 // Module global for the Legacy Region Protocol instance that is installed onto
    126 // mLegacyRegionHandle
    127 //
    128 EFI_LEGACY_REGION_PROTOCOL  mLegacyRegion = {
    129   LegacyRegionDecode,
    130   LegacyRegionLock,
    131   LegacyRegionBootLock,
    132   LegacyRegionUnlock
    133 };
    134 
    135 /**
    136   The user Entry Point for module LegacyRegionDxe.  The user code starts with this function.
    137 
    138   @param[in] ImageHandle    The firmware allocated handle for the EFI image.
    139   @param[in] SystemTable    A pointer to the EFI System Table.
    140 
    141   @retval EFI_SUCCESS       The entry point is executed successfully.
    142   @retval other             Some error occurs when executing this entry point.
    143 
    144 **/
    145 EFI_STATUS
    146 EFIAPI
    147 LegacyRegionInstall (
    148   IN EFI_HANDLE        ImageHandle,
    149   IN EFI_SYSTEM_TABLE  *SystemTable
    150   )
    151 {
    152   EFI_STATUS  Status;
    153 
    154   //
    155   // Make sure the Legacy Region Protocol is not already installed in the system
    156   //
    157   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegionProtocolGuid);
    158 
    159   //
    160   // Install the protocol on a new handle.
    161   //
    162   Status = gBS->InstallMultipleProtocolInterfaces (
    163                   &mLegacyRegionHandle,
    164                   &gEfiLegacyRegionProtocolGuid, &mLegacyRegion,
    165                   NULL
    166                   );
    167   ASSERT_EFI_ERROR (Status);
    168 
    169   return Status;
    170 }
    171