From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.2958.1573003566641973092 for ; Tue, 05 Nov 2019 17:26:06 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: prince.agyeman@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2019 17:26:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,272,1569308400"; d="scan'208";a="196033094" Received: from paagyema-desk2.amr.corp.intel.com ([10.24.15.58]) by orsmga008.jf.intel.com with ESMTP; 05 Nov 2019 17:26:04 -0800 From: "Agyeman, Prince" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone Subject: [edk2-platforms] [Patch v2 5/9] BoardModulePkg: Added Pcds to Super I/O driver Date: Tue, 5 Nov 2019 17:25:59 -0800 Message-Id: <20191106012603.4724-6-prince.agyeman@intel.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20191106012603.4724-1-prince.agyeman@intel.com> References: <20191106012603.4724-1-prince.agyeman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Included PCDs to the Super I/O DXE driver, to allow the enable/disable of Ps2 keyboard/mouse, UART1 and UART2 ports. Cc: Michael Kubacki Cc: Chasel Chiu Cc: Nate DeSimone Signed-off-by: Prince Agyeman --- .../LegacySioDxe/LegacySioDxe.inf | 12 ++++ .../BoardModulePkg/LegacySioDxe/SioChip.c | 68 +++++++++++++++++-- .../BoardModulePkg/LegacySioDxe/SioChip.h | 8 +++ .../BoardModulePkg/LegacySioDxe/SioDriver.c | 40 +++++++++++ 4 files changed, 122 insertions(+), 6 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf index f01f63e69e..ccddc97e91 100644 --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf @@ -34,6 +34,7 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + BoardModulePkg/BoardModulePkg.dec [Sources] SioChip.c @@ -44,6 +45,17 @@ 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..e63977be60 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, @@ -74,6 +93,7 @@ ACPI_SIO_RESOURCES_IO_IRQ mMouseResources = { // Table of SIO Controllers // DEVICE_INFO mDeviceInfo[] = { +#if FixedPcdGet8 (PcdUart1Enable) == DEVICE_ENABLED { { EISA_PNP_ID(0x501), @@ -84,6 +104,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 +137,30 @@ 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; + // Get mDeviceInfo item count + // -1 to account for for the end device info + Count = ARRAY_SIZE (mDeviceInfo) - 1; + return Count; +} + /** Return the supported devices. @@ -128,7 +182,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) { @@ -175,8 +229,10 @@ DeviceSearch ( ) { UINTN Index; + UINTN DeviceCount; - for (Index = 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]); Index++) { + DeviceCount = GetDeviceCount (); + 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..afff6fe7b5 100644 --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h @@ -24,6 +24,8 @@ UINT8 #define RESOURCE_DMA BIT2 #define RESOURCE_MEM BIT3 +#define DEVICE_ENABLED 0x01 +#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } } #pragma pack(1) typedef struct { @@ -45,6 +47,12 @@ typedef struct { ACPI_RESOURCE_HEADER_PTR Resources; 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..5bfdc94681 100644 --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c @@ -106,6 +106,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 +159,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 +272,24 @@ 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; + } + } + } } } -- 2.19.1.windows.1