xref: /dragonfly/sys/platform/pc64/icu/icu_ipl.s (revision bbf928c6)
1c8fe38aeSMatthew Dillon/*
2c8fe38aeSMatthew Dillon * Copyright (c) 2003,2004,2008 The DragonFly Project.  All rights reserved.
3c8fe38aeSMatthew Dillon *
4c8fe38aeSMatthew Dillon * This code is derived from software contributed to The DragonFly Project
5c8fe38aeSMatthew Dillon * by Matthew Dillon <dillon@backplane.com>
6c8fe38aeSMatthew Dillon *
7c8fe38aeSMatthew Dillon * Redistribution and use in source and binary forms, with or without
8c8fe38aeSMatthew Dillon * modification, are permitted provided that the following conditions
9c8fe38aeSMatthew Dillon * are met:
10c8fe38aeSMatthew Dillon *
11c8fe38aeSMatthew Dillon * 1. Redistributions of source code must retain the above copyright
12c8fe38aeSMatthew Dillon *    notice, this list of conditions and the following disclaimer.
13c8fe38aeSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright
14c8fe38aeSMatthew Dillon *    notice, this list of conditions and the following disclaimer in
15c8fe38aeSMatthew Dillon *    the documentation and/or other materials provided with the
16c8fe38aeSMatthew Dillon *    distribution.
17c8fe38aeSMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its
18c8fe38aeSMatthew Dillon *    contributors may be used to endorse or promote products derived
19c8fe38aeSMatthew Dillon *    from this software without specific, prior written permission.
20c8fe38aeSMatthew Dillon *
21c8fe38aeSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22c8fe38aeSMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23c8fe38aeSMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24c8fe38aeSMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25c8fe38aeSMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26c8fe38aeSMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27c8fe38aeSMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28c8fe38aeSMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29c8fe38aeSMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30c8fe38aeSMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31c8fe38aeSMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32c8fe38aeSMatthew Dillon * SUCH DAMAGE.
33c8fe38aeSMatthew Dillon *
34c8fe38aeSMatthew Dillon * Copyright (c) 1989, 1990 William F. Jolitz.
35c8fe38aeSMatthew Dillon * Copyright (c) 1990 The Regents of the University of California.
36c8fe38aeSMatthew Dillon * All rights reserved.
37c8fe38aeSMatthew Dillon *
38c8fe38aeSMatthew Dillon * This code is derived from software contributed to Berkeley by
39c8fe38aeSMatthew Dillon * William Jolitz.
40c8fe38aeSMatthew Dillon *
41c8fe38aeSMatthew Dillon * Redistribution and use in source and binary forms, with or without
42c8fe38aeSMatthew Dillon * modification, are permitted provided that the following conditions
43c8fe38aeSMatthew Dillon * are met:
44c8fe38aeSMatthew Dillon * 1. Redistributions of source code must retain the above copyright
45c8fe38aeSMatthew Dillon *    notice, this list of conditions and the following disclaimer.
46c8fe38aeSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright
47c8fe38aeSMatthew Dillon *    notice, this list of conditions and the following disclaimer in the
48c8fe38aeSMatthew Dillon *    documentation and/or other materials provided with the distribution.
492c64e990Szrj * 3. Neither the name of the University nor the names of its contributors
50c8fe38aeSMatthew Dillon *    may be used to endorse or promote products derived from this software
51c8fe38aeSMatthew Dillon *    without specific prior written permission.
52c8fe38aeSMatthew Dillon *
53c8fe38aeSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54c8fe38aeSMatthew Dillon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55c8fe38aeSMatthew Dillon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56c8fe38aeSMatthew Dillon * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57c8fe38aeSMatthew Dillon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58c8fe38aeSMatthew Dillon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59c8fe38aeSMatthew Dillon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60c8fe38aeSMatthew Dillon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61c8fe38aeSMatthew Dillon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62c8fe38aeSMatthew Dillon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63c8fe38aeSMatthew Dillon * SUCH DAMAGE.
64c8fe38aeSMatthew Dillon *
65c8fe38aeSMatthew Dillon * $FreeBSD: src/sys/i386/isa/icu_ipl.s,v 1.6 1999/08/28 00:44:42 peter Exp $
66c8fe38aeSMatthew Dillon * $DragonFly: src/sys/platform/pc64/icu/icu_ipl.s,v 1.1 2008/08/29 17:07:16 dillon Exp $
67c8fe38aeSMatthew Dillon */
68c8fe38aeSMatthew Dillon
69c8fe38aeSMatthew Dillon#include <machine/asmacros.h>
70c8fe38aeSMatthew Dillon#include <machine/segments.h>
71c8fe38aeSMatthew Dillon#include <machine/lock.h>
72c8fe38aeSMatthew Dillon#include <machine/psl.h>
73c8fe38aeSMatthew Dillon#include <machine/trap.h>
741c2bce94SSepherosa Ziehau#include <machine_base/icu/icu.h>
751c2bce94SSepherosa Ziehau#include <machine_base/icu/icu_ipl.h>
76c8fe38aeSMatthew Dillon
77c8fe38aeSMatthew Dillon#include <bus/isa/isareg.h>
781c2bce94SSepherosa Ziehau
79c8fe38aeSMatthew Dillon#include "assym.s"
80c8fe38aeSMatthew Dillon
81c8fe38aeSMatthew Dillon/*
82c8fe38aeSMatthew Dillon * WARNING!  SMP builds can use the ICU now so this code must be MP safe.
83c8fe38aeSMatthew Dillon */
84c8fe38aeSMatthew Dillon
85c8fe38aeSMatthew Dillon	.data
86c8fe38aeSMatthew Dillon	ALIGN_DATA
87c8fe38aeSMatthew Dillon
88c8fe38aeSMatthew Dillon	/*
89c8fe38aeSMatthew Dillon	 * Interrupt mask for ICU interrupts, defaults to all hardware
90c8fe38aeSMatthew Dillon	 * interrupts turned off.
91c8fe38aeSMatthew Dillon	 */
92c8fe38aeSMatthew Dillon	.p2align 2			/* MUST be 32bit aligned */
93c8fe38aeSMatthew Dillon
94c8fe38aeSMatthew Dillon	.globl	icu_imen
95c8fe38aeSMatthew Dillonicu_imen:
96c8fe38aeSMatthew Dillon	.long	ICU_HWI_MASK
97c8fe38aeSMatthew Dillon
98c8fe38aeSMatthew Dillon	.text
99c8fe38aeSMatthew Dillon	SUPERALIGN_TEXT
100c8fe38aeSMatthew Dillon
101c8fe38aeSMatthew Dillon	/*
102c8fe38aeSMatthew Dillon	 * Functions to enable and disable a hardware interrupt.  Only
103c8fe38aeSMatthew Dillon	 * 16 ICU interrupts exist.
104c8fe38aeSMatthew Dillon	 *
105c8fe38aeSMatthew Dillon	 * INTREN(irq:%edi)
106c8fe38aeSMatthew Dillon	 * INTRDIS(irq:%edi)
107c8fe38aeSMatthew Dillon	 */
108c8fe38aeSMatthew DillonENTRY(ICU_INTRDIS)
109c8fe38aeSMatthew Dillon	ICU_IMASK_LOCK
110*bbf928c6SMatthew Dillon	cmpl	$8,%edi
111*bbf928c6SMatthew Dillon	jl	1f
112*bbf928c6SMatthew Dillon	movl	%edi,%eax	/* C argument */
113*bbf928c6SMatthew Dillon	btsl	%eax,icu_imen
114*bbf928c6SMatthew Dillon	movl	icu_imen,%eax
115*bbf928c6SMatthew Dillon	mov	%ah,%al
116*bbf928c6SMatthew Dillon	outb	%al,$IO_ICU2+ICU_IMR_OFFSET
117*bbf928c6SMatthew Dillon	ICU_IMASK_UNLOCK
118*bbf928c6SMatthew Dillon	ret
119*bbf928c6SMatthew Dillon1:
120c8fe38aeSMatthew Dillon	movl	%edi,%eax	/* C argument */
121c8fe38aeSMatthew Dillon	btsl	%eax,icu_imen
122c8fe38aeSMatthew Dillon	movl	icu_imen,%eax
123c8fe38aeSMatthew Dillon	outb	%al,$IO_ICU1+ICU_IMR_OFFSET
124c8fe38aeSMatthew Dillon	ICU_IMASK_UNLOCK
125c8fe38aeSMatthew Dillon	ret
126c8fe38aeSMatthew Dillon
127c8fe38aeSMatthew DillonENTRY(ICU_INTREN)
128c8fe38aeSMatthew Dillon	ICU_IMASK_LOCK
129*bbf928c6SMatthew Dillon	cmpl	$8,%edi
130*bbf928c6SMatthew Dillon	jl	1f
131*bbf928c6SMatthew Dillon	movl	%edi,%eax	/* C argument */
132*bbf928c6SMatthew Dillon	btrl	%eax,icu_imen
133*bbf928c6SMatthew Dillon	movl	icu_imen,%eax
134*bbf928c6SMatthew Dillon	mov	%ah,%al
135*bbf928c6SMatthew Dillon	outb	%al,$IO_ICU2+ICU_IMR_OFFSET
136*bbf928c6SMatthew Dillon	ICU_IMASK_UNLOCK
137*bbf928c6SMatthew Dillon	ret
138*bbf928c6SMatthew Dillon1:
139c8fe38aeSMatthew Dillon	movl	%edi,%eax	/* C argument */
140c8fe38aeSMatthew Dillon	btrl	%eax,icu_imen
141c8fe38aeSMatthew Dillon	movl	icu_imen,%eax
142c8fe38aeSMatthew Dillon	outb	%al,$IO_ICU1+ICU_IMR_OFFSET
143c8fe38aeSMatthew Dillon	ICU_IMASK_UNLOCK
144c8fe38aeSMatthew Dillon	ret
145