From patchwork Tue Aug 30 23:51:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 1114642 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7UNpO29025345 for ; Tue, 30 Aug 2011 23:51:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754014Ab1H3XvW (ORCPT ); Tue, 30 Aug 2011 19:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3024 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986Ab1H3XvT (ORCPT ); Tue, 30 Aug 2011 19:51:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7UNpIoC006851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Aug 2011 19:51:18 -0400 Received: from freedom.local.com (vpn-8-93.rdu.redhat.com [10.11.8.93]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7UNpEeC012690; Tue, 30 Aug 2011 19:51:16 -0400 From: Lucas Meneghel Rodrigues To: kvm@vger.kernel.org Cc: avi@redhat.com, Lucas Meneghel Rodrigues , Anthony Liguori Subject: [PATCH 1/2] kvm-unit-tests: add x86 port io accessors Date: Tue, 30 Aug 2011 20:51:04 -0300 Message-Id: <1314748265-15488-2-git-send-email-lmr@redhat.com> In-Reply-To: <1314748265-15488-1-git-send-email-lmr@redhat.com> References: <1314748265-15488-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 30 Aug 2011 23:51:27 +0000 (UTC) Signed-off-by: Anthony Liguori --- lib/x86/io.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) create mode 100644 lib/x86/io.h diff --git a/lib/x86/io.h b/lib/x86/io.h new file mode 100644 index 0000000..bd6341c --- /dev/null +++ b/lib/x86/io.h @@ -0,0 +1,40 @@ +#ifndef IO_H +#define IO_H + +static inline unsigned char inb(unsigned short port) +{ + unsigned char value; + asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port)); + return value; +} + +static inline unsigned short inw(unsigned short port) +{ + unsigned short value; + asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port)); + return value; +} + +static inline unsigned int inl(unsigned short port) +{ + unsigned int value; + asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port)); + return value; +} + +static inline void outb(unsigned char value, unsigned short port) +{ + asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port)); +} + +static inline void outw(unsigned short value, unsigned short port) +{ + asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port)); +} + +static inline void outl(unsigned int value, unsigned short port) +{ + asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port)); +} + +#endif