> On May 30, 2016, at 12:29 PM, Vladimir Olovyannikov 
> <vladimir.olovyanni...@broadcom.com> wrote:
> 
>> -----Original Message-----
>> From: af...@apple.com [mailto:af...@apple.com]
>> Sent: Monday, May 30, 2016 11:53 AM
>> To: Vladimir Olovyannikov
>> Cc: edk2-de...@ml01.01.org
>> Subject: Re: [edk2] EfiConvertPointer/AllocatePages for an address
> return
>> EFI_NOT FOUND
>> 
>> 
>>> On May 30, 2016, at 11:38 AM, Vladimir Olovyannikov
>> <vladimir.olovyanni...@broadcom.com> wrote:
>>> 
>>> Hi Andrew,
>>> Please see below.
>>> The region of interest is marked as "Reserved".
>>> 
>>> Thanks,
>>> Vladimir
>>> 
>>>> -----Original Message-----
>>>> From: af...@apple.com [mailto:af...@apple.com]
>>>> Sent: Monday, May 30, 2016 11:32 AM
>>>> To: Vladimir Olovyannikov
>>>> Cc: edk2-de...@ml01.01.org
>>>> Subject: Re: [edk2] EfiConvertPointer/AllocatePages for an address
>>> return
>>>> EFI_NOT FOUND
>>>> 
>>>> 
>>>>> On May 30, 2016, at 10:37 AM, Vladimir Olovyannikov
>>>> <vladimir.olovyanni...@broadcom.com> wrote:
>>>>> 
>>>>> 
>>>>> Hello All,
>>>>> 
>>>>> I faced an issue with my UEFI implementation (Armv8 64 bit
> platform).
>>>>> I need to convert a device physical address to the virtual on
>>>>> VirtualAddressChange event.
>>>>> EfiConvertPointer always returns EFI_NOT_FOUND.
>>>>> 
>>>>> I tried to allocate just an address:
>>>>> gBS->AllocatePages(AllocateAddress, EfiRuntimeServicesCode, 1,
>>>>> &MyAddress); // Allocate one page
>>>>> where MyAddress is 0x65042000.
>>>>> Which also returns  EFI_NOT_FOUND.
>>>>> 
>>>>> I declared this device's memory in the Platform memory lib as
>>>>> 
>>>>> // Mydevice
>>>>> // 1MB @0x65000000 (0x65000000 - 0x650fffff)
>>>>> MMUTable[++Index].PhysicalBase    = MY_DEV_BASE;
>>>>> MMUTable[Index].VirtualBase            = MY_DEV_BASE;
>>>>> MMUTable[Index].Length                     = MY_DEV_SZ; // SIZE_1MB
>>>>> MMUTable[Index].Attributes              =
>>>>> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>>>>> 
>>>>> I can access this device perfectly from BootServices (read/write)
> with
>>> MMU
>>>>> (1:1) on.
>>>>> But it is nowhere in virtual table map which
>>>>> AllocatePages()/EfiConvertPointer() eventually use.
>>>>> 
>>>>> Please let me know what I am missing here?
>>>>> I have declared this memory as a Runtime with
>>>>> 
>>>>> Status = gDS->AddMemorySpace (
>>>>>              EfiGcdMemoryTypeMemoryMappedIo,
>>>>>              AlignedAddr, SIZE_64KB,
>>>>>              EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
>>>>>                );
>>>>> if (!EFI_ERROR (Status)) {
>>>>>    Status = gDS->SetMemorySpaceAttributes (
>>>>>                  AlignedAddr,
>>>>>                  SIZE_64KB,
>>>>>                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
>>>>>                    );
>>>>> }
>>>>> 
>>>> 
>>>> If you boot to the UEFI shell and dump the memory map what to do you
>>> see?
>>> 
>> 
>> The attribute is wrong, so it was not allocate correctly.
>> 
>> #define EFI_MEMORY_RUNTIME       0x8000000000000000
>> 
>> Did you check all the return Status from your gDS calls? You can read up
>> about them in the PI spec from the UEF Forum website.
>> 
>> If you do a gDS->GetMemorySpaceDescriptor() for the  AlignedAddr does it
>> succeed? If yes I think you want to get the descriptor and then set the
>> memory space attribute.
> OK. I think my attempt to build a resource descriptor hob for this device
> was wrong.
>    ResourceAttributes = (
>    EFI_RESOURCE_ATTRIBUTE_PRESENT |
>    EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
>    EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE );
>    BuildResourceDescriptorHob (EFI_RESOURCE_MEMORY_MAPPED_IO_PORT,
>                                      ResourceAttributes,
>                                      PcdGet32(PcdPlatformResetAddr) &
> ~(SIZE_64KB - 1),
>                                      SIZE_64KB);
> This is what provided the "Reserved".
> 
> When I removed it memmap gave me 65002000 as "Mmio" and ConvertPointer
> succeeded.
> 
> One thing which is not quite clear to me:
> Should I not declare this device in the Viirtual memory table for the
> platform and just use AddMemorySpace instead ?
> 

