2 Runtime Lib function for QNC internal network access.
4 Copyright (c) 2013-2015 Intel Corporation.
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
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.
19 #include <Guid/EventGroup.h>
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/UefiRuntimeLib.h>
25 #include <Library/QNCAccessLib.h>
28 /// Set Virtual Address Map Event
30 EFI_EVENT mDxeRuntimeQncAccessLibVirtualNotifyEvent
= NULL
;
33 /// Module global that contains the base physical address of the PCI Express MMIO range.
35 UINTN mDxeRuntimeQncAccessLibPciExpressBaseAddress
= 0;
38 Convert the physical PCI Express MMIO address to a virtual address.
40 @param[in] Event The event that is being processed.
41 @param[in] Context The Event Context.
45 DxeRuntimeQncAccessLibVirtualNotify (
53 // Convert the physical PCI Express MMIO address to a virtual address.
55 Status
= EfiConvertPointer (0, (VOID
**) &mDxeRuntimeQncAccessLibPciExpressBaseAddress
);
57 ASSERT_EFI_ERROR (Status
);
61 The constructor function to setup globals and goto virtual mode notify.
63 @param ImageHandle The firmware allocated handle for the EFI image.
64 @param SystemTable A pointer to the EFI System Table.
66 @retval EFI_SUCCESS The constructor completed successfully.
67 @retval Other value The constructor did not complete successfully.
72 DxeRuntimeQncAccessLibConstructor (
73 IN EFI_HANDLE ImageHandle
,
74 IN EFI_SYSTEM_TABLE
*SystemTable
80 // Cache the physical address of the PCI Express MMIO range into a module global variable
82 mDxeRuntimeQncAccessLibPciExpressBaseAddress
= (UINTN
) PcdGet64(PcdPciExpressBaseAddress
);
85 // Register SetVirtualAddressMap () notify function
87 Status
= gBS
->CreateEventEx (
90 DxeRuntimeQncAccessLibVirtualNotify
,
92 &gEfiEventVirtualAddressChangeGuid
,
93 &mDxeRuntimeQncAccessLibVirtualNotifyEvent
95 ASSERT_EFI_ERROR (Status
);
101 The destructor function frees any allocated buffers and closes the Set Virtual
104 @param ImageHandle The firmware allocated handle for the EFI image.
105 @param SystemTable A pointer to the EFI System Table.
107 @retval EFI_SUCCESS The destructor completed successfully.
108 @retval Other value The destructor did not complete successfully.
113 DxeRuntimeQncAccessLibDestructor (
114 IN EFI_HANDLE ImageHandle
,
115 IN EFI_SYSTEM_TABLE
*SystemTable
121 // Close the Set Virtual Address Map event
123 Status
= gBS
->CloseEvent (mDxeRuntimeQncAccessLibVirtualNotifyEvent
);
124 ASSERT_EFI_ERROR (Status
);
130 Gets the base address of PCI Express for Quark North Cluster.
132 @return The base address of PCI Express for Quark North Cluster.
137 QncGetPciExpressBaseAddress (
142 // If system goes to virtual mode then virtual notify callback will update
143 // mDxeRuntimeQncAccessLibPciExpressBaseAddress with virtual address of
146 return mDxeRuntimeQncAccessLibPciExpressBaseAddress
;