aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/SimpleClassUser
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/SimpleClassUser
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/SimpleClassUser')
-rw-r--r--UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c67
-rw-r--r--UefiLessonsPkg/SimpleClassUser/SimpleClassUser.inf22
2 files changed, 89 insertions, 0 deletions
diff --git a/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c b/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c
new file mode 100644
index 0000000..bd3ac1d
--- /dev/null
+++ b/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c
@@ -0,0 +1,67 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/SimpleClass.h>
+
+EFI_STATUS
+EFIAPI
+UefiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ UINTN HandleCount;
+ EFI_HANDLE* HandleBuffer;
+ UINTN Index;
+ SIMPLE_CLASS_PROTOCOL* SimpleClass;
+
+ EFI_STATUS Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gSimpleClassProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ Print(L"Error! Can't find any handle with gSimpleClassProtocolGuid: %r\n", Status);
+ return Status;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Print(L"Handle = %p\n", HandleBuffer[Index]);
+ Status = gBS->OpenProtocol(
+ HandleBuffer[Index],
+ &gSimpleClassProtocolGuid,
+ (VOID **)&SimpleClass,
+ ImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+
+ if (!EFI_ERROR(Status)) {
+ UINTN Number;
+
+ Status = SimpleClass->GetNumber(&Number);
+ if (!EFI_ERROR(Status)) {
+ Print(L"Number before=%d\n", Number);
+ } else {
+ Print(L"Error! Can't get number: %r\n", Status);
+ }
+
+ Status = SimpleClass->SetNumber(Number+5);
+ if (EFI_ERROR(Status))
+ Print(L"Error! Can't set number: %r\n", Status);
+
+ Status = SimpleClass->GetNumber(&Number);
+ if (!EFI_ERROR(Status)) {
+ Print(L"Number after=%d\n", Number);
+ } else {
+ Print(L"Error! Can't get number: %r\n", Status);
+ }
+ } else {
+ Print(L"Error! Can't open SimpleClass protocol: %r\n", Status);
+ }
+ }
+
+ return Status;
+}
diff --git a/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.inf b/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.inf
new file mode 100644
index 0000000..cb57e68
--- /dev/null
+++ b/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.inf
@@ -0,0 +1,22 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleClassUser
+ FILE_GUID = 466eed70-8def-44ea-9fb4-9012b266ec8c
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = UefiMain
+
+[Sources]
+ SimpleClassUser.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+
+[Protocols]
+ gSimpleClassProtocolGuid
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+