From ea49e59ed0fc50085716e55d66395b6afef8a554 Mon Sep 17 00:00:00 2001
From: Konstantin Aladyshev <aladyshev22@gmail.com>
Date: Mon, 12 Jul 2021 15:28:51 +0300
Subject: Update UefiLessonsPkg

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
---
 .../SimpleClassProtocol/SimpleClassProtocol.c      | 84 ++++++++++++++++++++++
 .../SimpleClassProtocol/SimpleClassProtocol.inf    | 23 ++++++
 2 files changed, 107 insertions(+)
 create mode 100644 UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.c
 create mode 100644 UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.inf

(limited to 'UefiLessonsPkg/SimpleClassProtocol')

diff --git a/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.c b/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.c
new file mode 100644
index 0000000..8bd7f87
--- /dev/null
+++ b/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.c
@@ -0,0 +1,84 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/SimpleClass.h>
+
+
+EFI_HANDLE  mSimpleClassHandle = NULL;
+
+UINTN mNumber = 0;
+
+EFI_STATUS
+EFIAPI
+SimpleClassProtocolSetNumber (
+  UINTN Number
+  )
+{
+  mNumber = Number;
+
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+SimpleClassProtocolGetNumber (
+  UINTN* Number
+  )
+{
+  if (Number == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Number = mNumber;
+
+  return EFI_SUCCESS;
+}
+
+
+SIMPLE_CLASS_PROTOCOL  mSimpleClass = {
+  SimpleClassProtocolGetNumber,
+  SimpleClassProtocolSetNumber
+};
+
+
+EFI_STATUS
+EFIAPI
+SimpleClassProtocolDriverUnload (
+  IN EFI_HANDLE        ImageHandle
+  )
+{
+  Print(L"Bye-bye from SimpleClassProtocol driver, handle=%p\n", mSimpleClassHandle);
+
+  EFI_STATUS Status = gBS->UninstallMultipleProtocolInterfaces(
+                             mSimpleClassHandle,
+                             &gSimpleClassProtocolGuid,
+                             &mSimpleClass,
+                             NULL
+                             );
+
+  return Status;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleClassProtocolDriverEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  Print(L"Hello from SimpleClassProtocol driver");
+
+  EFI_STATUS Status = gBS->InstallMultipleProtocolInterfaces(
+                             &mSimpleClassHandle,
+                             &gSimpleClassProtocolGuid,
+                             &mSimpleClass,
+                             NULL
+                             );
+  if (!EFI_ERROR(Status))
+    Print(L", handle=%p\n", mSimpleClassHandle);
+  else
+    Print(L"\n", mSimpleClassHandle);
+
+  return Status;
+}
diff --git a/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.inf b/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.inf
new file mode 100644
index 0000000..edd2297
--- /dev/null
+++ b/UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.inf
@@ -0,0 +1,23 @@
+[Defines]
+  INF_VERSION                    = 1.25
+  BASE_NAME                      = SimpleClassProtocol
+  FILE_GUID                      = 51d6a90a-c021-4472-b2c1-5fdd1b7f2196
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = SimpleClassProtocolDriverEntryPoint
+  UNLOAD_IMAGE                   = SimpleClassProtocolDriverUnload
+
+[Sources]
+  SimpleClassProtocol.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiLessonsPkg/UefiLessonsPkg.dec
+
+[Protocols]
+  gSimpleClassProtocolGuid
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  UefiLib
+
-- 
cgit v1.2.3-18-g5258