diff mbox

[edk2,v2,1/5] MdeModulePkg: introduce non-discoverable device protocol

Message ID 1478173302-22349-1-git-send-email-ard.biesheuvel@linaro.org
State Superseded
Headers show

Commit Message

Ard Biesheuvel Nov. 3, 2016, 11:41 a.m. UTC
Introduce a protocol that can be exposed by a platform for devices that
are not discoverable, usually because they are wired straight to the
memory bus rather than to an enumerable bus like PCI or USB.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 88 ++++++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                         |  3 +
 2 files changed, 91 insertions(+)

-- 
2.7.4

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

Comments

Ni, Ruiyu Nov. 15, 2016, 8:31 a.m. UTC | #1
Ard,

For the below protocol structure, it assumes that the non-discoverable
PCI device contains only one BAR and the type is limited to USB/AHCI/SD/UFS/NVME
devices.
Could we have more types of such kind of device in future?
Could we have a device that contains multiple BAR?
Could we have a device that contains one BAR but the BAR size is non-default size?

I am asking all about this is because I am thinking would it be more flexible to have
platform provide a ACPI resource descriptors and the NonDiscoverableDxe driver
converts the ACPI resource descriptors to PCI BARs?

You could refer to PciIo.GetBarAttributes() to see how one ACPI resource descriptor
is created for one BAR.

But please ignore my such concern if there is a spec to describe such non-discoverable
PCI device.

Thanks/Ray

> -----Original Message-----

> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of

> Ard Biesheuvel

> Sent: Thursday, November 3, 2016 7:42 PM

> To: edk2-devel@lists.01.org; leif.lindholm@linaro.org; Kinney, Michael D

> <michael.d.kinney@intel.com>; afish@apple.com

> Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>; Ard

> Biesheuvel <ard.biesheuvel@linaro.org>

> Subject: [edk2] [PATCH v2 1/5] MdeModulePkg: introduce non-discoverable

> device protocol

> 

> Introduce a protocol that can be exposed by a platform for devices that are

> not discoverable, usually because they are wired straight to the memory bus

> rather than to an enumerable bus like PCI or USB.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 88

> ++++++++++++++++++++

>  MdeModulePkg/MdeModulePkg.dec                         |  3 +

>  2 files changed, 91 insertions(+)

> 

> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> new file mode 100644

> index 000000000000..34388c0f99e3

> --- /dev/null

> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> @@ -0,0 +1,88 @@

> +/** @file

> +  Protocol to describe devices that are not on a discoverable bus

> +

> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>

> +

> +  This program and the accompanying materials  are licensed and made

> + available under the terms and conditions of the BSD License  which

> + accompanies this distribution.  The full text of the license may be

> + found at  http://opensource.org/licenses/bsd-license.php

> +

> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"

> BASIS,

> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER

> EXPRESS OR IMPLIED.

> +

> +**/

> +

> +#ifndef __NON_DISCOVERABLE_DEVICE_H__

> +#define __NON_DISCOVERABLE_DEVICE_H__

> +

> +#define NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \

> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d,

> +0x51, 0x4a } }

> +

> +//

> +// Protocol interface structure

> +//

> +typedef struct _NON_DISCOVERABLE_DEVICE

> NON_DISCOVERABLE_DEVICE;

> +

> +//

> +// Data Types

> +//

> +typedef enum {

> +  NonDiscoverableDeviceTypeAmba,

> +  NonDiscoverableDeviceTypeOhci,

> +  NonDiscoverableDeviceTypeUhci,

> +  NonDiscoverableDeviceTypeEhci,

> +  NonDiscoverableDeviceTypeXhci,

> +  NonDiscoverableDeviceTypeAhci,

> +  NonDiscoverableDeviceTypeSdhci,

> +  NonDiscoverableDeviceTypeUfs,

> +  NonDiscoverableDeviceTypeNvme,

> +  NonDiscoverableDeviceTypeMax,

> +} NON_DISCOVERABLE_DEVICE_TYPE;

> +

> +typedef enum {

> +  NonDiscoverableDeviceDmaTypeCoherent,

> +  NonDiscoverableDeviceDmaTypeNonCoherent,

> +  NonDiscoverableDeviceDmaTypeMax,

> +} NON_DISCOVERABLE_DEVICE_DMA_TYPE;

> +

> +//

> +// Function Prototypes

> +//

> +

