]>
Commit | Line | Data |
---|---|---|
9b6bbcdb MK |
1 | /** @file\r |
2 | Runtime Lib function for QNC internal network access.\r | |
3 | \r | |
4 | Copyright (c) 2013-2015 Intel Corporation.\r | |
5 | \r | |
c9f231d0 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9b6bbcdb MK |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | \r | |
11 | #include <PiDxe.h>\r | |
12 | \r | |
13 | #include <Guid/EventGroup.h>\r | |
14 | \r | |
15 | #include <Library/BaseLib.h>\r | |
16 | #include <Library/DebugLib.h>\r | |
17 | #include <Library/UefiBootServicesTableLib.h>\r | |
18 | #include <Library/UefiRuntimeLib.h>\r | |
19 | #include <Library/QNCAccessLib.h>\r | |
20 | \r | |
21 | ///\r | |
22 | /// Set Virtual Address Map Event\r | |
23 | ///\r | |
24 | EFI_EVENT mDxeRuntimeQncAccessLibVirtualNotifyEvent = NULL;\r | |
25 | \r | |
26 | ///\r | |
27 | /// Module global that contains the base physical address of the PCI Express MMIO range.\r | |
28 | ///\r | |
29 | UINTN mDxeRuntimeQncAccessLibPciExpressBaseAddress = 0;\r | |
30 | \r | |
31 | /**\r | |
32 | Convert the physical PCI Express MMIO address to a virtual address.\r | |
33 | \r | |
34 | @param[in] Event The event that is being processed.\r | |
35 | @param[in] Context The Event Context.\r | |
36 | **/\r | |
37 | VOID\r | |
38 | EFIAPI\r | |
39 | DxeRuntimeQncAccessLibVirtualNotify (\r | |
40 | IN EFI_EVENT Event,\r | |
41 | IN VOID *Context\r | |
42 | )\r | |
43 | {\r | |
44 | EFI_STATUS Status;\r | |
45 | \r | |
46 | //\r | |
47 | // Convert the physical PCI Express MMIO address to a virtual address.\r | |
48 | //\r | |
49 | Status = EfiConvertPointer (0, (VOID **) &mDxeRuntimeQncAccessLibPciExpressBaseAddress);\r | |
50 | \r | |
51 | ASSERT_EFI_ERROR (Status);\r | |
52 | }\r | |
53 | \r | |
54 | /**\r | |
55 | The constructor function to setup globals and goto virtual mode notify.\r | |
56 | \r | |
57 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
58 | @param SystemTable A pointer to the EFI System Table.\r | |
59 | \r | |
60 | @retval EFI_SUCCESS The constructor completed successfully.\r | |
61 | @retval Other value The constructor did not complete successfully.\r | |
62 | \r | |
63 | **/\r | |
64 | EFI_STATUS\r | |
65 | EFIAPI\r | |
66 | DxeRuntimeQncAccessLibConstructor (\r | |
67 | IN EFI_HANDLE ImageHandle,\r | |
68 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
69 | )\r | |
70 | {\r | |
71 | EFI_STATUS Status;\r | |
72 | \r | |
73 | //\r | |
74 | // Cache the physical address of the PCI Express MMIO range into a module global variable\r | |
75 | //\r | |
76 | mDxeRuntimeQncAccessLibPciExpressBaseAddress = (UINTN) PcdGet64(PcdPciExpressBaseAddress);\r | |
77 | \r | |
78 | //\r | |
79 | // Register SetVirtualAddressMap () notify function\r | |
80 | //\r | |
81 | Status = gBS->CreateEventEx (\r | |
82 | EVT_NOTIFY_SIGNAL,\r | |
83 | TPL_NOTIFY,\r | |
84 | DxeRuntimeQncAccessLibVirtualNotify,\r | |
85 | NULL,\r | |
86 | &gEfiEventVirtualAddressChangeGuid,\r | |
87 | &mDxeRuntimeQncAccessLibVirtualNotifyEvent\r | |
88 | );\r | |
89 | ASSERT_EFI_ERROR (Status);\r | |
90 | \r | |
91 | return Status;\r | |
92 | }\r | |
93 | \r | |
94 | /**\r | |
95 | The destructor function frees any allocated buffers and closes the Set Virtual\r | |
96 | Address Map event.\r | |
97 | \r | |
98 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
99 | @param SystemTable A pointer to the EFI System Table.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS The destructor completed successfully.\r | |
102 | @retval Other value The destructor did not complete successfully.\r | |
103 | \r | |
104 | **/\r | |
105 | EFI_STATUS\r | |
106 | EFIAPI\r | |
107 | DxeRuntimeQncAccessLibDestructor (\r | |
108 | IN EFI_HANDLE ImageHandle,\r | |
109 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
110 | )\r | |
111 | {\r | |
112 | EFI_STATUS Status;\r | |
113 | \r | |
114 | //\r | |
115 | // Close the Set Virtual Address Map event\r | |
116 | //\r | |
117 | Status = gBS->CloseEvent (mDxeRuntimeQncAccessLibVirtualNotifyEvent);\r | |
118 | ASSERT_EFI_ERROR (Status);\r | |
119 | \r | |
120 | return Status;\r | |
121 | }\r | |
122 | \r | |
123 | /**\r | |
124 | Gets the base address of PCI Express for Quark North Cluster.\r | |
125 | \r | |
126 | @return The base address of PCI Express for Quark North Cluster.\r | |
127 | \r | |
128 | **/\r | |
129 | UINTN\r | |
130 | EFIAPI\r | |
131 | QncGetPciExpressBaseAddress (\r | |
132 | VOID\r | |
133 | )\r | |
134 | {\r | |
135 | //\r | |
136 | // If system goes to virtual mode then virtual notify callback will update\r | |
137 | // mDxeRuntimeQncAccessLibPciExpressBaseAddress with virtual address of\r | |
138 | // PCIe memory base.\r | |
139 | //\r | |
140 | return mDxeRuntimeQncAccessLibPciExpressBaseAddress;\r | |
141 | }\r | |
142 | \r |