aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/SimpleClassProtocol
diff options
context:
space:
mode:
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
+