I was thinking the PI spec would be clear on what to do. I've not had a chance 
to reread that section. 

>From looking at the Quark code:
~/work/src/edk2(master)>cd QuarkSocPkg; git grep -W GetMemorySpaceDescriptor
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c=371=QNCInitializeResource (
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-372-  )
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-373-{
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-374-  EFI_PHYSICAL_ADDRESS            
BaseAddress;
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-375-  EFI_STATUS                      
Status;
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-376-  UINT64                          
ExtraRegionLength;
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-377-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR 
Descriptor;
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-378-  UINTN                           
Index;
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-379-
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-380-  // Report TSEG range
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-381-  // This range maybe has been 
reportted in PEI phase via Resource Hob.
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-382-  //
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-383-  QNCGetTSEGMemoryRange 
(&BaseAddress, &ExtraRegionLength);
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-384-  if (ExtraRegionLength != 0) {
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c:385:    Status = 
gDS->GetMemorySpaceDescriptor (BaseAddress, &Descriptor);
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-386-    if (Status == EFI_NOT_FOUND) {
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-387-      Status = gDS->AddMemorySpace (
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-388-                      
EfiGcdMemoryTypeReserved,
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-389-                      BaseAddress,
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-390-                      
ExtraRegionLength,
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-391-                      EFI_MEMORY_UC
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-392-                      );
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-393-    }
QuarkNorthCluster/QNCInit/Dxe/QNCInit.c-394-  }

So if you construct the HOB then you should just be able to do  
gDS->GetMemorySpaceDescriptor(), you only need to  gDS->AddMemorySpace() if it 
does not exist. 

Thanks,

Andrew Fish

> Thank you,
> Vladimir
>> 
>> Thanks,
>> 
>> Andrew Fish
>> 
>>> Shell> memmap
>>> Type       Start            End              # Pages
> Attributes
>>> Available  0000000080000000-0000000084FFFFFF 0000000000005000
>>> 000000000000000F
>>> Available  00000000850F0000-00000000B986FFFF 0000000000034780
>>> 000000000000000F
>>> RT_Data    00000000B9870000-00000000B98DFFFF 0000000000000070
>>> 800000000000000F
>>> Available  00000000B98E0000-00000000B98E5FFF 0000000000000006
>>> 000000000000000F
>>> LoaderCode 00000000B98E6000-00000000B9A12FFF 000000000000012D
>>> 000000000000000F
>>> BS_Code    00000000B9A13000-00000000B9B8FFFF 000000000000017D
>>> 000000000000000F
>>> RT_Data    00000000B9B90000-00000000B9BDFFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9BE0000-00000000B9C2FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Data    00000000B9C30000-00000000B9C7FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9C80000-00000000B9CCFFFF 0000000000000050
>>> 800000000000000F
>>> RT_Data    00000000B9CD0000-00000000B9D1FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9D20000-00000000B9D7FFFF 0000000000000060
>>> 800000000000000F
>>> ACPI_Recl  00000000B9D80000-00000000B9D9FFFF 0000000000000020
>>> 000000000000000F
>>> RT_Data    00000000B9DA0000-00000000B9DEFFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9DF0000-00000000B9E3FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Data    00000000B9E40000-00000000B9E8FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9E90000-00000000B9EDFFFF 0000000000000050
>>> 800000000000000F
>>> RT_Data    00000000B9EE0000-00000000B9F2FFFF 0000000000000050
>>> 800000000000000F
>>> RT_Code    00000000B9F30000-00000000B9F7FFFF 0000000000000050
>>> 800000000000000F
>>> Available  00000000B9F80000-00000000B9F80FFF 0000000000000001
>>> 000000000000000F
>>> 
>>> Reserved   00000000B9F81000-00000000B9F84FFF 0000000000000004
>>> 000000000000000F
>>> 
>>> BS_Code    00000000B9F85000-00000000B9F8BFFF 0000000000000007
>>> 000000000000000F
>>> 
>>> Available  00000000B9F8C000-00000000BCA7AFFF 0000000000002AEF
>>> 000000000000000F
>>> 
>>> BS_Data    00000000BCA7B000-00000000BEDBFFFF 0000000000002345
>>> 000000000000000F
>>> 
>>> Available  00000000BEDC0000-00000000BEDC5FFF 0000000000000006
>>> 000000000000000F
>>> 
>>> BS_Code    00000000BEDC6000-00000000BEF4FFFF 000000000000018A
>>> 000000000000000F
>>> 
>>> Available  00000000BEF50000-00000000BEFBFFFF 0000000000000070
>>> 000000000000000F
>>> 
>>> RT_Data    00000000BEFC0000-00000000BEFEFFFF 0000000000000030
>>> 800000000000000F
>>> 
>>> Available  00000000BEFF0000-00000000BEFFEFFF 000000000000000F
>>> 000000000000000F
>>> 
>>> BS_Data    00000000BEFFF000-00000000BEFFFFFF 0000000000000001
>>> 000000000000000F
>>> 
>>> Available  00000000BF000000-00000000BF293FFF 0000000000000294
>>> 000000000000000F
>>> 
>>> BS_Data    00000000BF294000-00000000BFFFFFFF 0000000000000D6C
>>> 000000000000000F
>>> 
>>> Reserved   0000000065020000-000000006502FFFF 0000000000000010
>>> 0000000000000001
>>> 
>>> 
>>> 
>>> Reserved  :             20 Pages (81,920 Bytes)
>>> 
>>> LoaderCode:            301 Pages (1,232,896 Bytes)
>>> 
>>> LoaderData:              0 Pages (0 Bytes)
>>> 
>>> BS_Code   :            782 Pages (3,203,072 Bytes)
>>> 
>>> BS_Data   :         12,466 Pages (51,060,736 Bytes)
>>> 
>>> RT_Code   :            496 Pages (2,031,616 Bytes)
>>> 
>>> RT_Data   :            640 Pages (2,621,440 Bytes)
>>> 
>>> ACPI_Recl :             32 Pages (131,072 Bytes)
>>> 
>>> ACPI_NVS  :              0 Pages (0 Bytes)
>>> 
>>> MMIO      :              0 Pages (0 Bytes)
>>> 
>>> MMIO_Port :              0 Pages (0 Bytes)
>>> 
>>> PalCode   :              0 Pages (0 Bytes)
>>> 
>>> Available :        247,183 Pages (1,012,461,568 Bytes)
>>> 
>>>             --------------
>>> 
>>> Total Memory:          1,023 MB (1,072,742,400 Bytes)
>>> 
>>> 
>>>> 
>>>> Thanks,
>>>> 
>>>> Andrew Fish
>>>> 
>>>>> Thank you,
>>>>> Vladimir
>>>>> _______________________________________________
>>>>> edk2-devel mailing list
>>>>> edk2-devel@lists.01.org
>>>>> https://urldefense.proofpoint.com/v2/url?u=https-
>>>> 3A__lists.01.org_mailman_listinfo_edk2-2Ddevel&d=CwICAg&c=Hw-
>>>> 
>> EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=4sdzHKz0eU1vXqaUyS
>>>> VmyA&m=dj-
>>>> 
>> PLSCQ4D53smC8eOprHa7aKtcLYkZDhDWnczTquDU&s=jb4N3rlGt6jI92m5sab
>>>> AKDmsB2T9jdtvYQhw_A91Xi4&e=
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to