T
T
TheDarhi2020-10-27 10:48:52
C++ / C#
TheDarhi, 2020-10-27 10:48:52

How to work with functions correctly?

Good afternoon,

Faced with the difficulties of recreating "according to" a lesson from DarkTiger .
At the moment:

Let's insert the output of our string into the EntryPoint() function of our driver. In the variable declaration area, we add our variable of type CHAR16 (using double-byte character encoding UCS-2) in the MyFirstDriverDriverEntryPoint() function in MyFirstDriver.c:


CHAR16 *MyString = L"I have written my first UEFI driver\r\n";


After, at the very end of the MyFirstDriverDriverEntryPoint() function, paste the output code of our text variable to the output console (default screen, in our case):


gST->ConOut->OutputString(gST->ConOut, MyString);

And so I understood it like this:

EFI_STATUS
EFIAPI
MyFirstDriverDriverEntryPoint (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  CHAR16 *MyString = L"I have written my first UEFI driver\r\n";
  )
{
  EFI_STATUS  Status;

  Status = EFI_SUCCESS;

  //
  // Install UEFI Driver Model protocol(s).
  //
  Status = EfiLibInstallDriverBindingComponentName2 (
             ImageHandle,
             SystemTable,
             &gMyFirstDriverDriverBinding,
             ImageHandle,
             &gMyFirstDriverComponentName,
             &gMyFirstDriverComponentName2
             );
  ASSERT_EFI_ERROR (Status);

  return Status;
}
  gST->ConOut->OutputString(gST->ConOut, MyString);


and got an error while compiling.

Where is the variable declaration area in the MyFirstDriverDriverEntryPoint() function ?

Insert the output of our string into a function
Does that mean put the given code inside the brackets () ?

After, at the very end of the MyFirstDriverDriverEntryPoint() function
Does that mean before the next function starts? Or at the end of the parenthesis?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lnxlnxlnx, 2020-10-27
@lnxlnxlnx

Before return Status;
The scope of the function begins with the opening of the curly brace, respectively, the exit - when closing. I advise, before writing software products, to learn the language at an easier level

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question