From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.1201.1573087777486242069 for ; Wed, 06 Nov 2019 16:49:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=NQOWnVvg; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: michael.a.kubacki@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2019 16:49:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,276,1569308400"; d="scan'208";a="214433155" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga002.jf.intel.com with ESMTP; 06 Nov 2019 16:49:36 -0800 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 6 Nov 2019 16:49:36 -0800 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX153.amr.corp.intel.com (10.22.226.247) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 6 Nov 2019 16:49:35 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.51) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 6 Nov 2019 16:49:35 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VKkM7CeUT9eQJ+gC6SQyvOAiIdsdbAcK/WS//fN0R28ScwAISucdSlzcB7iRK+3cNxOaT3vhRSPQhtWmZeM+RdIO1EPF8LF1UAPw2nhfMWs6rY+1D0/Lmj7gber5PMfIYTfQRn2FgS0IpojeD6eaDtPjch/P4SYRA1f+pyhzagbfJSzQd86anSj0kDh+una3xw0DLeOuNlCsTzeEBFk4ENjg2eMiz4WXkUFrwSfe1Y7J+MBljkMCVoT5K3bc5vamJyLKXC7Q5OloIHV92JZk8Z4HdTbGXU0K7LL8gI4V+EUrdsawAtZrl29PyYP4DuMdd7fNYyXCIMBjXv3kkaq0AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/BMn26DdA65jfp8njTNCb/IDbRf7xhsqt70joLH1NNw=; b=hPGJyYnJS5byfzKT5r1ruJCe9TpUqoOI5uRnNVVV72cws0C9NF4B7ShI90A9Y/5dEBpoBmitVQeKpjMpvBjBAbZo7IOTbL6YSrF5xPT7dzdz2HukGz8eNmleNtcSuGdCF8ofBPh+1G0V00c3UBnZvnAIOeApAnItSGnVfATLagOJqXsULwfPYtvqZBd2HPIf5glgQHpue12mK6JFBC/5M2ZiBvqtew3EmM5BwJkRoIIHTabDn6JRA4JRi8+l1xB14lN9zkoEXjTcPEIQd2GEukddna2PFEBreOXWsijkAPtT9d/gQ24HsVsfnYcwvZSMSEkXO4MWKZvcQelbLJJITg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/BMn26DdA65jfp8njTNCb/IDbRf7xhsqt70joLH1NNw=; b=NQOWnVvg6FUvfagyXuQRUCOWL4Qpj0B1wVJG+Nm6/73C9AQ+Wxsy1qAZn5gAywvLYYnHwNXDOc6DN/XIH2SMFQ7dgHsGHWzfIaES9C4NP1XroN0r16W0Otj8c0xX3fAxi8b2rJ1xBoH4J/J63R5LX3ZvMqV+F4DDfmupTGNKj+I= Received: from BY5PR11MB4484.namprd11.prod.outlook.com (52.132.254.155) by BY5PR11MB3976.namprd11.prod.outlook.com (10.255.160.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Thu, 7 Nov 2019 00:49:33 +0000 Received: from BY5PR11MB4484.namprd11.prod.outlook.com ([fe80::c1ef:6e0b:90c8:55e2]) by BY5PR11MB4484.namprd11.prod.outlook.com ([fe80::c1ef:6e0b:90c8:55e2%7]) with mapi id 15.20.2430.020; Thu, 7 Nov 2019 00:49:33 +0000 From: "Kubacki, Michael A" To: "Agyeman, Prince" , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "Desimone, Nathaniel L" Subject: Re: [edk2-platforms] [Patch v2 3/9] BoardModulePkg: Add Super I/O driver Thread-Topic: [edk2-platforms] [Patch v2 3/9] BoardModulePkg: Add Super I/O driver Thread-Index: AQHVlEE6CHzlvwx3bk2Yxx3TTGDHHKd+21gA Date: Thu, 7 Nov 2019 00:49:32 +0000 Message-ID: References: <20191106012603.4724-1-prince.agyeman@intel.com> <20191106012603.4724-4-prince.agyeman@intel.com> In-Reply-To: <20191106012603.4724-4-prince.agyeman@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzMxNGQxOGYtYTBlNS00N2QzLTg0ZTUtZGQ1NDYwZjcxNjVmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRjB6R0gyTStoRW9UUXl2dUlFRngyZytPZWVmVzh2TEdPQ2cxRk11dUhDZWFPOWUxTW9VSTIxdmpwZzQyTHhidiJ9 dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=michael.a.kubacki@intel.com; x-originating-ip: [134.134.136.217] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a0a99fd8-f49d-45df-571e-08d7631c5ad0 x-ms-traffictypediagnostic: BY5PR11MB3976: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0214EB3F68 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(376002)(396003)(346002)(366004)(13464003)(199004)(189003)(486006)(11346002)(6436002)(305945005)(66066001)(55016002)(6246003)(2501003)(14454004)(2906002)(19627235002)(4326008)(86362001)(6116002)(14444005)(3846002)(33656002)(110136005)(7736002)(71190400001)(478600001)(25786009)(99286004)(446003)(8676002)(107886003)(52536014)(81166006)(81156014)(8936002)(54906003)(9686003)(316002)(256004)(66946007)(53546011)(66446008)(6506007)(64756008)(26005)(66556008)(7696005)(74316002)(76176011)(102836004)(476003)(186003)(71200400001)(66476007)(76116006)(229853002)(30864003)(5660300002)(579004)(569006);DIR:OUT;SFP:1102;SCL:1;SRVR:BY5PR11MB3976;H:BY5PR11MB4484.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 45r+YBCx3ytECJ9O6bzgCJl788raADCQ4Jf23Yc0BpkS0oEOOmIc741NVQBIlnlqlhiseNIkA4m9jMi/oPE4unZ5HzfBzre8PvXGUnm/2fhOtreWGE5XWuhIfAGXG1u2NQfZraR+ehA3ME6eaYwZDLFKnt4Kx6aoQJCRCSEyKX4jURsXxxtDdTulkN+N4CzsQaCufVG25uWnJMKH+xYQ98nLY/AKqAiQQQp8qmEuVHoCG6Hb9kr7JzSzUEz+PK6M3Cuc73dJMNaybPIsgpFA/NMz9GJp4SsYRSC+OkR05E/730/EUzF4DqeDfX2QNoEtmPD67C7YBEysrVQYPa0QDp45zgUtOsCHaFOq7fuKsWSlEp7MTWevFBT0XbFBAguGE4Xu/QPBT/XUGm7puvqN7SB9sJWpkP0avHWmMg9jbDeba6aeq/DvEZutFBI18Js+ MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: a0a99fd8-f49d-45df-571e-08d7631c5ad0 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2019 00:49:32.8532 (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: RYn7v5tIE4YMSZ44IsszuG3GcZ4TgqArYWJtXtSC9UnHEXSFr4+i5O3/ZJ4FOEsvHkgsPJXtJjNlV2ylSxCGzZfCdyz21oBahuRzKEEA4U0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB3976 Return-Path: michael.a.kubacki@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Michael Kubacki > -----Original Message----- > From: Agyeman, Prince > Sent: Tuesday, November 5, 2019 5:26 PM > To: devel@edk2.groups.io > Cc: Kubacki, Michael A ; Chiu, Chasel > ; Desimone, Nathaniel L > > Subject: [edk2-platforms] [Patch v2 3/9] BoardModulePkg: Add Super I/O > driver >=20 > Added a generic Super I/O driver that produces the > Sio protocol. This driver was moved from the > SimicsOpenBoardPkg. >=20 > Cc: Michael Kubacki > Cc: Chasel Chiu > Cc: Nate DeSimone >=20 > Signed-off-by: Prince Agyeman > --- > .../Intel/BoardModulePkg/BoardModulePkg.dsc | 5 + > .../LegacySioDxe/ComponentName.c | 173 +++++ > .../LegacySioDxe/ComponentName.h | 87 +++ > .../LegacySioDxe/LegacySioDxe.inf | 51 ++ > .../BoardModulePkg/LegacySioDxe/Register.h | 15 + > .../BoardModulePkg/LegacySioDxe/SioChip.c | 270 ++++++++ > .../BoardModulePkg/LegacySioDxe/SioChip.h | 185 ++++++ > .../BoardModulePkg/LegacySioDxe/SioDriver.c | 600 > ++++++++++++++++++ > .../BoardModulePkg/LegacySioDxe/SioDriver.h | 133 ++++ > .../BoardModulePkg/LegacySioDxe/SioService.c | 249 ++++++++ > .../BoardModulePkg/LegacySioDxe/SioService.h | 143 +++++ > 11 files changed, 1911 insertions(+) > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c > create mode 100644 > Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h >=20 > diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc > b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc > index 5ec68ceebf..5af26eb97e 100644 > --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc > +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc > @@ -32,6 +32,10 @@ > PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf > PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf > + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf > + > UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry > Point.inf > + > UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib > /UefiRuntimeServicesTableLib.inf >=20 > [LibraryClasses.common.PEIM] >=20 > FirmwareBootMediaLib|IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/P > eiFirmwareBootMediaLib.inf > @@ -76,6 +80,7 @@ >=20 > [Components] > BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf > + BoardModulePkg/LegacySioDxe/LegacySioDxe.inf > BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf >=20 > BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessL > ibNull.inf >=20 > diff --git > a/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c > b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c > new file mode 100644 > index 0000000000..c9b3df0473 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c > @@ -0,0 +1,173 @@ > +/** @file > + Component Name functions implementation for the Super I/O DXE driver. > + > + Copyright (c) 2013 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include "SioDriver.h" > + > +/// > +/// Component Name Protocol instance > +/// > +GLOBAL_REMOVE_IF_UNREFERENCED > EFI_COMPONENT_NAME_PROTOCOL mSioComponentName =3D { > + SioComponentNameGetDriverName, > + SioComponentNameGetControllerName, > + "eng" > +}; > + > +/// > +/// Component Name 2 Protocol instance > +/// > +GLOBAL_REMOVE_IF_UNREFERENCED > EFI_COMPONENT_NAME2_PROTOCOL mSioComponentName2 =3D { > + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) > SioComponentNameGetDriverName, > + > (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)SioComponentName > GetControllerName, > + "en" > +}; > + > +/// > +/// Table of driver names > +/// > +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE > mSioDriverNameTable[] =3D { > + { > + "eng;en", > + L"Super I/O Driver" > + }, > + { > + NULL, > + NULL > + } > +}; > + > +/// > +/// Table of Controller names > +/// > +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE > mSioControllerNameTable[] =3D { > + { > + "eng;en", > + L"Super I/O Controller" > + }, > + { > + NULL, > + NULL > + } > +}; > + > +/** > + Retrieves a Unicode string that is the user-readable name of the EFI D= river. > + > + @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL > instance. > + @param Language A pointer to a three-character ISO 639-2 language > identifier. > + This is the language of the driver name that that t= he caller > + is requesting, and it must match one of the languag= es specified > + in SupportedLanguages. The number of languages sup= ported by > a > + driver is up to the driver writer. > + @param DriverName A pointer to the Unicode string to return. This > Unicode string > + is the name of the driver specified by This in the = language > + specified by Language. > + > + @retval EFI_SUCCESS The Unicode string for the Driver specif= ied by > This > + and the language specified by Language w= as returned > + in DriverName. > + @retval EFI_INVALID_PARAMETER Language is NULL. > + @retval EFI_INVALID_PARAMETER DriverName is NULL. > + @retval EFI_UNSUPPORTED The driver specified by This does not > support the > + language specified by Language. > + > +**/ > +EFI_STATUS > +EFIAPI > +SioComponentNameGetDriverName ( > + IN EFI_COMPONENT_NAME_PROTOCOL *This, > + IN CHAR8 *Language, > + OUT CHAR16 **DriverName > + ) > +{ > + return LookupUnicodeString2 ( > + Language, > + This->SupportedLanguages, > + mSioDriverNameTable, > + DriverName, > + (BOOLEAN)(This =3D=3D &mSioComponentName) > + ); > +} > + > +/** > + Retrieves a Unicode string that is the user readable name of the contr= oller > + that is being managed by an EFI Driver. > + > + @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL > instance. > + @param ControllerHandle The handle of a controller that the driver > specified by > + This is managing. This handle specifies the = controller > + whose name is to be returned. > + @param ChildHandle The handle of the child controller to retriev= e the > name > + of. This is an optional parameter that may b= e NULL. It > + will be NULL for device drivers. It will als= o be NULL > + for a bus drivers that wish to retrieve the n= ame of the > + bus controller. It will not be NULL for a bu= s driver > + that wishes to retrieve the name of a child c= ontroller. > + @param Language A pointer to a three character ISO 639-2 lang= uage > + identifier. This is the language of the cont= roller name > + that the caller is requesting, and it must ma= tch one > + of the languages specified in SupportedLangua= ges. The > + number of languages supported by a driver is = up to the > + driver writer. > + @param ControllerName A pointer to the Unicode string to return. T= his > Unicode > + string is the name of the controller specifie= d by > + ControllerHandle and ChildHandle in the langu= age specified > + by Language, from the point of view of the dr= iver specified > + by This. > + > + @retval EFI_SUCCESS The Unicode string for the user-readable= name > in the > + language specified by Language for the d= river > + specified by This was returned in Driver= Name. > + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. > + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a > valid EFI_HANDLE. > + @retval EFI_INVALID_PARAMETER Language is NULL. > + @retval EFI_INVALID_PARAMETER ControllerName is NULL. > + @retval EFI_UNSUPPORTED The driver specified by This is not curr= ently > managing > + the controller specified by ControllerHa= ndle and > + ChildHandle. > + @retval EFI_UNSUPPORTED The driver specified by This does not > support the > + language specified by Language. > + > +**/ > +EFI_STATUS > +EFIAPI > +SioComponentNameGetControllerName ( > + IN EFI_COMPONENT_NAME_PROTOCOL *This, > + IN EFI_HANDLE ControllerHandle, > + IN EFI_HANDLE ChildHandle OPTIONAL, > + IN CHAR8 *Language, > + OUT CHAR16 **ControllerName > + ) > +{ > + EFI_STATUS Status; > + > + // > + // Make sure this driver is currently managing ControllHandle > + // > + Status =3D EfiTestManagedDevice ( > + ControllerHandle, > + mSioDriver.DriverBindingHandle, > + &gEfiPciIoProtocolGuid > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + // > + // ChildHandle must be NULL for a Device Driver > + // > + if (ChildHandle !=3D NULL) { > + return EFI_UNSUPPORTED; > + } > + > + return LookupUnicodeString2 ( > + Language, > + This->SupportedLanguages, > + mSioControllerNameTable, > + ControllerName, > + (BOOLEAN)(This =3D=3D &mSioComponentName) > + ); > +} > diff --git > a/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h > b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h > new file mode 100644 > index 0000000000..85ca348701 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h > @@ -0,0 +1,87 @@ > +/** @file > + Component Name functions declaration for Super I/O DXE driver. > + > + Copyright (c) 2013 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +/** > + Retrieves a Unicode string that is the user-readable name of the EFI D= river. > + > + @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL > instance. > + @param Language A pointer to a three-character ISO 639-2 language > identifier. > + This is the language of the driver name that that t= he caller > + is requesting, and it must match one of the languag= es specified > + in SupportedLanguages. The number of languages sup= ported by > a > + driver is up to the driver writer. > + @param DriverName A pointer to the Unicode string to return. This > Unicode string > + is the name of the driver specified by This in the = language > + specified by Language. > + > + @retval EFI_SUCCESS The Unicode string for the Driver specif= ied by > This > + and the language specified by Language w= as returned > + in DriverName. > + @retval EFI_INVALID_PARAMETER Language is NULL. > + @retval EFI_INVALID_PARAMETER DriverName is NULL. > + @retval EFI_UNSUPPORTED The driver specified by This does not > support the > + language specified by Language. > + > +**/ > +EFI_STATUS > +EFIAPI > +SioComponentNameGetDriverName ( > + IN EFI_COMPONENT_NAME_PROTOCOL *This, > + IN CHAR8 *Language, > + OUT CHAR16 **DriverName > + ); > + > +/** > + Retrieves a Unicode string that is the user readable name of the contr= oller > + that is being managed by an EFI Driver. > + > + @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL > instance. > + @param ControllerHandle The handle of a controller that the driver > specified by > + This is managing. This handle specifies the = controller > + whose name is to be returned. > + @param ChildHandle The handle of the child controller to retriev= e the > name > + of. This is an optional parameter that may b= e NULL. It > + will be NULL for device drivers. It will als= o be NULL > + for a bus drivers that wish to retrieve the n= ame of the > + bus controller. It will not be NULL for a bu= s driver > + that wishes to retrieve the name of a child c= ontroller. > + @param Language A pointer to a three character ISO 639-2 lang= uage > + identifier. This is the language of the cont= roller name > + that the caller is requesting, and it must ma= tch one > + of the languages specified in SupportedLangua= ges. The > + number of languages supported by a driver is = up to the > + driver writer. > + @param ControllerName A pointer to the Unicode string to return. T= his > Unicode > + string is the name of the controller specifie= d by > + ControllerHandle and ChildHandle in the langu= age specified > + by Language, from the point of view of the dr= iver specified > + by This. > + > + @retval EFI_SUCCESS The Unicode string for the user-readable= name > in the > + language specified by Language for the d= river > + specified by This was returned in Driver= Name. > + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. > + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a > valid EFI_HANDLE. > + @retval EFI_INVALID_PARAMETER Language is NULL. > + @retval EFI_INVALID_PARAMETER ControllerName is NULL. > + @retval EFI_UNSUPPORTED The driver specified by This is not curr= ently > managing > + the controller specified by ControllerHa= ndle and > + ChildHandle. > + @retval EFI_UNSUPPORTED The driver specified by This does not > support the > + language specified by Language. > + > +**/ > +EFI_STATUS > +EFIAPI > +SioComponentNameGetControllerName ( > + IN EFI_COMPONENT_NAME_PROTOCOL *This, > + IN EFI_HANDLE ControllerHandle, > + IN EFI_HANDLE ChildHandle OPTIONAL, > + IN CHAR8 *Language, > + OUT CHAR16 **ControllerName > + ); > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf > b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf > new file mode 100644 > index 0000000000..f01f63e69e > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf > @@ -0,0 +1,51 @@ > +## @file > +# Module information that produces the > +# EFI_SIO_PROTOCOL. > +# > +# Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010017 > + BASE_NAME =3D LegacySioDxe > + FILE_GUID =3D 7807E404-8281-4FF1-8457-0B54BABE263= F > + VERSION_STRING =3D 1.0 > + MODULE_TYPE =3D UEFI_DRIVER > + ENTRY_POINT =3D SioDriverEntryPoint > +# > +# The following information is for reference only and not required by th= e > build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC > +# > + > +[LibraryClasses] > + BaseLib > + UefiLib > + DebugLib > + MemoryAllocationLib > + PcdLib > + DevicePathLib > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[Sources] > + SioChip.c > + SioChip.h > + SioService.c > + SioService.h > + SioDriver.c > + SioDriver.h > + ComponentName.c > + > +[Protocols] > + gEfiPciIoProtocolGuid ## CONSUMES > + gEfiDevicePathProtocolGuid ## PRODUCES > + gEfiSioProtocolGuid ## PRODUCES > + > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h > b/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h > new file mode 100644 > index 0000000000..f61f713cf2 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h > @@ -0,0 +1,15 @@ > +/** @file > + Super I/O register definitions > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef _REGISTER_H_ > +#define _REGISTER_H_ > + > +#define EC_COMMAND_PORT 0x66 > +#define EC_DATA_PORT 0x62 > + > +#endif > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c > new file mode 100644 > index 0000000000..81efe3c38b > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c > @@ -0,0 +1,270 @@ > +/** @file > + Super I/O specific implementation. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include "SioDriver.h" > + > +// > +// System configuration (setup) information > +// > +// SYSTEM_CONFIGURATION mSystemConfiguration; > + > +// > +// COM 1 UART Controller > +// > +ACPI_SIO_RESOURCES_IO_IRQ mCom1Resources =3D { > + { > + { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR }, > + 0x3f8, > + 8 > + }, > + { > + { ACPI_IRQ_NOFLAG_DESCRIPTOR }, > + BIT4 // IRQ4 > + }, > + { > + ACPI_END_TAG_DESCRIPTOR, > + 0 > + } > +}; > + > +// > +// PS/2 Keyboard Controller > +// > +ACPI_SIO_RESOURCES_IO_IRQ mKeyboardResources =3D { > + { > + { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR }, > + 0x60, > + 5 > + }, > + { > + { ACPI_IRQ_NOFLAG_DESCRIPTOR }, > + BIT1 > + }, > + { > + ACPI_END_TAG_DESCRIPTOR, > + 0 > + } > +}; > + > +// > +// PS/2 Mouse Controller > +// > +ACPI_SIO_RESOURCES_IO_IRQ mMouseResources =3D { > + { > + { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR }, > + 0x60, > + 5 > + }, > + { > + { ACPI_IRQ_NOFLAG_DESCRIPTOR }, > + BIT12 > + }, > + { > + ACPI_END_TAG_DESCRIPTOR, > + 0 > + } > +}; > + > +// > +// Table of SIO Controllers > +// > +DEVICE_INFO mDeviceInfo[] =3D { > + { > + { > + EISA_PNP_ID(0x501), > + 0 > + }, > + 0, > + RESOURCE_IO | RESOURCE_IRQ, > + { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }, > + { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources } > + }, // COM 1 UART Controller > + { > + { > + EISA_PNP_ID(0x303), > + 0 > + }, > + 0, > + 0, // Cannot change resource > + { (ACPI_SMALL_RESOURCE_HEADER *) &mKeyboardResources }, > + { (ACPI_SMALL_RESOURCE_HEADER *) &mKeyboardResources } > + }, // PS/2 Keyboard Controller > + { > + { > + EISA_PNP_ID(0xF03), > + 0 > + }, > + 0, > + 0, // Cannot change resource > + { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources }, > + { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources } > + } // PS/2 Mouse Controller > +}; > + > + > +/** > + Return the supported devices. > + > + @param[out] Devices Pointer to pointer of EFI_SIO_ACPI_DEVICE_= ID. > + Caller is responsible to free the buffer. > + @param[out] Count Pointer to UINTN holding the device count. > +**/ > +VOID > +DeviceGetList ( > + OUT EFI_SIO_ACPI_DEVICE_ID **Devices, > + OUT UINTN *Count > + ) > +{ > + EFI_SIO_ACPI_DEVICE_ID *LocalDevices; > + UINTN LocalCount; > + UINTN DeviceCount; > + UINTN Index; > + > + // > + // Allocate enough memory for simplicity > + // > + DeviceCount =3D sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]); > + LocalDevices =3D AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) * > DeviceCount); > + ASSERT (LocalDevices !=3D NULL); > + if (LocalDevices =3D=3D NULL) { > + return; > + } > + LocalCount =3D 0; > + > + for (Index =3D 0; Index < DeviceCount; Index++) { > + CopyMem (&LocalDevices[LocalCount], &mDeviceInfo[Index].Device, > sizeof (EFI_SIO_ACPI_DEVICE_ID)); > + LocalCount++; > + } > + > + *Devices =3D LocalDevices; > + *Count =3D LocalCount; > +} > + > + > +/** > + Super I/O controller initialization. > + > + @retval EFI_SUCCESS The super I/O controller is found and in= itialized. > + @retval EFI_UNSUPPORTED The super I/O controller is not found. > +**/ > +EFI_STATUS > +SioInit ( > + VOID > + ) > +{ > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Find the DEVICE_INFO for specified Device. > + > + @param[in] Device Pointer to the EFI_SIO_ACPI_DEVICE_ID. > + > + @retval DEVICE_INFO* Pointer to the DEVICE_INFO. > +**/ > +DEVICE_INFO * > +DeviceSearch ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device > + ) > +{ > + UINTN Index; > + > + for (Index =3D 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0= ]); > Index++) { > + if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device)= ) > =3D=3D 0) { > + return &mDeviceInfo[Index]; > + } > + } > + > + ASSERT (FALSE); > + return NULL; > +} > + > + > +/** > + Program the SIO chip to enable the specified device using the default > resource. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > +**/ > +VOID > +DeviceEnable ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device > + ) > +{ > +} > + > + > +/** > + Get the ACPI resources for specified device. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_SUCCESS The resources are returned successfully. > +**/ > +EFI_STATUS > +DeviceGetResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + OUT ACPI_RESOURCE_HEADER_PTR *Resources > + ) > +{ > + DEVICE_INFO *DeviceInfo; > + > + DeviceInfo =3D DeviceSearch (Device); > + > + *Resources =3D DeviceInfo->Resources; > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Set the ACPI resources for specified device. > + > + The SIO chip is programmed to use the new resources and the > + resources setting are saved. The function assumes the resources > + are valid. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[in] Resources ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_UNSUPPORTED > +**/ > +EFI_STATUS > +DeviceSetResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + IN ACPI_RESOURCE_HEADER_PTR Resources > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > + > +/** > + Get the possible ACPI resources for specified device. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_SUCCESS The resources are returned successfully. > +**/ > +EFI_STATUS > +DevicePossibleResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + OUT ACPI_RESOURCE_HEADER_PTR *Resources > + ) > +{ > + DEVICE_INFO *DeviceInfo; > + > + DeviceInfo =3D DeviceSearch (Device); > + > + *Resources =3D DeviceInfo->PossibleResources; > + > + return EFI_SUCCESS; > +} > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h > new file mode 100644 > index 0000000000..9322365923 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h > @@ -0,0 +1,185 @@ > +/** @file > + Super I/O specific header. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef _SIO_H_ > +#define _SIO_H_ > + > + > +#include "Register.h" > + > +typedef > +UINT8 > +(EFIAPI *LOCAL_IO_WRITE8) ( > + IN UINTN Port, > + IN UINT8 Value > + ); > + > +#define RESOURCE_IO BIT0 > +#define RESOURCE_IRQ BIT1 > +#define RESOURCE_DMA BIT2 > +#define RESOURCE_MEM BIT3 > + > +#pragma pack(1) > + > +typedef struct { > + EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR Io; > + EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR Irq; > + EFI_ACPI_END_TAG_DESCRIPTOR End; > +} ACPI_SIO_RESOURCES_IO_IRQ; > +#pragma pack() > + > +typedef struct { > + UINT32 HID; > + UINT32 UID; > +} EFI_SIO_ACPI_DEVICE_ID; > + > +typedef struct { > + EFI_SIO_ACPI_DEVICE_ID Device; > + UINT8 DeviceId; > + UINT8 ResourceMask; > + ACPI_RESOURCE_HEADER_PTR Resources; > + ACPI_RESOURCE_HEADER_PTR PossibleResources; > +} DEVICE_INFO; > + > +/** > + Return the supported devices. > + > + @param[out] Devices Pointer to pointer of EFI_SIO_ACPI_DEVICE_= ID. > + Caller is responsible to free the buffer. > + @param[out] Count Pointer to UINTN holding the device count. > +**/ > +VOID > +DeviceGetList ( > + OUT EFI_SIO_ACPI_DEVICE_ID **Devices, > + OUT UINTN *Count > + ); > + > + > +/** > + Program the SIO chip to enable the specified device using the default > resource. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > +**/ > +VOID > +DeviceEnable ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device > + ); > + > + > +/** > + Get the possible ACPI resources for specified device. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_SUCCESS The resources are returned successfully. > +**/ > +EFI_STATUS > +DevicePossibleResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + OUT ACPI_RESOURCE_HEADER_PTR *Resources > + ); > + > + > +/** > + Set the ACPI resources for specified device. > + > + The SIO chip is programmed to use the new resources and the > + resources setting are saved. The function assumes the resources > + are valid. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[in] Resources ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_SUCCESS The resources are set successfully. > +**/ > +EFI_STATUS > +DeviceSetResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + IN ACPI_RESOURCE_HEADER_PTR Resources > + ); > + > + > +/** > + Get the ACPI resources for specified device. > + > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR. > + > + @retval EFI_SUCCESS The resources are returned successfully. > +**/ > +EFI_STATUS > +DeviceGetResources ( > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + OUT ACPI_RESOURCE_HEADER_PTR *Resources > + ); > + > + > +/** > + Program the SIO chip to enter the configure mode. > +**/ > +VOID > +EnterConfigMode ( > + VOID > + ); > + > + > +/** > + Program the SIO chip to exit the configure mode. > +**/ > +VOID > +ExitConfigMode ( > + VOID > + ); > + > + > +/** > + Perform a 8-bit I/O write to SIO register. > + > + @param[in] Index The register index. > + @param[in] Data The value to write to register. > +**/ > +VOID > +WriteRegister ( > + IN UINT8 Index, > + IN UINT8 Data > + ); > + > + > +/** > + Perform a 8-bit I/O read from SIO register. > + > + @param[in] Index The register index. > + > + @retval Value The value written to the register. > +**/ > +UINT8 > +ReadRegister ( > + IN UINT8 Index > + ); > + > +// > +// Prototypes for the sio internal function > +// > +// > +// Internal function > +// > + > + > +/** > + Find Super I/O controller. > + > + @retval EFI_SUCCESS Super I/O controller exists. > + @retval EFI_UNSUPPORTED Super I/O controller does not exist. > +**/ > +EFI_STATUS > +SioInit ( > + VOID > + ); > + > +#endif > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c > new file mode 100644 > index 0000000000..408c6ff301 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c > @@ -0,0 +1,600 @@ > +/** @file > + EFI Driver following Driver Binding Protocol. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include "SioDriver.h" > + > + > +// > +// This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0) > +// > +// > +// Sio Driver Global Variables > +// > +EFI_DRIVER_BINDING_PROTOCOL mSioDriver =3D { > + SioDriverSupported, > + SioDriverStart, > + SioDriverStop, > + 1, > + NULL, > + NULL > +}; > + > +// > +// The list of the created SIO_DEV > +// > +LIST_ENTRY mSioDevPool =3D INITIALIZE_LIST_HEAD_VARIABL= E > (mSioDevPool); > + > +// > +// Template structure to create SIO_DEV > +// > +SIO_DEV mSioDevTemplate =3D { > + SIO_DEV_SIGNATURE, // Signature > + NULL, // PciHandle > + { > + 0x00000000, // HID > + 0x00000000 // UID > + }, > + NULL, // Handle > + { // Sio Instance > + SioRegisterAccess, > + SioGetResources, > + SioSetResources, > + SioPossibleResources, > + SioModify > + }, > + NULL, // DevicePath > + { > + NULL, // ForwardLink > + NULL, // BackLink > + } > +}; > + > +// > +// Template ACPI_HID_DEVICE_PATH structure to create device path > +// > +ACPI_HID_DEVICE_PATH mAcpiNodeTemplate =3D { > + { > + ACPI_DEVICE_PATH, // Type > + ACPI_DP, // SubType > + { > + sizeof (ACPI_HID_DEVICE_PATH), // Length[0] > + 0 // Length[1] > + } > + }, > + 0x00000000, // HID > + 0x00000000 // UID > +}; > + > + > +/** > + The user Entry Point for module Lpc47m17x. The user code starts with t= his > function. > + > + @param[in] ImageHandle The firmware allocated handle for the EFI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval other Some error occurs when executing this entry= point. > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + if (EFI_ERROR (SioInit())) { > + return EFI_UNSUPPORTED; > + } else { > + > + // > + // Install protocols > + // > + return EfiLibInstallDriverBindingComponentName2 ( > + ImageHandle, > + SystemTable, > + &mSioDriver, > + ImageHandle, > + &mSioComponentName, > + &mSioComponentName2 > + ); > + } > +} > + > + > +/** > + Test to see if this driver supports Controller Handle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to test > + @param[in] RemainingDevicePath Optional parameter use to pick a > specific child > + device to start. > + > + @retval EFI_SUCCESS This driver supports this device > + @retval EFI_ALREADY_STARTED This driver is already running on this > device > + @retval other This driver does not support this devi= ce > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverSupported ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath > + ) > +{ > + EFI_STATUS Status; > + EFI_PCI_IO_PROTOCOL *PciIo; > + EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; > + ACPI_HID_DEVICE_PATH *AcpiNode; > + PCI_TYPE00 Pci; > + UINTN Index; > + EFI_SIO_ACPI_DEVICE_ID *Devices; > + UINTN Count; > + UINTN SegmentNumber; > + UINTN BusNumber; > + UINTN DeviceNumber; > + UINTN FunctionNumber; > + > + // > + // If RemainingDevicePath is not NULL, it should verify that the first= device > + // path node in RemainingDevicePath is an ACPI Device path node which = is > a > + // legal Device Path Node for this bus driver's children. > + // > + if (RemainingDevicePath !=3D NULL) { > + if (!IsDevicePathEnd (RemainingDevicePath)) { > + if ((RemainingDevicePath->Type !=3D ACPI_DEVICE_PATH) || > + (((RemainingDevicePath->SubType !=3D ACPI_DP) || > (DevicePathNodeLength (RemainingDevicePath) !=3D sizeof > (ACPI_HID_DEVICE_PATH))) && > + ((RemainingDevicePath->SubType !=3D ACPI_EXTENDED_DP) || > (DevicePathNodeLength (RemainingDevicePath) !=3D sizeof > (ACPI_EXTENDED_HID_DEVICE_PATH)))) > + ) { > + return EFI_UNSUPPORTED; > + } > + > + DeviceGetList (&Devices, &Count); > + if (Devices =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + AcpiNode =3D (ACPI_HID_DEVICE_PATH *) RemainingDevicePath; > + for (Index =3D 0; Index < Count; Index++) { > + if ((AcpiNode->HID =3D=3D Devices[Index].HID) && > + (AcpiNode->UID =3D=3D Devices[Index].UID)) { > + break; > + } > + } > + FreePool (Devices); > + if (Index =3D=3D Count) { > + return EFI_UNSUPPORTED; > + } > + } > + } > + > + // > + // See if the parent device path can be opened BY_DRIVER > + // > + Status =3D gBS->OpenProtocol ( > + Controller, > + &gEfiDevicePathProtocolGuid, > + (VOID **) &ParentDevicePath, > + This->DriverBindingHandle, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status) && (Status !=3D EFI_ALREADY_STARTED)) { > + return Status; > + } > + > + gBS->CloseProtocol ( > + Controller, > + &gEfiDevicePathProtocolGuid, > + This->DriverBindingHandle, > + Controller > + ); > + > + // > + // Get PciIo protocol instance > + // > + Status =3D gBS->OpenProtocol ( > + Controller, > + &gEfiPciIoProtocolGuid, > + (VOID **) &PciIo, > + This->DriverBindingHandle, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + > + if (!EFI_ERROR (Status)) { > + Status =3D PciIo->Pci.Read ( > + PciIo, > + EfiPciIoWidthUint32, > + 0, > + sizeof (Pci) / sizeof (UINT32), > + &Pci > + ); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D EFI_UNSUPPORTED; > + if ((Pci.Hdr.Command & (EFI_PCI_COMMAND_IO_SPACE | > EFI_PCI_COMMAND_MEMORY_SPACE)) > + =3D=3D (EFI_PCI_COMMAND_IO_SPACE | > EFI_PCI_COMMAND_MEMORY_SPACE) > + ) { > + if (Pci.Hdr.ClassCode[2] =3D=3D PCI_CLASS_BRIDGE) { > + // > + // See if this is a standard PCI to ISA Bridge from the Base Cod= e and > Class Code > + // > + if (Pci.Hdr.ClassCode[1] =3D=3D PCI_CLASS_BRIDGE_ISA) { > + Status =3D EFI_SUCCESS; > + } > + > + // > + // See if this is an Intel PCI to ISA Bridge in Positive Decode = Mode > + // > + if ((Pci.Hdr.ClassCode[1] =3D=3D PCI_CLASS_BRIDGE_ISA_PDECODE) &= & > + (Pci.Hdr.VendorId =3D=3D 0x8086)) { > + // > + // See if this is on Function #0 to avoid false positive on > + // PCI_CLASS_BRIDGE_OTHER that has the same value as > + // PCI_CLASS_BRIDGE_ISA_PDECODE > + // > + Status =3D PciIo->GetLocation ( > + PciIo, > + &SegmentNumber, > + &BusNumber, > + &DeviceNumber, > + &FunctionNumber > + ); > + if (!EFI_ERROR (Status) && (FunctionNumber =3D=3D 0)) { > + Status =3D EFI_SUCCESS; > + } else { > + Status =3D EFI_UNSUPPORTED; > + } > + } > + } > + } > + > + gBS->CloseProtocol ( > + Controller, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + Controller > + ); > + } > + if (EFI_ERROR (Status) && (Status !=3D EFI_ALREADY_STARTED)) { > + return Status; > + } > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Destroy the SIO controller handle. > + > + @param[in] ChildHandle The SIO controller handle. > + > + @retval EFI_SUCCESS The SIO controller handle is destroyed > successfully. > +**/ > +EFI_STATUS > +SioDestroyDevice ( > + IN EFI_HANDLE ChildHandle > + ) > +{ > + EFI_STATUS Status; > + SIO_DEV *SioDev; > + EFI_SIO_PROTOCOL *Sio; > + EFI_PCI_IO_PROTOCOL *PciIo; > + > + Status =3D gBS->HandleProtocol ( > + ChildHandle, > + &gEfiSioProtocolGuid, > + (VOID **) &Sio > + ); > + ASSERT_EFI_ERROR (Status); > + > + SioDev =3D SIO_DEV_FROM_THIS (Sio); > + > + Status =3D gBS->CloseProtocol ( > + SioDev->PciHandle, > + &gEfiPciIoProtocolGuid, > + mSioDriver.DriverBindingHandle, > + ChildHandle > + ); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D gBS->UninstallMultipleProtocolInterfaces ( > + ChildHandle, > + &gEfiDevicePathProtocolGuid, > + SioDev->DevicePath, > + &gEfiSioProtocolGuid, > + &SioDev->Sio, > + NULL > + ); > + if (EFI_ERROR (Status)) { > + gBS->OpenProtocol ( > + SioDev->PciHandle, > + &gEfiPciIoProtocolGuid, > + (VOID **) &PciIo, > + mSioDriver.DriverBindingHandle, > + ChildHandle, > + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER > + ); > + return Status; > + } > + > + RemoveEntryList (&SioDev->Link); > + FreePool (SioDev->DevicePath); > + FreePool (SioDev); > + return EFI_SUCCESS; > +} > + > + > +/** > + Create the SIO controller handle. > + > + @param[in] Controller The parent PCI controller handle. > + @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID. > + @param[in] ParentDevicePath The device path of the parent controller. > + @param[out] PciIo The PciIo instance of the parent controll= er. > +**/ > +VOID > +SioCreateDevice ( > + IN EFI_HANDLE Controller, > + IN EFI_SIO_ACPI_DEVICE_ID *Device, > + IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, > + OUT EFI_PCI_IO_PROTOCOL *PciIo > + ) > +{ > + EFI_STATUS Status; > + SIO_DEV *SioDev; > + > + DeviceEnable (Device); > + SioDev =3D AllocateCopyPool (sizeof (SIO_DEV), &mSioDevTemplate); > + ASSERT (SioDev !=3D NULL); > + if (SioDev =3D=3D NULL) { > + return; > + } > + InsertHeadList (&mSioDevPool, &SioDev->Link); > + > + SioDev->PciHandle =3D Controller; > + > + CopyMem (&SioDev->Device, Device, sizeof (*Device)); > + > + mAcpiNodeTemplate.HID =3D Device->HID; > + mAcpiNodeTemplate.UID =3D Device->UID; > + SioDev->DevicePath =3D AppendDevicePathNode (ParentDevicePath, > (EFI_DEVICE_PATH_PROTOCOL *) &mAcpiNodeTemplate); > + ASSERT (SioDev->DevicePath !=3D NULL); > + > + Status =3D gBS->InstallMultipleProtocolInterfaces ( > + &SioDev->Handle, > + &gEfiSioProtocolGuid, &SioDev->Sio, > + &gEfiDevicePathProtocolGuid, SioDev->DevicePath, > + NULL > + ); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D gBS->OpenProtocol ( > + Controller, > + &gEfiPciIoProtocolGuid, > + (VOID **) &PciIo, > + mSioDriver.DriverBindingHandle, > + SioDev->Handle, > + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER > + ); > + ASSERT_EFI_ERROR (Status); > +} > + > + > +/** > + Start this driver on ControllerHandle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to bind driver to > + @param[in] RemainingDevicePath Optional parameter use to pick a > specific child > + device to start. > + > + @retval EFI_SUCCESS This driver is added to ControllerHan= dle > + @retval EFI_ALREADY_STARTED This driver is already running on > ControllerHandle > + @retval other This driver does not support this dev= ice > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverStart ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath > + ) > +{ > + EFI_STATUS Status; > + EFI_PCI_IO_PROTOCOL *PciIo; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; > + EFI_SIO_ACPI_DEVICE_ID *Devices; > + SIO_DEV *SioDev; > + UINTN Count; > + UINTN Index; > + ACPI_HID_DEVICE_PATH *AcpiNode; > + BOOLEAN *HasCreated; > + BOOLEAN *RequestCreate; > + LIST_ENTRY *Node; > + > + HasCreated =3D NULL; > + RequestCreate =3D NULL; > + // > + // Get the ISA bridge's Device Path > + // > + Status =3D gBS->OpenProtocol ( > + Controller, > + &gEfiDevicePathProtocolGuid, > + (VOID **) &ParentDevicePath, > + This->DriverBindingHandle, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status) && Status !=3D EFI_ALREADY_STARTED) { > + return Status; > + } > + > + // > + // Get Pci IO > + // > + Status =3D gBS->OpenProtocol ( > + Controller, > + &gEfiPciIoProtocolGuid, > + (VOID **) &PciIo, > + This->DriverBindingHandle, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + > + if (EFI_ERROR (Status) && Status !=3D EFI_ALREADY_STARTED) { > + gBS->CloseProtocol ( > + Controller, > + &gEfiDevicePathProtocolGuid, > + This->DriverBindingHandle, > + Controller > + ); > + return Status; > + } > + > + if ((RemainingDevicePath !=3D NULL) && IsDevicePathEnd > (RemainingDevicePath)) { > + return EFI_SUCCESS; > + } > + > + DeviceGetList (&Devices, &Count); > + if (Devices =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto Exit_Start; > + } > + HasCreated =3D AllocatePool (sizeof (BOOLEAN) * Count); > + ASSERT (HasCreated !=3D NULL); > + if (HasCreated =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto Exit_Start; > + } > + RequestCreate =3D AllocatePool (sizeof (BOOLEAN) * Count); > + ASSERT (RequestCreate !=3D NULL); > + if (RequestCreate =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto Exit_Start; > + } > + > + // > + // Assume no children has been created. > + // Assume the SIO interface hasn't been initialized. > + // > + ZeroMem (HasCreated, sizeof (BOOLEAN) * Count); > + > + if (Status =3D=3D EFI_ALREADY_STARTED) { > + for (Node =3D GetFirstNode (&mSioDevPool); > + !IsNull (&mSioDevPool, Node); > + Node =3D GetNextNode (&mSioDevPool, Node) > + ) { > + SioDev =3D CR (Node, SIO_DEV, Link, SIO_DEV_SIGNATURE); > + Status =3D gBS->HandleProtocol ( > + SioDev->PciHandle, > + &gEfiDevicePathProtocolGuid, > + (VOID **) &DevicePath > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // See if they are under the same PCI to ISA Bridge > + // > + if (CompareMem (DevicePath, ParentDevicePath, GetDevicePathSize > (DevicePath)) =3D=3D 0) { > + for (Index =3D 0; Index < Count; Index++) { > + if (CompareMem (&SioDev->Device, &Devices[Index], sizeof > (EFI_SIO_ACPI_DEVICE_ID)) =3D=3D 0) { > + HasCreated[Index] =3D TRUE; > + break; > + } > + } > + } > + } > + } > + > + AcpiNode =3D (ACPI_HID_DEVICE_PATH *) RemainingDevicePath; > + for (Index =3D 0; Index < Count; Index++) { > + if ((AcpiNode =3D=3D NULL) || > + ((AcpiNode->HID =3D=3D Devices[Index].HID) && (AcpiNode->UID =3D= =3D > Devices[Index].UID)) > + ) { > + RequestCreate[Index] =3D TRUE; > + } else { > + RequestCreate[Index] =3D FALSE; > + } > + } > + > + for (Index =3D 0; Index < Count; Index++) { > + if (RequestCreate[Index] && !HasCreated[Index]) { > + SioCreateDevice (Controller, &Devices[Index], ParentDevicePath, Pc= iIo); > + } > + } > +Exit_Start: > + if (Devices !=3D NULL) { > + FreePool (Devices); > + } > + if (HasCreated !=3D NULL) { > + FreePool (HasCreated); > + } > + if (RequestCreate !=3D NULL) { > + FreePool (RequestCreate); > + } > + > + return Status; > +} > + > + > +/** > + Stop this driver on ControllerHandle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to stop driver on > + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. > If number of > + children is zero stop the entire bus dri= ver. > + @param[in] ChildHandleBuffer List of Child Handles to Stop. > + > + @retval EFI_SUCCESS This driver is removed ControllerHandle > + @retval other This driver was not removed from this de= vice > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverStop ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN UINTN NumberOfChildren, > + IN EFI_HANDLE *ChildHandleBuffer > + ) > +{ > + EFI_STATUS Status; > + UINTN Index; > + BOOLEAN AllChildrenStopped; > + > + if (NumberOfChildren =3D=3D 0) { > + gBS->CloseProtocol ( > + Controller, > + &gEfiDevicePathProtocolGuid, > + This->DriverBindingHandle, > + Controller > + ); > + gBS->CloseProtocol ( > + Controller, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + Controller > + ); > + return EFI_SUCCESS; > + } > + > + AllChildrenStopped =3D TRUE; > + for (Index =3D 0; Index < NumberOfChildren; Index++) { > + Status =3D SioDestroyDevice (ChildHandleBuffer[Index]); > + if (EFI_ERROR (Status)) { > + AllChildrenStopped =3D FALSE; > + } > + } > + > + if (AllChildrenStopped) { > + return EFI_SUCCESS; > + } else { > + return EFI_DEVICE_ERROR; > + } > +} > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h > new file mode 100644 > index 0000000000..8817019fbf > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h > @@ -0,0 +1,133 @@ > +/** @file > + Header file for Driver Binding Protocol. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef _SIO_DRIVER_H_ > +#define _SIO_DRIVER_H_ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +// > +// Driver Consumed Protocol Prototypes > +// > +#include > +#include > +#include > + > +// > +// Driver Produced Protocol Prototypes > +// > +#include > + > + > +#include "SioChip.h" > +#include "SioService.h" > +#include "ComponentName.h" > + > +// > +// Global Variables definitions > +// > +extern EFI_DRIVER_BINDING_PROTOCOL mSioDriver; > +extern EFI_COMPONENT_NAME_PROTOCOL mSioComponentName; > +extern EFI_COMPONENT_NAME2_PROTOCOL mSioComponentName2; > + > +// > +// SIO device private data structure > +// > +#define SIO_DEV_SIGNATURE SIGNATURE_32 ('_', 'S', 'I', 'O') > + > +typedef struct _SIO_DEV { > + UINT32 Signature; > + EFI_HANDLE PciHandle; > + EFI_SIO_ACPI_DEVICE_ID Device; > + EFI_HANDLE Handle; > + EFI_SIO_PROTOCOL Sio; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + LIST_ENTRY Link; > +} SIO_DEV; > + > +#define SIO_DEV_FROM_THIS(a) CR (a, SIO_DEV, Sio, > SIO_DEV_SIGNATURE) > + > +// > +// Prototypes for Driver model protocol interface > +// > + > + > +/** > + Test to see if this driver supports Controller Handle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to test > + @param[in] RemainingDevicePath Optional parameter use to pick a > specific child > + device to start. > + > + @retval EFI_SUCCESS This driver supports this device > + @retval EFI_ALREADY_STARTED This driver is already running on this > device > + @retval other This driver does not support this devi= ce > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverSupported ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath > + ); > + > + > +/** > + Start this driver on ControllerHandle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to bind driver to > + @param[in] RemainingDevicePath Optional parameter use to pick a > specific child > + device to start. > + > + @retval EFI_SUCCESS This driver is added to ControllerHan= dle > + @retval EFI_ALREADY_STARTED This driver is already running on > ControllerHandle > + @retval other This driver does not support this dev= ice > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverStart ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath > + ); > + > + > +/** > + Stop this driver on ControllerHandle. > + > + @param[in] This Protocol instance pointer. > + @param[in] Controller Handle of device to stop driver on > + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. > If number of > + children is zero stop the entire bus dri= ver. > + @param[in] ChildHandleBuffer List of Child Handles to Stop. > + > + @retval EFI_SUCCESS This driver is removed ControllerHandle > + @retval other This driver was not removed from this de= vice > +**/ > +EFI_STATUS > +EFIAPI > +SioDriverStop ( > + IN EFI_DRIVER_BINDING_PROTOCOL *This, > + IN EFI_HANDLE Controller, > + IN UINTN NumberOfChildren, > + IN EFI_HANDLE *ChildHandleBuffer > + ); > +#endif > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c > new file mode 100644 > index 0000000000..379002b833 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c > @@ -0,0 +1,249 @@ > +/** @file > + Super I/O Interface implementation. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include "SioDriver.h" > + > + > +/** > + Provides an interface to get a list of the current resources consumed = by > the device in the ACPI > + Resource Descriptor format. > + > + GetResources() returns a list of resources currently consumed by the > device. The > + ResourceList is a pointer to the buffer containing resource descriptor= s for > the device. The > + descriptors are in the format of Small or Large ACPI resource descript= or as > defined by ACPI > + specification (2.0 & 3.0). The buffer of resource descriptors is termi= nated > with the 'End tag' > + resource descriptor. > + > + @param[in] This Indicates a pointer to the calling c= ontext. > + @param[out] ResourceList A pointer to an ACPI resource descri= ptor > list that defines the current resources > + used by the device. Type ACPI_RESOUR= CE_HEADER_PTR > is defined in the "Related > + Definitions" below. > + > + @retval EFI_SUCCESS The operation completed successfully > + @retval EFI_INVALID_PARAMETER ResourceList is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioGetResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + OUT ACPI_RESOURCE_HEADER_PTR *ResourceList > + ) > +{ > + SIO_DEV *SioDev; > + > + if (ResourceList =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + SioDev =3D SIO_DEV_FROM_THIS (This); > + > + return DeviceGetResources (&SioDev->Device, ResourceList); > +} > + > + > +/** > + Provides a collection of resource descriptor lists. Each resource desc= riptor > list in the collection > + defines a combination of resources that can potentially be used by the > device. > + > + @param[in] This Indicates a pointer to the calli= ng context. > + @param[out] ResourceCollection Collection of the resource descr= iptor > lists. > + > + @retval EFI_SUCCESS The operation completed successf= ully > + @retval EFI_INVALID_PARAMETER ResourceCollection is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioPossibleResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + OUT ACPI_RESOURCE_HEADER_PTR *ResourceCollection > + ) > +{ > + SIO_DEV *SioDev; > + > + if (ResourceCollection =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + SioDev =3D SIO_DEV_FROM_THIS (This); > + > + return DevicePossibleResources (&SioDev->Device, ResourceCollection); > +} > + > + > +/** > + Sets the resources for the device. > + > + @param[in] This Indicates a pointer to the calling c= ontext. > + @param[in] ResourceList Pointer to the ACPI resource descrip= tor list. > Type ACPI_RESOURCE_HEADER_PTR > + is defined in the "Related Definitio= ns" section of > + EFI_SIO_PROTOCOL.GetResources(). > + > + @retval EFI_SUCCESS The operation completed successfully > + @retval EFI_INVALID_PARAMETER ResourceList is invalid > + @retval EFI_ACCESS_DENIED Some of the resources in ResourceLis= t > are in use > +**/ > +EFI_STATUS > +EFIAPI > +SioSetResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN ACPI_RESOURCE_HEADER_PTR ResourceList > + ) > +{ > + SIO_DEV *SioDev; > + ACPI_RESOURCE_HEADER_PTR ResourcePtr; > + ACPI_RESOURCE_HEADER_PTR ResourceCollection; > + ACPI_RESOURCE_HEADER_PTR ResourcePtr2; > + BOOLEAN Found; > + > + ResourcePtr =3D ResourceList; > + SioDev =3D SIO_DEV_FROM_THIS (This); > + > + // > + // Check whether the resource is in the possible resource collection > + // > + DevicePossibleResources (&SioDev->Device, &ResourceCollection); > + > + while (ResourcePtr.SmallHeader->Byte !=3D ACPI_END_TAG_DESCRIPTOR) { > + > + Found =3D FALSE; > + ResourcePtr2 =3D ResourceCollection; > + while (ResourcePtr2.SmallHeader->Byte !=3D ACPI_END_TAG_DESCRIPTOR) > { > + if (ResourcePtr2.SmallHeader->Bits.Type =3D=3D 0) { > + // > + // Small Header > + // > + if (CompareMem ( > + ResourcePtr2.SmallHeader, > + ResourcePtr.SmallHeader, > + ResourcePtr2.SmallHeader->Bits.Length + sizeof > (*ResourcePtr2.SmallHeader) > + ) =3D=3D 0) { > + Found =3D TRUE; > + break; > + } > + > + ResourcePtr2.SmallHeader =3D (ACPI_SMALL_RESOURCE_HEADER *) > ((UINT8 *) ResourcePtr2.SmallHeader > + + ResourcePtr2.SmallHeader->Bits.Length > + + sizeof (*ResourcePtr2.SmallHeader)); > + > + } else { > + // > + // Large Header > + // > + if (CompareMem ( > + ResourcePtr2.LargeHeader, > + ResourcePtr.LargeHeader, > + ResourcePtr2.LargeHeader->Length + sizeof > (*ResourcePtr2.LargeHeader) > + ) =3D=3D 0) { > + Found =3D TRUE; > + break; > + } > + > + ResourcePtr2.LargeHeader =3D (ACPI_LARGE_RESOURCE_HEADER *) > ((UINT8 *) ResourcePtr2.LargeHeader > + + ResourcePtr2.LargeHeader->Length > + + sizeof (*ResourcePtr2.LargeHeader)); > + } > + } > + > + if (!Found) { > + return EFI_ACCESS_DENIED; > + } > + > + if (ResourcePtr.SmallHeader->Bits.Type =3D=3D 0) { > + ResourcePtr.SmallHeader =3D (ACPI_SMALL_RESOURCE_HEADER *) > ((UINT8 *) ResourcePtr.SmallHeader > + + ResourcePtr.SmallHeader->Bits.Length > + + sizeof (*ResourcePtr.SmallHeader)); > + } else { > + ResourcePtr.LargeHeader =3D (ACPI_LARGE_RESOURCE_HEADER *) > ((UINT8 *) ResourcePtr.LargeHeader > + + ResourcePtr.LargeHeader->Length > + + sizeof (*ResourcePtr.LargeHeader)); > + } > + } > + > + // > + // ResourceList can be set > + // > + return DeviceSetResources (&SioDev->Device, ResourceList); > +} > + > + > +/** > + Provides a low level access to the registers for the Super I/O. > + > + @param[in] This Indicates a pointer to the cal= ling context. > + @param[in] Write Specifies the type of the regi= ster operation. > If this parameter is TRUE, > + Value is interpreted as an inp= ut parameter and the > operation is a register write. > + If this parameter is FALSE, Va= lue is interpreted as an > output parameter and the > + operation is a register read. > + @param[in] ExitCfgMode Exit Configuration Mode Indica= tor. If this > parameter is set to TRUE, the > + Super I/O driver will turn off= configuration mode of the > Super I/O prior to returning > + from this function. If this pa= rameter is set to FALSE, the > Super I/O driver will > + leave Super I/O in the configu= ration mode. > + The Super I/O driver must trac= k the current state of > the Super I/O and enable the > + configuration mode of Super I/= O if necessary prior to > register access. > + @param[in] Register Register number. > + @param[in, out] Value If Write is TRUE, Value is a p= ointer to the > buffer containing the byte of data to be > + written to the Super I/O regis= ter. If Write is FALSE, > Value is a pointer to the > + destination buffer for the byt= e of data to be read from > the Super I/O register. > + > + @retval EFI_SUCCESS The operation completed succes= sfully > + @retval EFI_INVALID_PARAMETER The Value is NULL > + @retval EFI_INVALID_PARAMETER Invalid Register number > +**/ > +EFI_STATUS > +EFIAPI > +SioRegisterAccess ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN BOOLEAN Write, > + IN BOOLEAN ExitCfgMode, > + IN UINT8 Register, > + IN OUT UINT8 *Value > + ) > +{ > + if (Value =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Provides an interface for a table based programming of the Super I/O > registers. > + > + The Modify() function provides an interface for table based programmin= g > of the Super I/O > + registers. This function can be used to perform programming of multipl= e > Super I/O registers with a > + single function call. For each table entry, the Register is read, its = content is > bitwise ANDed with > + AndMask, and then ORed with OrMask before being written back to the > Register. The Super > + I/O driver must track the current state of the Super I/O and enable th= e > configuration mode of Super I/ > + O if necessary prior to table processing. Once the table is processed,= the > Super I/O device has to be > + returned to the original state. > + > + @param[in] This Indicates a pointer to the calling co= ntext. > + @param[in] Command A pointer to an array of > NumberOfCommands EFI_SIO_REGISTER_MODIFY > + structures. Each structure specifies = a single Super I/O > register modify operation. > + Type EFI_SIO_REGISTER_MODIFY is defin= ed in the > "Related Definitions" below. > + @param[in] NumberOfCommands Number of elements in the > Command array. > + > + @retval EFI_SUCCESS The operation completed successfully > + @retval EFI_INVALID_PARAMETER Command is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioModify ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN CONST EFI_SIO_REGISTER_MODIFY *Command, > + IN UINTN NumberOfCommands > + ) > +{ > + > + if (Command =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + return EFI_SUCCESS; > +} > diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h > b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h > new file mode 100644 > index 0000000000..df08da80b4 > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h > @@ -0,0 +1,143 @@ > +/** @file > + Super I/O Interface function declarations. > + > + Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef _SIO_ACPI_H_ > +#define _SIO_ACPI_H_ > + > +// > +// Prototypes for the SIO protocol interface > +// > + > + > +/** > + Provides an interface to get a list of the current resources consumed = by > the device in the ACPI > + Resource Descriptor format. > + > + GetResources() returns a list of resources currently consumed by the > device. The > + ResourceList is a pointer to the buffer containing resource descriptor= s for > the device. The > + descriptors are in the format of Small or Large ACPI resource descript= or as > defined by ACPI > + specification (2.0 & 3.0). The buffer of resource descriptors is termi= nated > with the 'End tag' > + resource descriptor. > + > + @param[in] This Indicates a pointer to the calling= context. > + @param[out] ResourceList A pointer to an ACPI resource desc= riptor > list that defines the current resources > + used by the device. Type ACPI_RESO= URCE_HEADER_PTR > is defined in the "Related > + Definitions" below. > + > + @retval EFI_SUCCESS The operation completed successful= ly > + @retval EFI_INVALID_PARAMETER ResourceList is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioGetResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + OUT ACPI_RESOURCE_HEADER_PTR *ResourceList > + ); > + > + > +/** > + Sets the resources for the device. > + > + @param[in] This Indicates a pointer to the calling c= ontext. > + @param[in] ResourceList Pointer to the ACPI resource descrip= tor list. > Type ACPI_RESOURCE_HEADER_PTR > + is defined in the "Related Definitio= ns" section of > + EFI_SIO_PROTOCOL.GetResources(). > + > + @retval EFI_SUCCESS The operation completed successfully > + @retval EFI_INVALID_PARAMETER ResourceList is invalid > + @retval EFI_ACCESS_DENIED Some of the resources in ResourceLis= t > are in use > +**/ > +EFI_STATUS > +EFIAPI > +SioSetResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN ACPI_RESOURCE_HEADER_PTR ResourceList > + ); > + > + > +/** > + Provides a collection of resource descriptor lists. Each resource desc= riptor > list in the collection > + defines a combination of resources that can potentially be used by the > device. > + > + @param[in] This Indicates a pointer to the calli= ng context. > + @param[out] ResourceCollection Collection of the resource descr= iptor > lists. > + > + @retval EFI_SUCCESS The operation completed successf= ully > + @retval EFI_INVALID_PARAMETER ResourceCollection is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioPossibleResources ( > + IN CONST EFI_SIO_PROTOCOL *This, > + OUT ACPI_RESOURCE_HEADER_PTR *ResourceCollection > + ); > + > + > +/** > + Provides a low level access to the registers for the Super I/O. > + > + @param[in] This Indicates a pointer to the cal= ling context. > + @param[in] Write Specifies the type of the regi= ster operation. > If this parameter is TRUE, > + Value is interpreted as an inp= ut parameter and the > operation is a register write. > + If this parameter is FALSE, Va= lue is interpreted as an > output parameter and the > + operation is a register read. > + @param[in] ExitCfgMode Exit Configuration Mode Indica= tor. If this > parameter is set to TRUE, the > + Super I/O driver will turn off= configuration mode of the > Super I/O prior to returning > + from this function. If this pa= rameter is set to FALSE, the > Super I/O driver will > + leave Super I/O in the configu= ration mode. > + The Super I/O driver must trac= k the current state of > the Super I/O and enable the > + configuration mode of Super I/= O if necessary prior to > register access. > + @param[in] Register Register number. > + @param[in, out] Value If Write is TRUE, Value is a p= ointer to the > buffer containing the byte of data to be > + written to the Super I/O regis= ter. If Write is FALSE, > Value is a pointer to the > + destination buffer for the byt= e of data to be read from > the Super I/O register. > + > + @retval EFI_SUCCESS The operation completed succes= sfully > + @retval EFI_INVALID_PARAMETER The Value is NULL > + @retval EFI_INVALID_PARAMETER Invalid Register number > +**/ > +EFI_STATUS > +EFIAPI > +SioRegisterAccess ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN BOOLEAN Write, > + IN BOOLEAN ExitCfgMode, > + IN UINT8 Register, > + IN OUT UINT8 *Value > + ); > + > + > +/** > + Provides an interface for a table based programming of the Super I/O > registers. > + > + The Modify() function provides an interface for table based programmin= g > of the Super I/O > + registers. This function can be used to perform programming of multipl= e > Super I/O registers with a > + single function call. For each table entry, the Register is read, its = content is > bitwise ANDed with > + AndMask, and then ORed with OrMask before being written back to the > Register. The Super > + I/O driver must track the current state of the Super I/O and enable th= e > configuration mode of Super I/ > + O if necessary prior to table processing. Once the table is processed,= the > Super I/O device has to be > + returned to the original state. > + > + @param[in] This Indicates a pointer to the calling co= ntext. > + @param[in] Command A pointer to an array of > NumberOfCommands EFI_SIO_REGISTER_MODIFY > + structures. Each structure specifies = a single Super I/O > register modify operation. > + Type EFI_SIO_REGISTER_MODIFY is defin= ed in the > "Related Definitions" below. > + @param[in] NumberOfCommands Number of elements in the > Command array. > + > + @retval EFI_SUCCESS The operation completed successfully > + @retval EFI_INVALID_PARAMETER Command is NULL > +**/ > +EFI_STATUS > +EFIAPI > +SioModify ( > + IN CONST EFI_SIO_PROTOCOL *This, > + IN CONST EFI_SIO_REGISTER_MODIFY *Command, > + IN UINTN NumberOfCommands > + ); > + > +#endif > -- > 2.19.1.windows.1