From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5FDE021DFA7AF for ; Wed, 5 Apr 2017 02:37:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5BB161D2F; Wed, 5 Apr 2017 09:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5BB161D2F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5BB161D2F Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-13.phx2.redhat.com [10.3.116.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id B440477E42; Wed, 5 Apr 2017 09:37:25 +0000 (UTC) To: Phil Dennis-Jordan References: <1491173097-37305-1-git-send-email-lists@philjordan.eu> <1491173097-37305-3-git-send-email-lists@philjordan.eu> <13cff49c-1034-eca5-5ad1-7d3d4e8bc6d7@redhat.com> Cc: edk2-devel-01 , Jordan Justen , Phil Dennis-Jordan From: Laszlo Ersek Message-ID: <183d7d9c-54e6-ace3-203c-950c0f08454e@redhat.com> Date: Wed, 5 Apr 2017 11:37:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 05 Apr 2017 09:37:26 +0000 (UTC) Subject: Re: [PATCH v2 2/3] OvmfPkg/QemuVideoDxe: Helper functions for unaligned port I/O. 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: Wed, 05 Apr 2017 09:37:27 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 04/05/17 11:16, Phil Dennis-Jordan wrote: > On Tue, Apr 4, 2017 at 8:19 PM, Laszlo Ersek wrote: >> On 04/03/17 00:44, Phil Dennis-Jordan wrote: >>> +/** >>> + Performs a 32-bit write to the specified, possibly unaligned I/O-type address. >>> + >>> + Writes the 32-bit I/O port specified by Port with the value specified by Value >>> + and returns Value. This function must guarantee that all I/O read and write >>> + operations are serialized. >>> + >>> + If 32-bit unaligned I/O port operations are not supported, then ASSERT(). >>> + >>> + @param[in] Port I/O port address >>> + @param[in] Value 32-bit word to write >>> + >>> + @return The value written to the I/O port. >>> + >>> +**/ >>> +UINT32 >>> +UnalignedIoWrite32 ( >>> + IN UINTN Port, >>> + IN UINT32 Value >>> + ) >>> +{ >>> + __asm__ __volatile__ ( "outl %0, %1" : : "a"(Value), "Nd"((UINT16)Port) ); >> >> Please insert a space after each second quote character: >> >> "a" (Value) >> >> "Nd" ((UINT16)Port) >> >> Also, a question: what does the N character (constraint?) do in the >> input operand specification? I tried to check the gcc inline assembly >> docs at , and I >> couldn't find it. Thanks. > > The N constraint is x86-specific and indicates an 8-bit unsigned > immediate value can be used as the operand. This enables emitting the > OUT imm8, EAX > instruction variant, see > https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html > In practice, this is most likely not going to happen here, even if > link time optimisation happens to inline the call, as the port number > isn't hardcoded. I can remove it if you like. Either a comment or removal would be fine, I think. I feel slightly more attracted to removal because the "N" diverges from IoWrite32() in "MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c", and that difference seems to deserve justification. Thanks Laszlo