> On Nov 26, 2014, at 6:14 AM, Debabrata Chattopadhyay 
> <debabrata.chattopadh...@pmcs.com> wrote:
> 
> Hi,
>  
> In our option ROM for our storage controller , I am trying to allocate some 
> memory using BS->AllocatePool().I see that the call just hangs and never 
> comes out.
>  
> Basically , we have a structure like this :
>  
> Struct A
> {
>                 //some elements
>                 void * ptr;
>                 //some elements
> };
>  
> We are calling BS->Allocate pool with the arguments EfiBootServicesData, 
> sizeof(struct A), (void **)&p  where ā€œpā€ is  of type  Struct A * p  .
>  
> This allocation is successful. The return value is success.
>  
> Now again after this allocation we do another call  to BS->AllocatePool(). 
> The argument passed this time are EfiBootServicesData, sizeof(struct B),(void 
> **)&p->ptr . The intention is to later typecast p->ptr to struct *B and use 
> it.
>  
> This allocation just hangs inside AllocatePool function and control never 
> come out of AllocatePool call.
>  
> Can I get come pointers to debug this issue? Am I missing any finer point 
> here ? memmap command shows ample amount of memory in the system . Addresses 
> allocated in first allocation looks sane enough (0xFXXXXXXX range) .
> Also I have used a skeleton EFI driver to allocate huge amount of memory 
> (around 30000 bytes at one time , running into 1000 loops) with a couple of 
> structure similar to structs A and B above , passed to the Allocatepoo() in 
> the same way as shown above. Allocation is successful in all the 1000 loops. 
> Any ideas ?
>  

Likely it is some memory corruption that is causing the hang. The bug could be 
earlier in your driver?

The allocation will be prefixed with a POOL_HEAD and postfixed with a POOL_TAIL 
structure. The pointer returned by AllocatePool points to POOL_HEAD.Data. So 
you could dump out data around your other allocations to look for buffer over 
run/underrun. 


https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c 
<https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Pool.c>
#define POOL_HEAD_SIGNATURE   SIGNATURE_32('p','h','d','0')
typedef struct {
  UINT32          Signature;
  UINT32          Reserved;
  EFI_MEMORY_TYPE Type;
  UINTN           Size;
  CHAR8           Data[1];
} POOL_HEAD;

#define SIZE_OF_POOL_HEAD OFFSET_OF(POOL_HEAD,Data)

#define POOL_TAIL_SIGNATURE   SIGNATURE_32('p','t','a','l')
typedef struct {
  UINT32      Signature;
  UINT32      Reserved;
  UINTN       Size;
} POOL_TAIL;


#define POOL_SHIFT  7

#define POOL_OVERHEAD (SIZE_OF_POOL_HEAD + sizeof(POOL_TAIL))

#define HEAD_TO_TAIL(a)   \
  ((POOL_TAIL *) (((CHAR8 *) (a)) + (a)->Size - sizeof(POOL_TAIL)));


#define SIZE_TO_LIST(a)   ((a) >> POOL_SHIFT)
#define LIST_TO_SIZE(a)   ((a+1) << POOL_SHIFT)

#define MAX_POOL_LIST       SIZE_TO_LIST(DEFAULT_PAGE_ALLOCATION)

#define MAX_POOL_SIZE     (MAX_ADDRESS - POOL_OVERHEAD)

Thanks,

Andrew Fish


> BTW the platform is Itanium (so I am building an IPF version of our oprom) , 
> 64 bit machine. And the EDK is EDK 2.0. And system BIOS is  confirming to 
> UEFI 2.0.
>  
> Regards
> Deb
>  
>  
>  
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________
>  
> <http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________>
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net <mailto:edk2-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/edk2-devel 
> <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&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