From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbeANOdB (ORCPT + 1 other); Sun, 14 Jan 2018 09:33:01 -0500 Received: from mga12.intel.com ([192.55.52.136]:3700 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbeANOc6 (ORCPT ); Sun, 14 Jan 2018 09:32:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,359,1511856000"; d="scan'208";a="19394692" From: Andy Shevchenko To: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/6] x86/boot: Add MMIO byte accessors Date: Sun, 14 Jan 2018 16:32:51 +0200 Message-Id: <20180114143254.15429-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180114143254.15429-1-andriy.shevchenko@linux.intel.com> References: <20180114143254.15429-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: readb() and writeb() would help to access serial device via MMIO address space. Signed-off-by: Andy Shevchenko --- arch/x86/boot/boot.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index 7e6ac187275c..09f6829f2778 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h @@ -79,6 +79,18 @@ static inline void io_delay(void) asm volatile("outb %%al,%0" : : "dN" (DELAY_PORT)); } +static inline u8 readb(const volatile void __iomem *addr) +{ + u8 v; + asm volatile("movb %1,%0" : "=q" (v) : "m" (*(volatile u8 __force *)addr)); + return v; +} + +static inline void writeb(u8 v, volatile void __iomem *addr) +{ + asm volatile("movb %0,%1" : : "q" (v), "m" (*(volatile u8 __force *)addr)); +} + /* These functions are used to reference data in other segments. */ static inline u16 ds(void) -- 2.15.1