On Apr 9, 2013, at 12:15 PM, Rafael Machado <rafaelrodrigues.mach...@gmail.com> 
wrote:

> The only point I imagine is that there is a possibility of some application 
> fail if it alocates the first page returned by the GetMemoryMap function even 
> with this page being of type Desc->Type == EfiConventionalMemory And this 
> seems to be possible when CSM is disabled.

Again it should not matter what addresses get allocated from an EFI point of 
view. The EFI memory manager will tend to allocate from higher memory and leave 
low memory free for OS or CSM usage.  

>  
> Should I disconsider the first MB returned by the GetMemoryMap ?
>  

Are you writing an OS loader is that why you are calling GetMemoryMap? If an 
EFI application needs memory it can call gBS->AllocatePool() (or a library 
equivalent) to get memory. An EFI application should not make any assumptions 
about where memory exists in the system. For example a non PC compatible system 
could have FLASH mapped at zero and that is totally legal. Some ARM processors 
use zero as the reset vector.

So if you don't call GetMemoryMap()/AllocatePages() and just call 
AllocatePool() your problems would go away. You have not explained why you need 
to control the addresses where memory gets allocated in the system. EFI has no 
restrictions on where memory exists or gets allocated. For example allocating 
pages < 4GB is good for supporting broken PCI hardware that does not support 
DMA above 4GB. Allocating specific addresses is needed to allocate the BDA or 
fill in the real mode interrupt vector tables. None of this is required by EFI, 
but it could be required by the system. 

Thanks,

Andrew Fish

> Thanks a lot for the help.
> Rafael R. Machado
> 
> 
> 2013/4/9 Andrew Fish <af...@apple.com>
> 
> On Apr 9, 2013, at 11:42 AM, Rafael Machado 
> <rafaelrodrigues.mach...@gmail.com> wrote:
> 
>> I think I was not clear. I didn't add all information
>> The first step at the application is to get the MemoryMap 
>> (gBS->GetMemoryMap), and after that, alocate the pages of the first block I 
>> can access Based on the description of that page if  Desc->Type == 
>> EfiConventionalMemory
>>  
>> The problem seems that the first block returned by GetMemoryMap is 0xC000 if 
>> CSM is ON. But it is 0x0000 if CSM is off.
>>  
>> Do you mean I should not call AllocatePages starting at 0x0000? Instead of 
>> that, should I allocate starting at 1MB even when the map indicates it 
>> starts at 0x0000 ?
>>  
>> Am I right ?
>>  
> 
> Why do you care what memory address you allocate? 
> 
> Thanks,
> 
> Andrew Fish
> 
>> Rafael R. Machado
>>          
>> 
>> 2013/4/9 Andrew Fish <af...@apple.com>
>> 
>> 
>> On Apr 9, 2013, at 10:50 AM, Rafael Machado 
>> <rafaelrodrigues.mach...@gmail.com> wrote:
>> 
>>> Hi Andrew
>>>  
>>> Thanks for the answer.
>>> It's strange the the application allocated these addresses.
>>> These seems to be at the BDA right ? They should not be allocated.
>>>  
>>> At the application I use several calls to:
>>>  
>>> gBS->AllocatePool(EfiBootServicesData,
>>>  sizeof(EFI_MEMORY_BLOCKS),
>>>  (VOID**) &MemoryBlocks);
>>>  
>>> Now I think this may be an error at my code.
>>> What type of MEMORY_TYPE should I use at the AllocatePool call so only 
>>> addresses I can used are returned ?
>>>  
>> 
>> EfiBootServicesData is OK. 
>> 
>>> Does the memory_type parameter works like a filter at this function 
>>> (AllocatePool) ?
>>> I mean, depending on the memory_type no bda memory area is returned. Does 
>>> this make sence ?
>>>  
>> 
>> No. 
>> 
>> If you want to go after specific addressees you need to use 
>> gBS->AllocatePages()
>> 
>> Per Chapter 6 of the UEFI spec with AllocatePages() you can request an 
>> arbitrary page, an address < a certain max address value (like < 4GB), or a 
>> specific address. 
>> 
>>     //*******************************************************
>>     //EFI_ALLOCATE_TYPE
>>     //*******************************************************
>>     // These types are discussed in the “Description” section below.
>>     typedef enum {
>>         AllocateAnyPages,
>>         AllocateMaxAddress,
>>         AllocateAddress,
>>         MaxAllocateType
>>      } EFI_ALLOCATE_TYPE;
>> 
>>> Thanks
>>> Rafael R. Machado
>>>  
>>> 
>>> 
>>> 2013/4/9 Andrew Fish <af...@apple.com>
>>> 
>>> On Apr 9, 2013, at 7:48 AM, Rafael Machado 
>>> <rafaelrodrigues.mach...@gmail.com> wrote:
>>> 
>>>> After some debug here comes the question.
>>>> Why am I able to allocated more memory when csm is off ?
>>> 
>>> Because the CSM allocates memory when it runs. 
>>> 
>>>>  
>>>> Does uefi have some kind of virtual memory ?
>>> 
>>> Not generally. For X64 and ARM paging is enabled but virtual == physical 
>>> addresses. 
>>> 
>>> Why are you allocating memory < 1 MB? In EFI memory is memory.
>>> 
>>> Thanks,
>>> 
>>> Andrew Fish
>>> 
>>>>  
>>>> Thanks and Regards
>>>> Rafael R. Machado
>>>>  
>>>> 
>>>> 
>>>> 2013/4/9 Rafael Machado <rafaelrodrigues.mach...@gmail.com>
>>>> Hi everyone
>>>> 
>>>> 
>>>> I'm having some problems with an uefi application that works perfectly 
>>>> when CSM (Compatibility Support Module) is enabled but doesn't work when 
>>>> CSM is off.
>>>> 
>>>> At the application I have a big array allocated to store some data.
>>>> 
>>>> When CSM is on I have:
>>>> 
>>>> 
>>>> current address: 0000000000066FF8
>>>>  next address: 0000000000066FF0 (current --)
>>>> 
>>>> 
>>>> But when I have csm of:
>>>> 
>>>> 
>>>> current address: 0000000000086FF8
>>>> next address: FFFFFFFFFF886FF8 (current --)
>>>> 
>>>> Any idea about this error ?
>>>> 
>>>> I know that several changes happen when csm is on or off, but probably you 
>>>> may know the exactly reason that cause this error.
>>>> 
>>>> 
>>>> Thanks everyone.
>>>> 
>>>> Rafael R. Machado
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Precog is a next-generation analytics platform capable of advanced
>>>> analytics on semi-structured data. The platform includes APIs for building
>>>> apps and a phenomenal toolset for data science. Developers can use
>>>> our toolset for easy data analysis & visualization. Get a free account!
>>>> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Precog is a next-generation analytics platform capable of advanced
>>> analytics on semi-structured data. The platform includes APIs for building
>>> apps and a phenomenal toolset for data science. Developers can use
>>> our toolset for easy data analysis & visualization. Get a free account!
>>> http://www2.precog.com/precogplatform/slashdotnewsletter
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Precog is a next-generation analytics platform capable of advanced
>>> analytics on semi-structured data. The platform includes APIs for building
>>> apps and a phenomenal toolset for data science. Developers can use
>>> our toolset for easy data analysis & visualization. Get a free account!
>>> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Precog is a next-generation analytics platform capable of advanced
>> analytics on semi-structured data. The platform includes APIs for building
>> apps and a phenomenal toolset for data science. Developers can use
>> our toolset for easy data analysis & visualization. Get a free account!
>> http://www2.precog.com/precogplatform/slashdotnewsletter
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Precog is a next-generation analytics platform capable of advanced
>> analytics on semi-structured data. The platform includes APIs for building
>> apps and a phenomenal toolset for data science. Developers can use
>> our toolset for easy data analysis & visualization. Get a free account!
>> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> 
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> 
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to