public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Query on Variable Services
@ 2019-01-17 17:23 galla rao
  2019-01-17 17:54 ` Andrew Fish
  0 siblings, 1 reply; 4+ messages in thread
From: galla rao @ 2019-01-17 17:23 UTC (permalink / raw)
  To: edk2-devel

Hi All,

Have a question for Variable services

Given PCD's are initialized

 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase   | 0xFFE00000

  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase |
0xFFE3E000

  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase   |
0xFFE40000

Do i need to make these regions as *EFI_MEMORY_RUNTIME *through
*gDS->SetMemorySpaceAttributes*

SPI Flash writes within BIOS works good!

*when trying to change BootOrder from efibootmgr, the failure is seen*

It would be useful if someone has faced this issue earlier and can respond
kindly.

Best Regards
Galla


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Query on Variable Services
  2019-01-17 17:23 Query on Variable Services galla rao
@ 2019-01-17 17:54 ` Andrew Fish
  2019-01-17 18:26   ` galla rao
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Fish @ 2019-01-17 17:54 UTC (permalink / raw)
  To: galla rao; +Cc: edk2-devel

Galla,

The PCD value usually get set as the result of the build. 

EFI_MEMORY_RUNTIME attribute is used to request a virtual mapping from the OS. When the variable services are called from the OS the run in a virtual address space provided by the OS. Thus trying to access 0xFFE00000 would page fault. 

You can run the memmap command from the EFI Shell and see if bit 63 is set. If your SPI controller is a memory mapped hardware device you may also need to map the SPI register via EFI_MEMORY_RUNTIME. The SPI driver also needs to deal with the SetVirtualAddress map event to convert its pointers over to the new OS provided virtual memory space.

Thanks,

Andrew Fish


> On Jan 17, 2019, at 9:23 AM, galla rao <galla.rao80@gmail.com> wrote:
> 
> Hi All,
> 
> Have a question for Variable services
> 
> Given PCD's are initialized
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase   | 0xFFE00000
> 
>  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase |
> 0xFFE3E000
> 
>  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase   |
> 0xFFE40000
> 
> Do i need to make these regions as *EFI_MEMORY_RUNTIME *through
> *gDS->SetMemorySpaceAttributes*
> 
> SPI Flash writes within BIOS works good!
> 
> *when trying to change BootOrder from efibootmgr, the failure is seen*
> 
> It would be useful if someone has faced this issue earlier and can respond
> kindly.
> 
> Best Regards
> Galla
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Query on Variable Services
  2019-01-17 17:54 ` Andrew Fish
@ 2019-01-17 18:26   ` galla rao
  2019-01-17 18:48     ` Andrew Fish
  0 siblings, 1 reply; 4+ messages in thread
From: galla rao @ 2019-01-17 18:26 UTC (permalink / raw)
  To: Andrew Fish; +Cc: edk2-devel

Thanks Andrew!

SPI driver has failed the call to, in the log i could see the failure

Status = gDS->SetMemorySpaceAttributes (

                    BaseAddress,

                    Length,

                    GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME

                    );

    if (EFI_ERROR (Status)) {

      DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME
attribute to Flash.\n"));

    }

if this call has failed SetVirtualAddress would not be useful for Virtual
Address conversion for this region I believe

Best Regards
Ranga

On Thu, Jan 17, 2019 at 5:55 PM Andrew Fish <afish@apple.com> wrote:

> Galla,
>
> The PCD value usually get set as the result of the build.
>
> EFI_MEMORY_RUNTIME attribute is used to request a virtual mapping from the
> OS. When the variable services are called from the OS the run in a virtual
> address space provided by the OS. Thus trying to access 0xFFE00000 would
> page fault.
>
> You can run the memmap command from the EFI Shell and see if bit 63 is
> set. If your SPI controller is a memory mapped hardware device you may also
> need to map the SPI register via EFI_MEMORY_RUNTIME. The SPI driver also
> needs to deal with the SetVirtualAddress map event to convert its pointers
> over to the new OS provided virtual memory space.
>
> Thanks,
>
> Andrew Fish
>
>
> > On Jan 17, 2019, at 9:23 AM, galla rao <galla.rao80@gmail.com> wrote:
> >
> > Hi All,
> >
> > Have a question for Variable services
> >
> > Given PCD's are initialized
> >
> > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase   |
> 0xFFE00000
> >
> >  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase |
> > 0xFFE3E000
> >
> >  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase   |
> > 0xFFE40000
> >
> > Do i need to make these regions as *EFI_MEMORY_RUNTIME *through
> > *gDS->SetMemorySpaceAttributes*
> >
> > SPI Flash writes within BIOS works good!
> >
> > *when trying to change BootOrder from efibootmgr, the failure is seen*
> >
> > It would be useful if someone has faced this issue earlier and can
> respond
> > kindly.
> >
> > Best Regards
> > Galla
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Query on Variable Services
  2019-01-17 18:26   ` galla rao
@ 2019-01-17 18:48     ` Andrew Fish
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Fish @ 2019-01-17 18:48 UTC (permalink / raw)
  To: galla rao; +Cc: edk2-devel



