From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:400c:c09::234; helo=mail-wm0-x234.google.com; envelope-from=pete@akeo.ie; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2B41B22152380 for ; Mon, 4 Dec 2017 05:07:46 -0800 (PST) Received: by mail-wm0-x234.google.com with SMTP id g75so5741357wme.0 for ; Mon, 04 Dec 2017 05:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=FJtmqmt+hVhV+Ci1wr4M8yiOrAXegcP8vEyddby1754=; b=p4wIFSaP/NBITzxQ3YR2ix08X7/7yY1ILhIOB3K38HPegwE0RWq3Cb4+KqoXsP0SbI PbH944q5ZBENspW+dMv/yRzCu7bUYhJ3FW0P8t6kH2ezGa1LrKUqKKZ8UHbvj/wADADg amN1IqTu2cZRaPQ4+3jkodmt9vKc6Uz21IQTaNS9qloZMvtiopbPiL33BOk+F2FF3CLZ op8sw3bJAkhoSkb0DPt2+Cllv7dvA+I/N1ZEa/ktXp9aFgcF8jnQxwsNBcGnL/uM3ZdJ mGGpFx6HxrvkEZDCUNf+OPBxs8djatd/jxq+f+zGIwAECC7nmY85rj4PkhaWiVKNOezz GyGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FJtmqmt+hVhV+Ci1wr4M8yiOrAXegcP8vEyddby1754=; b=i3Fjipds/fAFcOfdFOTe9x1HHqoG37SYvOVcSQUTN3LVjtF6aKQHa2Gp4UgqZNe6+j 82cQ3wigeAC03cxzn1Y7xA+G0GqZLrh/vnNUZyze0Oh9M32oyGdhqs1qZQ4VtS1e1PQQ Kq8UWTUayx6jo3j7pMAdq/4/y+fEdBA0T64LjmGSkMuWUsBse7NWaBiYeRP80vHprpDt A2dUybWDSotllsQ6ku+Ua/1h/KjajRj0tq90+GvncSki2ZuPfxUGIWRAvY1GZ4m3dKGr WdcTPRdfkSUrcuPYY2FDlaOSfmLQbEC3Oz9FavtsajmDXzl8SatNbrtPfJkoFi6RWhXC QO0Q== X-Gm-Message-State: AJaThX7vpEeAfuTtoJnWw+sd7DnySUFQF7K19W77jy3E/iIzAD5ZRqov Gi+j8RWCxY/4BU2Znwv/pm8GYF+LXH8= X-Google-Smtp-Source: AGs4zMYFGJh6ZPl6sL9DI5oyIB7ADawFr9pDyc0LVRZEJ4/A8UrRxzCHvfsLi1KY7YEzBF64O1PmnQ== X-Received: by 10.80.154.35 with SMTP id o32mr30054506edb.125.1512393134781; Mon, 04 Dec 2017 05:12:14 -0800 (PST) Received: from localhost.localdomain ([84.203.42.156]) by smtp.gmail.com with ESMTPSA id y3sm7936797edb.37.2017.12.04.05.12.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 05:12:14 -0800 (PST) From: Pete Batard To: edk2-devel@lists.01.org Cc: liming.gao@intel.com Date: Mon, 4 Dec 2017 13:11:59 +0000 Message-Id: <20171204131205.11304-1-pete@akeo.ie> X-Mailer: git-send-email 2.9.3.windows.2 Subject: [PATCH 0/6] Add ARM support for VS2017 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 13:07:47 -0000 The following series adds ARM compilation support for the VS2017 toolchain. * PATCH 1 targets the disabling of VS Level 4 warnings. The warnings we chose to remove are the ones that were seen generated more than 5 times, during the compilation of a QEMU firmware. * PATCH 2 adds a NULL handler for the base stack check, since this is a GCC functionality. * PATCH 3 updates MdePkg/Library/BaseLib so that the RVCT assembly sources are also used for MSFT. * PATCH 4 adds the required compiler intrinsics replacements for division, shift and memset/memcpy. * PATCH 5 adds variable argument handlers for print output. Note that this is done without relying on any external headers, with the VA_ARG macro having been reverse engineered from MSFT ARM assembly output. * PATCH 6 enables the selection of ARM in the conf templates. With these patches, VS2017 toolchain users should be able to compile regular UEFI ARM applications using EDK2. Note that, unlike ARM64 support, ARM support does not require a specific update of Visual Studio 2017, as the ARM toolchain has been available from the very first release. Additional notes: With an additional patch [1], it is also possible to use this proposal to compile a complete QEMU ARM firmware. As the patch shows, the changes that need to be applied to the EDK2 sources to achive this are actually very minimal. However, the generated firmware does not currently boot, possibly because of the following warnings being generated by the MS compiler: - ArmCpuDxe.dll : warning LNK4072: section count 118 exceeds max (96); image may not run - UiApp.dll : warning LNK4072: section count 113 exceeds max (96); image may not run As far as I could see, the section count max is hardcoded so a workaround would be needed to address those. Also, because the VS2017 ARM compiler forces a section alignment of 4096 bytes (which in turn forces use to use /FILEALIGN:4096 as a linker option for the firmware generation), the generated firmware exceeds 2MB and we had to double its size to 4MB. You can find a full github repo, including this series and the additional QEMU compilation patch at [2]. At this stage, since the goal of this series is to allow users to compile regular ARM UEFI applications using the VS2017 toolchain, I have non plans to spend more time on the QEMU firmware issues, especially as I suspect that reducing the firmware size back to 2 MB may not be achievable without Microsoft altering their compiler. I am however hopeful that ARM specialists can take this matter over eventually... Regards, /Pete [1] https://github.com/pbatard/edk2/commit/c4ce41094a46f4f3dc7ccc64a90604813f037b13 [2] https://github.com/pbatard/edk2/tree/vs2017_arm Pete Batard (6): MdePkg: Disable some Level 4 warnings for VS2017/ARM MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM MdePkg/Library/BaseLib: Enable VS2017/ARM builds ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds MdePkg/Include: Add VA list support for VS2017/ARM BaseTools/Conf: Add VS2017/ARM support ArmPkg/Library/CompilerIntrinsicsLib/Arm/rtdiv.asm | 255 ++++++++++++++++++++ ArmPkg/Library/CompilerIntrinsicsLib/Arm/rtsrsh.asm | 45 ++++ ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 13 +- ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34 +++ ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33 +++ BaseTools/Conf/build_rule.template | 30 +++ BaseTools/Conf/tools_def.template | 28 +++ MdePkg/Include/Arm/ProcessorBind.h | 96 ++++++-- MdePkg/Include/Base.h | 13 + MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm | 5 +- MdePkg/Library/BaseLib/BaseLib.inf | 19 +- MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf | 5 +- MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c | 18 ++ 13 files changed, 565 insertions(+), 29 deletions(-) create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/Arm/rtdiv.asm create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/Arm/rtsrsh.asm create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c create mode 100644 MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c -- 2.9.3.windows.2