From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.66]) by mx.groups.io with SMTP id smtpd.web11.21689.1671637332995195436 for ; Wed, 21 Dec 2022 07:42:13 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=4twJXX8s; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.220.66, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NtzVTnUN6sTQLGcP3GYn/11pO7ihoNDt/dvEjuJ/SQYLmfnNy5w6AXum/06XOu8FQeq43Tf9tqdEIRJ0cezrxAyNCY3eDJBhvH5d+AAnz0gpsKw6sHqo9rY64lAyenuSJf41uhYlzE21LXmiB4toxc96F2c40m1KaLPeT1nPrxRP55FcODK4wNMELTmeUPoHFKzsSCw23cnbksFRfLWxzK3MZsJ6xW7nfkUqiiHXgCw3DeHIGMJzoUXyLXQFVvyK9IZoURv52IVRWqFMa95TallWfsRAwcr/gveyW9ztPyNY7fe+nb6ASmDuQGfFnwCCx58P6cyGnpdZcyY+WxdIzw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tb4+RI3css/1WwpGGJXO4kioar6lwzp8dkOJpDdGUGs=; b=XOkf0kWDzXOKb8IjsM+4bMKF1LSFOODGOdbhX80uMB9rOz8HIHZWRhWMn6ICfEhug0OfO1zcFdTJXuceHBgAHKcXtPYzMyLJYDTMaTU9ElTRKCUDc+VtsGE2AaKFlLklGWSoyI1qtP07eNDDB1aD/kzMdTNm+JHk8Z7BM8x2wNaoZeECRIZ5j1ggI6qBHSXDF1EVJwAfl1ZIqIsAhaqRr7ivm1hPuXngGwLk1cBg9swQsg/b6oKQmG3b/Sp0PhdiE/vz9xuNADf5jZx5rUw6bHdLNNFUbO1Kyci7k9TUKWqZupVsSUA6OS30BzpL9wOye5zD0SGjRG/Kk1ld13Yi+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tb4+RI3css/1WwpGGJXO4kioar6lwzp8dkOJpDdGUGs=; b=4twJXX8sgal+V1YRCh+3p5GD3QULYa+raQtR2NaA86iabzLEjDaJ8+D/B/qHrMy7lYvc0AypIF3XnqND/V3cEfvMQvb00gKHcy0XvKRfL1FL+0EyzgJNTTI1ZWz0r+nIqPDG1XPMmDMt6akjGiAK8K5nwNTWUfd9DugCTZn/3fs= Received: from MW4PR04CA0351.namprd04.prod.outlook.com (2603:10b6:303:8a::26) by CY5PR12MB6348.namprd12.prod.outlook.com (2603:10b6:930:f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 15:42:11 +0000 Received: from CO1NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::44) by MW4PR04CA0351.outlook.office365.com (2603:10b6:303:8a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.21 via Frontend Transport; Wed, 21 Dec 2022 15:42:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT068.mail.protection.outlook.com (10.13.175.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.10 via Frontend Transport; Wed, 21 Dec 2022 15:42:10 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 21 Dec 2022 09:42:07 -0600 From: "Chang, Abner" To: CC: Hao A Wu , Ray Ni , "Garrett Kirkendall" , Abner Chang , Kuei-Hung Lin Subject: [PATCH 2/3] MdeModulePkg/Usb: Read a large number of blocks Date: Wed, 21 Dec 2022 23:41:44 +0800 Message-ID: <20221221154144.623-1-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT068:EE_|CY5PR12MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c8f2468-80e9-49c6-32c7-08dae369ecc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TuynHC3H11HEf6Qaz/kFn74Atm9PR0/VrWx+EDt3BpZREzvJh2maO3/jHbARUSW88Jv7Hb3MhIy6ne1+Cip0HB1OB4b2n9IVgpnV7GhBREdu7XJYsnGQPT8cxRmONhAEYiNeYNkBaJY9a2sxmOaGMnh80M1XBcxjCiiyHWB1oNAvJd0vdbqMS+cAt8N/DuBh9osb9j1AwPAE2tvTGA+nJZdQRQDwPSVOmwTNUBWkBxYipp0S5GuJtW0j8TcVS8R78Hmlkxnc3dsXbqbdLYi72Nfcl9uOVu5eaMH0dVIw4IZPhfVhAd4t8ssD0OM+cvAW1RASxFrX7bQkE8TDugtIOTNUXEM7g+t6fxRKqh8JkpsvMnDXVl4KKPu530zbuCfY1AXaO117WAaDidXbICcGW5k2OPu4ZahuL8GfdVfi2gXbCjVOxAactdYcA2RFRPi2Dhpd7PPJpY6gGT2zlR3Je8aEe/vwea6753UUAoVlPoSMTHlLeWE69w+0RujCHOR0919XPPjSa99HqyYtmBV/37XLqz7WHHZCxO+ObdFz8ehrY7cCDENyUKZ/xQv6+1kNv+ci24xZTuFvCnZj8VHYm/+oAuvrPDzih82OCuKHG+OTMsvjJq5sJ7J8HnIssypb2akY9BrnCTsLRUYnImDJDM3Jmvxc3I2T+MEcbFRNhtt5lJXe9PF89+wPCBfnPhVX7XXd96GgABX4Tv6pI0MxfXOkYJmdIBZKSkNBxlI6slU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199015)(40470700004)(46966006)(36840700001)(426003)(6666004)(47076005)(8936002)(41300700001)(5660300002)(82310400005)(6916009)(83380400001)(86362001)(54906003)(2906002)(36756003)(7696005)(16526019)(336012)(2876002)(316002)(82740400003)(478600001)(36860700001)(26005)(40480700001)(81166007)(40460700003)(1076003)(2616005)(4326008)(8676002)(70586007)(356005)(70206006)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 15:42:10.8423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c8f2468-80e9-49c6-32c7-08dae369ecc6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6348 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Changes to allow reading blocks that greater than 65535 sectors. Signed-off-by: Jiangang He Cc: Hao A Wu Cc: Ray Ni Cc: Garrett Kirkendall Cc: Abner Chang Cc: Kuei-Hung Lin --- MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c b/MdeModulePkg/Bus/U= sb/UsbBotPei/PeiAtapi.c index 422ac5fec99..5111e4579e2 100644 --- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c +++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c @@ -2,6 +2,7 @@ Pei USB ATAPI command implementations. =20 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -382,14 +383,14 @@ PeiUsbRead10 ( ATAPI_PACKET_COMMAND Packet; ATAPI_READ10_CMD *Read10Packet; UINT16 MaxBlock; - UINT16 BlocksRemaining; - UINT16 SectorCount; + UINT32 BlocksRemaining; + UINT32 SectorCount; UINT32 Lba32; UINT32 BlockSize; UINT32 ByteCount; VOID *PtrBuffer; EFI_STATUS Status; - UINT16 TimeOut; + UINT32 TimeOut; =20 // // prepare command packet for the Inquiry Packet Command. @@ -401,16 +402,13 @@ PeiUsbRead10 ( =20 BlockSize =3D (UINT32)PeiBotDevice->Media.BlockSize; =20 - MaxBlock =3D (UINT16)(65535 / BlockSize); - BlocksRemaining =3D (UINT16)NumberOfBlocks; + MaxBlock =3D (UINT16)(MAX_UINT16 / BlockSize); + ASSERT (NumberOfBlocks < MAX_UINT32); + BlocksRemaining =3D (UINT32)NumberOfBlocks; =20 Status =3D EFI_SUCCESS; while (BlocksRemaining > 0) { - if (BlocksRemaining <=3D MaxBlock) { - SectorCount =3D BlocksRemaining; - } else { - SectorCount =3D MaxBlock; - } + SectorCount =3D MIN (BlocksRemaining, MaxBlock); =20 // // fill the Packet data structure @@ -435,7 +433,7 @@ PeiUsbRead10 ( =20 ByteCount =3D SectorCount * BlockSize; =20 - TimeOut =3D (UINT16)(SectorCount * 2000); + TimeOut =3D SectorCount * 2000; =20 // // send command packet @@ -448,16 +446,17 @@ PeiUsbRead10 ( (VOID *)PtrBuffer, ByteCount, EfiUsbDataIn, - TimeOut + (UINT16)MIN (TimeOut, MAX_UINT16) ); =20 if (Status !=3D EFI_SUCCESS) { return Status; } =20 + ASSERT (Lba32 <=3D (MAX_UINT32-SectorCount)); Lba32 +=3D SectorCount; PtrBuffer =3D (UINT8 *)PtrBuffer + SectorCount * BlockSize; - BlocksRemaining =3D (UINT16)(BlocksRemaining - SectorCount); + BlocksRemaining =3D BlocksRemaining - SectorCount; } =20 return Status; --=20 2.37.1.windows.1