source: mainline/kernel/arch/sparc64/src/trap/sun4v/interrupt.c@ 7da160b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7da160b was 7da160b, checked in by Jakub Jermar <jakub@…>, 15 years ago

Differentiate between the hypervisor error codes and HelenOS error codes by
using the HV_ prefix for the former.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2009 Pavel Rimsky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup sparc64interrupt
30 * @{
31 */
32/** @file
33 */
34
35#include <arch/interrupt.h>
36#include <arch/trap/interrupt.h>
37#include <arch/sparc64.h>
38#include <interrupt.h>
39#include <ddi/irq.h>
40#include <arch/types.h>
41#include <debug.h>
42#include <arch/asm.h>
43#include <arch/barrier.h>
44#include <print.h>
45#include <arch.h>
46#include <mm/tlb.h>
47#include <config.h>
48#include <synch/spinlock.h>
49#include <arch/sun4v/hypercall.h>
50
51/** number of uint64_t-s in one CPU mondo message */
52#define CPU_MONDO_ENTRY_SIZE 8
53
54/** number of entries (messages) in the CPU mondo queue */
55#define CPU_MONDO_NENTRIES 8
56
57/** number of uint64_t-s in the CPU mondo queue */
58#define CPU_MONDO_QUEUE_SIZE ((CPU_MONDO_NENTRIES) * (CPU_MONDO_ENTRY_SIZE))
59
60/** used to identify CPU mondo queue in the hypercall */
61#define CPU_MONDO_QUEUE_ID 0x3c
62
63/** ASI for reading/writing CPU mondo head/tail registers */
64#define ASI_QUEUE 0x25
65
66/** VA for reading the CPU mondo tail */
67#define VA_CPU_MONDO_QUEUE_TAIL 0x3c8
68
69/** VA for reading/writing the CPU mondo head */
70#define VA_CPU_MONDO_QUEUE_HEAD 0x3c0
71
72/**
73 * array which contains CPU mondo queue for every CPU
74 */
75uint64_t cpu_mondo_queues[MAX_NUM_STRANDS][CPU_MONDO_QUEUE_SIZE]
76 __attribute__((aligned(
77 CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t))));
78
79/**
80 * Initializes CPU mondo queue for the current CPU.
81 */
82void sun4v_ipi_init(void)
83{
84 if (__hypercall_fast3(
85 CPU_QCONF,
86 CPU_MONDO_QUEUE_ID,
87 KA2PA(cpu_mondo_queues[CPU->id]),
88 CPU_MONDO_NENTRIES) != HV_EOK)
89 panic("Initializing mondo queue failed on CPU %d.\n",
90 CPU->arch.id);
91}
92
93/**
94 * Handler of the CPU Mondo trap. Reads the message queue, updates the head
95 * register and processes the message (invokes a function call).
96 */
97void cpu_mondo(void)
98{
99#ifdef CONFIG_SMP
100 unsigned int tail = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_TAIL);
101 unsigned int head = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD);
102
103 while (head != tail) {
104 uint64_t data1 = cpu_mondo_queues[CPU->id][0];
105
106 head = (head + CPU_MONDO_ENTRY_SIZE * sizeof(uint64_t)) %
107 (CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t));
108 asi_u64_write(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD, head);
109
110 if (data1 == (uintptr_t) tlb_shootdown_ipi_recv) {
111 ((void (*)(void)) data1)();
112 } else {
113 printf("Spurious interrupt on %d, data = %lx.\n",
114 CPU->arch.id, data1);
115 }
116 }
117#endif
118}
119
120/** @}
121 */
Note: See TracBrowser for help on using the repository browser.