+++ /dev/null
-/** @file\r
-\r
- A sample PRM Module implementation. This PRM Module provides 3 PRM handlers that simply take a DEBUG print\r
- function from the OS and invoke it with a debug message internal the PRM handler.\r
-\r
- Copyright (c) Microsoft Corporation\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PrmModule.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-//\r
-// PRM Handler GUIDs\r
-//\r
-\r
-// {149a5cb3-6a9c-403f-940a-156abf63938a}\r
-#define PRM_HANDLER_1_GUID {0x149a5cb3, 0x6a9c, 0x403f, {0x94, 0x0a, 0x15, 0x6a, 0xbf, 0x63, 0x93, 0x8a}}\r
-\r
-// Note: If the signature size is modified, the PRM Handler test code in this module needs to be updated.\r
-#define MEMORY_ALLOCATION_TEST_DATA_SIGNATURE SIGNATURE_32('T','E','S','T')\r
-#define MEMORY_ALLOCATION_TEST_DATA_SIZE sizeof(UINT32)\r
-#define MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE 256\r
-\r
-/**\r
- A sample Platform Runtime Mechanism (PRM) handler.\r
-\r
- This sample handler currently uses the OS_SERVICES to write a debug message\r
- indicating this is PRM handler 1.\r
-\r
- @param[in] ParameterBuffer A pointer to the PRM handler parameter buffer\r
- @param[in] ContextBuffer A pointer to the PRM handler context buffer\r
-\r
- @retval EFI_STATUS The PRM handler executed successfully.\r
- @retval Others An error occurred in the PRM handler.\r
-\r
-**/\r
-EFI_STATUS\r
-PRM_EXPORT_API\r
-EFIAPI\r
-PrmHandler1 (\r
- IN VOID *ParameterBuffer,\r
- IN PRM_CONTEXT_BUFFER *ContextBUffer\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- VOID *NonPagedPool;\r
- CHAR8 DebugMessage[256];\r
-\r
- if (OsServices == NULL || OsServices->DebugPrint == NULL || OsServices->AllocateMemory == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- OsServices->DebugPrint ("Memory Allocation PrmHandler1 entry.\n");\r
- OsServices->DebugPrint (" Requesting allocation of a 256 byte non-paged pool...\n");\r
-\r
- NonPagedPool = NULL;\r
- NonPagedPool = OsServices->AllocateMemory (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, FALSE);\r
- if (NonPagedPool == NULL) {\r
- OsServices->DebugPrint (" NULL was returned from AllocateMemory()...\n");\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- AsciiSPrint (\r
- &DebugMessage[0],\r
- ARRAY_SIZE (DebugMessage),\r
- " Buffer address returned from AllocateMemory() = 0x%016lx.\n",\r
- (UINTN) NonPagedPool\r
- );\r
- OsServices->DebugPrint (&DebugMessage[0]);\r
-\r
- // Write the test data\r
- OsServices->DebugPrint (" Beginning memory buffer write and read back test...\n");\r
- SetMem32 (NonPagedPool, MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, MEMORY_ALLOCATION_TEST_DATA_SIGNATURE);\r
-\r
- // Read back and verify the test data is valid\r
- for (Index = 0, Status = EFI_SUCCESS; Index < (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE / MEMORY_ALLOCATION_TEST_DATA_SIZE); Index++) {\r
- if (((UINT32 *) NonPagedPool)[Index] != MEMORY_ALLOCATION_TEST_DATA_SIGNATURE) {\r
- Status = EFI_DEVICE_ERROR;\r
- break;\r
- }\r
- }\r
- if (EFI_ERROR (Status)) {\r
- OsServices->DebugPrint (" Memory write & read test failed.\n");\r
- } else {\r
- OsServices->DebugPrint (" Memory write & read test passed.\n");\r
- }\r
-\r
- OsServices->DebugPrint ("Memory Allocation PrmHandler1 exit.\n");\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Register the PRM export information for this PRM Module\r
-//\r
-PRM_MODULE_EXPORT (\r
- PRM_HANDLER_EXPORT_ENTRY (PRM_HANDLER_1_GUID, PrmHandler1)\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PrmSampleMemoryAllocationModuleInit (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- return EFI_SUCCESS;\r
-}\r
+++ /dev/null
-## @file\r
-# Sample PRM Driver\r
-#\r
-# This driver simply uses an OS-provided debug message print service to write\r
-# a debug message. Three PRM handlers are provided that each print a unique\r
-# debug message.\r
-#\r
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
-# Copyright (c) Microsoft Corporation\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = PrmSampleMemoryAllocationModule\r
- FILE_GUID = C6B3E74A-12E3-4364-8FB4-8C8B34DD153B\r
- MODULE_TYPE = DXE_RUNTIME_DRIVER\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = PrmSampleMemoryAllocationModuleInit\r
-\r
-[Sources]\r
- PrmSampleMemoryAllocationModule.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- PrmPkg/PrmPkg.dec\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- BaseMemoryLib\r
- PrintLib\r
- UefiDriverEntryPoint\r
- UefiLib\r
-\r
-[Depex]\r
- TRUE\r
-\r
-[BuildOptions.common]\r
- MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE /VERSION:1.0\r
- MSFT:*_*_*_GENFW_FLAGS = --keepoptionalheader\r