From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [62.140.7.102]) by mx.groups.io with SMTP id smtpd.web12.10701.1594885602132259356 for ; Thu, 16 Jul 2020 00:46:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=hWBtgfok; spf=pass (domain: suse.com, ip: 62.140.7.102, mailfrom: glin@suse.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1594885599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nstBE28e/MNW2HL+wR9okD2MUalEpdJKz1wyYZvcGSE=; b=hWBtgfokxVW7mSFla/WV2wzXeqbv/7m7M/grifHB6nmtJsbJ/hzflLprGjOeD29yaSEjcm JMq6qIzTLNpF4WoZ7a519dRs+PVss5uU/xO+SfMDk151AGRB4fEuG9yOzjVPklfL4BOqGY ++0Ill+z3XfX9ifULhaYqcbj9vDGYOs= Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-20-ISck9tuUMEmmUJ8lBvK4Bg-1; Thu, 16 Jul 2020 09:46:37 +0200 X-MC-Unique: ISck9tuUMEmmUJ8lBvK4Bg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bp7lLkywYxhLtPwyLYgcVO5PHoHk1H5cYxkuO5GfXjnSlaZuXNsHrmjqsPs1+rGgbtJwEbKpK+zfFG/iezucM1eCri1ldvcXFOEuaCfLh1lQWrIXzoO+jAYzWgJ5HYk8XaD7WV15JDeHkXHBkJs7S8Or7Q+MC6SoYiHX6szOva8vF/MB+hCDPLhmWUlXb4F6/G6/9XVG2SnMng255EhqM1phq7dkZyATN22wjQBKL8M3ErjSoyJw4AH9FsJAn477wVfuDbu2jJT6pKDU6uJkXmGeSINcxP0vWvL5g7dkAR1qI6DvOGjPPYLDc5dC+RCuhQMlw5tgWSUuraRRwPWw3w== 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=nstBE28e/MNW2HL+wR9okD2MUalEpdJKz1wyYZvcGSE=; b=Hoqw3qvJEZWmNUsZ3wkseIJvo2koSfvdFKyv0oSQsm4pO/kJddcJaBQ/bBXDG9+UgPmvLWePuOvI/bXMdr1ucCU9VlFGXEj/xvjNfz+lDt3CdTgL6teiLZ1jbkZ3FmWF9jt+SFz7PjF3atYHUcfKmP1jhq5YgfT/yLB0LEvTA3Lr+lIMJkrb9N7ZKj0MNsJ58ZHlg93SJ0QhxE9SiZAdIvO2QC1lVcE4U3Ei/JlLpgJGMwOMNyP9Usiwg14QB+/Bu8S6S0DwZ8tqi4sG0UaOJ0Fh7OLXcjk4Vp7Y64ujL5+Bv0Z6fASoWYbCVKEVUznihJlTOZjF9IAtZQjhiq0y6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=suse.com; Received: from AM0PR0402MB3809.eurprd04.prod.outlook.com (2603:10a6:208:10::30) by AM0PR04MB4740.eurprd04.prod.outlook.com (2603:10a6:208:c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Thu, 16 Jul 2020 07:46:36 +0000 Received: from AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::a14c:d441:c8a9:77ba]) by AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::a14c:d441:c8a9:77ba%6]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 07:46:36 +0000 From: "Gary Lin" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v2 05/12] OvmfPkg/LsiScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Date: Thu, 16 Jul 2020 15:46:00 +0800 Message-Id: <20200716074607.18048-6-glin@suse.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200716074607.18048-1-glin@suse.com> References: <20200716074607.18048-1-glin@suse.com> X-ClientProxiedBy: AM3PR07CA0118.eurprd07.prod.outlook.com (2603:10a6:207:7::28) To AM0PR0402MB3809.eurprd04.prod.outlook.com (2603:10a6:208:10::30) Return-Path: glin@suse.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from GaryWorkstation.suse.cz (60.251.47.115) by AM3PR07CA0118.eurprd07.prod.outlook.com (2603:10a6:207:7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17 via Frontend Transport; Thu, 16 Jul 2020 07:46:34 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [60.251.47.115] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c0dcdac-00c5-4431-26db-08d8295c5da7 X-MS-TrafficTypeDiagnostic: AM0PR04MB4740: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FKNSGRvg0FMZZWiBIXm+obyUmNJUC/EYEeZr69ZGxQdU+rOuXk9xbc33DTfzK2zu1RTQX0Vx2TBYvxJukhfoq/STzO8ZqNFjH+A82poP/lp7P/YX6xi9QAwfPbo5NMOd33z6yu7HTtyDNO9S8oXnluDhCR3avyN0VbiVyfpCXdSSh6wRLjA0pvNHhLRsPfHnHU8dF3gIZtAeC2BI/KGyJwWrsNgn80qPE5gOMd28OVSQ7pfHCi2Ven9h9g7WnHpMdyO++Umx0TZW5WgsuI99lyniSaaoi8/t8rfa4juOJE8hl3lLAhbsQyglqVlgPi3LjQDYr9X31lnwGMMjyMXf3A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR0402MB3809.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(136003)(376002)(346002)(39860400002)(366004)(396003)(2616005)(956004)(26005)(478600001)(8936002)(36756003)(2906002)(54906003)(8676002)(52116002)(6916009)(316002)(6512007)(186003)(16526019)(1076003)(6486002)(5660300002)(66556008)(66476007)(66946007)(6666004)(83380400001)(86362001)(6506007)(55236004)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Cz3PvYpVtAl0Nv3ZUeTm98u6yp0v0/DOLYP+3rzNITQB0VMm0SXFTWs76FlzlK32YtKYs6XkuUYnS+WPbNFNDOE8jOFx+yWsfRLCh4H3xcfz32HUxIIzIev5OO0tuW8nefc1gK6oA7r+W66gUnMr/RUDRCv+AeXStq2jQu1W5YGDtrI7KDYWVXZXEb7a+TRZ94gmxtBcknGjOtvLe+39nLJxk7xc/dE1U0iZwcn+WooT97/0C+LmhmR8xLSovqOtPgQNgdOhacry0sea1h9N6dz5K7+jF6iLjqB+xOL5yptihWP1EugA8ayOt0fQhhmUy3klcAsiGXkNxlQ5h5n6VqaewkACcWWgan0DF4By8zxj8YbTy1mehUxjKEigQP8lx3ffJETG8BKkbKogmgpj2xepvyBw+df1n4iejGKEOr4r7yRIlNRAkiPTKch5bxas1JhG0Spg6YU9+nBVCBr8mYhnfde2VgEx7FR/IWXNNJY= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c0dcdac-00c5-4431-26db-08d8295c5da7 X-MS-Exchange-CrossTenant-AuthSource: AM0PR0402MB3809.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2020 07:46:36.1758 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nFXGm/ycVqlV5P0IQVOCEBqXW098581oe44W5tArrxa3B/9iM+lnz9QSSsiPqsPt X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4740 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Partially implement LsiScsiControllerStart() and LsiScsiControllerStop() to insert the scaffolding of EXT_SCSI_PASS_THRU functions. v2: Remove the closing of PciIo protocol from LsiScsiControllerStop(). Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Gary Lin Reviewed-by: Laszlo Ersek --- OvmfPkg/LsiScsiDxe/LsiScsi.c | 164 +++++++++++++++++++++++++++++- OvmfPkg/LsiScsiDxe/LsiScsi.h | 77 ++++++++++++++ OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf | 3 + 3 files changed, 243 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.c b/OvmfPkg/LsiScsiDxe/LsiScsi.c index 5bca85bd75eb..67fadb411e85 100644 --- a/OvmfPkg/LsiScsiDxe/LsiScsi.c +++ b/OvmfPkg/LsiScsiDxe/LsiScsi.c @@ -11,14 +11,105 @@ =0D #include =0D #include =0D +#include =0D +#include =0D +#include =0D +#include =0D #include =0D #include =0D #include =0D #include =0D +#include =0D #include =0D =0D #include "LsiScsi.h"=0D =0D +//=0D +// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL=0D +// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata = C,=0D +// sections=0D +// - 14.1 SCSI Driver Model Overview,=0D +// - 14.7 Extended SCSI Pass Thru Protocol.=0D +//=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiPassThru (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun,=0D + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,=0D + IN EFI_EVENT Event OPTIONAL=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetNextTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN OUT UINT8 **TargetPointer,=0D + IN OUT UINT64 *Lun=0D + )=0D +{=0D + return EFI_NOT_FOUND;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiBuildDevicePath (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun,=0D + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath=0D + )=0D +{=0D + return EFI_NOT_FOUND;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,=0D + OUT UINT8 **TargetPointer,=0D + OUT UINT64 *Lun=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiResetChannel (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiResetTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetNextTarget (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN OUT UINT8 **TargetPointer=0D + )=0D +{=0D + return EFI_NOT_FOUND;=0D +}=0D +=0D //=0D // Probe, start and stop functions of this driver, called by the DXE core = for=0D // specific devices.=0D @@ -88,7 +179,49 @@ LsiScsiControllerStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL=0D )=0D {=0D + EFI_STATUS Status;=0D + LSI_SCSI_DEV *Dev;=0D +=0D + Dev =3D AllocateZeroPool (sizeof (*Dev));=0D + if (Dev =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + Dev->Signature =3D LSI_SCSI_DEV_SIGNATURE;=0D +=0D + //=0D + // Host adapter channel, doesn't exist=0D + //=0D + Dev->PassThruMode.AdapterId =3D MAX_UINT32;=0D + Dev->PassThruMode.Attributes =3D=0D + EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL |=0D + EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;=0D +=0D + Dev->PassThru.Mode =3D &Dev->PassThruMode;=0D + Dev->PassThru.PassThru =3D &LsiScsiPassThru;=0D + Dev->PassThru.GetNextTargetLun =3D &LsiScsiGetNextTargetLun;=0D + Dev->PassThru.BuildDevicePath =3D &LsiScsiBuildDevicePath;=0D + Dev->PassThru.GetTargetLun =3D &LsiScsiGetTargetLun;=0D + Dev->PassThru.ResetChannel =3D &LsiScsiResetChannel;=0D + Dev->PassThru.ResetTargetLun =3D &LsiScsiResetTargetLun;=0D + Dev->PassThru.GetNextTarget =3D &LsiScsiGetNextTarget;=0D +=0D + Status =3D gBS->InstallProtocolInterface (=0D + &ControllerHandle,=0D + &gEfiExtScsiPassThruProtocolGuid,=0D + EFI_NATIVE_INTERFACE,=0D + &Dev->PassThru=0D + );=0D + if (EFI_ERROR (Status)) {=0D + goto FreePool;=0D + }=0D +=0D return EFI_SUCCESS;=0D +=0D +FreePool:=0D + FreePool (Dev);=0D +=0D + return Status;=0D }=0D =0D EFI_STATUS=0D @@ -100,7 +233,36 @@ LsiScsiControllerStop ( IN EFI_HANDLE *ChildHandleBuffer=0D )=0D {=0D - return EFI_SUCCESS;=0D + EFI_STATUS Status;=0D + EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;=0D + LSI_SCSI_DEV *Dev;=0D +=0D + Status =3D gBS->OpenProtocol (=0D + ControllerHandle,=0D + &gEfiExtScsiPassThruProtocolGuid,=0D + (VOID **)&PassThru,=0D + This->DriverBindingHandle,=0D + ControllerHandle,=0D + EFI_OPEN_PROTOCOL_GET_PROTOCOL // Lookup only=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Dev =3D LSI_SCSI_FROM_PASS_THRU (PassThru);=0D +=0D + Status =3D gBS->UninstallProtocolInterface (=0D + ControllerHandle,=0D + &gEfiExtScsiPassThruProtocolGuid,=0D + &Dev->PassThru=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + FreePool (Dev);=0D +=0D + return Status;=0D }=0D =0D //=0D diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.h b/OvmfPkg/LsiScsiDxe/LsiScsi.h index 6c8dcbd70a0a..c194dfbf3347 100644 --- a/OvmfPkg/LsiScsiDxe/LsiScsi.h +++ b/OvmfPkg/LsiScsiDxe/LsiScsi.h @@ -12,6 +12,17 @@ #ifndef _LSI_SCSI_DXE_H_=0D #define _LSI_SCSI_DXE_H_=0D =0D +typedef struct {=0D + UINT32 Signature;=0D + EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;=0D + EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;=0D +} LSI_SCSI_DEV;=0D +=0D +#define LSI_SCSI_DEV_SIGNATURE SIGNATURE_32 ('L','S','I','S')=0D +=0D +#define LSI_SCSI_FROM_PASS_THRU(PassThruPtr) \=0D + CR (PassThruPtr, LSI_SCSI_DEV, PassThru, LSI_SCSI_DEV_SIGNATURE)=0D +=0D //=0D // Probe, start and stop functions of this driver, called by the DXE core = for=0D // specific devices.=0D @@ -47,6 +58,72 @@ LsiScsiControllerStop ( );=0D =0D =0D +//=0D +// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL=0D +// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata = C,=0D +// sections=0D +// - 14.1 SCSI Driver Model Overview,=0D +// - 14.7 Extended SCSI Pass Thru Protocol.=0D +//=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiPassThru (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun,=0D + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,=0D + IN EFI_EVENT Event OPTIONAL=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetNextTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN OUT UINT8 **TargetPointer,=0D + IN OUT UINT64 *Lun=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiBuildDevicePath (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun,=0D + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,=0D + OUT UINT8 **TargetPointer,=0D + OUT UINT64 *Lun=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiResetChannel (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiResetTargetLun (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN UINT8 *Target,=0D + IN UINT64 Lun=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +LsiScsiGetNextTarget (=0D + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,=0D + IN OUT UINT8 **TargetPointer=0D + );=0D +=0D +=0D //=0D // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL a= nd=0D // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's = name=0D diff --git a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf b/OvmfPkg/LsiScsiDxe/LsiScsi= Dxe.inf index 7ce11fcc6a03..14f9c68308cc 100644 --- a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf +++ b/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf @@ -26,9 +26,12 @@ [Packages] =0D [LibraryClasses]=0D BaseLib=0D + BaseMemoryLib=0D + MemoryAllocationLib=0D UefiBootServicesTableLib=0D UefiDriverEntryPoint=0D UefiLib=0D =0D [Protocols]=0D + gEfiExtScsiPassThruProtocolGuid ## BY_START=0D gEfiPciIoProtocolGuid ## TO_START=0D --=20 2.25.1