Hi Ramesh,

PFA the source code.


On Tue, Dec 3, 2013 at 11:39 AM, Ramesh R. <rame...@ami.com> wrote:

>  Nishit,
>
>
>
>   Could you please attach your draft source where the locate protocol
> works and doesn’t work. That might give us some idea where are going wrong.
>
>
>
> Thanks,
>
> Ramesh
>
>
>
> *From:* Nishit Patira [mailto:nishitpat...@gmail.com]
> *Sent:* Tuesday, December 03, 2013 9:39 AM
>
> *To:* edk2-devel@lists.sourceforge.net
> *Subject:* Re: [edk2] gBS->LocateProtocol
>
>
>
> Hi Justen,
>
>
> No, it is not even returning an error. The GUIDs match, I have verified
> them.
>
>  Regards,
>
> Nishit
>
>
>
> On Sun, Dec 1, 2013 at 3:12 AM, Jordan Justen <jljus...@gmail.com> wrote:
>
> On Sat, Nov 30, 2013 at 10:35 AM, Nishit Patira <nishitpat...@gmail.com>
> wrote:
> > Hii,
> >
> > Yes, it is by a DXE Driver. However, it is not returning anything.
>
> I think you mean that it is returning an error. In other words, the
> call returns, but EFI_ERROR (Status) shows an error was returned. ??
>
> gEfiIntelDimmToolProtocolGuid is not a UEFI protocol, so it probably
> is not surprising that it would not be found on your average UEFI
> system. In that case, your application should exit indicating that it
> was not found.
>
> Are you sure it is being installed by a driver on the system you are
> testing with? If so, then I guess you might double check that the
> GUIDs match.
>
> -Jordan
>
>
> > On Sat, Nov 30, 2013 at 4:06 PM, Galla Rao <gallagnv....@gmail.com>
> wrote:
> >>
> >> Is this Protocol installed by any DXE driver?
> >> The Status should return EFI_NOT_FOUND atleast
> >>
> >>
> >>
> >> On Sat, Nov 30, 2013 at 12:28 PM, Nishit Patira <nishitpat...@gmail.com
> >
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I am writing an UEFI Application. I am using gBS_>LocateProtocol to
> >>> return the instance where the protocl is found.
> >>>
> >>> EFI_STATUS Status;
> >>> gBS = SystemTable->BootServices;
> >>> Status = gBS->LocateProtocol (&gEfiIntelDimmToolProtocolGuid,
> NULL,(void
> >>> **) &mDimmToolProtocol);
> >>>
> >>> However, the function is not returning anything.
> >>>
> >>> Could someone point out the error to me??
> >>>
> >>> Regards,
> >>> Nishit H Patira
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------------
> >>> Rapidly troubleshoot problems before they affect your business. Most IT
> >>> organizations don't have a clear picture of how application performance
> >>> affects their revenue. With AppDynamics, you get 100% visibility into
> >>> your
> >>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
> AppDynamics
> >>> Pro!
> >>>
> >>>
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> >>> _______________________________________________
> >>> edk2-devel mailing list
> >>> edk2-devel@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> >>>
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> Rapidly troubleshoot problems before they affect your business. Most IT
> >> organizations don't have a clear picture of how application performance
> >> affects their revenue. With AppDynamics, you get 100% visibility into
> your
> >> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
> AppDynamics
> >> Pro!
> >>
> >>
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> >>
> >
> >
> >
> ------------------------------------------------------------------------------
> > Rapidly troubleshoot problems before they affect your business. Most IT
> > organizations don't have a clear picture of how application performance
> > affects their revenue. With AppDynamics, you get 100% visibility into
> your
> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> > Pro!
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/edk2-devel
> >
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
>
> The information contained in this message may be confidential and
> proprietary to American Megatrends, Inc. This communication is intended to
> be read only by the individual or entity to whom it is addressed or by
> their designee. If the reader of this message is not the intended
> recipient, you are on notice that any distribution of this message, in any
> form, is strictly prohibited. Please promptly notify the sender by reply
> e-mail or by telephone at 770-246-8600, and then delete or destroy all
> copies of the transmission.
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
#include <Uefi.h>
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Include/stdio.h>
#include <stdlib.h>
#include <Include/string.h>
#include <Include/math.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiShellLib/UefiShellLib.h>
#include <Include/Protocol/cpuio2.h>
#include <Library/PrintLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/DebugLib.h>
#include <Library/ShellCEntryLib.h>

#include "DIMMApp.h"

//#define DEBUG_EFI 0

EFI_HANDLE MyHandle=NULL;


EFI_GUID  gEfiIntelDimmToolProtocolGuid = EFI_INTEL_DIMM_TOOL_PROTOCOL_GUID;
EFI_STATUS Status;
EFI_INTEL_DIMM_TOOL_PROTOCOL         *mDimmToolProtocol;
ADDRESS_DECODE     AddressDecode;
UINT32		TranslateStatus = 0;	

//extern EFI_BOOT_SERVICES     *gBS;
EFI_HANDLE         ImageHandle;
EFI_SYSTEM_TABLE   *SystemTable;
//gBS = SystemTable->BootServices;

void ExitProgram(void);
void translate_file(UINT64, char *);
void translate_console (UINT64);

