From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.508.1572645346153461797 for ; Fri, 01 Nov 2019 14:55:46 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: nathaniel.l.desimone@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 14:55:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,257,1569308400"; d="scan'208";a="211859997" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga001.fm.intel.com with ESMTP; 01 Nov 2019 14:55:35 -0700 Received: from orsmsx151.amr.corp.intel.com (10.22.226.38) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 Nov 2019 14:55:35 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.28]) by ORSMSX151.amr.corp.intel.com ([169.254.7.36]) with mapi id 14.03.0439.000; Fri, 1 Nov 2019 14:55:35 -0700 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Agyeman, Prince" CC: "Kubacki, Michael A" , "Chiu, Chasel" Subject: Re: [edk2-devel] [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Thread-Topic: [edk2-devel] [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Thread-Index: AQHVkO3EwgzRIdYtD06Ez20cBcsDoad23Ezg Date: Fri, 1 Nov 2019 21:55:34 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AB5B97677@ORSMSX113.amr.corp.intel.com> References: <20191101195116.23212-1-prince.agyeman@intel.com> <20191101195116.23212-4-prince.agyeman@intel.com> In-Reply-To: <20191101195116.23212-4-prince.agyeman@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTQ4MWEzZjMtNzcwNy00ODBlLWE1ODgtZjBlN2U3N2E4M2RkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNVpSUzRIMlY3S0JrXC9TdXBxOTZQTmprVlwvUTRuaTVGUElMYXV2dmhxQzVreGpFWjBHVEYyVTF3WFhMNVQzS1JzIn0= x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Agyeman, Pr= ince Sent: Friday, November 1, 2019 12:51 PM To: devel@edk2.groups.io Cc: Kubacki, Michael A ; Chiu, Chasel ; Desimone, Nathaniel L Subject: [edk2-devel] [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added P= cds 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 Cc: Chasel Chiu Cc: Nate DeSimone Signed-off-by: Prince Agyeman --- .../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 @@ =20 [Defines] INF_VERSION =3D 0x00010017 - BASE_NAME =3D HitachiH8s2113Dxe + BASE_NAME =3D LegacySioDxe FILE_GUID =3D 7807E404-8281-4FF1-8457-0B54BABE263F VERSION_STRING =3D 1.0 MODULE_TYPE =3D UEFI_DRIVER @@ -34,6 +34,7 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + BoardModulePkg/BoardModulePkg.dec =20 [Sources] SioChip.c @@ -44,6 +45,18 @@ SioDriver.h ComponentName.c =20 +[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/Platfo= rm/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 =3D { { { 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 =3D { + { + { 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 =3D { } }; =20 + // // Table of SIO Controllers // DEVICE_INFO mDeviceInfo[] =3D { +#if FixedPcdGet8 (PcdUart1Enable) =3D=3D DEVICE_ENABLED { { EISA_PNP_ID(0x501), @@ -84,6 +105,20 @@ DEVICE_INFO mDeviceInfo[] =3D { { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }, { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources } }, // COM 1 UART Controller +#endif +#if FixedPcdGet8 (PcdUart2Enable) =3D=3D 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) =3D=3D DEVICE_ENABLED { { EISA_PNP_ID(0x303), @@ -103,10 +138,28 @@ DEVICE_INFO mDeviceInfo[] =3D { 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 }; =20 =20 + +/** + 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 =3D ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the en= d device info + return Count; +} + /** Return the supported devices. =20 @@ -128,7 +181,7 @@ DeviceGetList ( // // Allocate enough memory for simplicity // - DeviceCount =3D sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]); + DeviceCount =3D GetDeviceCount(); LocalDevices =3D AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) * Device= Count); ASSERT (LocalDevices !=3D NULL); if (LocalDevices =3D=3D NULL) { @@ -157,7 +210,6 @@ SioInit ( VOID ) { - return EFI_SUCCESS; } =20 @@ -175,8 +227,11 @@ DeviceSearch ( ) { UINTN Index; + UINTN DeviceCount; + + DeviceCount =3D GetDeviceCount(); =20 - for (Index =3D 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]= ); Index++) { + for (Index =3D 0; Index < DeviceCount; Index++) { if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device))= =3D=3D 0) { return &mDeviceInfo[Index]; } diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h b/Platfo= rm/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 =20 +#define DEVICE_ENABLED 0x01 +#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } } + #pragma pack(1) =20 typedef struct { @@ -46,6 +49,13 @@ typedef struct { ACPI_RESOURCE_HEADER_PTR PossibleResources; } DEVICE_INFO; =20 +typedef struct { + UINT8 Segment; + UINT8 Bus; + UINT8 Device; + UINT8 Funtion; +} SIO_PCI_ISA_BRIDGE_DEVICE_INFO; + /** Return the supported devices. =20 diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c b/Plat= form/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 @@ =20 #include "SioDriver.h" =20 - // // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0) // @@ -106,6 +105,27 @= @ SioDriverEntryPoint ( } =20 =20 +/** + Compares a PCI to ISA bridge device segment, bus, device and function= =20 +to the + PcdSuperIoPciIsaBridgeDevice values. + + @param[in] CurrentDevice The device to be compared with the PcdS= uperIoPciIsaBridgeDevice information + @retval TRUE This device matches PcdSuperIoPciIsaBri= dgeDevice values + @retval FALSE This device does not match the PcdSuper= IoPciIsaBridgeDevice values +**/ +BOOLEAN +EFIAPI +SioDeviceEnabled ( + IN SIO_PCI_ISA_BRIDGE_DEVICE_INFO *CurrentDevice ){ + SIO_PCI_ISA_BRIDGE_DEVICE_INFO *Device =3D \ + (SIO_PCI_ISA_BRIDGE_DEVICE_INFO *) FixedPcdGetPtr (PcdSuperIoPciIsa= BridgeDevice); + if(CompareMem (Device, CurrentDevice, sizeof (SIO_PCI_ISA_BRIDGE_DEVI= CE_INFO)) =3D=3D 0) { + return TRUE; + } + return FALSE; +} + /** Test to see if this driver supports Controller Handle. =20 @@ -138,6 +158,7 @@ SioDriverSupported ( UINTN BusNumber; UINTN DeviceNumber; UINTN FunctionNumber; + SIO_PCI_ISA_BRIDGE_DEVICE_INFO SioDevice; =20 // // If RemainingDevicePath is not NULL, it should verify that the first = device @@ -250,6 +271,25 @@ SioDriverSupported ( Status =3D EFI_UNSUPPORTED; } } + + if(!EFI_ERROR (Status)) { + Status =3D PciIo->GetLocation ( + PciIo, + &SegmentNumber, + &BusNumber, + &DeviceNumber, + &FunctionNumber + ); + if(!EFI_ERROR (Status)) { + SioDevice.Segment =3D (UINT8) SegmentNumber; + SioDevice.Bus =3D (UINT8) BusNumber; + SioDevice.Device =3D (UINT8) DeviceNumber; + SioDevice.Funtion =3D (UINT8) FunctionNumber; + if(!SioDeviceEnabled (&SioDevice)) { + Status =3D EFI_UNSUPPORTED; + } + } + } } } =20 diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgP= cd.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds= c index 0298e4b12d..b85991b772 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds +++ c @@ -196,6 +196,12 @@ gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|4 gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase|0xFEC01000 =20 + ###################################### + # Board Configuration + ###################################### + gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1 + + gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00,0x00, + 0x1F,0x00} + [PcdsFixedAtBuild.X64] ###################################### # Edk2 Configuration -- 2.19.1.windows.1