From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7FF4CD80230 for ; Wed, 8 May 2024 03:27:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ETNdY2VCmWZAIAqyPOy6PAgbTVetV62wdYPQDDanYOA=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240206; t=1715138833; v=1; b=0lOYuvFud7RU5dzSury4+LCodPXHDItHvehLoD6TKp81Oxp9W4YirZx24WGACw4U/YjL4hL6 07w5g1GJ9FYHGPhGz5mrx5RHgDi9y5wt5xq3Bkc/lMV6a8p5rqebgRrkmeMs7qL5xqXp5wcTmai 2D037JOAQ42T1vQc6XADe7gXTMbgULf7KPoMZyG6C//W1ImXD7yWIN8kDh7vXFvkuvFzXO2DSKd V5RHekTV+HxKSKGtwlZ13IdlWHn6n4POKQJkDRsBy0T+wDb+hS4iiIYEGnJgown7a2T+ojgjlDs 0WhDH8Pvv9A+bOKQ1VPKV0OaJjEXhofm7DDlODeRWUsRQ== X-Received: by 127.0.0.2 with SMTP id UezNYY7687511xCH3Y7c64S9; Tue, 07 May 2024 20:27:13 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by mx.groups.io with SMTP id smtpd.web11.3942.1715138832865142461 for ; Tue, 07 May 2024 20:27:12 -0700 X-CSE-ConnectionGUID: XLe+ONbJQ4u7ojwkKHf6dw== X-CSE-MsgGUID: DOykzyzLRrScrxOf6w4jzg== X-IronPort-AV: E=McAfee;i="6600,9927,11066"; a="21644994" X-IronPort-AV: E=Sophos;i="6.08,144,1712646000"; d="scan'208,217";a="21644994" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 20:27:12 -0700 X-CSE-ConnectionGUID: 1rBSdX3ATuyfBMjhn/6rzQ== X-CSE-MsgGUID: GAG1sNUgSN+C23ixSTpQ5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,144,1712646000"; d="scan'208,217";a="66167331" X-Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 07 May 2024 20:27:12 -0700 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 7 May 2024 20:27:11 -0700 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 7 May 2024 20:27:11 -0700 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 7 May 2024 20:27:11 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 7 May 2024 20:27:11 -0700 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by DS7PR11MB6200.namprd11.prod.outlook.com (2603:10b6:8:98::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Wed, 8 May 2024 03:27:03 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8%4]) with mapi id 15.20.7544.041; Wed, 8 May 2024 03:27:02 +0000 From: "Ni, Ray" To: "Borzeszkowski, Alan" , "devel@edk2.groups.io" CC: "Gao, Zhichao" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Load Serial driver in early DXE Thread-Topic: [PATCH 1/1] MdeModulePkg: Load Serial driver in early DXE Thread-Index: AQHaoIAZsIMOkNnYAUGapUdq5gpuvrGMrfje Date: Wed, 8 May 2024 03:27:02 +0000 Message-ID: References: <640b9bf1b87b9a47f43bc5f231540b8f64a75945.1715087162.git.alan.borzeszkowski@intel.com> In-Reply-To: <640b9bf1b87b9a47f43bc5f231540b8f64a75945.1715087162.git.alan.borzeszkowski@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|DS7PR11MB6200:EE_ x-ms-office365-filtering-correlation-id: 23bdacfa-3fdd-4b59-1a2e-08dc6f0eba39 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?yqKWLf2bnGzYBJCnxymhbWVGMVrVyokAUo68kXclhsm3N17Pqoj/dnJGIBM/?= =?us-ascii?Q?nQKJP2r0RmBqvGJ5YWx8H1UbDDKTAAf7+dFoLlCEbVpRJgCUJfC+BgTUm1Bd?= =?us-ascii?Q?8tp/dM0MKwnwKvVgFD+k+Pc08x16euuT8+TrtZqCS4M5pvJmC1m9tEoFd+Dt?= =?us-ascii?Q?LESC0mO89V8iQZ5a5W1Pmfv+LWz7EVxc/HCWjNARHiyEXBr2PPkWNzSUrE5B?= =?us-ascii?Q?0/CUeplUJrhN66W72PNRKBVke7WvdPZXEQOcTOmcJfQJ3TdokNJVmLI0JD5Z?= =?us-ascii?Q?/1uVXcOs7sYx1wq/gyMY9gUUUmDJ5fDsb68gA/sU0PQJb5wlxOyWrOGN3xdN?= =?us-ascii?Q?0bq2YM0oGOadKaZG7bVNFSqY16BSY7MOKXtUsO0d0bdInUAwbpeookg10mOX?= =?us-ascii?Q?m4xVllVDf0vabDLLh7oYYvny56rZdRNtwi5sP1BVwH2Ox5SiruOnfI8Jmvq0?= =?us-ascii?Q?8Zdbee4sz7Te8EW2zE464EQEwnxMPY5sagk/McMgn0isHpB3KTXY7x8ueh7n?= =?us-ascii?Q?fQdmSTd/ezxKgzetBw53WPqU+OxK+5kR9hDW846rd4mwT6f/9uoH1qLDZhYw?= =?us-ascii?Q?N2BRoEAwsSUOLfp4HudtCceRooznht+iWA2W0NacPNGqaTrd9SFvxU++4Csg?= =?us-ascii?Q?UfeUcoGSzKqj/4uGTL1D81LxKFE4ZIinYrtm+sPsWORE14tI05MMnq2ZVNR7?= =?us-ascii?Q?/cEXcjBP8Bp662F1scuFb5RAeQ7XNH5duR7Yc/WXfUSPD1ofU6uA4x1oHvwE?= =?us-ascii?Q?1+d3iYcaLHAZevVCeoOhznOjXuXwDnQy5oZ2L+nEJCSVuzIwMLMCkPpk7pli?= =?us-ascii?Q?P8HyPxZRJleYjKLuJ3MyQkT2vw0e+sGehbUQh7M49gtrp/fQdNPE9sVioGgw?= =?us-ascii?Q?h4iPZmNyed5M5xaYGTqokc1GQw0OhmJjK79JWp/snSXxllBPZS93iLUzkbEv?= =?us-ascii?Q?ubI9Dx9birHRYq6AZeb4koi87NNieQtueaD7loUFQgwEDk0VuUN4sDSdO1ny?= =?us-ascii?Q?un4q/VdhojHJhUO2wlRV4VIk7wUF4B9Cn09QCH0+Yk4HKvznAGGtpzmqvfXI?= =?us-ascii?Q?8q7ntKcREPONjLRXM73RbLNslwWNLS4DAZXyJzThzdDqreNUR1NLzCJYbGf8?= =?us-ascii?Q?YEaY97PzRBPuKBqLfSFeIUxcEi9aJ3nzrFw/lPrj9Z1XQjnEMp0NgtMQ8nJx?= =?us-ascii?Q?zZ0UjiQimP5gBML2EBi+gF2EHrQqu5p4iGxGgYDj01YjwY3k8HcZoZpNrMcG?= =?us-ascii?Q?jHti0zxIR4uXoPRn1o/Mn5HZ6OvpRtjmplq9Xj2DFyswzPyIOsIYFycNgup9?= =?us-ascii?Q?ElksJkTqFRTZeTR0cQaixB/A8sSWylM+7i8qLsjZbLlxpA=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?85VmbymOq1Rxl+zl778ADFPC25V8dei4jblGXCMG93mtCzGqCcr4zAjlx3Ks?= =?us-ascii?Q?5tuwu/5vx8ApK4s9XSL81ZIm2W7EVmIiWh4qg+y12wcaXqnKRMgbKEyuocVJ?= =?us-ascii?Q?Ng/60Dh4IB0otVmd56X6Hy4Co/5KKDfMRKCAIUbVAtSM4HWeJrYWa2vg7ULy?= =?us-ascii?Q?VTuGUQpKTwbC5Hi5wl07nWY6Tk4CHg3w8RzBFQ/7StVXkZuLoaolxt+grCsx?= =?us-ascii?Q?78Khre+BJaQXMrL0lpY9vbfDwFuTRFJ04rZ//HODwDWiLlJxSxjUCyKftNSO?= =?us-ascii?Q?Izf865WQApamXTBUlg00RM9aq0fcvlLMA29JKPgMjlEdl2kgJEXfRj9DSeLH?= =?us-ascii?Q?yZ0ud9WA+GqJuAKw8r0JfLkY+s8GQKF33pnqQw6bkYjfXwSBJFBVEzb8+cf3?= =?us-ascii?Q?N0HL+TreHKrXF5QErW3jGDhTL7CKYTKb1I7VNfGn6ZaQX6hOBZ4iAoQWe0s7?= =?us-ascii?Q?x/LZ46uoVxXEH3G4Gz236yOEMvP5vVLX6DSlqee0R37jFVGFdddM5lfUD4aA?= =?us-ascii?Q?M7oovlEWG3pVdVpY4ICYs98dnpCethJ4btiC8FE8UhRrEPj+tk3BdZXVHoVu?= =?us-ascii?Q?K2DqPvB46mopkgNb33oNBCJ4mdzsUSsepfiuALJ3mBArjKIrr2ESgkkSTQdV?= =?us-ascii?Q?ZvY51hczJP0gkTI64aEullHQmP5Oluun6XCla+Vvg28jFpr8RQsOyjihg4Bf?= =?us-ascii?Q?tUaVOywmsAWDxpU49OdhGy1T1d9oOxiLFEqWcBjBGPcKafWdiVWvORD5YniA?= =?us-ascii?Q?/4CAfbzFftz+4glcILGCLasp8iIM7yiqJzYNpwK1Q3tYEdkYgsSXBiEjkjNJ?= =?us-ascii?Q?PXiQ6OWr+ZxLq3kr2MnYuLl7buuw4mK5vnG7JaZoPK2z70m+cNc94AJNig9E?= =?us-ascii?Q?cBeHY/LOQVEh/zuAldn83P11MBeLZGe6R2lstZ2uVvPNQavNWPpn34ilBPYE?= =?us-ascii?Q?oiwU9Q7QLd/guYtUkJb7fR7c8s+5rWsGaZXAWMysdO6yBvCHLjC9YdCajkHh?= =?us-ascii?Q?6uyS8rGenkU0Z9iZJi7WNcp/Y4bpSoS//SgfpuBaBB7/S3j3RFkbeukca8Al?= =?us-ascii?Q?4Sl4a8/xe04C+/cPxiE7xtUfvUSkhW+SWLHP8Z7sFt1q9pgiZzBGrJi9x95d?= =?us-ascii?Q?EtrOt0Jq9S2VamsjCnZOwKuiqLOPH0bVkKK8hkyLXj/GbqyAZbZhpJr3H0na?= =?us-ascii?Q?08i1z1LIWu5GoZHnkSSJ7vGRi0CQhfr//qglH8DaqCSUuhyD3P/tgA4ohpL2?= =?us-ascii?Q?LhxUOCmasbEUjz4331+oUksWaownW5eDGyDgDHmDf89U7irVgN4y6zvywRKJ?= =?us-ascii?Q?PYvpwpbwFaG7nUM2nC4wCZC0S4bd8XfVb1JNwoB2cHGFOYxAOIpgAVGlOt9T?= =?us-ascii?Q?jKMpslcQsAK3Frq3maESqLnu6wZmmisgEYKYMWJ9xd5qKbe1hvSjkf2QUy+w?= =?us-ascii?Q?rY0JW5vvuVOw2JPYS+GiWPLHt1PqxKkqFmvGp0dMqx8IeyeDRMEnHG/KXnCT?= =?us-ascii?Q?i0TR1wRpV1ZTF6utLzeN7hFaTzMuZWCVYWXAlyHNCeYtlxupOmzqo0bbaGkH?= =?us-ascii?Q?CRQ7j9jL4SdO5Zwuoow=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23bdacfa-3fdd-4b59-1a2e-08dc6f0eba39 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2024 03:27:02.3884 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: X3e30/UY6mZfRocn8GXfXjrj4MOV78yOYfKo825OyLNBY8FBkactFFUQkB5qZNLP36LG/E6/T8praJl7In9g1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR11MB6200 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 07 May 2024 20:27:12 -0700 Resent-From: ray.ni@intel.com Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: NtIuXmT1UI54eX4UmPDawnB2x7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB8244FCAD8137FF36EEC5C53A8CE52MN6PR11MB8244namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=0lOYuvFu; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) --_000_MN6PR11MB8244FCAD8137FF36EEC5C53A8CE52MN6PR11MB8244namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Why not implement a customized SerialPortLib and use MdeModulePkg/Universal= /SerialDxe/SerialDxe.inf? Thanks, Ray ________________________________ From: Borzeszkowski, Alan Sent: Tuesday, May 7, 2024 21:09 To: devel@edk2.groups.io Cc: Borzeszkowski, Alan ; Gao, Zhichao ; Ni, Ray ; Kinney, Michael D Subject: [PATCH 1/1] MdeModulePkg: Load Serial driver in early DXE For the purpose of UEFI debug prints enablement in early DXE, Serial driver should load earlier. To comply with EDK2 specification and maximize code reuse, new driver entrypoint was created and separate .inf file was added. Cc: Zhichao Gao Cc: Ray Ni Cc: Michael D Kinney Signed-off-by: Alan Borzeszkowski --- .../PciSioSerialDxe/PciSioSerialDxeEarly.inf | 81 ++++++++ MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 184 ++++++++++++++---- .../Bus/Pci/PciSioSerialDxe/SerialIo.c | 16 +- MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 245 insertions(+), 37 deletions(-) create mode 100644 MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEar= ly.inf diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf = b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf new file mode 100644 index 0000000000..1b88f7a1cc --- /dev/null +++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf @@ -0,0 +1,81 @@ +## @file +# Serial driver for standard UARTS on a SIO chip or PCI/PCIE card. +# +# Produces the Serial I/O protocol for standard UARTS using Super I/O or P= CI I/O. +# +# This is Early DXE version of Serial driver. It's intended use is for deb= ug purposes +# in early DXE. There is added dependency on either Super I/O Protocol or = PCI I/O Protocol. +# +# Copyright (c) 2007 - 2024, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PciSioSerialDxeEarly + MODULE_UNI_FILE =3D PciSioSerialDxe.uni + FILE_GUID =3D E47C4BFB-9CCC-47B6-A3C1-79C3FBF8B6C8 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DxePciSioSerialDriverEntrypoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# +# DRIVER_BINDING =3D gSerialControllerDriver +# COMPONENT_NAME =3D gPciSioSerialComponentName +# COMPONENT_NAME2 =3D gPciSioSerialComponentName2 +# + +[Sources] + ComponentName.c + SerialIo.c + Serial.h + Serial.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + PcdLib + ReportStatusCodeLib + UefiBootServicesTableLib + MemoryAllocationLib + BaseMemoryLib + DevicePathLib + UefiLib + UefiDriverEntryPoint + DebugLib + IoLib + +[Guids] + gEfiUartDevicePathGuid ## SOMETIMES_CONSUMES ##= GUID + +[Protocols] + gEfiSioProtocolGuid ## TO_START + gEfiDevicePathProtocolGuid ## TO_START + gEfiPciIoProtocolGuid ## TO_START + gEfiSerialIoProtocolGuid ## BY_START + gEfiDevicePathProtocolGuid ## BY_START + +[FeaturePcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHalfHandshake|FALSE ## CONS= UMES + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPciSerialParameters ## CONSUMES + +[UserExtensions.TianoCore."ExtraFiles"] + PciSioSerialDxeExtra.uni + +[Depex] + gEfiSioProtocolGuid OR gEfiPciIoProtocolGuid diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg/B= us/Pci/PciSioSerialDxe/Serial.c index 8b1ce70118..cc77d12748 100644 --- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c +++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c @@ -156,6 +156,7 @@ InitializePciSioSerial ( /** Return whether the controller is a SIO serial controller. + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instan= ce. @param Controller The controller handle. @retval EFI_SUCCESS The controller is a SIO serial controller. @@ -163,7 +164,8 @@ InitializePciSioSerial ( **/ EFI_STATUS IsSioSerialController ( - EFI_HANDLE Controller + IN EFI_DRIVER_BINDING_PROTOCOL *This, + EFI_HANDLE Controller ) { EFI_STATUS Status; @@ -178,7 +180,7 @@ IsSioSerialController ( Controller, &gEfiSioProtocolGuid, (VOID **)&Sio, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -193,7 +195,7 @@ IsSioSerialController ( gBS->CloseProtocol ( Controller, &gEfiSioProtocolGuid, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller ); @@ -201,7 +203,7 @@ IsSioSerialController ( Controller, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -228,7 +230,7 @@ IsSioSerialController ( gBS->CloseProtocol ( Controller, &gEfiDevicePathProtocolGuid, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller ); } @@ -239,14 +241,16 @@ IsSioSerialController ( /** Return whether the controller is a PCI serial controller. - @param Controller The controller handle. + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL ins= tance. + @param Controller The controller handle. @retval EFI_SUCCESS The controller is a PCI serial controller. @retval others The controller is not a PCI serial controller. **/ EFI_STATUS IsPciSerialController ( - EFI_HANDLE Controller + IN EFI_DRIVER_BINDING_PROTOCOL *This, + EFI_HANDLE Controller ) { EFI_STATUS Status; @@ -262,7 +266,7 @@ IsPciSerialController ( Controller, &gEfiPciIoProtocolGuid, (VOID **)&PciIo, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -301,7 +305,7 @@ IsPciSerialController ( gBS->CloseProtocol ( Controller, &gEfiPciIoProtocolGuid, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller ); } @@ -317,7 +321,7 @@ IsPciSerialController ( Controller, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -329,7 +333,7 @@ IsPciSerialController ( gBS->CloseProtocol ( Controller, &gEfiDevicePathProtocolGuid, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller ); @@ -348,12 +352,11 @@ IsPciSerialController ( **/ EFI_STATUS EFIAPI -SerialControllerDriverSupported ( +SerialDriverSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) - { EFI_STATUS Status; UART_DEVICE_PATH *Uart; @@ -393,17 +396,40 @@ SerialControllerDriverSupported ( } } - Status =3D IsSioSerialController (Controller); + Status =3D IsSioSerialController (This, Controller); if (EFI_ERROR (Status)) { - Status =3D IsPciSerialController (Controller); + Status =3D IsPciSerialController (This, Controller); } return Status; } +/** + Check to see if this driver supports the given controller + + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCO= L instance. + @param Controller The handle of the controller to test. + @param RemainingDevicePath A pointer to the remaining portion of a dev= ice path. + + @return EFI_SUCCESS This driver can support the given controlle= r + +**/ +EFI_STATUS +EFIAPI +SerialControllerDriverSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) + +{ + return SerialDriverSupported (This, Controller, RemainingDevicePath); +} + /** Create the child serial device instance. + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL= instance. @param Controller The parent controller handle. @param Uart Pointer to the UART device path node in Rema= iningDevicePath, or NULL if RemainingDevicePath is NULL. @@ -423,14 +449,15 @@ SerialControllerDriverSupported ( **/ EFI_STATUS CreateSerialDevice ( - IN EFI_HANDLE Controller, - IN UART_DEVICE_PATH *Uart, - IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, - IN BOOLEAN CreateControllerNode, - IN UINT32 Instance, - IN PARENT_IO_PROTOCOL_PTR ParentIo, - IN PCI_SERIAL_PARAMETER *PciSerialParameter OPTIONAL, - IN PCI_DEVICE_INFO *PciDeviceInfo OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN UART_DEVICE_PATH *Uart, + IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, + IN BOOLEAN CreateControllerNode, + IN UINT32 Instance, + IN PARENT_IO_PROTOCOL_PTR ParentIo, + IN PCI_SERIAL_PARAMETER *PciSerialParameter OPTIONAL, + IN PCI_DEVICE_INFO *PciDeviceInfo OPTIONAL ) { EFI_STATUS Status; @@ -685,7 +712,7 @@ CreateSerialDevice ( Controller, PciSerialParameter !=3D NULL ? &gEfiPciIoProtocolGuid : = &gEfiSioProtocolGuid, (VOID **)&ParentIo, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, SerialDevice->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); @@ -720,6 +747,7 @@ CreateError: /** Returns an array of pointers containing all the child serial device poin= ters. + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL inst= ance. @param Controller The parent controller handle. @param IoProtocolGuid The protocol GUID, either equals to gEfiSioProtoc= olGuid or equals to gEfiPciIoProtocolGuid. @@ -729,9 +757,10 @@ CreateError: **/ SERIAL_DEV ** GetChildSerialDevices ( - IN EFI_HANDLE Controller, - IN EFI_GUID *IoProtocolGuid, - OUT UINTN *Count + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_GUID *IoProtocolGuid, + OUT UINTN *Count ) { EFI_STATUS Status; @@ -768,7 +797,7 @@ GetChildSerialDevices ( OpenInfoBuffer[Index].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo, - gSerialControllerDriver.DriverBindingHandle, + This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); @@ -778,7 +807,7 @@ GetChildSerialDevices ( } if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != =3D 0) { - ASSERT (OpenInfoBuffer[Index].AgentHandle =3D=3D gSerialControllerDr= iver.DriverBindingHandle); + ASSERT (OpenInfoBuffer[Index].AgentHandle =3D=3D This->DriverBinding= Handle); OpenByDriver =3D TRUE; } } @@ -793,7 +822,7 @@ GetChildSerialDevices ( } /** - Start to management the controller passed in + Start to manage the controller passed in @param This A pointer to the EFI_DRIVER_BINDING_PROTOCO= L instance. @param Controller The handle of the controller to test. @@ -803,7 +832,7 @@ GetChildSerialDevices ( **/ EFI_STATUS EFIAPI -SerialControllerDriverStart ( +SerialDriverStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath @@ -890,7 +919,7 @@ SerialControllerDriverStart ( ControllerNumber =3D 0; ContainsControllerNode =3D FALSE; - SerialDevices =3D GetChildSerialDevices (Controller, IoProtocol= Guid, &SerialDeviceCount); + SerialDevices =3D GetChildSerialDevices (This, Controller, IoPr= otocolGuid, &SerialDeviceCount); if (SerialDeviceCount !=3D 0) { if (RemainingDevicePath =3D=3D NULL) { @@ -991,7 +1020,7 @@ SerialControllerDriverStart ( Node =3D NextDevicePathNode (Node); } while (!IsDevicePathEnd (Node)); - Status =3D CreateSerialDevice (Controller, Uart, ParentDevicePath, F= ALSE, Acpi->UID, ParentIo, NULL, NULL); + Status =3D CreateSerialDevice (This, Controller, Uart, ParentDeviceP= ath, FALSE, Acpi->UID, ParentIo, NULL, NULL); DEBUG ((DEBUG_INFO, "PciSioSerial: Create SIO child serial device - = %r\n", Status)); } } else { @@ -1073,7 +1102,7 @@ SerialControllerDriverStart ( PciSerialParameter =3D PcdGetPtr (PcdPciSerialParameters); } - Status =3D CreateSerialDevice (Controller, Uart, ParentDevicePat= h, FALSE, 0, ParentIo, PciSerialParameter, PciDeviceInfo); + Status =3D CreateSerialDevice (This, Controller, Uart, ParentDev= icePath, FALSE, 0, ParentIo, PciSerialParameter, PciDeviceInfo); DEBUG ((DEBUG_INFO, "PciSioSerial: Create PCI child serial devic= e (single) - %r\n", Status)); if (!EFI_ERROR (Status)) { PciDeviceInfo->ChildCount++; @@ -1094,7 +1123,7 @@ SerialControllerDriverStart ( // // Create controller node when PCI serial device contains mu= ltiple UARTs // - Status =3D CreateSerialDevice (Controller, Uart, ParentDevic= ePath, TRUE, PciSerialCount, ParentIo, PciSerialParameter, PciDeviceInfo); + Status =3D CreateSerialDevice (This, Controller, Uart, Paren= tDevicePath, TRUE, PciSerialCount, ParentIo, PciSerialParameter, PciDeviceI= nfo); PciSerialCount++; DEBUG ((DEBUG_INFO, "PciSioSerial: Create PCI child serial d= evice (multiple) - %r\n", Status)); if (!EFI_ERROR (Status)) { @@ -1147,6 +1176,91 @@ SerialControllerDriverStart ( return Status; } +/** + Start to manage the controller passed in + + @param This A pointer to the EFI_DRIVER_BINDING_PROTOCO= L instance. + @param Controller The handle of the controller to test. + @param RemainingDevicePath A pointer to the remaining portion of a dev= ice path. + + @return EFI_SUCCESS Driver is started successfully +**/ +EFI_STATUS +EFIAPI +SerialControllerDriverStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + return SerialDriverStart (This, Controller, RemainingDevicePath); +} + +/** + Initialize Serial driver in DXE phase + + @param ImageHandle Handle for the image of this driver. + @param SystemTable Pointer to the EFI System Table. + + @return EFI_SUCCESS Driver is started successfully +**/ +EFI_STATUS +EFIAPI +DxePciSioSerialDriverEntrypoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *EfiDevicePath; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + EFI_DRIVER_BINDING_PROTOCOL *SerialControllerDriver; + UINTN Index; + + EfiDevicePath =3D NULL; + HandleBuffer =3D NULL; + // + // Initialize the serial controller instance + // + SerialControllerDriver =3D AllocateCopyPool (sizeof (EFI_DRIVER_BINDING_= PROTOCOL), &gSerialControllerDriver); + ASSERT (SerialControllerDriver !=3D NULL); + + SerialControllerDriver->DriverBindingHandle =3D ImageHandle; + // + // Initialize UART default setting in gSerialDevTemplate + // + gSerialDevTemplate.SerialMode.BaudRate =3D PcdGet64 (PcdUartDefaultB= audRate); + gSerialDevTemplate.SerialMode.DataBits =3D PcdGet8 (PcdUartDefaultDa= taBits); + gSerialDevTemplate.SerialMode.Parity =3D PcdGet8 (PcdUartDefaultPa= rity); + gSerialDevTemplate.SerialMode.StopBits =3D PcdGet8 (PcdUartDefaultSt= opBits); + gSerialDevTemplate.UartDevicePath.BaudRate =3D PcdGet64 (PcdUartDefaultB= audRate); + gSerialDevTemplate.UartDevicePath.DataBits =3D PcdGet8 (PcdUartDefaultDa= taBits); + gSerialDevTemplate.UartDevicePath.Parity =3D PcdGet8 (PcdUartDefaultPa= rity); + gSerialDevTemplate.UartDevicePath.StopBits =3D PcdGet8 (PcdUartDefaultSt= opBits); + gSerialDevTemplate.ClockRate =3D PcdGet32 (PcdSerialClockR= ate); + + // Check all handles for compatible Device Path and appropriate I/O Prot= ocol + Status =3D gBS->LocateHandleBuffer (ByProtocol, &gEfiDevicePathProtocolG= uid, NULL, &NumberOfHandles, &HandleBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index =3D 0; Index < NumberOfHandles; Index++) { + EfiDevicePath =3D DevicePathFromHandle (HandleBuffer[Index]); + Status =3D SerialDriverSupported (SerialControllerDriver, Handl= eBuffer[Index], EfiDevicePath); + DEBUG ((DEBUG_INFO, "SerialDriverSupported status: %r\n", Status)); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D SerialDriverStart (SerialControllerDriver, HandleBuffer[Ind= ex], EfiDevicePath); + DEBUG ((DEBUG_INFO, "SerialDriverStart status: %r\n", Status)); + } + + return EFI_SUCCESS; +} + /** Disconnect this driver with the controller, uninstall related protocol i= nstance diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c b/MdeModulePkg= /Bus/Pci/PciSioSerialDxe/SerialIo.c index 8a85a6c3b8..c052d43b84 100644 --- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c +++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c @@ -1367,7 +1367,13 @@ SerialReadRegister ( EFI_STATUS Status; if (SerialDev->PciDeviceInfo =3D=3D NULL) { - return IoRead8 ((UINTN)SerialDev->BaseAddress + Offset * SerialDev->Re= gisterStride); + if (SerialDev->MmioAccess) + { + return MmioRead8((UINTN)SerialDev->BaseAddress + Offset * SerialDev-= >RegisterStride); + } + else { + return IoRead8 ((UINTN)SerialDev->BaseAddress + Offset * SerialDev->= RegisterStride); + } } else { if (SerialDev->MmioAccess) { Status =3D SerialDev->PciDeviceInfo->PciIo->Mem.Read ( @@ -1411,7 +1417,13 @@ SerialWriteRegister ( EFI_STATUS Status; if (SerialDev->PciDeviceInfo =3D=3D NULL) { - IoWrite8 ((UINTN)SerialDev->BaseAddress + Offset * SerialDev->Register= Stride, Data); + if (SerialDev->MmioAccess) + { + MmioWrite8((UINTN)SerialDev->BaseAddress + Offset * SerialDev->Regis= terStride, Data); + } + else { + IoWrite8 ((UINTN)SerialDev->BaseAddress + Offset * SerialDev->Regist= erStride, Data); + } } else { if (SerialDev->MmioAccess) { Status =3D SerialDev->PciDeviceInfo->PciIo->Mem.Write ( diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index c0f1df3bfb..b209fe2696 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -240,6 +240,7 @@ MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf + MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf MdeModulePkg/Bus/Pci/IncompatiblePciDeviceSupportDxe/IncompatiblePciDevi= ceSupportDxe.inf MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -- 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118657): https://edk2.groups.io/g/devel/message/118657 Mute This Topic: https://groups.io/mt/105959587/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_MN6PR11MB8244FCAD8137FF36EEC5C53A8CE52MN6PR11MB8244namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Why not implement a customized SerialPortLib and use MdeModulePkg/Universal= /SerialDxe/SerialDxe.inf?