int main (int argc, char ** argv)
{	
	
	UINT64  PhyAddress = 2342;
	FILE	*infile = NULL;
	char addr_file[16];
	CHAR16 *unicode_str;
	unicode_str = malloc(sizeof(CHAR16)*(strlen(argv[1]) + 1));
	//printf("%d",argc);
	
	MyHandle = ImageHandle;
	Print(L"\n--------------------------------------------------------------\n");
    Print(L"\nIntel (R) DIMM Address Decode Tool. Version 1.3.0.1000 ");
    Print(L"\nCopyright (c) 2012, Intel Corporation. All rights reserved.");
    Print(L"\n--------------------------------------------------------------");

	AsciiStrToUnicodeStr(argv[1], unicode_str);
	printf("\n%s\n",argv[1]);
	printf("\t%s\n",unicode_str);
	//Parse
	if(argc != 2)
	{
		Print(L"\nInvalid arguments. Please check the help option by giving DIMMApp.efi -?");
		ExitProgram();
	}
	else
	{
		printf("Hello1\n");
		if((StrCmp((CONST CHAR16 *)argv[1],(CONST CHAR16 *)"input.txt")) != 0)
		{
			if(!( (StrCmp((CONST CHAR16 *)argv[1], (CONST CHAR16 *)"?")) && (StrCmp((CONST CHAR16 *)argv[1],(CONST CHAR16 *)"-?")) ))
			{
				printf("\nHello2\n");
				Print(L"\nHelp Menu:");
				Print(L"\n<Address>					  :Enter the address to be decoded in hexadecimal");			
				Print(L"\n-------------------------------------------------------------\n");
				return EFI_SUCCESS;			
			}
			else
			{
				printf("\nHello4 inside Hello2\n\n");
				printf("\n\n%x\n\n\n",PhyAddress);
				printf("%s\n\n",argv[0]);
				printf("%s\n\n",argv[1]);
				PhyAddress = (UINT64) StrHexToUint64(unicode_str);
				printf("%d\n",PhyAddress);
				translate_console(PhyAddress) ;
			}
		} 
		else if((StrCmp((CONST CHAR16 *)argv[1],(CONST CHAR16 *)"input.txt")) ==0)
		{
				printf("Hello3\n");
				infile = fopen((const char *)argv[1], "rb");
				if (infile == (FILE*) NULL)
				{
					(void) printf("error: could not load %s\n",unicode_str);
				}
				while(fgets(addr_file,17,infile)!= NULL)
				{
					PhyAddress = (UINT64)StrHexToUint64((CONST CHAR16 *)addr_file) ;
					translate_file(PhyAddress,argv[1]);
				}
		}	
	}
fclose(infile);
return EFI_SUCCESS;
}

#ifdef DEBUG_EFI
		Print(L"\nDIMMMApp:- PhysicalAddress:%x",PhyAddress);
#endif

void translate_file(UINT64 PhyAddress,char *filename)
{
	FILE *outfile;
	AddressDecode.ChannelNumber = 0xFF;
	AddressDecode.DIMMNumber = 0xFF;	
	printf("This is before in file\n");
	printf("%d\n",Status);
	gBS = SystemTable->BootServices;
	printf("This is after in file\n");
	printf("%d\n",Status);
	Status = gBS->LocateProtocol (&gEfiIntelDimmToolProtocolGuid, NULL,(void **) &mDimmToolProtocol);
	if(Status != 0)
	{
		Print(L"\nDIMMDXE Driver may not be loaded properly");
		ExitProgram();
	}
	TranslateStatus = mDimmToolProtocol->TranslatePhysicalAddress(PhyAddress,&AddressDecode);
	if(TranslateStatus != 0)
	{
			outfile = fopen("output.txt","a");
			fprintf(outfile, "%x\t", PhyAddress);
			fprintf(outfile, "%x\t", AddressDecode.ChannelNumber);
			fprintf(outfile, "%x\t", AddressDecode.DIMMNumber);
			fprintf(outfile, "%x\t", AddressDecode.Rank);
			fprintf(outfile, "%x\t", AddressDecode.Bank);
			fprintf(outfile, "%x\t", AddressDecode.CAS);
			fprintf(outfile, "%x\n", AddressDecode.RAS);
			fclose(outfile);
		}
		
	else
		Print(L"\nInvalid Address");
}

void translate_console(UINT64 PhyAddress)
{
	printf("This is before in console\n");
	printf("%d\n",Status);
	gBS = SystemTable->BootServices;
	printf("This is after in console\n");
	printf("%d\n",Status);
	AddressDecode.ChannelNumber = 0xFF;
	
	AddressDecode.DIMMNumber = 0xFF;	
	printf("%d",AddressDecode.DIMMNumber);
	Status = gBS->LocateProtocol (&gEfiIntelDimmToolProtocolGuid, NULL,(void **) &mDimmToolProtocol);
	printf("Test 1");
	if(Status != 0)
	{
		printf("\nDIMMDXE Driver may not be loaded properly");
		ExitProgram();
	}
	TranslateStatus = mDimmToolProtocol->TranslatePhysicalAddress(PhyAddress,&AddressDecode);
	printf("Test 2");
	printf("%d",TranslateStatus);
	if(TranslateStatus != 0)
	{
		
			printf("\nPhysicalAddress: %x \nChannelNumber: %x \nDIMMNumber: %x",PhyAddress,AddressDecode.ChannelNumber,AddressDecode.DIMMNumber);
			printf("\nRank: %x \nBank: %x",AddressDecode.Rank, AddressDecode.Bank);
			printf("\nCAS: 0x%x  \nRAS: 0x%x",AddressDecode.CAS, AddressDecode.RAS);
		
	}
	else
		Print(L"\nInvalid Address");
		ExitProgram();
	
}
void ExitProgram(void)
{
	gBS->Exit(MyHandle, EFI_ABORTED,0,NULL);
}
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to