public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* mmio mappings for runtime service
@ 2021-08-30 10:23 Gerd Hoffmann
  2021-08-30 13:01 ` [edk2-devel] " Yao, Jiewen
  0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2021-08-30 10:23 UTC (permalink / raw)
  To: devel

  Hi,

What is the correct way to make sure runtime services can access
mmio registers, i.e. that there is a mapping in the page tables
for the mmio page needed?

Is that the job of the firmware?
Or should the OS calling the runtime service handle that?
In case of the latter: How does the OS figure which pages are needed?

thanks,
  Gerd


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

* Re: [edk2-devel] mmio mappings for runtime service
  2021-08-30 10:23 mmio mappings for runtime service Gerd Hoffmann
@ 2021-08-30 13:01 ` Yao, Jiewen
  2021-08-30 16:26   ` Michael D Kinney
  0 siblings, 1 reply; 3+ messages in thread
From: Yao, Jiewen @ 2021-08-30 13:01 UTC (permalink / raw)
  To: devel@edk2.groups.io, kraxel@redhat.com

The BIOS driver must set EFI_RUNTIME_MEMORY attribute for the EfiGcdMemoryTypeMemoryMappedIo region with GCD service gDS->SetMemorySpaceAttributes().
Then DXE will report EfiMemoryMappedIO with EFI_RUNTIME_MEMORY attribute in UEFI memory map.
The OS will gBS->GetMemoryMap() and assign virtual address for the MMIO, and gRT->SetVirtualAddressMap() back to the BIOS.

Finally, the BIOS driver can gRT->ConvertPointer() the MMIO physical address to virtual address, then access it at runtime.

Thank you
Yao Jiewen

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gerd
> Hoffmann
> Sent: Monday, August 30, 2021 6:24 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] mmio mappings for runtime service
> 
>   Hi,
> 
> What is the correct way to make sure runtime services can access
> mmio registers, i.e. that there is a mapping in the page tables
> for the mmio page needed?
> 
> Is that the job of the firmware?
> Or should the OS calling the runtime service handle that?
> In case of the latter: How does the OS figure which pages are needed?
> 
> thanks,
>   Gerd
> 
> 
> 
> 
> 


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

* Re: [edk2-devel] mmio mappings for runtime service
  2021-08-30 13:01 ` [edk2-devel] " Yao, Jiewen
@ 2021-08-30 16:26   ` Michael D Kinney
  0 siblings, 0 replies; 3+ messages in thread
From: Michael D Kinney @ 2021-08-30 16:26 UTC (permalink / raw)
  To: devel@edk2.groups.io, Yao, Jiewen, kraxel@redhat.com,
	Kinney, Michael D

Hi Gerd,

The following library provides an example of all the steps to register an MMIO range for RT access.

https://github.com/tianocore/edk2/blob/master/MdePkg/Library/DxeRuntimePciExpressLib/PciExpressLib.c

The example is from PCI Express, but the PCI Config space for PCI Express is an MMIO window.  This
library contains a Constructor/Destructor to create/close a Set Virtual Address Map event.  It has the 
Set Virtual Address Map Event Notification Function and a function to request a specific 4KB 
portion of the 256 MB MMIO window to be marked as RT.

DxeRuntimePciExpressLibConstructor()
DxeRuntimePciExpressLibDestructor()
DxeRuntimePciExpressLibVirtualNotify()
PciExpressRegisterForRuntimeAccess()

Best regards,

Mike


> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yao, Jiewen
> Sent: Monday, August 30, 2021 6:02 AM
> To: devel@edk2.groups.io; kraxel@redhat.com
> Subject: Re: [edk2-devel] mmio mappings for runtime service
> 
> The BIOS driver must set EFI_RUNTIME_MEMORY attribute for the EfiGcdMemoryTypeMemoryMappedIo region with GCD service gDS-
> >SetMemorySpaceAttributes().
> Then DXE will report EfiMemoryMappedIO with EFI_RUNTIME_MEMORY attribute in UEFI memory map.
> The OS will gBS->GetMemoryMap() and assign virtual address for the MMIO, and gRT->SetVirtualAddressMap() back to the BIOS.
> 
> Finally, the BIOS driver can gRT->ConvertPointer() the MMIO physical address to virtual address, then access it at
> runtime.
> 
> Thank you
> Yao Jiewen
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gerd
> > Hoffmann
> > Sent: Monday, August 30, 2021 6:24 PM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] mmio mappings for runtime service
> >
> >   Hi,
> >
> > What is the correct way to make sure runtime services can access
> > mmio registers, i.e. that there is a mapping in the page tables
> > for the mmio page needed?
> >
> > Is that the job of the firmware?
> > Or should the OS calling the runtime service handle that?
> > In case of the latter: How does the OS figure which pages are needed?
> >
> > thanks,
> >   Gerd
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 


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

end of thread, other threads:[~2021-08-30 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-30 10:23 mmio mappings for runtime service Gerd Hoffmann
2021-08-30 13:01 ` [edk2-devel] " Yao, Jiewen
2021-08-30 16:26   ` Michael D Kinney

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