Thanks,
Ray

From: Borzeszkowski, Alan &= lt;alan.borzeszkowski@intel.com>
Sent: Tuesday, May 7, 2024 21:09
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Borzeszkowski, Alan <alan.borzeszkowski@intel.com>; Gao, Z= hichao <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>; Kin= ney, Michael D <michael.d.kinney@intel.com>
Subject: [PATCH 1/1] MdeModulePkg: Load Serial driver in early DXE
 
For the purpose of UEFI debug prints enablement in= early DXE,
Serial driver should load earlier. To comply with EDK2 specification
and maximize code reuse, new driver entrypoint was created
and separate .inf file was added.

Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Alan Borzeszkowski <alan.borzeszkowski@intel.com>
---
 .../PciSioSerialDxe/PciSioSerialDxeEarly.inf  |  81 +++++++= +
 MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 184 ++++++++++++++---= -
 .../Bus/Pci/PciSioSerialDxe/SerialIo.c     &= nbsp;  |  16 +-
 MdeModulePkg/MdeModulePkg.dsc      &nbs= p;          |   1 +<= br>  4 files changed, 245 insertions(+), 37 deletions(-)
 create mode 100644 MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialD= xeEarly.inf

diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf = b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf
new file mode 100644
index 0000000000..1b88f7a1cc
--- /dev/null
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf
@@ -0,0 +1,81 @@
+## @file

+# Serial driver for standard UARTS on a SIO chip or PCI/PCIE card.

+#

+# Produces the Serial I/O protocol for standard UARTS using Super I/O or P= CI I/O.

+#

+# This is Early DXE version of Serial driver. It's intended use is for deb= ug purposes

+# in early DXE. There is added dependency on either Super I/O Protocol or = PCI I/O Protocol.

+#

+# Copyright (c) 2007 - 2024, Intel Corporation. All rights reserved.<BR= >

+#

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+##

+

+[Defines]

+  INF_VERSION         &n= bsp;          =3D 0x00010005
+  BASE_NAME         &nbs= p;            =3D Pc= iSioSerialDxeEarly

+  MODULE_UNI_FILE        &nbs= p;       =3D PciSioSerialDxe.uni

+  FILE_GUID         &nbs= p;            =3D E4= 7C4BFB-9CCC-47B6-A3C1-79C3FBF8B6C8

+  MODULE_TYPE         &n= bsp;          =3D DXE_DRIVER
+  VERSION_STRING         = ;        =3D 1.0

+  ENTRY_POINT         &n= bsp;          =3D DxePciSioSer= ialDriverEntrypoint

+

+#

+# The following information is for reference only and not required by the = build tools.

+#

+#  VALID_ARCHITECTURES        = ;   =3D IA32 X64 EBC

