123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- /** @file
- Legacy Region Support
- Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
- **/
- #ifndef _LEGACY_REGION_DXE_H_
- #define _LEGACY_REGION_DXE_H_
- #include <PiDxe.h>
- #include <Protocol/LegacyRegion2.h>
- #include <IndustryStandard/Pci.h>
- #include <IndustryStandard/Q35MchIch9.h>
- #include <IndustryStandard/I440FxPiix4.h>
- #include <Library/PciLib.h>
- #include <Library/PcdLib.h>
- #include <Library/DebugLib.h>
- #include <Library/MemoryAllocationLib.h>
- #include <Library/UefiBootServicesTableLib.h>
- #define PAM_BASE_ADDRESS 0xc0000
- #define PAM_LIMIT_ADDRESS BASE_1MB
- //
- // Describes Legacy Region blocks and status.
- //
- typedef struct {
- UINT32 Start;
- UINT32 Length;
- BOOLEAN ReadEnabled;
- BOOLEAN WriteEnabled;
- } LEGACY_MEMORY_SECTION_INFO;
- //
- // Provides a map of the PAM registers and bits used to set Read/Write access.
- //
- typedef struct {
- UINTN PAMRegPciLibAddress;
- UINT8 ReadEnableData;
- UINT8 WriteEnableData;
- } PAM_REGISTER_VALUE;
- /**
- Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
- If the On parameter evaluates to TRUE, this function enables memory reads in the address range
- Start to (Start + Length - 1).
- If the On parameter evaluates to FALSE, this function disables memory reads in the address range
- Start to (Start + Length - 1).
- @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
- @param Start[in] The beginning of the physical address of the region whose attributes
- should be modified.
- @param Length[in] The number of bytes of memory whose attributes should be modified.
- The actual number of bytes modified may be greater than the number
- specified.
- @param Granularity[out] The number of bytes in the last region affected. This may be less
- than the total number of bytes affected if the starting address
- was not aligned to a region's starting address or if the length
- was greater than the number of bytes in the first region.
- @param On[in] Decode / Non-Decode flag.
- @retval EFI_SUCCESS The region's attributes were successfully modified.
- @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
- **/
- EFI_STATUS
- EFIAPI
- LegacyRegion2Decode (
- IN EFI_LEGACY_REGION2_PROTOCOL *This,
- IN UINT32 Start,
- IN UINT32 Length,
- OUT UINT32 *Granularity,
- IN BOOLEAN *On
- );
- /**
- Modify the hardware to disallow memory writes in a region.
- This function changes the attributes of a memory range to not allow writes.
- @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
- @param Start[in] The beginning of the physical address of the region whose
- attributes should be modified.
- @param Length[in] The number of bytes of memory whose attributes should be modified.
- The actual number of bytes modified may be greater than the number
- specified.
- @param Granularity[out] The number of bytes in the last region affected. This may be less
- than the total number of bytes affected if the starting address was
- not aligned to a region's starting address or if the length was
- greater than the number of bytes in the first region.
- @retval EFI_SUCCESS The region's attributes were successfully modified.
- @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
- **/
- EFI_STATUS
- EFIAPI
- LegacyRegion2Lock (
- IN EFI_LEGACY_REGION2_PROTOCOL *This,
- IN UINT32 Start,
- IN UINT32 Length,
- OUT UINT32 *Granularity
- );
- /**
- Modify the hardware to disallow memory attribute changes in a region.
- This function makes the attributes of a region read only. Once a region is boot-locked with this
- function, the read and write attributes of that region cannot be changed until a power cycle has
- reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
- @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
- @param Start[in] The beginning of the physical address of the region whose
- attributes should be modified.
- @param Length[in] The number of bytes of memory whose attributes should be modified.
- The actual number of bytes modified may be greater than the number
- specified.
- @param Granularity[out] The number of bytes in the last region affected. This may be less
- than the total number of bytes affected if the starting address was
- not aligned to a region's starting address or if the length was
- greater than the number of bytes in the first region.
- @retval EFI_SUCCESS The region's attributes were successfully modified.
- @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
- @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
- a way that will not affect memory regions outside the legacy memory
- region.
- **/
- EFI_STATUS
- EFIAPI
- LegacyRegion2BootLock (
- IN EFI_LEGACY_REGION2_PROTOCOL *This,
- IN UINT32 Start,
- IN UINT32 Length,
- OUT UINT32 *Granularity
- );
- /**
- Modify the hardware to allow memory writes in a region.
- This function changes the attributes of a memory range to allow writes.
- @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
- @param Start[in] The beginning of the physical address of the region whose
- attributes should be modified.
- @param Length[in] The number of bytes of memory whose attributes should be modified.
- The actual number of bytes modified may be greater than the number
- specified.
- @param Granularity[out] The number of bytes in the last region affected. This may be less
- than the total number of bytes affected if the starting address was
- not aligned to a region's starting address or if the length was
- greater than the number of bytes in the first region.
- @retval EFI_SUCCESS The region's attributes were successfully modified.
- @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
- **/
- EFI_STATUS
- EFIAPI
- LegacyRegion2Unlock (
- IN EFI_LEGACY_REGION2_PROTOCOL *This,
- IN UINT32 Start,
- IN UINT32 Length,
- OUT UINT32 *Granularity
- );
- /**
- Get region information for the attributes of the Legacy Region.
- This function is used to discover the granularity of the attributes for the memory in the legacy
- region. Each attribute may have a different granularity and the granularity may not be the same
- for all memory ranges in the legacy region.
- @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
- @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
- buffer.
- @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
- region information is deposited. This buffer will contain a list of
- DescriptorCount number of region descriptors. This function will
- provide the memory for the buffer.
- @retval EFI_SUCCESS The region's attributes were successfully modified.
- @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
- **/
- EFI_STATUS
- EFIAPI
- LegacyRegionGetInfo (
- IN EFI_LEGACY_REGION2_PROTOCOL *This,
- OUT UINT32 *DescriptorCount,
- OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor
- );
- #endif
|