From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>,
Scott Wood <scottwood@freescale.com>,
qemu-ppc@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 01/31] openpic: symbolicize some magic numbers
Date: Mon, 7 Jan 2013 16:38:30 +0100 [thread overview]
Message-ID: <1357573140-8877-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1357573140-8877-1-git-send-email-agraf@suse.de>
From: Scott Wood <scottwood@freescale.com>
Deefine symbolic names for some register bits, and use some that
have already been defined.
Also convert some register values from hex to decimal when it improves
readability.
IPVP_PRIORITY_MASK is corrected from (0x1F << 16) to (0xF << 16), in
conjunction with making wider use of the symbolic name. I looked at
Freescale and IBM MPIC docs and at the base OpenPIC spec, and all three
had priority as 4 bits rather than 5. Plus, the magic nubmer that is
being replaced with symbolic values treated the field as 4 bits wide.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/openpic.c | 54 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/hw/openpic.c b/hw/openpic.c
index 9c956b9..eff1eee 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -124,6 +124,11 @@
#define VENI_GENERIC 0x00000000 /* Generic Vendor ID */
+#define GLBC_RESET 0x80000000
+
+#define TIBC_CI 0x80000000 /* count inhibit */
+#define TICC_TOG 0x80000000 /* toggles when decrement to zero */
+
#define IDR_EP_SHIFT 31
#define IDR_EP_MASK (1 << IDR_EP_SHIFT)
#define IDR_CI0_SHIFT 30
@@ -190,11 +195,15 @@ typedef struct IRQ_src_t {
#define IPVP_SENSE_SHIFT 22
#define IPVP_SENSE_MASK (1 << IPVP_SENSE_SHIFT)
-#define IPVP_PRIORITY_MASK (0x1F << 16)
+#define IPVP_PRIORITY_MASK (0xF << 16)
#define IPVP_PRIORITY(_ipvpr_) ((int)(((_ipvpr_) & IPVP_PRIORITY_MASK) >> 16))
#define IPVP_VECTOR_MASK ((1 << VECTOR_BITS) - 1)
#define IPVP_VECTOR(_ipvpr_) ((_ipvpr_) & IPVP_VECTOR_MASK)
+/* IDE[EP/CI] are only for FSL MPIC prior to v4.0 */
+#define IDE_EP 0x80000000 /* external pin */
+#define IDE_CI 0x40000000 /* critical interrupt */
+
typedef struct IRQ_dst_t {
uint32_t pctp; /* CPU current task priority */
uint32_t pcsr; /* CPU sensitivity register */
@@ -375,7 +384,7 @@ static void openpic_update_irq(OpenPICState *opp, int n_IRQ)
DPRINTF("%s: IRQ %d is already active\n", __func__, n_IRQ);
return;
}
- if (src->ide == 0x00000000) {
+ if (src->ide == 0) {
/* No target */
DPRINTF("%s: IRQ %d has no target\n", __func__, n_IRQ);
return;
@@ -432,13 +441,13 @@ static void openpic_reset(DeviceState *d)
OpenPICState *opp = FROM_SYSBUS(typeof (*opp), sysbus_from_qdev(d));
int i;
- opp->glbc = 0x80000000;
+ opp->glbc = GLBC_RESET;
/* Initialise controller registers */
opp->frep = ((opp->nb_irqs -1) << FREP_NIRQ_SHIFT) |
((opp->nb_cpus -1) << FREP_NCPU_SHIFT) |
(opp->vid << FREP_VID_SHIFT);
- opp->pint = 0x00000000;
+ opp->pint = 0;
opp->spve = -1 & opp->spve_mask;
opp->tifr = opp->tifr_reset;
/* Initialise IRQ sources */
@@ -448,7 +457,7 @@ static void openpic_reset(DeviceState *d)
}
/* Initialise IRQ destinations */
for (i = 0; i < MAX_CPU; i++) {
- opp->dst[i].pctp = 0x0000000F;
+ opp->dst[i].pctp = 15;
opp->dst[i].pcsr = 0x00000000;
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
opp->dst[i].raised.next = -1;
@@ -457,11 +466,11 @@ static void openpic_reset(DeviceState *d)
}
/* Initialise timers */
for (i = 0; i < MAX_TMR; i++) {
- opp->timers[i].ticc = 0x00000000;
- opp->timers[i].tibc = 0x80000000;
+ opp->timers[i].ticc = 0;
+ opp->timers[i].tibc = TIBC_CI;
}
/* Go out of RESET state */
- opp->glbc = 0x00000000;
+ opp->glbc = 0;
}
static inline uint32_t read_IRQreg_ide(OpenPICState *opp, int n_IRQ)
@@ -478,7 +487,7 @@ static inline void write_IRQreg_ide(OpenPICState *opp, int n_IRQ, uint32_t val)
{
uint32_t tmp;
- tmp = val & 0xC0000000;
+ tmp = val & (IDE_EP | IDE_CI);
tmp |= val & ((1ULL << MAX_CPU) - 1);
opp->src[n_IRQ].ide = tmp;
DPRINTF("Set IDE %d to 0x%08x\n", n_IRQ, opp->src[n_IRQ].ide);
@@ -488,8 +497,8 @@ static inline void write_IRQreg_ipvp(OpenPICState *opp, int n_IRQ, uint32_t val)
{
/* NOTE: not fully accurate for special IRQs, but simple and sufficient */
/* ACTIVITY bit is read-only */
- opp->src[n_IRQ].ipvp = (opp->src[n_IRQ].ipvp & 0x40000000)
- | (val & 0x800F00FF);
+ opp->src[n_IRQ].ipvp = (opp->src[n_IRQ].ipvp & IPVP_ACTIVITY_MASK) |
+ (val & (IPVP_MASK_MASK | IPVP_PRIORITY_MASK | IPVP_VECTOR_MASK));
openpic_update_irq(opp, n_IRQ);
DPRINTF("Set IPVP %d to 0x%08x -> 0x%08x\n", n_IRQ, val,
opp->src[n_IRQ].ipvp);
@@ -521,7 +530,7 @@ static void openpic_gbl_write(void *opaque, hwaddr addr, uint64_t val,
case 0x1000: /* FREP */
break;
case 0x1020: /* GLBC */
- if (val & 0x80000000) {
+ if (val & GLBC_RESET) {
openpic_reset(&opp->busdev.qdev);
}
break;
@@ -634,10 +643,11 @@ static void openpic_tmr_write(void *opaque, hwaddr addr, uint64_t val,
case 0x00: /* TICC (GTCCR) */
break;
case 0x10: /* TIBC (GTBCR) */
- if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
- (val & 0x80000000) == 0 &&
- (opp->timers[idx].tibc & 0x80000000) != 0)
- opp->timers[idx].ticc &= ~0x80000000;
+ if ((opp->timers[idx].ticc & TICC_TOG) != 0 &&
+ (val & TIBC_CI) == 0 &&
+ (opp->timers[idx].tibc & TIBC_CI) != 0) {
+ opp->timers[idx].ticc &= ~TICC_TOG;
+ }
opp->timers[idx].tibc = val;
break;
case 0x20: /* TIVP (GTIVPR) */
@@ -1190,9 +1200,9 @@ static int openpic_init(SysBusDevice *dev)
opp->vid = VID_REVISION_1_2;
opp->veni = VENI_GENERIC;
opp->spve_mask = 0xFFFF;
- opp->tifr_reset = 0x00000000;
- opp->ipvp_reset = 0x80000000;
- opp->ide_reset = 0x00000001;
+ opp->tifr_reset = 0;
+ opp->ipvp_reset = IPVP_MASK_MASK;
+ opp->ide_reset = 1 << 0;
opp->max_irq = FSL_MPIC_20_MAX_IRQ;
opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ;
opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ;
@@ -1206,9 +1216,9 @@ static int openpic_init(SysBusDevice *dev)
opp->vid = VID_REVISION_1_3;
opp->veni = VENI_GENERIC;
opp->spve_mask = 0xFF;
- opp->tifr_reset = 0x003F7A00;
- opp->ipvp_reset = 0xA0000000;
- opp->ide_reset = 0x00000000;
+ opp->tifr_reset = 4160000;
+ opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK;
+ opp->ide_reset = 0;
opp->max_irq = RAVEN_MAX_IRQ;
opp->irq_ipi0 = RAVEN_IPI_IRQ;
opp->irq_tim0 = RAVEN_TMR_IRQ;
--
1.6.0.2
next prev parent reply other threads:[~2013-01-07 15:39 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-07 15:38 [Qemu-devel] [PULL 00/31] ppc patch queue 2013-01-07 Alexander Graf
2013-01-07 15:38 ` Alexander Graf [this message]
2013-01-07 15:38 ` [Qemu-devel] [PATCH 02/31] openpic: remove pcsr (CPU sensitivity register) Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 03/31] openpic: support large vectors on FSL mpic Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 04/31] openpic: BRR1 is not a CPU-specific register Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 05/31] openpic: s/opp->nb_irqs -1/opp->nb_cpus - 1/ Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 06/31] openpic: don't crash on a register access without a CPU context Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 07/31] powerpc: linux header sync script includes epapr_hcalls.h Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 08/31] openpic: fix coding style issues Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 09/31] PPC: Reset qemu timers when guest reset Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 10/31] PPC: fix segfault in signal handling code Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 11/31] openpic: fix debug prints Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 12/31] openpic: lower interrupt when reading the MSI register Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 13/31] ppc/booke: fix crit/mcheck/debug exceptions Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 14/31] openpic: make register names correspond better with hw docs Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 15/31] openpic: rework critical interrupt support Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 16/31] openpic: make ctpr signed Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 17/31] openpic/fsl: critical interrupts ignore mask before v4.1 Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 18/31] openpic: always call IRQ_check from IRQ_get_next Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 19/31] Revert "openpic: Accelerate pending irq search" Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 20/31] openpic: use standard bitmap operations Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 21/31] openpic: add some bounds checking for IRQ numbers Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 22/31] openpic: fix sense and priority bits Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 23/31] openpic: IRQ_check: search the queue a word at a time Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 24/31] openpic: move IACK to its own function Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 25/31] openpic: fix CTPR and de-assertion of interrupts Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 26/31] kvm: Update kernel headers Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 27/31] PPC: KVM: set has-idle in guest device tree Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 28/31] PPC: Bring EPR support closer to reality Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 29/31] target-ppc: Slim conversion of model definitions to QOM subclasses Alexander Graf
2013-01-07 15:38 ` [Qemu-devel] [PATCH 30/31] target-ppc: Error out for -cpu host on unknown PVR Alexander Graf
2013-01-07 15:39 ` [Qemu-devel] [PATCH 31/31] PPC: linux-user: Calculate context pointer explicitly Alexander Graf
2013-01-07 16:21 ` [Qemu-devel] [PULL 00/31] ppc patch queue 2013-01-07 Andreas Färber
2013-01-07 16:40 ` Alexander Graf
2013-01-08 8:54 ` Stefan Hajnoczi
2013-01-08 9:12 ` Alexander Graf
2013-01-08 15:49 ` Richard Henderson
2013-01-12 16:13 ` Blue Swirl
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=1357573140-8877-2-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=scottwood@freescale.com \
/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).