+#

+#  DRIVER_BINDING        &nbs= p;       =3D  gSerialControllerDriver
+#  COMPONENT_NAME        &nbs= p;       =3D  gPciSioSerialComponentName=

+#  COMPONENT_NAME2        &nb= sp;      =3D  gPciSioSerialComponentName2

+#

+

+[Sources]

+  ComponentName.c

+  SerialIo.c

+  Serial.h

+  Serial.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+

+[LibraryClasses]

+  PcdLib

+  ReportStatusCodeLib

+  UefiBootServicesTableLib

+  MemoryAllocationLib

+  BaseMemoryLib

+  DevicePathLib

+  UefiLib

+  UefiDriverEntryPoint

+  DebugLib

+  IoLib

+

+[Guids]

+  gEfiUartDevicePathGuid       &nb= sp;            =     ## SOMETIMES_CONSUMES   ## GUID

+

+[Protocols]

+  gEfiSioProtocolGuid        =             &nb= sp;      ## TO_START

+  gEfiDevicePathProtocolGuid       = ;             #= # TO_START

+  gEfiPciIoProtocolGuid       &nbs= p;            &= nbsp;    ## TO_START

+  gEfiSerialIoProtocolGuid       &= nbsp;           &nbs= p;  ## BY_START

+  gEfiDevicePathProtocolGuid       = ;             #= # BY_START

