Re: [edk2] introductory questions about uefi programming

Subject: Re: [edk2] introductory questions about uefi programming

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2012-05-06 18:15:36

As you can see the HelloWorld.inf file is not in the OvmfPkg DSC files:
~/work/edk2TOT>find . -iname "*dsc" -exec grep -l  HelloWorld.inf {} \;
./BeagleBoardPkg/BeagleBoardPkg.dsc
./DuetPkg/DuetPkgIa32.dsc
./DuetPkg/DuetPkgX64.dsc
./EmulatorPkg/EmulatorPkg.dsc
./MdeModulePkg/MdeModulePkg.dsc
./Nt32Pkg/Nt32Pkg.dsc
./UnixPkg/UnixPkg.dsc
./UnixPkg/UnixPkgX64.dsc

If you look at https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/OvmfPkg/build.sh you will see that the main build command is:
build -p $PLATFORMFILE $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS

I'm on a Mac using Xcode so I need to set the compiler to XCLANG, you will need to set it you your compiler. This is the error you get from the clang C compiler on an undefined PCD token name. 
~/work/edk2TOT>. edksetup.sh BaseTools
~/work/edk2TOT>build -a X64 -p MdeModulePkg/MdeModulePkg.dsc -t XCLANG
/Users/fish/work/edk2TOT/MdeModulePkg/Application/HelloWorld/HelloWorld.c:53:22: error: use of undeclared identifier '_PCD_GET_MODE_PTR_PcdThisWillFail'
        Print ((CHAR16*)PcdGetPtr (PcdThisWillFail));
                        ^
/Users/fish/work/edk2TOT/MdePkg/Include/Library/PcdLib.h:419:63: note: instantiated from:
#define PcdGetPtr(TokenName)                _PCD_GET_MODE_PTR_##TokenName
                                                              ^
<scratch space>:15:1: note: instantiated from:
_PCD_GET_MODE_PTR_PcdThisWillFail
^
1 error generated.


You can also use the #error pragma in your C code to force a compiler error. 

/Users/fish/work/edk2TOT/MdeModulePkg/Application/HelloWorld/HelloWorld.c:15:2: error: #error The error pragma can also be used to force an error
#error The error pragma can also be used to force an error
 ^
1 error generated.


Andrew Fish





On May 6, 2012, at 5:00 AM, Iurie wrote:

yes, i also thought taht the the problem was this, but when i compile with the command: OvmfPkg/build.sh
it is not very clear in the terminal when the HelloWorld and other source code files are well compiled or not.

so, is there a way to see, like when i compile c code with gcc, the line and the file and the problem that is the source of the compilation error?

or at least is there a way when i compile with the command OvmfPkg/build.sh  to see i in the terminal if the compilation was succesfull or not?


On 5 May 2012 15:07, Andrew Fish <afish@apple.com> wrote:
You are not building the code. Random PCD values do not compile.


Sent from my iPhone

On May 5, 2012, at 5:10 AM, Iurie <iurcic@gmail.com> wrote:

i also have changed the code to :

  if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
  	for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
  	  //
  	  // Use UefiLib Print API to print string to UEFI console
  	  //
    	Print ((CHAR16*)PcdGetPtr (PcdHelloWorldPrintString));
Print ((CHAR16*)PcdGetPtr (PcdHelloWorldPrintString));  } }
but i am always getting the same output

On 5 May 2012 12:31, Iurie <iurcic@gmail.com> wrote:
i even was not expecting the string: uefi hello world to be printed


On 5 May 2012 11:45, Iurie <iurcic@gmail.com> wrote:
ola--> is a generic word that i put there to see what will happen, unfortunatedly i have not got what i was expecting

On 5 May 2012 11:43, Iurie <iurcic@gmail.com> wrote:
when i compile to get some error message


On 5 May 2012 11:43, Iurie <iurcic@gmail.com> wrote:
yes, but i was expecting at least to get some error message, or even when i compile it with the command
OvmfPkg/build.sh

On 5 May 2012 03:23, Andrew Fish <afish@apple.com> wrote:
Lurie,

What is ola? It does not exist in the open source code. Show use how you defined ola in a .DEC file, and what you set it to in your .DSC file. 

/**
  The user Entry Point for Application. The user code starts with this function
  as the real entry point for the application.

  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  
  @param[in] SystemTable    A pointer to the EFI System Table.
  
  @retval EFI_SUCCESS       The entry point is executed successfully.
  @retval other             Some error occurs when executing this entry point.

**/
EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
	UINT32 Index;
	
	Index = 0;
  
  //
  // Three PCD type (FeatureFlag, UINT32 and String) are used as the sample.
  //
  if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
  	for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
  	  //
  	  // Use UefiLib Print API to print string to UEFI console
  	  //
    	Print ((CHAR16*)PcdGetPtr (PcdHelloWorldPrintString));
    }
  }

  return EFI_SUCCESS;
}


Andrew Fish





On May 4, 2012, at 7:03 PM, Iurie wrote:

hello,
i am a beginer to the uefi programming (gsoc) so i am coming through this way to get some help from the uefi/edk community

today i had been finnaly able to run the hello world program.

beside that i have some questions regarding it.

so this is the original hello world program:

EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
    UINT32 Index;
    
    Index = 0;
 
  //
  // Three PCD type (FeatureFlag, UINT32 and String) are used as the sample.
  //
  if (FeaturePcdGet (ola)) {
      for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
        //
        // Use UefiLib Print API to print string to UEFI console
        //
    Print ((CHAR16*)PcdGetPtr (PcdHelloWorldPrintString));
    }
  }

  return EFI_SUCCESS;
}



when i change the code to the following one:


EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
    UINT32 Index;
    
    Index = 0;
 
  //
  // Three PCD type (FeatureFlag, UINT32 and String) are used as the sample.
  //
  if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
      for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
        //
        // Use UefiLib Print API to print string to UEFI console
        //
      Print ((UINT16*)PcdGet32 (ola));
        Print ((CHAR16*)PcdGetPtr (ola));
    Print ((CHAR16*)PcdGetPtr (ola));
    }
  }

  return EFI_SUCCESS;
}


i get always the same output, which is uefi hello world!

so why it keeps the same output if i have changed there something?

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel






------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel