xref: /netbsd-src/sys/arch/cesfic/cesfic/sic6351.c (revision 82357f6d420792564499086cb6440ad2fcce8410)
1*82357f6dSdsl /* $NetBSD: sic6351.c,v 1.6 2009/03/14 21:04:08 dsl Exp $ */
2e047259aSdrochner 
3e047259aSdrochner /*
4e047259aSdrochner  * Copyright (c) 1997, 1999
5e047259aSdrochner  *	Matthias Drochner.  All rights reserved.
6e047259aSdrochner  *
7e047259aSdrochner  * Redistribution and use in source and binary forms, with or without
8e047259aSdrochner  * modification, are permitted provided that the following conditions
9e047259aSdrochner  * are met:
10e047259aSdrochner  * 1. Redistributions of source code must retain the above copyright
11e047259aSdrochner  *    notice, this list of conditions and the following disclaimer.
12e047259aSdrochner  * 2. Redistributions in binary form must reproduce the above copyright
13e047259aSdrochner  *    notice, this list of conditions and the following disclaimer in the
14e047259aSdrochner  *    documentation and/or other materials provided with the distribution.
15e047259aSdrochner  *
16e047259aSdrochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17e047259aSdrochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18e047259aSdrochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19e047259aSdrochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20e047259aSdrochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21e047259aSdrochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22e047259aSdrochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23e047259aSdrochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24e047259aSdrochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25e047259aSdrochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26e047259aSdrochner  *
27e047259aSdrochner  */
28e047259aSdrochner 
29e803bea7Slukem #include <sys/cdefs.h>
30*82357f6dSdsl __KERNEL_RCSID(0, "$NetBSD: sic6351.c,v 1.6 2009/03/14 21:04:08 dsl Exp $");
31e803bea7Slukem 
32e047259aSdrochner #include <sys/param.h>
33e047259aSdrochner #include <sys/systm.h>
34e047259aSdrochner 
35e047259aSdrochner #include <machine/cpu.h>
36e047259aSdrochner #include <machine/pte.h>
37e047259aSdrochner 
3802cdf4d2Sdsl void sicinit(void*);
3902cdf4d2Sdsl int act2icr(int);
4002cdf4d2Sdsl void sic_enable_int(int, int, int, int, int);
41e047259aSdrochner 
42e047259aSdrochner static char *sicbase;
43e047259aSdrochner 
44e047259aSdrochner void
sicinit(void * base)45454af1c0Sdsl sicinit(void *base)
46e047259aSdrochner {
47e047259aSdrochner 	int i;
48e047259aSdrochner 
49e047259aSdrochner 	sicbase = base;
50e047259aSdrochner 
51e047259aSdrochner 	for(i = 0x100; i <= 0x1a4; i += 4)
52e047259aSdrochner 		*(volatile int *)(sicbase + i) = 0;
53e047259aSdrochner }
54e047259aSdrochner 
55e047259aSdrochner int
act2icr(int act)56454af1c0Sdsl act2icr(int act)
57e047259aSdrochner {
58e047259aSdrochner 	if (act == 17)
59e047259aSdrochner 		return (0x90); /* ILACC */
60e047259aSdrochner 	if (act == 19)
61e047259aSdrochner 		return (0x94); /* ZS */
62e047259aSdrochner 	if (act == 25)
63e047259aSdrochner 		return (0xa4); /* RTC */
64e047259aSdrochner 	if (act == 39)
65e047259aSdrochner 		return (0x6c); /* ABORT A */
66e047259aSdrochner 	panic("sic: unknown act %d", act);
67e047259aSdrochner }
68e047259aSdrochner 
69e047259aSdrochner void
sic_enable_int(int nr,int type,int icod,int level,int vector)70*82357f6dSdsl sic_enable_int(int nr, int type, int icod, int level, int vector)
71e047259aSdrochner {
72e047259aSdrochner 
73e047259aSdrochner 	if (icod == 0)
74e047259aSdrochner 		*(volatile int *)(sicbase + 0x300 + nr * 4) = vector;
75e047259aSdrochner 	*(volatile int *)(sicbase + 0x200 + nr * 4) = icod;
76e047259aSdrochner 	*(volatile int *)(sicbase + 0x100 + act2icr(nr))
77e047259aSdrochner 		= 0x80 | (type << 4) | level;
78e047259aSdrochner }
79