> +/**

> +  Perform device specific initialization before the device is started

> +

> +  @param  This          The non-discoverable device protocol pointer

> +

> +  @retval EFI_SUCCESS   Initialization successful, the device may be used

> +  @retval Other         Initialization failed, device should not be started

> +**/

> +typedef

> +EFI_STATUS

> +(EFIAPI *NON_DISCOVERABLE_DEVICE_INIT) (

> +  IN  NON_DISCOVERABLE_DEVICE       *This

> +  );

> +

> +struct _NON_DISCOVERABLE_DEVICE {

> +  //

> +  // The MMIO address of the device

> +  //

> +  EFI_PHYSICAL_ADDRESS              BaseAddress;

> +  //

> +  // The type of device

> +  //

> +  NON_DISCOVERABLE_DEVICE_TYPE      Type;

> +  //

> +  // Whether this device is DMA coherent

> +  //

> +  NON_DISCOVERABLE_DEVICE_DMA_TYPE  DmaType;

> +  //

> +  // Initialization function for the device

> +  //

> +  NON_DISCOVERABLE_DEVICE_INIT      Initialize;

> +};

> +

> +extern EFI_GUID gNonDiscoverableDeviceProtocolGuid;

> +

> +#endif

> diff --git a/MdeModulePkg/MdeModulePkg.dec

> b/MdeModulePkg/MdeModulePkg.dec index 74b870051c67..84b489d3fdb7

> 100644

> --- a/MdeModulePkg/MdeModulePkg.dec

> +++ b/MdeModulePkg/MdeModulePkg.dec

> @@ -505,6 +505,9 @@ [Protocols]

>    #  Include/Protocol/Ps2Policy.h

>    gEfiPs2PolicyProtocolGuid = { 0x4DF19259, 0xDC71, 0x4D46, { 0xBE, 0xF1,

> 0x35, 0x7B, 0xB5, 0x78, 0xC4, 0x18 } }

> 

> +  ## Include/Protocol/NonDiscoverableDevice.h

> +  gNonDiscoverableDeviceProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a,

> + {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }

> +

>  #

>  # [Error.gEfiMdeModulePkgTokenSpaceGuid]

>  #   0x80000001 | Invalid value provided.

> --

> 2.7.4

> 

> _______________________________________________

> 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
Ni, Ruiyu Nov. 15, 2016, 8:38 a.m. UTC | #2
Please have Edkii prefix for implementation specific protocols/GUIDs.

gNonDiscoverableDeviceProtocolGuid -> gEdkiiNonDiscoverableDeviceProtocolGuid

Thanks/Ray

> -----Original Message-----

> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of

> Ard Biesheuvel

> Sent: Thursday, November 3, 2016 7:42 PM

> To: edk2-devel@lists.01.org; leif.lindholm@linaro.org; Kinney, Michael D

> <michael.d.kinney@intel.com>; afish@apple.com

> Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>; Ard

> Biesheuvel <ard.biesheuvel@linaro.org>

> Subject: [edk2] [PATCH v2 1/5] MdeModulePkg: introduce non-discoverable

> device protocol

> 

> Introduce a protocol that can be exposed by a platform for devices that are

> not discoverable, usually because they are wired straight to the memory bus

> rather than to an enumerable bus like PCI or USB.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 88

> ++++++++++++++++++++

>  MdeModulePkg/MdeModulePkg.dec                         |  3 +

>  2 files changed, 91 insertions(+)

> 

> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> new file mode 100644

> index 000000000000..34388c0f99e3

> --- /dev/null

> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h

> @@ -0,0 +1,88 @@

> +/** @file

> +  Protocol to describe devices that are not on a discoverable bus

> +

> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>

> +

> +  This program and the accompanying materials  are licensed and made

> + available under the terms and conditions of the BSD License  which

> + accompanies this distribution.  The full text of the license may be

> + found at  http://opensource.org/licenses/bsd-license.php

> +

> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"

> BASIS,

> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER

> EXPRESS OR IMPLIED.

> +

> +**/

> +

> +#ifndef __NON_DISCOVERABLE_DEVICE_H__

> +#define __NON_DISCOVERABLE_DEVICE_H__

> +

> +#define NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \

> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d,

> +0x51, 0x4a } }

> +

> +//

> +// Protocol interface structure

> +//

> +typedef struct _NON_DISCOVERABLE_DEVICE

