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.web10.14126.1593576343177488099 for ; Tue, 30 Jun 2020 21:05:43 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: suse.com, ip: 62.140.7.102, mailfrom: glin@suse.com) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2054.outbound.protection.outlook.com [104.47.4.54]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-28-IfCPIfVwOK28mhrY-vORYw-4; Wed, 01 Jul 2020 06:05:40 +0200 X-MC-Unique: IfCPIfVwOK28mhrY-vORYw-4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dpv9M7l37299nm8wWP5R5/VDwPc6vdEgSeIHAcMJ53YeXtggGDgfGRsZLsh9plJpPoDtpAKWfJYG06eSYq11GLDPA88n3geMYPUJ5yYilI5wT2083pOe5Zdrny9gb5nD3gkNMwq1p8GjWuS366K42i/t4OQdKzdb4vAE8UNUY9Fg39t0z6nIiV8aU/Kq7J2scgZ3rKrlNntrX99erTxVW7KU+4GvPiZVFEEFXWeZepanXLKHEJynow1IHgfylMPtXQx+hfCQpnDFJ7/tVtvfvbQDFDdS19gYSZ09apiiKlZN0n5AoijrFtaT+YaAnBJ3AFCEkpNmd9cYg0n+2Xwp9g== 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=ANF5I55jNeO2v0y2oHj1iJClQUyweqWzkROz8RhOToQ=; b=lm/NLDYQpEbVh7s3vWLaxA9QptEwzKR2h4Ba1o329ilpHdE29Vz4dxHiok3+z5a8dEy7BLpKvp6ss4ddDN58WMO8bQxIOi8kMbFZCQ26apudYCin817egN6nM/rniymQCPswgYkhhzHR7XeehwhUQMcFP/0jKh8ZPEcrmTkrGbhJw4spoK5v6kPRN271GZ9EXyatmko169DwvTNcRue+b3+Qrf9J19HmJJP/R4qouZ2XJaTaUEgY0u4dZ7PTnXmB/sJqkPfm0vayr19BYiW/iV3ruvnpNK24leX3u/D+OUHSepPfK71NWcc6bWuEMNFCdDFW6ZYMHcRVNicqowrIQQ== 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 AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Wed, 1 Jul 2020 04:05:40 +0000 Received: from AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::8806:715f:1409:8c6b]) by AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::8806:715f:1409:8c6b%7]) with mapi id 15.20.3153.021; Wed, 1 Jul 2020 04:05:39 +0000 From: "Gary Lin" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH 05/11] OvmfPkg/LsiScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Date: Wed, 1 Jul 2020 12:04:42 +0800 Message-Id: <20200701040448.14871-6-glin@suse.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200701040448.14871-1-glin@suse.com> References: <20200701040448.14871-1-glin@suse.com> X-ClientProxiedBy: AM0PR10CA0047.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::27) 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 AM0PR10CA0047.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21 via Frontend Transport; Wed, 1 Jul 2020 04:05:38 +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: bd96ed7a-4ee7-4e04-4a58-08d81d74041a X-MS-TrafficTypeDiagnostic: AM0PR04MB4481: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 04519BA941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HepftTzYiLQlgdHbNzCv90l7R0UQXIF/07b5NoAwFIMZWmepWyQxqM1Sl8Pm6xMmCiRoZTW7pT5fGzx9Xu7CxygBg5UY23c4E9qZw6bWI7W+tLaz7rZfnAPucxlNSww6OWy+HiPPTER1yvJLrhnbXvuTBmgtjHFP9hlYUAAQQhEk57TsTTC29HrhfdKYhOsGjlzyEoWSsWH1d2u8qkJpqr8dlwEHfzFoZMevy+EFWavwoZUyOLpPEMtlQ5E2UgGP6jlL7MjgEAqpYbIgFXXGMLOhIDQnNHpL2A5PpsXMEh1wLXOdkoUJ6t7uyX8dqkc8D12Svv20rQKGzZZgUZIRug== 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:(366004)(136003)(376002)(39860400002)(396003)(346002)(2616005)(83380400001)(26005)(54906003)(4326008)(16526019)(1076003)(956004)(86362001)(6506007)(186003)(6666004)(66476007)(66556008)(8936002)(6486002)(52116002)(6916009)(5660300002)(8676002)(36756003)(66946007)(55236004)(316002)(6512007)(478600001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: b1SVse+/uKT1A83wGZAL1GeOSDlUmDLxMGQ59C8nhIPHjD7EBibs/mOAO8cUDDlNvbuuDmZW/9P4Px1JtwgT74AsMpwiaXUJZzoYd5aLlexm7aFk8msZxCXH7VNHre+7yKHZSd+MAMcRP73xrosv1oZhYjx7xTTsmJB1CobknT97leYkv+XOPF+qOEIotzGNdqDoCaNQ7NQ1EsU0D+vXWbyQXc0EItLxF4dCKYUrknkSj2lfEaE0CrM2RNlfUr6SyGS0OismF/YLH6q1Ge+dTuGhUj4e1DtrDMsKrWZvXx1hI+faq/e7PdgztdON+MUttTav5mG3JK4lPiSzpvswnpLu7Sdy5cqnE9/s/prTqSw25bdDhS3al5/rH0RtlmUp8aLSrte2AEiXT28WokTRt3c4Ba7Uiq/xCVVlxjXrhizmRLtscMBazNICKM/sfv/5ouWH+RWiZeBPH8uvPtHjrvxZ6a6u1oOYGE2RS0Z5kY0= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd96ed7a-4ee7-4e04-4a58-08d81d74041a X-MS-Exchange-CrossTenant-AuthSource: AM0PR0402MB3809.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2020 04:05:39.8786 (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: y1JgZmzyUC0hCXf7APl5ougTBTosoDKyvVnWgRKlCTD7rxkO8nZW5kZkGSVh1/FI X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4481 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Partially implement LsiScsiControllerStart() and LsiScsiControllerStop() to insert the scaffolding of EXT_SCSI_PASS_THRU functions. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Gary Lin --- OvmfPkg/LsiScsiDxe/LsiScsi.c | 171 +++++++++++++++++++++++++++++- OvmfPkg/LsiScsiDxe/LsiScsi.h | 77 ++++++++++++++ OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf | 3 + 3 files changed, 250 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.c b/OvmfPkg/LsiScsiDxe/LsiScsi.c index 5bca85bd75eb..f633c6793298 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,43 @@ 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 + gBS->CloseProtocol (=0D + ControllerHandle,=0D + &gEfiPciIoProtocolGuid,=0D + This->DriverBindingHandle,=0D + ControllerHandle=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 00db9ada12d2..fca1007f9b98 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 @@ -48,6 +59,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 e86c626a61aa..8660513e2ffd 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