aboutsummaryrefslogtreecommitdiffstats
path: root/docs/reference_glossary.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference_glossary.md')
0 files changed, 0 insertions, 0 deletions
2'>52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Copyright (C) IBM Corp. 2005, 2006
 *
 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
 */

#include <xen/config.h>
#include <xen/types.h>
#include <xen/sched.h>
#include <xen/lib.h>
#include <xen/event.h>
#include <xen/irq.h>
#include <public/xen.h>
#include <asm/current.h>
#include <asm/hardirq.h>
#include <asm/mpic.h>
#include "mpic_init.h"
#include "exceptions.h"

#undef DEBUG
#ifdef DEBUG
#define DBG(fmt...) printk(fmt)
#else
#define DBG(fmt...)
#endif

int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1};

unsigned long io_apic_irqs;
int ioapic_ack_new = 1;

static struct hw_interrupt_type *hc_irq;

/* deliver_ee: called with interrupts off when resuming every vcpu */
void deliver_ee(struct cpu_user_regs *regs)
{
    const ulong srr_mask = ~(MSR_IR | MSR_DR | MSR_FE0 | MSR_FE1 | MSR_EE |
                             MSR_RI |
                             MSR_BE | MSR_FP | MSR_PMM | MSR_PR | MSR_SE);

    BUG_ON(mfmsr() & MSR_EE);
    BUG_ON(regs->msr & MSR_HV);

    if (!local_events_need_delivery())
        return;

    /* XXX OS error: EE was set but RI was not. We could trigger a machine
     * check, or kill the domain... for now just crash Xen so we notice. */
    BUG_ON(!(regs->msr & MSR_RI));

    regs->srr0 = regs->pc;
    /* zero SRR1[33:36] and SRR1[42:47] */
    regs->srr1 = regs->msr & ~0x00000000783f0000;
    regs->pc = 0x500;
    regs->msr &= srr_mask;
    regs->msr |= MSR_SF | MSR_ME;

    DBG("<HV: pc=0x%lx, msr=0x%lx\n", regs->pc, regs->msr);
}

void do_external(struct cpu_user_regs *regs)
{
    int vec;
    static unsigned spur_count;

    BUG_ON(!(regs->msr & MSR_EE));
    BUG_ON(mfmsr() & MSR_EE);

    vec = xen_mpic_get_irq(regs);

    if (vec != -1) {
        DBG("EE:0x%lx isrc: %d\n", regs->msr, vec);
        regs->entry_vector = vec;
        do_IRQ(regs);

        BUG_ON(mfmsr() & MSR_EE);
        spur_count = 0;
    } else {
        ++spur_count;
        if (spur_count > 100)
            panic("Too many (%d) spurrious interrupts in a row\n"
                  "  Known problem, please halt and let machine idle/cool "
                  "  then reboot\n",
                  100);
    }
}

static int xen_local_irq(unsigned int irq)
{
    irq_desc_t *desc;
    unsigned int vector;

    vector = irq_to_vector(irq);
    desc = &irq_desc[vector];

    return !(desc->status & IRQ_GUEST);
}

static unsigned int xen_startup_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        return hc_irq->startup(irq);
    }
    return 0;
}

static void xen_shutdown_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        hc_irq->shutdown(irq);
    }
}

static void xen_enable_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        hc_irq->enable(irq);
    }
}

static void xen_disable_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        hc_irq->disable(irq);
    }
}
    
static void xen_ack_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        if (hc_irq->ack) hc_irq->ack(irq);
    }
}

static void xen_end_irq(unsigned int irq)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        hc_irq->end(irq);
    }
}

static void xen_set_affinity(unsigned int irq, cpumask_t mask)
{
    DBG("%s(%d)\n", __func__, irq);
    if (xen_local_irq(irq)) {
        if (hc_irq->set_affinity) hc_irq->set_affinity(irq, mask);
    }
}

static struct hw_interrupt_type xen_irq = {
    .startup = xen_startup_irq,
    .enable = xen_enable_irq,
    .disable = xen_disable_irq,
    .shutdown = xen_shutdown_irq,