sync hh.org
[hh.org.git] / include / asm-mips / smtc_ipi.h
blobf22c3e2f993aa29424765dc030fff9ebe9ca2a28
1 /*
2 * Definitions used in MIPS MT SMTC "Interprocessor Interrupt" code.
3 */
4 #ifndef __ASM_SMTC_IPI_H
5 #define __ASM_SMTC_IPI_H
7 //#define SMTC_IPI_DEBUG
9 #ifdef SMTC_IPI_DEBUG
10 #include <asm/mipsregs.h>
11 #include <asm/mipsmtregs.h>
12 #endif /* SMTC_IPI_DEBUG */
15 * An IPI "message"
18 struct smtc_ipi {
19 struct smtc_ipi *flink;
20 int type;
21 void *arg;
22 int dest;
23 #ifdef SMTC_IPI_DEBUG
24 int sender;
25 long stamp;
26 #endif /* SMTC_IPI_DEBUG */
30 * Defined IPI Types
33 #define LINUX_SMP_IPI 1
34 #define SMTC_CLOCK_TICK 2
37 * A queue of IPI messages
40 struct smtc_ipi_q {
41 struct smtc_ipi *head;
42 spinlock_t lock;
43 struct smtc_ipi *tail;
44 int depth;
47 extern struct smtc_ipi_q IPIQ[NR_CPUS];
48 extern struct smtc_ipi_q freeIPIq;
50 static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p)
52 long flags;
54 spin_lock_irqsave(&q->lock, flags);
55 if (q->head == NULL)
56 q->head = q->tail = p;
57 else
58 q->tail->flink = p;
59 p->flink = NULL;
60 q->tail = p;
61 q->depth++;
62 #ifdef SMTC_IPI_DEBUG
63 p->sender = read_c0_tcbind();
64 p->stamp = read_c0_count();
65 #endif /* SMTC_IPI_DEBUG */
66 spin_unlock_irqrestore(&q->lock, flags);
69 static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
71 struct smtc_ipi *p;
72 long flags;
74 spin_lock_irqsave(&q->lock, flags);
75 if (q->head == NULL)
76 p = NULL;
77 else {
78 p = q->head;
79 q->head = q->head->flink;
80 q->depth--;
81 /* Arguably unnecessary, but leaves queue cleaner */
82 if (q->head == NULL)
83 q->tail = NULL;
85 spin_unlock_irqrestore(&q->lock, flags);
86 return p;
89 static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p)
91 long flags;
93 spin_lock_irqsave(&q->lock, flags);
94 if (q->head == NULL) {
95 q->head = q->tail = p;
96 p->flink = NULL;
97 } else {
98 p->flink = q->head;
99 q->head = p;
101 q->depth++;
102 spin_unlock_irqrestore(&q->lock, flags);
105 static inline int smtc_ipi_qdepth(struct smtc_ipi_q *q)
107 long flags;
108 int retval;
110 spin_lock_irqsave(&q->lock, flags);
111 retval = q->depth;
112 spin_unlock_irqrestore(&q->lock, flags);
113 return retval;
116 extern void smtc_send_ipi(int cpu, int type, unsigned int action);
118 #endif /* __ASM_SMTC_IPI_H */