> NON_DISCOVERABLE_DEVICE;

> +

> +//

> +// Data Types

> +//

> +typedef enum {

> +  NonDiscoverableDeviceTypeAmba,

> +  NonDiscoverableDeviceTypeOhci,

> +  NonDiscoverableDeviceTypeUhci,

> +  NonDiscoverableDeviceTypeEhci,

> +  NonDiscoverableDeviceTypeXhci,

> +  NonDiscoverableDeviceTypeAhci,

> +  NonDiscoverableDeviceTypeSdhci,

> +  NonDiscoverableDeviceTypeUfs,

> +  NonDiscoverableDeviceTypeNvme,

> +  NonDiscoverableDeviceTypeMax,

> +} NON_DISCOVERABLE_DEVICE_TYPE;

> +

> +typedef enum {

> +  NonDiscoverableDeviceDmaTypeCoherent,

> +  NonDiscoverableDeviceDmaTypeNonCoherent,

> +  NonDiscoverableDeviceDmaTypeMax,

> +} NON_DISCOVERABLE_DEVICE_DMA_TYPE;

> +

> +//

> +// Function Prototypes

> +//

> +

> +/**

> +  Perform device specific initialization before the device is started

> +

> +  @param  This          The non-discoverable device protocol pointer

> +

> +  @retval EFI_SUCCESS   Initialization successful, the device may be used

> +  @retval Other         Initialization failed, device should not be started

> +**/

> +typedef

> +EFI_STATUS

> +(EFIAPI *NON_DISCOVERABLE_DEVICE_INIT) (

> +  IN  NON_DISCOVERABLE_DEVICE       *This

> +  );

> +

> +struct _NON_DISCOVERABLE_DEVICE {

> +  //

> +  // The MMIO address of the device

> +  //

> +  EFI_PHYSICAL_ADDRESS              BaseAddress;

> +  //

> +  // The type of device

> +  //

> +  NON_DISCOVERABLE_DEVICE_TYPE      Type;

> +  //

> +  // Whether this device is DMA coherent

> +  //

> +  NON_DISCOVERABLE_DEVICE_DMA_TYPE  DmaType;

> +  //

> +  // Initialization function for the device

> +  //

> +  NON_DISCOVERABLE_DEVICE_INIT      Initialize;

> +};

> +

> +extern EFI_GUID gNonDiscoverableDeviceProtocolGuid;

> +

> +#endif

> diff --git a/MdeModulePkg/MdeModulePkg.dec

> b/MdeModulePkg/MdeModulePkg.dec index 74b870051c67..84b489d3fdb7

> 100644

> --- a/MdeModulePkg/MdeModulePkg.dec

> +++ b/MdeModulePkg/MdeModulePkg.dec

> @@ -505,6 +505,9 @@ [Protocols]

>    #  Include/Protocol/Ps2Policy.h

>    gEfiPs2PolicyProtocolGuid = { 0x4DF19259, 0xDC71, 0x4D46, { 0xBE, 0xF1,

> 0x35, 0x7B, 0xB5, 0x78, 0xC4, 0x18 } }

> 

> +  ## Include/Protocol/NonDiscoverableDevice.h

> +  gNonDiscoverableDeviceProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a,

> + {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }

> +

>  #

>  # [Error.gEfiMdeModulePkgTokenSpaceGuid]

>  #   0x80000001 | Invalid value provided.

> --

> 2.7.4

> 

> _______________________________________________

> 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
Ard Biesheuvel Nov. 15, 2016, 11:29 a.m. UTC | #3
On 15 November 2016 at 08:31, Ni, Ruiyu <ruiyu.ni@intel.com> wrote:
> Ard,

>

> For the below protocol structure, it assumes that the non-discoverable

> PCI device contains only one BAR and the type is limited to USB/AHCI/SD/UFS/NVME

> devices.


For now, yes. It is quite unusual for such non-enumerable devices to
have several MMIO ranges (and I/O ranges do not exist at all on many
architectures, except when dealing with real PCI devices where the
root complex takes care of the I/O to MMIO translation)

> Could we have more types of such kind of device in future?


Yes. I actually added AMBA as well, because those devices have a
standardized identification register

> Could we have a device that contains multiple BAR?


Perhaps others could chime in here? The only example of mutiple BARs
would be multiple SDHCI slots on the same controller, but those could
easily be modeled as separate controllers as well, since they are
completely independent.

> Could we have a device that contains one BAR but the BAR size is non-default size?

>


Another good question. I think the best way for now is to extend the
protocol to allow it, but only add support to the helper library when
the need arises.

> I am asking all about this is because I am thinking would it be more flexible to have

> platform provide a ACPI resource descriptors and the NonDiscoverableDxe driver

> converts the ACPI resource descriptors to PCI BARs?

>

> You could refer to PciIo.GetBarAttributes() to see how one ACPI resource descriptor

> is created for one BAR.

>

> But please ignore my such concern if there is a spec to describe such non-discoverable

> PCI device.

>


No, there is no such spec, and I think your suggestion is very good. I
will investigate.

Thanks,
Ard.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ard Biesheuvel Nov. 15, 2016, 11:29 a.m. UTC | #4
On 15 November 2016 at 08:38, Ni, Ruiyu <ruiyu.ni@intel.com> wrote:
> Please have Edkii prefix for implementation specific protocols/GUIDs.

>

> gNonDiscoverableDeviceProtocolGuid -> gEdkiiNonDiscoverableDeviceProtocolGuid

>\


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

Patch

diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
new file mode 100644
index 000000000000..34388c0f99e3
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
@@ -0,0 +1,88 @@ 
+/** @file
+  Protocol to describe devices that are not on a discoverable bus
+
+  Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __NON_DISCOVERABLE_DEVICE_H__
+#define __NON_DISCOVERABLE_DEVICE_H__
+
+#define NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
+  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }
+
+//
+// Protocol interface structure
+//
+typedef struct _NON_DISCOVERABLE_DEVICE NON_DISCOVERABLE_DEVICE;
+
+//
+// Data Types
+//
+typedef enum {
+  NonDiscoverableDeviceTypeAmba,
+  NonDiscoverableDeviceTypeOhci,
+  NonDiscoverableDeviceTypeUhci,
+  NonDiscoverableDeviceTypeEhci,
+  NonDiscoverableDeviceTypeXhci,
+  NonDiscoverableDeviceTypeAhci,
+  NonDiscoverableDeviceTypeSdhci,
+  NonDiscoverableDeviceTypeUfs,
+  NonDiscoverableDeviceTypeNvme,
+  NonDiscoverableDeviceTypeMax,
+} NON_DISCOVERABLE_DEVICE_TYPE;
+
+typedef enum {
+  NonDiscoverableDeviceDmaTypeCoherent,
+  NonDiscoverableDeviceDmaTypeNonCoherent,
+  NonDiscoverableDeviceDmaTypeMax,
+} NON_DISCOVERABLE_DEVICE_DMA_TYPE;
+
+//
+// Function Prototypes
+//
+
+/**
+  Perform device specific initialization before the device is started
+
+  @param  This          The non-discoverable device protocol pointer
+
+  @retval EFI_SUCCESS   Initialization successful, the device may be used
+  @retval Other         Initialization failed, device should not be started
+**/
+typedef
+EFI_STATUS
+(EFIAPI *NON_DISCOVERABLE_DEVICE_INIT) (
+  IN  NON_DISCOVERABLE_DEVICE       *This
+  );
+
+struct _NON_DISCOVERABLE_DEVICE {
+  //
+  // The MMIO address of the device
+  //
+  EFI_PHYSICAL_ADDRESS              BaseAddress;
+  //
+  // The type of device
+  //
+  NON_DISCOVERABLE_DEVICE_TYPE      Type;
+  //
+  // Whether this device is DMA coherent
+  //
+  NON_DISCOVERABLE_DEVICE_DMA_TYPE  DmaType;
+  //
+  // Initialization function for the device
+  //
+  NON_DISCOVERABLE_DEVICE_INIT      Initialize;
+};
+
+extern EFI_GUID gNonDiscoverableDeviceProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 74b870051c67..84b489d3fdb7 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -505,6 +505,9 @@  [Protocols]
   #  Include/Protocol/Ps2Policy.h
   gEfiPs2PolicyProtocolGuid = { 0x4DF19259, 0xDC71, 0x4D46, { 0xBE, 0xF1, 0x35, 0x7B, 0xB5, 0x78, 0xC4, 0x18 } }
 
+  ## Include/Protocol/NonDiscoverableDevice.h
+  gNonDiscoverableDeviceProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }
+
 #
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]
 #   0x80000001 | Invalid value provided.