qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: James Sullivan <sullivan.james.f@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, James Sullivan <sullivan.james.f@gmail.com>,
	mst@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/5] apic: Added helper function apic_match_dest, apic_match_[physical, logical]_dest
Date: Tue, 24 Mar 2015 13:13:44 -0600	[thread overview]
Message-ID: <1427224426-9025-4-git-send-email-sullivan.james.f@gmail.com> (raw)
In-Reply-To: <1427224426-9025-1-git-send-email-sullivan.james.f@gmail.com>

Added three helper functions apic_match_dest(),
apic_match_physical_dest(), and apic_match_logical_dest() which
can be used to determine if a logical or physical APIC ID match a
given LAPIC under a given dest_mode. This does not account for shorthand.

Signed-off-by: James Sullivan <sullivan.james.f@gmail.com>
---
 hw/intc/apic.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 47d2fb1..c49eb26 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -241,6 +241,32 @@ static struct APICCommonState *apic_lowest_prio(const uint32_t
     }\
 }
 
+static bool apic_match_physical_dest(struct APICCommonState *apic, uint8_t dest)
+{
+    return (dest == 0xff || apic->id == dest);
+}
+
+static bool apic_match_logical_dest(struct APICCommonState *apic, uint8_t dest)
+{
+    if (apic->dest_mode == 0xf) {
+        return (dest & apic->log_dest) > 0;
+    } else if (apic->dest_mode == 0) {
+        return ((dest & 0xf0) == (apic->log_dest & 0xf0)) &&
+                (dest & apic->log_dest & 0x0f) > 0;
+    }
+    return false;
+}
+
+static bool apic_match_dest(struct APICCommonState *apic, uint8_t dest_mode,
+                     uint8_t dest)
+{
+    if (dest_mode == 0) {
+        return apic_match_physical_dest(apic, dest);
+    } else {
+        return apic_match_logical_dest(apic, dest);
+    }
+}
+
 static void apic_bus_deliver(const uint32_t *deliver_bitmask,
                              uint8_t delivery_mode, uint8_t vector_num,
                              uint8_t trigger_mode)
-- 
2.3.3

  parent reply	other threads:[~2015-03-24 19:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24 19:13 [Qemu-devel] [PATCH v2 0/5] Implement RH bit handling and lowpri arbitration James Sullivan
2015-03-24 19:13 ` [Qemu-devel] [PATCH v3 2/5] apic: Implement LAPIC low priority arbitration functions James Sullivan
2015-03-24 19:13 ` [Qemu-devel] [PATCH v2 2/5] apic: Implement low priority arbitration for IRQ delivery James Sullivan
2015-03-24 19:13 ` James Sullivan [this message]
2015-03-24 19:13 ` [Qemu-devel] [PATCH v2 4/5] apic: Set and pass in RH bit for MSI interrupts James Sullivan
2015-03-24 19:13 ` [Qemu-devel] [PATCH v2 5/5] apic: Implement handling of RH=1 for MSI interrupt delivery James Sullivan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427224426-9025-4-git-send-email-sullivan.james.f@gmail.com \
    --to=sullivan.james.f@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).