xref: /haiku/src/add-ons/kernel/interrupt_controllers/openpic/openpic.h (revision a8193053ece43667030c4e6e51e033cbe0967d4c)
1*a8193053SIngo Weinhold /*-
2*a8193053SIngo Weinhold  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
3*a8193053SIngo Weinhold  *
4*a8193053SIngo Weinhold  * Redistribution and use in source and binary forms, with or without
5*a8193053SIngo Weinhold  * modification, are permitted provided that the following conditions
6*a8193053SIngo Weinhold  * are met:
7*a8193053SIngo Weinhold  * 1. Redistributions of source code must retain the above copyright
8*a8193053SIngo Weinhold  *    notice, this list of conditions and the following disclaimer.
9*a8193053SIngo Weinhold  * 2. Redistributions in binary form must reproduce the above copyright
10*a8193053SIngo Weinhold  *    notice, this list of conditions and the following disclaimer in the
11*a8193053SIngo Weinhold  *    documentation and/or other materials provided with the distribution.
12*a8193053SIngo Weinhold  * 3. The name of the author may not be used to endorse or promote products
13*a8193053SIngo Weinhold  *    derived from this software without specific prior written permission.
14*a8193053SIngo Weinhold  *
15*a8193053SIngo Weinhold  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*a8193053SIngo Weinhold  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*a8193053SIngo Weinhold  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*a8193053SIngo Weinhold  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*a8193053SIngo Weinhold  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*a8193053SIngo Weinhold  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*a8193053SIngo Weinhold  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*a8193053SIngo Weinhold  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*a8193053SIngo Weinhold  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24*a8193053SIngo Weinhold  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*a8193053SIngo Weinhold  *
26*a8193053SIngo Weinhold  * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp
27*a8193053SIngo Weinhold  * $FreeBSD$
28*a8193053SIngo Weinhold  */
29*a8193053SIngo Weinhold 
30*a8193053SIngo Weinhold #ifndef OPENPIC_H
31*a8193053SIngo Weinhold #define OPENPIC_H
32*a8193053SIngo Weinhold 
33*a8193053SIngo Weinhold /*
34*a8193053SIngo Weinhold  * Size of OpenPIC register space
35*a8193053SIngo Weinhold  */
36*a8193053SIngo Weinhold #define	OPENPIC_SIZE			0x40000
37*a8193053SIngo Weinhold 
38*a8193053SIngo Weinhold /*
39*a8193053SIngo Weinhold  * GLOBAL/TIMER register (IDU base + 0x1000)
40*a8193053SIngo Weinhold  */
41*a8193053SIngo Weinhold 
42*a8193053SIngo Weinhold /* feature reporting reg 0 */
43*a8193053SIngo Weinhold #define OPENPIC_FEATURE			0x1000
44*a8193053SIngo Weinhold #define	OPENPIC_FEATURE_VERSION_MASK	0x000000ff
45*a8193053SIngo Weinhold #define	OPENPIC_FEATURE_LAST_CPU_MASK	0x00001f00
46*a8193053SIngo Weinhold #define	OPENPIC_FEATURE_LAST_CPU_SHIFT	8
47*a8193053SIngo Weinhold #define	OPENPIC_FEATURE_LAST_IRQ_MASK	0x07ff0000
48*a8193053SIngo Weinhold #define	OPENPIC_FEATURE_LAST_IRQ_SHIFT	16
49*a8193053SIngo Weinhold 
50*a8193053SIngo Weinhold /* global config reg 0 */
51*a8193053SIngo Weinhold #define OPENPIC_CONFIG			0x1020
52*a8193053SIngo Weinhold #define  OPENPIC_CONFIG_RESET			0x80000000
53*a8193053SIngo Weinhold #define  OPENPIC_CONFIG_8259_PASSTHRU_DISABLE	0x20000000
54*a8193053SIngo Weinhold 
55*a8193053SIngo Weinhold /* interrupt configuration mode (direct or serial) */
56*a8193053SIngo Weinhold #define OPENPIC_ICR			0x1030
57*a8193053SIngo Weinhold #define  OPENPIC_ICR_SERIAL_MODE	(1 << 27)
58*a8193053SIngo Weinhold #define  OPENPIC_ICR_SERIAL_RATIO_MASK	(0x7 << 28)
59*a8193053SIngo Weinhold #define  OPENPIC_ICR_SERIAL_RATIO_SHIFT	28
60*a8193053SIngo Weinhold 
61*a8193053SIngo Weinhold /* processor initialization reg */
62*a8193053SIngo Weinhold #define OPENPIC_PROC_INIT		0x1090
63*a8193053SIngo Weinhold 
64*a8193053SIngo Weinhold /* IPI vector/priority reg */
65*a8193053SIngo Weinhold #define OPENPIC_IPI_VECTOR(ipi)		(0x10a0 + (ipi) * 0x10)
66*a8193053SIngo Weinhold 
67*a8193053SIngo Weinhold /* spurious intr. vector */
68*a8193053SIngo Weinhold #define OPENPIC_SPURIOUS_VECTOR		0x10e0
69*a8193053SIngo Weinhold 
70*a8193053SIngo Weinhold 
71*a8193053SIngo Weinhold /*
72*a8193053SIngo Weinhold  * INTERRUPT SOURCE register (IDU base + 0x10000)
73*a8193053SIngo Weinhold  */
74*a8193053SIngo Weinhold 
75*a8193053SIngo Weinhold /* interrupt vector/priority reg */
76*a8193053SIngo Weinhold #ifndef OPENPIC_SRC_VECTOR
77*a8193053SIngo Weinhold #define OPENPIC_SRC_VECTOR(irq)		(0x10000 + (irq) * 0x20)
78*a8193053SIngo Weinhold #endif
79*a8193053SIngo Weinhold #define  OPENPIC_SENSE_LEVEL			0x00400000
80*a8193053SIngo Weinhold #define  OPENPIC_SENSE_EDGE			0x00000000
81*a8193053SIngo Weinhold #define  OPENPIC_POLARITY_POSITIVE		0x00800000
82*a8193053SIngo Weinhold #define  OPENPIC_POLARITY_NEGATIVE		0x00000000
83*a8193053SIngo Weinhold #define  OPENPIC_IMASK				0x80000000
84*a8193053SIngo Weinhold #define  OPENPIC_ACTIVITY			0x40000000
85*a8193053SIngo Weinhold #define  OPENPIC_PRIORITY_MASK			0x000f0000
86*a8193053SIngo Weinhold #define  OPENPIC_PRIORITY_SHIFT			16
87*a8193053SIngo Weinhold #define  OPENPIC_VECTOR_MASK			0x000000ff
88*a8193053SIngo Weinhold 
89*a8193053SIngo Weinhold /* interrupt destination cpu */
90*a8193053SIngo Weinhold #ifndef OPENPIC_IDEST
91*a8193053SIngo Weinhold #define OPENPIC_IDEST(irq)		(0x10010 + (irq) * 0x20)
92*a8193053SIngo Weinhold #endif
93*a8193053SIngo Weinhold 
94*a8193053SIngo Weinhold /*
95*a8193053SIngo Weinhold  * PROCESSOR register (IDU base + 0x20000)
96*a8193053SIngo Weinhold  */
97*a8193053SIngo Weinhold 
98*a8193053SIngo Weinhold /* IPI command reg */
99*a8193053SIngo Weinhold #define OPENPIC_IPI(cpu, ipi)		(0x20040 + (cpu) * 0x1000 + (ipi))
100*a8193053SIngo Weinhold 
101*a8193053SIngo Weinhold /* current task priority reg */
102*a8193053SIngo Weinhold #define OPENPIC_CPU_PRIORITY(cpu)	(0x20080 + (cpu) * 0x1000)
103*a8193053SIngo Weinhold #define  OPENPIC_CPU_PRIORITY_MASK		0x0000000f
104*a8193053SIngo Weinhold 
105*a8193053SIngo Weinhold /* interrupt acknowledge reg */
106*a8193053SIngo Weinhold #define OPENPIC_IACK(cpu)		(0x200a0 + (cpu) * 0x1000)
107*a8193053SIngo Weinhold 
108*a8193053SIngo Weinhold /* end of interrupt reg */
109*a8193053SIngo Weinhold #define OPENPIC_EOI(cpu)		(0x200b0 + (cpu) * 0x1000)
110*a8193053SIngo Weinhold 
111*a8193053SIngo Weinhold #endif	// OPENPIC_H
112