aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/SimpleClassProtocol
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-12 15:28:51 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-12 15:34:20 +0300
commitea49e59ed0fc50085716e55d66395b6afef8a554 (patch)
tree91089f5b20ede7ee53f7f613b2d5eb72a23a1017 /UefiLessonsPkg/SimpleClassProtocol
parentf980e8c1e946285a212fad287164b0c9ef3b1625 (diff)
downloadUEFI-Lessons-ea49e59ed0fc50085716e55d66395b6afef8a554.tar.gz
UEFI-Lessons-ea49e59ed0fc50085716e55d66395b6afef8a554.tar.bz2
UEFI-Lessons-ea49e59ed0fc50085716e55d66395b6afef8a554.zip
Update UefiLessonsPkg
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'UefiLessonsPkg/SimpleClassProtocol')
-rw-r--r--UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.c84
-rw-r--r--UefiLessonsPkg/SimpleClassProtocol/SimpleClassProtocol.inf23
2 files changed, 107 insertions, 0 deletions
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
+