> On Jan 17, 2019, at 10:26 AM, galla rao <galla.rao80@gmail.com> wrote:
> 
> Thanks Andrew!
> 
> SPI driver has failed the call to, in the log i could see the failure
> 
> Status = gDS->SetMemorySpaceAttributes (
> 
>                     BaseAddress,
> 
>                     Length,
> 
>                     GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
> 
>                     );
> 
>     if (EFI_ERROR (Status)) {
> 
>       DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash. %r \n", Status));

You should dump out the Status value. I guess you could also make sure BaseAddress, and Length look correct. 

https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Pi/PiDxeCis.h#L368

/**
  Modifies the attributes for a memory region in the global coherency domain of the
  processor.
  @param  BaseAddress      The physical address that is the start address of a memory region.
  @param  Length           The size in bytes of the memory region.
  @param  Attributes       The bit mask of attributes to set for the memory region.
  @retval EFI_SUCCESS           The attributes were set for the memory region.
  @retval EFI_INVALID_PARAMETER Length is zero.
  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
                                resource range specified by BaseAddress and Length.
  @retval EFI_UNSUPPORTED       The bit mask of attributes is not support for the memory resource
                                range specified by BaseAddress and Length.
  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                BaseAddress and Length cannot be modified.
  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                the memory resource range.
  @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
                                not available yet.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_SET_MEMORY_SPACE_ATTRIBUTES)(
  IN EFI_PHYSICAL_ADDRESS         BaseAddress,
  IN UINT64                       Length,
  IN UINT64                       Attributes
  );


Thanks,

Andrew Fish

> 
>     }
> 
> if this call has failed SetVirtualAddress would not be useful for Virtual Address conversion for this region I believe
>   
> Best Regards
> Ranga
> 
> On Thu, Jan 17, 2019 at 5:55 PM Andrew Fish <afish@apple.com <mailto:afish@apple.com>> wrote:
> Galla,
> 
> The PCD value usually get set as the result of the build. 
> 
> EFI_MEMORY_RUNTIME attribute is used to request a virtual mapping from the OS. When the variable services are called from the OS the run in a virtual address space provided by the OS. Thus trying to access 0xFFE00000 would page fault. 
> 
> You can run the memmap command from the EFI Shell and see if bit 63 is set. If your SPI controller is a memory mapped hardware device you may also need to map the SPI register via EFI_MEMORY_RUNTIME. The SPI driver also needs to deal with the SetVirtualAddress map event to convert its pointers over to the new OS provided virtual memory space.
> 
> Thanks,
> 
> Andrew Fish
> 
> 
> > On Jan 17, 2019, at 9:23 AM, galla rao <galla.rao80@gmail.com <mailto:galla.rao80@gmail.com>> wrote:
> > 
> > Hi All,
> > 
> > Have a question for Variable services
> > 
> > Given PCD's are initialized
> > 
> > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase   | 0xFFE00000
> > 
> >  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase |
> > 0xFFE3E000
> > 
> >  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase   |
> > 0xFFE40000
> > 
> > Do i need to make these regions as *EFI_MEMORY_RUNTIME *through
> > *gDS->SetMemorySpaceAttributes*
> > 
> > SPI Flash writes within BIOS works good!
> > 
> > *when trying to change BootOrder from efibootmgr, the failure is seen*
> > 
> > It would be useful if someone has faced this issue earlier and can respond
> > kindly.
> > 
> > Best Regards
> > Galla
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
> > https://lists.01.org/mailman/listinfo/edk2-devel <https://lists.01.org/mailman/listinfo/edk2-devel>
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-17 18:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-17 17:23 Query on Variable Services galla rao
2019-01-17 17:54 ` Andrew Fish
2019-01-17 18:26   ` galla rao
2019-01-17 18:48     ` Andrew Fish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox