public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kubacki, Michael A" <michael.a.kubacki@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Agyeman, Prince" <prince.agyeman@intel.com>
Cc: "Chiu, Chasel" <chasel.chiu@intel.com>,
	"Desimone, Nathaniel L" <nathaniel.l.desimone@intel.com>
Subject: Re: [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver
Date: Mon, 4 Nov 2019 18:19:44 +0000	[thread overview]
Message-ID: <BY5PR11MB4484CFC3D42CE366CE124FB4B57F0@BY5PR11MB4484.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20191101195116.23212-4-prince.agyeman@intel.com>

Please fix style formatting, especially in this function:

/**
  Gets the number of devices in Table of SIO Controllers mDeviceInfo

  @retval     Number of enabled devices in Table of SIO Controllers.
**/
UINTN
EFIAPI
GetDeviceCount(
  VOID
){
   UINTN        Count;
   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end device info
   return Count;
}

This patch contains a change in SimicsOpenBoardPkg, as I suggested in the reply to the cover
letter, I believe that is better in a separate patch.

Thanks,
Michael

> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, November 1, 2019 12:51 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio
> Driver
> 
> Included PCDs to the Sio dxe driver,
> to allow the enable/disable of Ps2 keyboard/mouse,
> UART1 and UART2 com ports.
> 
> Renamed the Sio driver's base name
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
>  .../LegacySioDxe/LegacySioDxe.inf             | 15 +++-
>  .../BoardModulePkg/LegacySioDxe/SioChip.c     | 69 +++++++++++++++++--
>  .../BoardModulePkg/LegacySioDxe/SioChip.h     | 10 +++
>  .../BoardModulePkg/LegacySioDxe/SioDriver.c   | 42 ++++++++++-
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  6 ++
>  5 files changed, 133 insertions(+), 9 deletions(-)
> 
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> index d606ba43dc..4ab01a6098 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> @@ -10,7 +10,7 @@
> 
>  [Defines]
>    INF_VERSION                    = 0x00010017
> -  BASE_NAME                      = HitachiH8s2113Dxe
> +  BASE_NAME                      = LegacySioDxe
>    FILE_GUID                      = 7807E404-8281-4FF1-8457-0B54BABE263F
>    VERSION_STRING                 = 1.0
>    MODULE_TYPE                    = UEFI_DRIVER
> @@ -34,6 +34,7 @@
>  [Packages]
>    MdePkg/MdePkg.dec
>    MdeModulePkg/MdeModulePkg.dec
> +  BoardModulePkg/BoardModulePkg.dec
> 
>  [Sources]
>    SioChip.c
> @@ -44,6 +45,18 @@
>    SioDriver.h
>    ComponentName.c
> 
> +[Pcd]
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1Length
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2Length
> +  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
> +
>  [Protocols]
>    gEfiPciIoProtocolGuid                         ## CONSUMES
>    gEfiDevicePathProtocolGuid                    ## PRODUCES
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> index 81efe3c38b..09403a7354 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> @@ -19,12 +19,31 @@
>  ACPI_SIO_RESOURCES_IO_IRQ      mCom1Resources = {
>    {
>      { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
> -    0x3f8,
> -    8
> +      FixedPcdGet16 (PcdUart1IoPort),
> +      FixedPcdGet8 (PcdUart1Length)
> +    },
> +    {
> +      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
> +      FixedPcdGet16 (PcdUart1IrqMask)
> +    },
> +    {
> +      ACPI_END_TAG_DESCRIPTOR,
> +      0
> +    }
> +};
> +
> +//
> +// COM 2 UART Controller
> +//
> +ACPI_SIO_RESOURCES_IO_IRQ      mCom2Resources = {
> +  {
> +    { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
> +    FixedPcdGet16 (PcdUart2IoPort),
> +    FixedPcdGet8 (PcdUart2Length)
>    },
>    {
>      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
> -    BIT4    // IRQ4
> +    FixedPcdGet16 (PcdUart2IrqMask),
>    },
>    {
>      ACPI_END_TAG_DESCRIPTOR,
> @@ -70,10 +89,12 @@ ACPI_SIO_RESOURCES_IO_IRQ      mMouseResources
> = {
>    }
>  };
> 
> +
>  //
>  // Table of SIO Controllers
>  //
>  DEVICE_INFO    mDeviceInfo[] = {
> +#if FixedPcdGet8 (PcdUart1Enable) == DEVICE_ENABLED
>    {
>      {
>        EISA_PNP_ID(0x501),
> @@ -84,6 +105,20 @@ DEVICE_INFO    mDeviceInfo[] = {
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources },
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }
>    },  // COM 1 UART Controller
> +#endif
> +#if FixedPcdGet8 (PcdUart2Enable) == DEVICE_ENABLED
> +  {
> +    {
> +      EISA_PNP_ID(0x501),
> +      0
> +    },
> +    0,
> +    RESOURCE_IO | RESOURCE_IRQ,
> +    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources },
> +    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources }
> +  },  // COM 2 UART Controller
> +#endif
> +#if FixedPcdGet8 (PcdPs2KbMsEnable) == DEVICE_ENABLED
>    {
>      {
>        EISA_PNP_ID(0x303),
> @@ -103,10 +138,28 @@ DEVICE_INFO    mDeviceInfo[] = {
>      0,  // Cannot change resource
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources },
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources }
> -  }  // PS/2 Mouse Controller
> +  },  // PS/2 Mouse Controller
> +#endif
> +  DEVICE_INFO_END
>  };
> 
> 
> +
> +/**
> +  Gets the number of devices in Table of SIO Controllers mDeviceInfo
> +
> +  @retval     Number of enabled devices in Table of SIO Controllers.
> +**/
> +UINTN
> +EFIAPI
> +GetDeviceCount(
> +  VOID
> +){
> +   UINTN        Count;
> +   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end
> device info
> +   return Count;
> +}
> +
>  /**
>    Return the supported devices.
> 
> @@ -128,7 +181,7 @@ DeviceGetList (
>    //
>    // Allocate enough memory for simplicity
>    //
> -  DeviceCount =  sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
> +  DeviceCount = GetDeviceCount();
>    LocalDevices = AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) *
> DeviceCount);
>    ASSERT (LocalDevices != NULL);
>    if (LocalDevices == NULL) {
> @@ -157,7 +210,6 @@ SioInit (
>    VOID
>    )
>  {
> -
>    return EFI_SUCCESS;
>  }
> 
> @@ -175,8 +227,11 @@ DeviceSearch (
>    )
>  {
>    UINTN       Index;
> +  UINTN       DeviceCount;
> +
> +  DeviceCount = GetDeviceCount();
> 
> -  for (Index = 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
> Index++) {
> +  for (Index = 0; Index < DeviceCount; Index++) {
>      if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device))
> == 0) {
>        return &mDeviceInfo[Index];
>      }
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> index 9322365923..8bd53ccdd6 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> @@ -24,6 +24,9 @@ UINT8
>  #define RESOURCE_DMA   BIT2
>  #define RESOURCE_MEM   BIT3
> 
> +#define DEVICE_ENABLED  0x01
> +#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } }
> +
>  #pragma pack(1)
> 
>  typedef struct {
> @@ -46,6 +49,13 @@ typedef struct {
>    ACPI_RESOURCE_HEADER_PTR    PossibleResources;
>  } DEVICE_INFO;
> 
> +typedef struct {
> +  UINT8 Segment;
> +  UINT8 Bus;
> +  UINT8 Device;
> +  UINT8 Funtion;
> +} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
> +
>  /**
>    Return the supported devices.
> 
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> index 408c6ff301..5ab9109ad9 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> @@ -8,7 +8,6 @@
> 
>  #include "SioDriver.h"
> 
> -
>  //
>  // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)  // @@ -106,6 +105,27 @@
> SioDriverEntryPoint (  }
> 
> 
> +/**
> +  Compares a PCI to ISA bridge device segment, bus, device and function
> +to the
> +  PcdSuperIoPciIsaBridgeDevice values.
> +
> +  @param[in]  CurrentDevice       The device to be compared with the
> PcdSuperIoPciIsaBridgeDevice information
> +  @retval     TRUE                This device matches PcdSuperIoPciIsaBridgeDevice
> values
> +  @retval     FALSE               This device does not match the
> PcdSuperIoPciIsaBridgeDevice values
> +**/
> +BOOLEAN
> +EFIAPI
> +SioDeviceEnabled (
> +  IN SIO_PCI_ISA_BRIDGE_DEVICE_INFO *CurrentDevice ){
> +    SIO_PCI_ISA_BRIDGE_DEVICE_INFO *Device = \
> +      (SIO_PCI_ISA_BRIDGE_DEVICE_INFO *) FixedPcdGetPtr
> (PcdSuperIoPciIsaBridgeDevice);
> +    if(CompareMem (Device, CurrentDevice, sizeof
> (SIO_PCI_ISA_BRIDGE_DEVICE_INFO)) == 0) {
> +      return TRUE;
> +    }
> +    return FALSE;
> +}
> +
>  /**
>    Test to see if this driver supports Controller Handle.
> 
> @@ -138,6 +158,7 @@ SioDriverSupported (
>    UINTN                     BusNumber;
>    UINTN                     DeviceNumber;
>    UINTN                     FunctionNumber;
> +  SIO_PCI_ISA_BRIDGE_DEVICE_INFO  SioDevice;
> 
>    //
>    // If RemainingDevicePath is not NULL, it should verify that the first device
> @@ -250,6 +271,25 @@ SioDriverSupported (
>              Status = EFI_UNSUPPORTED;
>            }
>          }
> +
> +        if(!EFI_ERROR (Status)) {
> +          Status = PciIo->GetLocation (
> +                            PciIo,
> +                            &SegmentNumber,
> +                            &BusNumber,
> +                            &DeviceNumber,
> +                            &FunctionNumber
> +                            );
> +          if(!EFI_ERROR (Status)) {
> +            SioDevice.Segment = (UINT8) SegmentNumber;
> +            SioDevice.Bus = (UINT8) BusNumber;
> +            SioDevice.Device = (UINT8) DeviceNumber;
> +            SioDevice.Funtion = (UINT8) FunctionNumber;
> +            if(!SioDeviceEnabled (&SioDevice)) {
> +              Status = EFI_UNSUPPORTED;
> +            }
> +          }
> +        }
>        }
>      }
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> index 0298e4b12d..b85991b772 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> +++ c
> @@ -196,6 +196,12 @@
>    gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|4
>    gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase|0xFEC01000
> 
> +  ######################################
> +  # Board Configuration
> +  ######################################
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
> +
> +
> gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00,0x0
> 0,
> + 0x1F,0x00}
> +
>  [PcdsFixedAtBuild.X64]
>    ######################################
>    # Edk2 Configuration
> --
> 2.19.1.windows.1


  parent reply	other threads:[~2019-11-04 18:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-04  9:15   ` Chiu, Chasel
2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
2019-11-01 21:55   ` [edk2-devel] " Nate DeSimone
2019-11-04 18:19   ` Kubacki, Michael A [this message]
2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-04  9:03   ` Chiu, Chasel
2019-11-04 17:17     ` Agyeman, Prince
2019-11-01 19:51 ` [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support Agyeman, Prince
2019-11-01 21:54   ` [edk2-devel] " Nate DeSimone
2019-11-04 18:18 ` [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Kubacki, Michael A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BY5PR11MB4484CFC3D42CE366CE124FB4B57F0@BY5PR11MB4484.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox