2 Runtime Lib function for QNC internal network access.
4 Copyright (c) 2013-2015 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Guid/EventGroup.h>
15 #include <Library/BaseLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/UefiRuntimeLib.h>
19 #include <Library/QNCAccessLib.h>
22 /// Set Virtual Address Map Event
24 EFI_EVENT mDxeRuntimeQncAccessLibVirtualNotifyEvent
= NULL
;
27 /// Module global that contains the base physical address of the PCI Express MMIO range.
29 UINTN mDxeRuntimeQncAccessLibPciExpressBaseAddress
= 0;
32 Convert the physical PCI Express MMIO address to a virtual address.
34 @param[in] Event The event that is being processed.
35 @param[in] Context The Event Context.
39 DxeRuntimeQncAccessLibVirtualNotify (
47 // Convert the physical PCI Express MMIO address to a virtual address.
49 Status
= EfiConvertPointer (0, (VOID
**) &mDxeRuntimeQncAccessLibPciExpressBaseAddress
);
51 ASSERT_EFI_ERROR (Status
);
55 The constructor function to setup globals and goto virtual mode notify.
57 @param ImageHandle The firmware allocated handle for the EFI image.
58 @param SystemTable A pointer to the EFI System Table.
60 @retval EFI_SUCCESS The constructor completed successfully.
61 @retval Other value The constructor did not complete successfully.
66 DxeRuntimeQncAccessLibConstructor (
67 IN EFI_HANDLE ImageHandle
,
68 IN EFI_SYSTEM_TABLE
*SystemTable
74 // Cache the physical address of the PCI Express MMIO range into a module global variable
76 mDxeRuntimeQncAccessLibPciExpressBaseAddress
= (UINTN
) PcdGet64(PcdPciExpressBaseAddress
);
79 // Register SetVirtualAddressMap () notify function
81 Status
= gBS
->CreateEventEx (
84 DxeRuntimeQncAccessLibVirtualNotify
,
86 &gEfiEventVirtualAddressChangeGuid
,
87 &mDxeRuntimeQncAccessLibVirtualNotifyEvent
89 ASSERT_EFI_ERROR (Status
);
95 The destructor function frees any allocated buffers and closes the Set Virtual
98 @param ImageHandle The firmware allocated handle for the EFI image.
99 @param SystemTable A pointer to the EFI System Table.
101 @retval EFI_SUCCESS The destructor completed successfully.
102 @retval Other value The destructor did not complete successfully.
107 DxeRuntimeQncAccessLibDestructor (
108 IN EFI_HANDLE ImageHandle
,
109 IN EFI_SYSTEM_TABLE
*SystemTable
115 // Close the Set Virtual Address Map event
117 Status
= gBS
->CloseEvent (mDxeRuntimeQncAccessLibVirtualNotifyEvent
);
118 ASSERT_EFI_ERROR (Status
);
124 Gets the base address of PCI Express for Quark North Cluster.
126 @return The base address of PCI Express for Quark North Cluster.
131 QncGetPciExpressBaseAddress (
136 // If system goes to virtual mode then virtual notify callback will update
137 // mDxeRuntimeQncAccessLibPciExpressBaseAddress with virtual address of
140 return mDxeRuntimeQncAccessLibPciExpressBaseAddress
;