From patchwork Sun Aug 15 19:27:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 119630 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7FJUq8Z022813 for ; Sun, 15 Aug 2010 19:30:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304Ab0HOTar (ORCPT ); Sun, 15 Aug 2010 15:30:47 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:52742 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933Ab0HOTah (ORCPT ); Sun, 15 Aug 2010 15:30:37 -0400 Received: by fxm13 with SMTP id 13so2628988fxm.19 for ; Sun, 15 Aug 2010 12:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=D0dR2v/AQM1uOKpa53Z5UMlIMhuUez2BEWFmCXbBatY=; b=OAePIDofpJoSnspfcNBm57JoaiWDoS0xEY0jjIYZVufRd8EUr4YNv1K70m4lddtHBT F2yNMUwNCjviLhYiYES19Z8tgHDEDaqVAxDxkhgtvadlECr32pIu6mWaAxhNGw4YyG8C QC92FKyDBDA9DswrX2uRjNzbp7S9B4ddtM9NU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=t7Om1STrXyDE9iRbtpdh3YPmrIB6ciTT1qa3iqHKOeFdmxEbaaxRt9fiI7h6rD/LbM nhHLBIshRQ45DXFIE/xAdWNT+xsRhlrNjmyz7zuTG9RxJjIwktgZIqYC7NFG7H3zQ5Nx p1grbTOMNqngHpshCmxXLrab3gOhYtwrhdRLM= Received: by 10.223.103.134 with SMTP id k6mr4413003fao.5.1281900636329; Sun, 15 Aug 2010 12:30:36 -0700 (PDT) Received: from localhost.localdomain ([178.138.32.54]) by mx.google.com with ESMTPS id r4sm1362656faa.43.2010.08.15.12.30.34 (version=SSLv3 cipher=RC4-MD5); Sun, 15 Aug 2010 12:30:36 -0700 (PDT) From: Eduard - Gabriel Munteanu To: joro@8bytes.org Cc: paul@codesourcery.com, blauwirbel@gmail.com, anthony@codemonkey.ws, avi@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, Eduard - Gabriel Munteanu Subject: [PATCH 1/7] pci: add range_covers_range() Date: Sun, 15 Aug 2010 22:27:16 +0300 Message-Id: <1281900442-29971-2-git-send-email-eduard.munteanu@linux360.ro> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1281900442-29971-1-git-send-email-eduard.munteanu@linux360.ro> References: <1281900442-29971-1-git-send-email-eduard.munteanu@linux360.ro> 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.3 (demeter.kernel.org [140.211.167.41]); Sun, 15 Aug 2010 19:30:52 +0000 (UTC) diff --git a/hw/pci.h b/hw/pci.h index 4bd8a1a..5a6cdb5 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -419,6 +419,16 @@ static inline int range_covers_byte(uint64_t offset, uint64_t len, return offset <= byte && byte <= range_get_last(offset, len); } +/* Check whether a given range completely covers another. */ +static inline int range_covers_range(uint64_t first_big, uint64_t len_big, + uint64_t first_small, uint64_t len_small) +{ + uint64_t last_big = range_get_last(first_big, len_big); + uint64_t last_small = range_get_last(first_small, len_small); + + return first_big <= first_small && last_small <= last_big; +} + /* Check whether 2 given ranges overlap. * Undefined if ranges that wrap around 0. */ static inline int ranges_overlap(uint64_t first1, uint64_t len1,