--- /dev/null
+/**\r
+ Produces the Legacy Region Protocol.\r
+\r
+ This generic implementation of the Legacy Region Protocol does not actually \r
+ perform any lock/unlock operations. This module may be used on platforms \r
+ that do not provide HW locking of the legacy memory regions. It can also \r
+ be used as a template driver for implementing the Legacy Region Protocol on\r
+ a platform that does support HW locking of the legacy memory regions.\r
+\r
+Copyright (c) 2009, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/LegacyRegion.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+//\r
+// Function prototypes of the Legacy Region Protocol services this module produces\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionDecode (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ IN BOOLEAN *On\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionLock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionBootLock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionUnlock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ );\r
+\r
+//\r
+// Module global for the handle the Legacy Region Protocol is installed\r
+//\r
+EFI_HANDLE mLegacyRegionHandle = NULL;\r
+\r
+//\r
+// Module global for the Legacy Region Protocol instance that is installed onto\r
+// mLegacyRegionHandle\r
+//\r
+EFI_LEGACY_REGION_PROTOCOL mLegacyRegion = {\r
+ LegacyRegionDecode,\r
+ LegacyRegionLock,\r
+ LegacyRegionBootLock,\r
+ LegacyRegionUnlock\r
+};\r
+\r
+/**\r
+ Sets hardware to decode or not decode a region.\r
+\r
+ @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
+ @param Start Start of region to decode.\r
+ @param Length Size in bytes of the region.\r
+ @param On Decode/nondecode flag.\r
+\r
+ @retval EFI_SUCCESS Decode range successfully changed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionDecode (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ IN BOOLEAN *On\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Sets a region to read only.\r
+\r
+ @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
+ @param Start Start of region to lock.\r
+ @param Length Size in bytes of the region.\r
+ @param Granularity Lock attribute affects this granularity in bytes.\r
+\r
+ @retval EFI_SUCCESS The region was made read only.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionLock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Sets a region to read only and ensures that flash is locked from being\r
+ inadvertently modified.\r
+\r
+ @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
+ @param Start Start of region to lock.\r
+ @param Length Size in bytes of the region.\r
+ @param Granularity Lock attribute affects this granularity in bytes.\r
+\r
+ @retval EFI_SUCCESS The region was made read only and flash is locked.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionBootLock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Sets a region to read-write.\r
+\r
+ @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
+ @param Start Start of region to lock.\r
+ @param Length Size in bytes of the region.\r
+ @param Granularity Lock attribute affects this granularity in bytes.\r
+\r
+ @retval EFI_SUCCESS The region was successfully made read-write.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionUnlock (\r
+ IN EFI_LEGACY_REGION_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ The user Entry Point for module LegacyRegionDxe. The user code starts with this function.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionInstall (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ \r
+ //\r
+ // Make sure the Legacy Region Protocol is not already installed in the system\r
+ //\r
+ ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegionProtocolGuid);\r
+ \r
+ //\r
+ // Install the protocol on a new handle.\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mLegacyRegionHandle,\r
+ &gEfiLegacyRegionProtocolGuid, &mLegacyRegion,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+#/** @file\r
+# Produces the Legacy Region Protocol.\r
+#\r
+# This generic implementation of the Legacy Region Protocol does not actually \r
+# perform any lock/unlock operations. This module may be used on platforms \r
+# that do not provide HW locking of the legacy memory regions. It can also \r
+# be used as a template driver for implementing the Legacy Region Protocol on\r
+# a platform that does support HW locking of the legacy memory regions.\r
+#\r
+# Copyright (c) 2009, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = LegacyRegionDxe\r
+ FILE_GUID = 8C439043-85CA-467a-96F1-CB14F4D0DCDA\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = LegacyRegionInstall\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ LegacyRegion.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+ UefiBootServicesTableLib\r
+\r
+[Protocols]\r
+ gEfiLegacyRegionProtocolGuid ## PRODUCES\r
+\r
+[Depex]\r
+ TRUE\r