aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c
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/SimpleClassUser.c
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/SimpleClassUser.c')
-rw-r--r--UefiLessonsPkg/SimpleClassUser/SimpleClassUser.c67
1 files changed, 67 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;
+}