From patchwork Mon Oct 18 03:17:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 68109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9D16B70EF for ; Mon, 18 Oct 2010 14:41:16 +1100 (EST) Received: from localhost ([127.0.0.1]:44861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7gao-00048P-Ti for incoming@patchwork.ozlabs.org; Sun, 17 Oct 2010 23:40:58 -0400 Received: from [140.186.70.92] (port=51840 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7gEh-0002Yg-Fy for qemu-devel@nongnu.org; Sun, 17 Oct 2010 23:18:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7gEe-00044S-2Z for qemu-devel@nongnu.org; Sun, 17 Oct 2010 23:18:07 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:50713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7gEd-00043V-Iv for qemu-devel@nongnu.org; Sun, 17 Oct 2010 23:18:04 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 75ADF188E5; Mon, 18 Oct 2010 12:17:58 +0900 (JST) Received: (nullmailer pid 16504 invoked by uid 1000); Mon, 18 Oct 2010 03:17:56 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Mon, 18 Oct 2010 12:17:43 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: skandasa@cisco.com, adnan@khaleel.us, wexu2@cisco.com, mst@redhat.com, yamahata@valinux.co.jp, etmartin@cisco.com Subject: [Qemu-devel] [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch introduces helper functions to clear/set bits in configuration space. pci_{clear_set, clear, set}_bit_{byte, word, long, quad}(). They will be used later. Signed-off-by: Isaku Yamahata --- hw/pci.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 deletions(-) diff --git a/hw/pci.h b/hw/pci.h index d8b399f..eafa9f3 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -323,6 +323,78 @@ pci_config_set_interrupt_pin(uint8_t *pci_config, uint8_t val) pci_set_byte(&pci_config[PCI_INTERRUPT_PIN], val); } +static inline void +pci_clear_set_bit_byte(uint8_t *config, uint8_t clear, uint8_t set) +{ + pci_set_byte(config, (pci_get_byte(config) & ~clear) | set); +} + +static inline void +pci_clear_bit_byte(uint8_t *config, uint8_t clear) +{ + pci_clear_set_bit_byte(config, clear, 0); +} + +static inline void +pci_set_bit_byte(uint8_t *config, uint8_t set) +{ + pci_clear_set_bit_byte(config, 0, set); +} + +static inline void +pci_clear_set_bit_word(uint8_t *config, uint16_t clear, uint16_t set) +{ + pci_set_word(config, (pci_get_word(config) & ~clear) | set); +} + +static inline void +pci_clear_bit_word(uint8_t *config, uint16_t clear) +{ + pci_clear_set_bit_word(config, clear, 0); +} + +static inline void +pci_set_bit_word(uint8_t *config, uint16_t set) +{ + pci_clear_set_bit_word(config, 0, set); +} + +static inline void +pci_clear_set_bit_long(uint8_t *config, uint32_t clear, uint32_t set) +{ + pci_set_long(config, (pci_get_long(config) & ~clear) | set); +} + +static inline void +pci_clear_bit_long(uint8_t *config, uint32_t clear) +{ + pci_clear_set_bit_long(config, clear, 0); +} + +static inline void +pci_set_bit_long(uint8_t *config, uint32_t set) +{ + pci_clear_set_bit_long(config, 0, set); +} + +static inline void +pci_clear_set_bit_quad(uint8_t *config, uint64_t clear, uint64_t set) +{ + pci_set_quad(config, (pci_get_quad(config) & ~clear) | set); +} + +static inline void +pci_clear_bit_quad(uint8_t *config, uint64_t clear) +{ + pci_clear_set_bit_quad(config, clear, 0); +} + +static inline void +pci_set_bit_quad(uint8_t *config, uint64_t set) +{ + pci_clear_set_bit_quad(config, 0, set); +} + typedef int (*pci_qdev_initfn)(PCIDevice *dev); typedef struct { DeviceInfo qdev;