From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4a::61f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D4E0281B0D for ; Mon, 9 Jan 2017 16:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Z+ydKwM4oL+HTEfOI1Xqx7y2Jb7juA4gz6j3bDzaPkY=; b=NtuYcSFhIfB8ih7NwQx9B1JCrSFL+jbpxwuQsgOSxCBziyN/+P7SxfYmXPcjK5lxOMDneNl6EuFj4q9g3Ll/1dQy1yw6rpz0gcqplhjXGTGsKZaPOKCalk/OYG5nCvHeQkXKakIoPz2kcoAU4BEY5u4uxvavK9GpYUy9yLgTyHo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by BN6PR12MB1234.namprd12.prod.outlook.com (10.168.227.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Tue, 10 Jan 2017 00:17:23 +0000 From: Leo Duran To: CC: , , , , , , , , Leo Duran Date: Mon, 9 Jan 2017 18:17:01 -0600 Message-ID: <1484007421-15462-7-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484007421-15462-1-git-send-email-leo.duran@amd.com> References: <1484007421-15462-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR19CA0004.namprd19.prod.outlook.com (10.175.226.142) To BN6PR12MB1234.namprd12.prod.outlook.com (10.168.227.20) X-MS-Office365-Filtering-Correlation-Id: c7e4c4e9-3557-47fa-44b3-08d438ee0cf3 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR12MB1234; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 3:STIptMEb1VR1L1rqASahTGbW/WOdItq0yiPzlPV6vqCK6+qyqEoeLMhMPhE+viHuHFZoihvZDwsGlKOVM5mgjnztQJukBb+ZRo4MAvqOkahJQGObPf/yoskdDdMmEJjanehTEFwQGhl9r2Mtp5/FSTmjfZWlIHmbdzvsmNCFffo/c07ma19JRGfegJ83aiCrR1NadhLQ68MlVHl/3GCgXoVon+wifS0gG/BH6mKKaM491YXbjpdR9Hsot9OJQXEIK27zyG4wbcQMRUHXcR4g3w== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 25:wJtOCEzAZIw/maTeTvBCMLXKP28hqaMYjekBn9MFLXTGtmo3PKnkmo/O1mw+sMMpb/+WWw7PFkiTW/pdAGs00ikBOFQzB44HyLEEIc6iKyHpOELaHb+00KwSodIQvSZ9kx59/ao4i6Ta3E7x1IuAuM1VysW0+2enhTWPTsC1w3KeI67gPJ3kewQzSJgA1rrKKpgN3onmE1d+FtwRqd//of4SzCEhqEPWOg5gdDlbjdEh+8CxqIPRSZBcR7rxA7wNfBquT5nSToQDDQL4id+PuGnKFKjaDD7c0jYLUyR4IbjyMX5xLW5TZ2qMZRPxwe8JFwWv+vxREagwGwrIa+5fHSTu8quc96ZLHqt8E2FRp7Bpodrr7m4StpS0OAwqU0dr8Eo9K2gyy+kPbY8AkEKSrrdxIN1kwx51ryhu8Gx+eqD281izHflQIXvOVtpaKSCVCnHWTTxi/gI48BXQRoVz6KCOCgLojdv069HvcKBWwav6/BgNNpJD/PxyfxXnQafRzZXPbffBCIZK1g29CnNjYTk6oMGZxuiVaYykMDvwLiw3W2TosAkEaE7mRFkEJeB+Vs9qKUQlWlTq7yCYm+R+EQUD7ppP80x8I0CngsdY4/APxEB8NO25F7Trqr5yo8Xs0q21OEhDwog/roaEFGyccdLsAVSxKFOhki17YW6qtm2RWY3rB/OCaAkl2KkzfSfHGMq6SDJMjlf5WQCauTSsu80YGnujE2eCYSZR+I8WcoeCPZbfx053Ox3tK+hZt9VLoC2u0e0wF0nxFfKi4xcTYw== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 31:adGidjNpVE7VeskKPPp9HonaZ/GIobpYIHkI9xvQPMjgXaQXrlfXknH31VeyA0xW/LpB6rD4asmVzg7eCQ0YvEg2e/W68CsGWEHcNIDSmZ0WyvSipi21GLmNWfkaLhdxGuF9DS4n3tb2egs9v2V7Pt7fNF1UBCv7Qx8Y2GxIIKC9JYREfixEd7nhXXSd2wxxtQi/jDcYUY2wc+MU8LX/yvUxW5gaaz6Jkf/bWtdsR3/KMnCX64XlAks/JZC9TRFajpA9den5GoLXIYkOIxm7jw==; 20:9ZXyUBE7FeGafMpV2hLqsLyDSNE8pw4c5QovTfp9mSpDU6nJjq6wZpII2jHjlBl4EFsMDB1XHmEWs1zB1co83ZRO3SH5BYX69UA1LNVI1ltZmGGztdI8huF6TTDysC51uCaNzHkFs1YijmpUOvyV5u6L51NAthZ5XhZDoZLq5Ur4y9tIbXiPSDJeGMa3veZQefeewR1HhA3mY/YGpMqqMoDYHBhgsf1lxKnIAUH1K+0V2M1AdMVYqimPTqY9qaIKY3ZRlS/MwCuDSO9Y2VfhPhpvq5FXgYSao9M6G3q6J4mDhHFEFMBKbHbXifDEUAwO6p6FEz8Ix4AYMEXhml2zyyRii6h20yCJ0d+hjqpND/RAYyl9NwvfF4Hqsczr8e0VD1S7OhHtgjsMakV+5i8zEaey7oPqKS9VZ1DDcPOme2opqKycVhZZ/JCeJmwn3kdAZmD2yriQRXxn6Kiu6sppCI/VvmW7zxgoHoujSlG98jd/qSKeUipchvWkg0li0S5M X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:BN6PR12MB1234; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1234; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 4:10M1JkK+ueM02B3H2ZsGu+/Bsbebp346A1htM0lf9fIsbAm748K8VANc4U8Pm3UcHYCZR41NFhkk7589ITHmkp7WlerS+Nycbtoqv0pfk+oQSwDQ3PJX/GNLr6EHd2OqATpBV3TmLU/uPMKZyTUhaqHhXzRJfr52rMj0qENMdFyENL0ZsYCdjuEZMPbos72yoSXwblQk1ZuSpq7jtLWGm1GufRzc4J+dJmFg/nwe8OTjk1v21EI1yqW2cTvWs2mUiotuwhSUzoZeclQznsC7fntxuvJkfzImVHl3zUDJLkMyae8CXPXhxKiO2/pGJowaF147Zw6uT9Y+i2Ku/4Jm88XDrJruk91PrVzVkPcj1eGNxamwdCIgsge/dTA+owCgcqLj0PuICJkGudgWpPV7U7IViCX96K3xS+MSJ/xSRD9zLeLFSkpEZkmyddBe/bs3AoevdN4geAzmJX84dc6cuLoWYazjiKq57ZY6HliTQwmWUoJLkZopEIllbtFOjQyogrN3Cb+viv7IAXP5oaxU3/BcGaFE0OxSpYtwLEfE+ldt7FufbJ01R5P+Vd7iP9gqrGYCQ5vr7JN6cVCI8lXDkr1xXouqluiexNCxpVwukl84u1eRA9b1q8y/CW9gZ2KnCEQ3EpAmd2F6LoG8EiuX7fv75NStF1kt6B7i9z7B1aQ= X-Forefront-PRVS: 01834E39B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6029001)(6009001)(7916002)(39860400002)(39850400002)(39450400003)(39840400002)(39410400002)(189002)(199003)(4326007)(50986999)(47776003)(42186005)(50226002)(53416004)(66066001)(106356001)(105586002)(2351001)(5660300001)(33646002)(25786008)(54906002)(5003940100001)(97736004)(50466002)(110136003)(81166006)(2950100002)(92566002)(38730400001)(6486002)(48376002)(6666003)(8676002)(81156014)(6916009)(36756003)(6116002)(68736007)(189998001)(101416001)(2906002)(3846002)(76176999)(7736002)(86362001)(305945005)(19627235001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1234; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1234; 23:Xc3ZuobsE1RxlwBdf51LfFgpqpvBe47PnnCq/nJjY?= =?us-ascii?Q?G/z5W0bet3+WDfnaaFflzy5baBG8Kwt0Xo0XjKx25/LIlpVHdqdA6mvZN5qx?= =?us-ascii?Q?VLrFGh/V66GdlM/2vQ3pRkI4+C73mZiecrbiutPrAYFjH0Db6gH25FSSuOY4?= =?us-ascii?Q?W6xNPm81SSEXsR2Vv84RnMOBFAlhCpGNtf09LDmcLahKqF5UuQ1oDbL9O+OZ?= =?us-ascii?Q?QnXWCu5Q37fuLefJTx6pWzBsr+MPkQn6JcRhhzaGhUWzsaJHizjyFMl8YZIh?= =?us-ascii?Q?wZ400iZM8eTyrBhfSfbG+gV+xi+zQiGZMb3LKPE/stOrld0yaPGMUp3JHg9k?= =?us-ascii?Q?VcEyoU1cqZfDDNYItVzZNEkzHpHV/4kNxgGrq9B8Mo6kC2tYlH/fmlZynbMz?= =?us-ascii?Q?+AYI8qU7xo0wsnnmoBnBy4gNibHybY9V2zFhOF9GMYHpztY2fsjQDUHuJOtE?= =?us-ascii?Q?nX9sN8QTksO7Q7ML8LmHKPdGiSVZJCB57buVo6W5Z6mD5fMvh66085kKTFnV?= =?us-ascii?Q?djUbnJlwgpe6CSo+/BwfLLOHBKTiq7lQip2Z2iCu7gmgjpPTqpdMTugMfWtu?= =?us-ascii?Q?ygn0PKXY20q6bcRj+MaB8f/b0r8TXpGHe0Xx+dY/7FqX0btMd4VbY+EdMp7t?= =?us-ascii?Q?UhrlGlVlWzLcbFzIkKJbYST8adM9Y7mTz8ze+Ra04UA602hroUO1s5MGNQDT?= =?us-ascii?Q?anCZubHemK4UK05HyYVk8kFJdCjPNX0t7Y1rE9Ln+mX0Cq6cj1C74cCoxNjk?= =?us-ascii?Q?ENNDHBWXyG4/kiNXY1vQteeedqIWCaEGFdT3UZVzHPLuDWee5wiQd6JoH6u0?= =?us-ascii?Q?ZqHtYaSMNyAdfyScgM0h5Gf2F2fHmuun1G5Ch2G/SqHjEVPqa1BvRGQ4uHyA?= =?us-ascii?Q?n0XilPEmyuFgSB6xQpfXulEZPOF7LITMBGC5stX9300TU6Hw7JOOmV+jDC+j?= =?us-ascii?Q?n5HP4R52QjCF3ElgznrZYmQf+qyzZ42KqES93IW7klsPOWyh/k5r8Eeh2ns0?= =?us-ascii?Q?B1nxBhU3IlGOqHYztTSw2VRI76kj3kOWBb93xijP41ZkJigXF7SO21J5LycZ?= =?us-ascii?Q?NIe6WtV1MQkZHsed603EyXwP54nmxO4E65unFDH0h+UlLaJ94Z+JLbEe0ISh?= =?us-ascii?Q?55Tf/PAtOJPbnL2Pf8HNlkMBTCCvQzNBD+/DIjIC/LLileoz1jRE5oDUEVME?= =?us-ascii?Q?fb8JOehEN+/shqpgUbdMAM+4PYro9MnDtvMr1Z1XOYgXYF7OiNCSMYNp+U5i?= =?us-ascii?Q?aQ+h870WS63WwmpXYk99JGXgSby6rySanr4CP29kiNDijuPAMxIDUVMA2D+q?= =?us-ascii?Q?60F+OVft5IAAifr45cdsoDCRFgIHq5cw/Gtflskm3nqilnWsipP+TMDQ8UKS?= =?us-ascii?Q?xSlJw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 6:FljJodhwS2DetsLEG5gzt77rKAJJK1Hdvomd5sl041Nb7LtnkyjOlfyJcZRlrfgG45fNKXksWFgkwYU9Sm4t0Fln+OGmx86MoFVmfv43Eye1wTm9fF79SEi1nWTPNstoq4uZXMMyLmai6o89BOl8gPfZOhnblqOHv6z3ElnVPLQ3qLha2LzCY0QB/TXIzXpNb9usXs1ryzURPuwt3CPZ+eNFKL/Nu8QBFwhZKgyhwI6QFflfMaPm325B5I5BTiTd09vol/PgRUAbBn5+8eh7KpxwU5vkfFtCxYnLkh0WJWuxQqcKGazE7FsdxQmc4AVzdosyuYjGbp2ttRjDndDUv9+lwR92lsymTjZyBBji03fpS14w/qAAteF2CL/yY7T8gROp9lcVBINvjOC8TNqyvyicxNGCrSE9nQIqUlJqD/U35zRcdJUmQwT/1gMCDRMBRbkrmdGTywLaiLrqH+s6YQ==; 5:d4XC8YvNLg78hIxfXPMbI5VSuny9FhAqbS1iW9ycEEeVb1FyAuaKunNMlNLR1zmyU02jyJ5IsxnlphYv83bRvg3UfsU+YvBXRJ0oB0FgJ/XHD63Lp/t+w5gVD62PZgSHNyNCEUrCEPncXHIE1bCm5ipXk8RRL+wlL2yL8PfZjXA=; 24:j7ft0a7xcCe/OBb3OVaaOvejh8c4BEqmVKbRh7iNSN8PNye8Gh0wXE763FeoUERZJjw2AHCQI6ZOkq+/mTTEgcI7YSJpNDYsU3kfMGlc5qw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1234; 7:r6D4f6bBCRLdBTJHhwcCrl+dUkmRCMEiRGY5WG8695PTpUVVoilATCRnNLbIdUXbQlE1/Ik6+ugtwJBlwq/l93WJfShQFH1n3MQE31dsvFv+ZJ79FTH+BY91Xde8g+Lzkdxp8kaDS7Q4vWv6WH/Z2VNx33e1Sdy2/jvTvXLL3u/c3zqYMoJL7eq7h9iFDelgkwICwju2EyaazKUaJFFbv5KRMyubCR3gtUFLAoBhNfKqg0TEIoPXDwdBwF1NrbG+G92jWNDbsB1q00AWu6hS04G2dJiTktDQiBITST/aQ+XQNLpfkJnTKeHz18jMQoSR5o/FoiD8oiVKjRnZWPkFg1JBWF/4IDIRDZo3XqW0BJwfBNtJhLh4QKanpq+8PdO1R8Pvc/MEzDGu+6ouR4nDeqRXX+WPBLCxJia/pJOIw/lQ+ab3BEqY6Ia5WjMVBx06Y3J88Wnmu+LrSxgZ3n24bg==; 20:wGRet70D5Uemo15TnVisMf2nmVc3Gk5JTu8pai8sM1nTOz2kMI/q7Fi8Fi8Gq7FjI9socUA5k3b7MPCO7ZMw20wpc5e9vIffwe9k/wkRt9NkNnI++U8AeB7ineeicd9RrHmmrmAZ5vhERZgPakE/TtrwlcL4n3gAmrFxIdjzi0UzKsjBnAPlobfAXvA6arfgZwOsG9MJRyVrruwtieni50tMdXw2262MXEEtgIgqXA0jJMUNS2uci5m4hezigbzb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2017 00:17:23.0028 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1234 Subject: [RFC 6/6] MdeModulePkg: Modify PciHostBridgeDxe to use new BmDmaLib library. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2017 00:17:25 -0000 Content-Type: text/plain Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran --- .../Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf | 1 + .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h | 13 +- .../Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 272 +++++---------------- MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 67 insertions(+), 220 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf index d8b0439..35bb5c4 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf @@ -42,6 +42,7 @@ [LibraryClasses] BaseLib PciSegmentLib PciHostBridgeLib + BmDmaLib [Protocols] gEfiMetronomeArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h index 13185b4..c125fcd 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h @@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include "PciHostResource.h" @@ -43,17 +44,6 @@ typedef enum { PciOperation } OPERATION_TYPE; -#define MAP_INFO_SIGNATURE SIGNATURE_32 ('_', 'm', 'a', 'p') -typedef struct { - UINT32 Signature; - LIST_ENTRY Link; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation; - UINTN NumberOfBytes; - UINTN NumberOfPages; - EFI_PHYSICAL_ADDRESS HostAddress; - EFI_PHYSICAL_ADDRESS MappedHostAddress; -} MAP_INFO; -#define MAP_INFO_FROM_LINK(a) CR (a, MAP_INFO, Link, MAP_INFO_SIGNATURE) #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('_', 'p', 'r', 'b') @@ -79,7 +69,6 @@ typedef struct { EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL RootBridgeIo; BOOLEAN ResourceSubmitted; - LIST_ENTRY Maps; } PCI_ROOT_BRIDGE_INSTANCE; #define ROOT_BRIDGE_FROM_THIS(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, RootBridgeIo, PCI_ROOT_BRIDGE_SIGNATURE) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index 8af131b..8a74bf6 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "PciRootBridge.h" #include "PciHostResource.h" -#define NO_MAPPING (VOID *) (UINTN) -1 // // Lookup table for increment values based on transfer widths @@ -55,6 +54,39 @@ UINT8 mOutStride[] = { 0 // EfiPciWidthFillUint64 }; + +BM_DMA_OPERATION +ConvertDmaOperation ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION RbOperation + ) +{ + BM_DMA_OPERATION BmOperation; + + switch (RbOperation) { + case EfiPciOperationBusMasterRead: + case EfiPciOperationBusMasterRead64: + BmOperation = DmaOperationBusMasterRead; + break; + + case EfiPciOperationBusMasterWrite: + case EfiPciOperationBusMasterWrite64: + BmOperation = DmaOperationBusMasterWrite; + break; + + case EfiPciOperationBusMasterCommonBuffer: + case EfiPciOperationBusMasterCommonBuffer64: + BmOperation = DmaOperationBusMasterCommonBuffer; + break; + + default: + BmOperation = DmaOperationBusMasterMaximum; + break; + } + + return BmOperation; +} + + /** Construct the Pci Root Bridge instance. @@ -168,7 +200,6 @@ CreateRootBridge ( TypeMax * sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) ); ASSERT (RootBridge->ConfigBuffer != NULL); - InitializeListHead (&RootBridge->Maps); CopyMem (&RootBridge->Bus, &Bridge->Bus, sizeof (PCI_ROOT_BRIDGE_APERTURE)); CopyMem (&RootBridge->Io, &Bridge->Io, sizeof (PCI_ROOT_BRIDGE_APERTURE)); @@ -1053,118 +1084,27 @@ RootBridgeIoMap ( OUT VOID **Mapping ) { - EFI_STATUS Status; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - EFI_PHYSICAL_ADDRESS PhysicalAddress; - MAP_INFO *MapInfo; - - if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL || - Mapping == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure that Operation is valid - // - if ((UINT32) Operation >= EfiPciOperationMaximum) { - return EFI_INVALID_PARAMETER; - } + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + BOOLEAN DmaAbove4GB; + BM_DMA_OPERATION BmOperation; RootBridge = ROOT_BRIDGE_FROM_THIS (This); - - PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; - if ((!RootBridge->DmaAbove4G || - (Operation != EfiPciOperationBusMasterRead64 && - Operation != EfiPciOperationBusMasterWrite64 && - Operation != EfiPciOperationBusMasterCommonBuffer64)) && - ((PhysicalAddress + *NumberOfBytes) > SIZE_4GB)) { - - // - // If the root bridge or the device cannot handle performing DMA above - // 4GB but any part of the DMA transfer being mapped is above 4GB, then - // map the DMA transfer to a buffer below 4GB. - // - - if (Operation == EfiPciOperationBusMasterCommonBuffer || - Operation == EfiPciOperationBusMasterCommonBuffer64) { - // - // Common Buffer operations can not be remapped. If the common buffer - // if above 4GB, then it is not possible to generate a mapping, so return - // an error. - // - return EFI_UNSUPPORTED; - } - - // - // Allocate a MAP_INFO structure to remember the mapping when Unmap() is - // called later. - // - MapInfo = AllocatePool (sizeof (MAP_INFO)); - if (MapInfo == NULL) { - *NumberOfBytes = 0; - return EFI_OUT_OF_RESOURCES; - } - - // - // Initialize the MAP_INFO structure - // - MapInfo->Signature = MAP_INFO_SIGNATURE; - MapInfo->Operation = Operation; - MapInfo->NumberOfBytes = *NumberOfBytes; - MapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes); - MapInfo->HostAddress = PhysicalAddress; - MapInfo->MappedHostAddress = SIZE_4GB - 1; - - // - // Allocate a buffer below 4GB to map the transfer to. - // - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiBootServicesData, - MapInfo->NumberOfPages, - &MapInfo->MappedHostAddress - ); - if (EFI_ERROR (Status)) { - FreePool (MapInfo); - *NumberOfBytes = 0; - return Status; - } - - // - // If this is a read operation from the Bus Master's point of view, - // then copy the contents of the real buffer into the mapped buffer - // so the Bus Master can read the contents of the real buffer. - // - if (Operation == EfiPciOperationBusMasterRead || - Operation == EfiPciOperationBusMasterRead64) { - CopyMem ( - (VOID *) (UINTN) MapInfo->MappedHostAddress, - (VOID *) (UINTN) MapInfo->HostAddress, - MapInfo->NumberOfBytes - ); - } - - InsertTailList (&RootBridge->Maps, &MapInfo->Link); - - // - // The DeviceAddress is the address of the maped buffer below 4GB - // - *DeviceAddress = MapInfo->MappedHostAddress; - // - // Return a pointer to the MAP_INFO structure in Mapping - // - *Mapping = MapInfo; - } else { - // - // If the root bridge CAN handle performing DMA above 4GB or - // the transfer is below 4GB, so the DeviceAddress is simply the - // HostAddress - // - *DeviceAddress = PhysicalAddress; - *Mapping = NO_MAPPING; - } - - return EFI_SUCCESS; + DmaAbove4GB = RootBridge->DmaAbove4G && ( + Operation == EfiPciOperationBusMasterRead64 || + Operation == EfiPciOperationBusMasterWrite64 || + Operation == EfiPciOperationBusMasterCommonBuffer64 + ); + + BmOperation = ConvertDmaOperation (Operation); + + return BmDmaMap ( + DmaAbove4GB, + BmOperation, + HostAddress, + NumberOfBytes, + DeviceAddress, + Mapping + ); } /** @@ -1191,58 +1131,7 @@ RootBridgeIoUnmap ( IN VOID *Mapping ) { - MAP_INFO *MapInfo; - LIST_ENTRY *Link; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - - RootBridge = ROOT_BRIDGE_FROM_THIS (This); - // - // See if the Map() operation associated with this Unmap() required a mapping - // buffer. If a mapping buffer was not required, then this function simply - // returns EFI_SUCCESS. - // - if (Mapping == NO_MAPPING) { - return EFI_SUCCESS; - } - - MapInfo = NO_MAPPING; - for (Link = GetFirstNode (&RootBridge->Maps) - ; !IsNull (&RootBridge->Maps, Link) - ; Link = GetNextNode (&RootBridge->Maps, Link) - ) { - MapInfo = MAP_INFO_FROM_LINK (Link); - if (MapInfo == Mapping) { - break; - } - } - // - // Mapping is not a valid value returned by Map() - // - if (MapInfo != Mapping) { - return EFI_INVALID_PARAMETER; - } - RemoveEntryList (&MapInfo->Link); - - // - // If this is a write operation from the Bus Master's point of view, - // then copy the contents of the mapped buffer into the real buffer - // so the processor can read the contents of the real buffer. - // - if (MapInfo->Operation == EfiPciOperationBusMasterWrite || - MapInfo->Operation == EfiPciOperationBusMasterWrite64) { - CopyMem ( - (VOID *) (UINTN) MapInfo->HostAddress, - (VOID *) (UINTN) MapInfo->MappedHostAddress, - MapInfo->NumberOfBytes - ); - } - - // - // Free the mapped buffer and the MAP_INFO structure. - // - gBS->FreePages (MapInfo->MappedHostAddress, MapInfo->NumberOfPages); - FreePool (Mapping); - return EFI_SUCCESS; + return BmDmaUnmap (Mapping); } /** @@ -1282,56 +1171,23 @@ RootBridgeIoAllocateBuffer ( IN UINT64 Attributes ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS PhysicalAddress; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - EFI_ALLOCATE_TYPE AllocateType; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + BOOLEAN DmaAbove4GB; - // - // Validate Attributes - // if ((Attributes & EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) != 0) { return EFI_UNSUPPORTED; } - // - // Check for invalid inputs - // - if (HostAddress == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // The only valid memory types are EfiBootServicesData and - // EfiRuntimeServicesData - // - if (MemoryType != EfiBootServicesData && - MemoryType != EfiRuntimeServicesData) { - return EFI_INVALID_PARAMETER; - } - RootBridge = ROOT_BRIDGE_FROM_THIS (This); + DmaAbove4GB = RootBridge->DmaAbove4G && + (Attributes & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) != 0; - AllocateType = AllocateAnyPages; - if (!RootBridge->DmaAbove4G || - (Attributes & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) == 0) { - // - // Limit allocations to memory below 4GB - // - AllocateType = AllocateMaxAddress; - PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1); - } - Status = gBS->AllocatePages ( - AllocateType, - MemoryType, - Pages, - &PhysicalAddress - ); - if (!EFI_ERROR (Status)) { - *HostAddress = (VOID *) (UINTN) PhysicalAddress; - } - - return Status; + return BmDmaAllocateBuffer ( + DmaAbove4GB, + MemoryType, + Pages, + HostAddress + ); } /** @@ -1356,7 +1212,7 @@ RootBridgeIoFreeBuffer ( OUT VOID *HostAddress ) { - return gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress, Pages); + return BmDmaFreeBuffer (Pages, HostAddress); } /** diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b343c19..47aa9b9 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -83,6 +83,7 @@ [LibraryClasses] PalLib|MdePkg/Library/BasePalLibNull/BasePalLibNull.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf + BmDmaLib|MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf # # Misc # -- 1.9.1