+

+[FeaturePcd]

+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHalfHandshake|FALSE = ;  ## CONSUMES

+

+[Pcd]

+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200  &= nbsp; ## CONSUMES

+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8   =       ## CONSUMES

+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1   &n= bsp;       ## CONSUMES

+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1   =       ## CONSUMES

+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUM= ES

+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciSerialParameters  &n= bsp;  ## CONSUMES

+

+[UserExtensions.TianoCore."ExtraFiles"]

+  PciSioSerialDxeExtra.uni

+

+[Depex]

+  gEfiSioProtocolGuid OR gEfiPciIoProtocolGuid

diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg/B= us/Pci/PciSioSerialDxe/Serial.c
index 8b1ce70118..cc77d12748 100644
--- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
@@ -156,6 +156,7 @@ InitializePciSioSerial (
 /**

   Return whether the controller is a SIO serial controller.

 

+  @param  This         A= pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.

   @param  Controller   The controller handle.

 

   @retval EFI_SUCCESS  The controller is a SIO serial contr= oller.

@@ -163,7 +164,8 @@ InitializePciSioSerial (
 **/

 EFI_STATUS

 IsSioSerialController (

-  EFI_HANDLE  Controller

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  EFI_HANDLE         &nb= sp;            Contr= oller

   )

 {

   EFI_STATUS        &nbs= p;       Status;

@@ -178,7 +180,7 @@ IsSioSerialController (
            &nb= sp;      Controller,

            &nb= sp;      &gEfiSioProtocolGuid,

            &nb= sp;      (VOID **)&Sio,

-            &n= bsp;     gSerialControllerDriver.DriverBindingHandle,
+            &n= bsp;     This->DriverBindingHandle,

            &nb= sp;      Controller,

            &nb= sp;      EFI_OPEN_PROTOCOL_BY_DRIVER

            &nb= sp;      );

@@ -193,7 +195,7 @@ IsSioSerialController (
     gBS->CloseProtocol (

            Controll= er,

            &gEf= iSioProtocolGuid,

-           gSerialContro= llerDriver.DriverBindingHandle,

+           This->Driv= erBindingHandle,

            Controll= er

            );

 

@@ -201,7 +203,7 @@ IsSioSerialController (
            &nb= sp;        Controller,

            &nb= sp;        &gEfiDevicePathProtocolGu= id,

            &nb= sp;        (VOID **)&DevicePath,

-            &n= bsp;       gSerialControllerDriver.DriverBind= ingHandle,

+            &n= bsp;       This->DriverBindingHandle,

            &nb= sp;        Controller,

            &nb= sp;        EFI_OPEN_PROTOCOL_BY_DRIVER
            &nb= sp;        );

@@ -228,7 +230,7 @@ IsSioSerialController (
     gBS->CloseProtocol (

            Controll= er,

            &gEf= iDevicePathProtocolGuid,

-           gSerialContro= llerDriver.DriverBindingHandle,

+           This->Driv= erBindingHandle,

            Controll= er

            );

   }

@@ -239,14 +241,16 @@ IsSioSerialController (
 /**

   Return whether the controller is a PCI serial controller.

 

-  @param  Controller   The controller handle.

+  @param  This        &n= bsp;   A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.

+  @param  Controller      The controlle= r handle.

 

   @retval EFI_SUCCESS  The controller is a PCI serial contr= oller.

   @retval others       The control= ler is not a PCI serial controller.

 **/

 EFI_STATUS

 IsPciSerialController (

-  EFI_HANDLE  Controller

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  EFI_HANDLE         &nb= sp;            Contr= oller

   )

 {

   EFI_STATUS        &nbs= p;       Status;

@@ -262,7 +266,7 @@ IsPciSerialController (
            &nb= sp;      Controller,

            &nb= sp;      &gEfiPciIoProtocolGuid,

            &nb= sp;      (VOID **)&PciIo,

-            &n= bsp;     gSerialControllerDriver.DriverBindingHandle,
+            &n= bsp;     This->DriverBindingHandle,

            &nb= sp;      Controller,

            &nb= sp;      EFI_OPEN_PROTOCOL_BY_DRIVER

            &nb= sp;      );

@@ -301,7 +305,7 @@ IsPciSerialController (
     gBS->CloseProtocol (

            Controll= er,

            &gEf= iPciIoProtocolGuid,

-           gSerialContro= llerDriver.DriverBindingHandle,

+           This->Driv= erBindingHandle,

            Controll= er

            );

   }

@@ -317,7 +321,7 @@ IsPciSerialController (
            &nb= sp;      Controller,

            &nb= sp;      &gEfiDevicePathProtocolGuid,

            &nb= sp;      (VOID **)&DevicePath,

-            &n= bsp;     gSerialControllerDriver.DriverBindingHandle,
+            &n= bsp;     This->DriverBindingHandle,

            &nb= sp;      Controller,

            &nb= sp;      EFI_OPEN_PROTOCOL_BY_DRIVER

            &nb= sp;      );

@@ -329,7 +333,7 @@ IsPciSerialController (
   gBS->CloseProtocol (

          Controller,

          &gEfiDevicePathP= rotocolGuid,

-         gSerialControllerDriver.D= riverBindingHandle,

+         This->DriverBindingHan= dle,

          Controller

          );

 

@@ -348,12 +352,11 @@ IsPciSerialController (
 **/

 EFI_STATUS

 EFIAPI

-SerialControllerDriverSupported (

+SerialDriverSupported (

   IN EFI_DRIVER_BINDING_PROTOCOL  *This,

   IN EFI_HANDLE        &= nbsp;          Controller,

   IN EFI_DEVICE_PATH_PROTOCOL     *Remaining= DevicePath

   )

-

 {

   EFI_STATUS        &nbs= p;            Status= ;

   UART_DEVICE_PATH       &nbs= p;       *Uart;

@@ -393,17 +396,40 @@ SerialControllerDriverSupported (
     }

   }

 

-  Status =3D IsSioSerialController (Controller);

+  Status =3D IsSioSerialController (This, Controller);

   if (EFI_ERROR (Status)) {

-    Status =3D IsPciSerialController (Controller);

+    Status =3D IsPciSerialController (This, Controller);
   }

 

   return Status;

 }

 

+/**

+  Check to see if this driver supports the given controller

+

+  @param  This        &n= bsp;        A pointer to the EFI_DRIVER_= BINDING_PROTOCOL instance.

+  @param  Controller       &n= bsp;   The handle of the controller to test.

+  @param  RemainingDevicePath  A pointer to the remaining p= ortion of a device path.

+

+  @return EFI_SUCCESS        =   This driver can support the given controller

+

+**/

+EFI_STATUS

+EFIAPI

+SerialControllerDriverSupported (

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  IN EFI_HANDLE         =           Controller,

+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevic= ePath

+  )

+

+{

+  return SerialDriverSupported (This, Controller, RemainingDevicePath= );

+}

+

 /**

   Create the child serial device instance.

 

+  @param  This        &n= bsp;       A pointer to the EFI_DRIVER_BINDIN= G_PROTOCOL instance.

   @param Controller       &nb= sp;   The parent controller handle.

   @param Uart        &nb= sp;        Pointer to the UART device pa= th node in RemainingDevicePath,

            &nb= sp;            =       or NULL if RemainingDevicePath is NULL.

@@ -423,14 +449,15 @@ SerialControllerDriverSupported (
 **/

 EFI_STATUS

 CreateSerialDevice (

-  IN EFI_HANDLE         =        Controller,

-  IN UART_DEVICE_PATH        =   *Uart,

-  IN EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath,

-  IN BOOLEAN         &nb= sp;         CreateControllerNode,
-  IN UINT32         &nbs= p;          Instance,

-  IN PARENT_IO_PROTOCOL_PTR    ParentIo,

-  IN PCI_SERIAL_PARAMETER      *PciSerialPar= ameter  OPTIONAL,

-  IN PCI_DEVICE_INFO        &= nbsp;  *PciDeviceInfo       OPTIONAL

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  IN EFI_HANDLE         =           Controller,

+  IN UART_DEVICE_PATH        =      *Uart,

+  IN EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePa= th,

+  IN BOOLEAN         &nb= sp;            Creat= eControllerNode,

+  IN UINT32         &nbs= p;             = Instance,

+  IN PARENT_IO_PROTOCOL_PTR       Paren= tIo,

+  IN PCI_SERIAL_PARAMETER       &n= bsp; *PciSerialParameter  OPTIONAL,

+  IN PCI_DEVICE_INFO        &= nbsp;     *PciDeviceInfo     &= nbsp; OPTIONAL

   )

 {

   EFI_STATUS        &nbs= p;            &= nbsp;            Sta= tus;

@@ -685,7 +712,7 @@ CreateSerialDevice (
            &nb= sp;      Controller,

            &nb= sp;      PciSerialParameter !=3D NULL ? &gEfiP= ciIoProtocolGuid : &gEfiSioProtocolGuid,

            &nb= sp;      (VOID **)&ParentIo,

-            &n= bsp;     gSerialControllerDriver.DriverBindingHandle,
+            &n= bsp;     This->DriverBindingHandle,

            &nb= sp;      SerialDevice->Handle,

            &nb= sp;      EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER

            &nb= sp;      );

@@ -720,6 +747,7 @@ CreateError:
 /**

   Returns an array of pointers containing all the child serial d= evice pointers.

 

+  @param  This        &n= bsp;  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.

   @param Controller      The parent con= troller handle.

   @param IoProtocolGuid  The protocol GUID, either equals t= o gEfiSioProtocolGuid

            &nb= sp;            = or equals to gEfiPciIoProtocolGuid.

@@ -729,9 +757,10 @@ CreateError:
 **/

 SERIAL_DEV **

 GetChildSerialDevices (

-  IN EFI_HANDLE  Controller,

-  IN EFI_GUID    *IoProtocolGuid,

-  OUT UINTN      *Count

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  IN EFI_HANDLE         =           Controller,

+  IN EFI_GUID         &n= bsp;           *IoProtoco= lGuid,

+  OUT UINTN         &nbs= p;             = *Count

   )

 {

   EFI_STATUS        &nbs= p;            &= nbsp;     Status;

@@ -768,7 +797,7 @@ GetChildSerialDevices (
            &nb= sp;          OpenInfoBuffer[In= dex].ControllerHandle,

            &nb= sp;          &gEfiSerialIo= ProtocolGuid,

            &nb= sp;          (VOID **)&Ser= ialIo,

-            &n= bsp;         gSerialControllerDrive= r.DriverBindingHandle,

+            &n= bsp;         This->DriverBinding= Handle,

            &nb= sp;          Controller,

            &nb= sp;          EFI_OPEN_PROTOCOL= _GET_PROTOCOL

            &nb= sp;          );

@@ -778,7 +807,7 @@ GetChildSerialDevices (
     }

 

     if ((OpenInfoBuffer[Index].Attributes & EFI_OP= EN_PROTOCOL_BY_DRIVER) !=3D 0) {

-      ASSERT (OpenInfoBuffer[Index].AgentHandle = =3D=3D gSerialControllerDriver.DriverBindingHandle);

+      ASSERT (OpenInfoBuffer[Index].AgentHandle = =3D=3D This->DriverBindingHandle);

       OpenByDriver =3D TRUE;

     }

   }

@@ -793,7 +822,7 @@ GetChildSerialDevices (
 }

 

 /**

-  Start to management the controller passed in

+  Start to manage the controller passed in

 

   @param  This       &nb= sp;         A pointer to the EFI_DR= IVER_BINDING_PROTOCOL instance.

   @param  Controller      &nb= sp;    The handle of the controller to test.

@@ -803,7 +832,7 @@ GetChildSerialDevices (
 **/

 EFI_STATUS

 EFIAPI

-SerialControllerDriverStart (

+SerialDriverStart (

   IN EFI_DRIVER_BINDING_PROTOCOL  *This,

   IN EFI_HANDLE        &= nbsp;          Controller,

   IN EFI_DEVICE_PATH_PROTOCOL     *Remaining= DevicePath

@@ -890,7 +919,7 @@ SerialControllerDriverStart (
 

   ControllerNumber       =3D 0;
   ContainsControllerNode =3D FALSE;

-  SerialDevices         = =3D GetChildSerialDevices (Controller, IoProtocolGuid, &SerialDeviceCo= unt);

+  SerialDevices         = =3D GetChildSerialDevices (This, Controller, IoProtocolGuid, &SerialDe= viceCount);

 

   if (SerialDeviceCount !=3D 0) {

     if (RemainingDevicePath =3D=3D NULL) {

@@ -991,7 +1020,7 @@ SerialControllerDriverStart (
         Node =3D NextDevicePathNod= e (Node);

       } while (!IsDevicePathEnd (Node));

 

-      Status =3D CreateSerialDevice (Controller, = Uart, ParentDevicePath, FALSE, Acpi->UID, ParentIo, NULL, NULL);

+      Status =3D CreateSerialDevice (This, Contro= ller, Uart, ParentDevicePath, FALSE, Acpi->UID, ParentIo, NULL, NULL);
       DEBUG ((DEBUG_INFO, "PciSioSerial= : Create SIO child serial device - %r\n", Status));

     }

   } else {

@@ -1073,7 +1102,7 @@ SerialControllerDriverStart (
             Pc= iSerialParameter =3D PcdGetPtr (PcdPciSerialParameters);

           }

 

-          Status =3D CreateSe= rialDevice (Controller, Uart, ParentDevicePath, FALSE, 0, ParentIo, PciSeri= alParameter, PciDeviceInfo);

+          Status =3D CreateSe= rialDevice (This, Controller, Uart, ParentDevicePath, FALSE, 0, ParentIo, P= ciSerialParameter, PciDeviceInfo);

           DEBUG ((DEBUG_= INFO, "PciSioSerial: Create PCI child serial device (single) - %r\n&qu= ot;, Status));

           if (!EFI_ERROR= (Status)) {

             Pc= iDeviceInfo->ChildCount++;

@@ -1094,7 +1123,7 @@ SerialControllerDriverStart (
            &nb= sp;  //

            &nb= sp;  // Create controller node when PCI serial device contains multipl= e UARTs

            &nb= sp;  //

-            &n= bsp; Status =3D CreateSerialDevice (Controller, Uart, ParentDevicePath, TRU= E, PciSerialCount, ParentIo, PciSerialParameter, PciDeviceInfo);

+            &n= bsp; Status =3D CreateSerialDevice (This, Controller, Uart, ParentDevicePat= h, TRUE, PciSerialCount, ParentIo, PciSerialParameter, PciDeviceInfo);

            &nb= sp;  PciSerialCount++;

            &nb= sp;  DEBUG ((DEBUG_INFO, "PciSioSerial: Create PCI child serial d= evice (multiple) - %r\n", Status));

            &nb= sp;  if (!EFI_ERROR (Status)) {

@@ -1147,6 +1176,91 @@ SerialControllerDriverStart (
   return Status;

 }

 

+/**

+  Start to manage the controller passed in

+

+  @param  This        &n= bsp;        A pointer to the EFI_DRIVER_= BINDING_PROTOCOL instance.

+  @param  Controller       &n= bsp;   The handle of the controller to test.

+  @param  RemainingDevicePath  A pointer to the remaining p= ortion of a device path.

+

+  @return EFI_SUCCESS   Driver is started successfully

+**/

+EFI_STATUS

+EFIAPI

+SerialControllerDriverStart (

+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,

+  IN EFI_HANDLE         =           Controller,

+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevic= ePath

+  )

+{

+  return SerialDriverStart (This, Controller, RemainingDevicePath);
+}

+

+/**

+  Initialize Serial driver in DXE phase

+

+  @param ImageHandle  Handle for the image of this driver.

+  @param SystemTable  Pointer to the EFI System Table.

+

+  @return EFI_SUCCESS   Driver is started successfully

+**/

+EFI_STATUS

+EFIAPI

+DxePciSioSerialDriverEntrypoint (

+  IN EFI_HANDLE        ImageHandle= ,

+  IN EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS         &nb= sp;         Status;

+  EFI_DEVICE_PATH_PROTOCOL     *EfiDevicePath;
+  EFI_HANDLE         &nb= sp;         *HandleBuffer;

+  UINTN          &n= bsp;            = ; NumberOfHandles;

+  EFI_DRIVER_BINDING_PROTOCOL  *SerialControllerDriver;

+  UINTN          &n= bsp;            = ; Index;

+

+  EfiDevicePath =3D NULL;

+  HandleBuffer  =3D NULL;

+  //

+  // Initialize the serial controller instance

+  //

+  SerialControllerDriver =3D AllocateCopyPool (sizeof (EFI_DRIVER_BIN= DING_PROTOCOL), &gSerialControllerDriver);

+  ASSERT (SerialControllerDriver !=3D NULL);

+

+  SerialControllerDriver->DriverBindingHandle =3D ImageHandle;

+  //

+  // Initialize UART default setting in gSerialDevTemplate

+  //

+  gSerialDevTemplate.SerialMode.BaudRate     =3D = PcdGet64 (PcdUartDefaultBaudRate);

+  gSerialDevTemplate.SerialMode.DataBits     =3D = PcdGet8 (PcdUartDefaultDataBits);

+  gSerialDevTemplate.SerialMode.Parity     &= nbsp; =3D PcdGet8 (PcdUartDefaultParity);

+  gSerialDevTemplate.SerialMode.StopBits     =3D = PcdGet8 (PcdUartDefaultStopBits);

+  gSerialDevTemplate.UartDevicePath.BaudRate =3D PcdGet64 (PcdUartDef= aultBaudRate);

+  gSerialDevTemplate.UartDevicePath.DataBits =3D PcdGet8 (PcdUartDefa= ultDataBits);

+  gSerialDevTemplate.UartDevicePath.Parity   =3D PcdGet8 (P= cdUartDefaultParity);

+  gSerialDevTemplate.UartDevicePath.StopBits =3D PcdGet8 (PcdUartDefa= ultStopBits);

+  gSerialDevTemplate.ClockRate      &nb= sp;        =3D PcdGet32 (PcdSerialClockR= ate);

+

+  // Check all handles for compatible Device Path and appropriate I/O= Protocol

+  Status =3D gBS->LocateHandleBuffer (ByProtocol, &gEfiDeviceP= athProtocolGuid, NULL, &NumberOfHandles, &HandleBuffer);

+  if (EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  for (Index =3D 0; Index < NumberOfHandles; Index++) {

+    EfiDevicePath =3D DevicePathFromHandle (HandleBuffer[In= dex]);

+    Status        =3D Se= rialDriverSupported (SerialControllerDriver, HandleBuffer[Index], EfiDevice= Path);

+    DEBUG ((DEBUG_INFO, "SerialDriverSupported status:= %r\n", Status));

+    if (EFI_ERROR (Status)) {

+      continue;

+    }

+

+    Status =3D SerialDriverStart (SerialControllerDriver, H= andleBuffer[Index], EfiDevicePath);

+    DEBUG ((DEBUG_INFO, "SerialDriverStart status: %r\= n", Status));

+  }

+

+  return EFI_SUCCESS;

+}

+

 /**

   Disconnect this driver with the controller, uninstall related = protocol instance

 

diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c b/MdeModulePkg= /Bus/Pci/PciSioSerialDxe/SerialIo.c
index 8a85a6c3b8..c052d43b84 100644
--- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c
@@ -1367,7 +1367,13 @@ SerialReadRegister (
   EFI_STATUS  Status;

 

   if (SerialDev->PciDeviceInfo =3D=3D NULL) {

-    return IoRead8 ((UINTN)SerialDev->BaseAddress + Offs= et * SerialDev->RegisterStride);

+    if (SerialDev->MmioAccess)

+    {

+      return MmioRead8((UINTN)SerialDev->BaseA= ddress + Offset * SerialDev->RegisterStride);

+    }

+    else {

+      return IoRead8 ((UINTN)SerialDev->BaseAd= dress + Offset * SerialDev->RegisterStride);

+    }

   } else {

     if (SerialDev->MmioAccess) {

       Status =3D SerialDev->PciDeviceInfo= ->PciIo->Mem.Read (

@@ -1411,7 +1417,13 @@ SerialWriteRegister (
   EFI_STATUS  Status;

 

   if (SerialDev->PciDeviceInfo =3D=3D NULL) {

-    IoWrite8 ((UINTN)SerialDev->BaseAddress + Offset * S= erialDev->RegisterStride, Data);

+    if (SerialDev->MmioAccess)

+    {

+      MmioWrite8((UINTN)SerialDev->BaseAddress= + Offset * SerialDev->RegisterStride, Data);

+    }

+    else {

+      IoWrite8 ((UINTN)SerialDev->BaseAddress = + Offset * SerialDev->RegisterStride, Data);

+    }

   } else {

     if (SerialDev->MmioAccess) {

       Status =3D SerialDev->PciDeviceInfo= ->PciIo->Mem.Write (

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc<= br> index c0f1df3bfb..b209fe2696 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -240,6 +240,7 @@
 

   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf

   MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf

+  MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxeEarly.inf

   MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf

   MdeModulePkg/Bus/Pci/IncompatiblePciDeviceSupportDxe/Incompati= blePciDeviceSupportDxe.inf

   MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

--
2.34.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#118657) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_MN6PR11MB8244FCAD8137FF36EEC5C53A8CE52MN6PR11MB8244namp_--