1997-07-20 19:41:38 +00:00
|
|
|
/*-
|
1997-05-26 17:58:27 +00:00
|
|
|
* Copyright (c) 1997, by Steve Passe
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. The name of the developer may NOT be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1997-05-26 17:58:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
.data
|
|
|
|
ALIGN_DATA
|
|
|
|
|
1997-07-23 20:47:19 +00:00
|
|
|
/*
|
|
|
|
* Note:
|
|
|
|
* This is the UP equivilant of _imen.
|
|
|
|
* It is OPAQUE, and must NOT be accessed directly.
|
|
|
|
* It MUST be accessed along with the IO APIC as a 'critical region'.
|
|
|
|
* Accessed by:
|
|
|
|
* INTREN()
|
|
|
|
* INTRDIS()
|
|
|
|
* imen_dump()
|
|
|
|
*/
|
1999-08-25 23:42:02 +00:00
|
|
|
.p2align 2 /* MUST be 32bit aligned */
|
2001-02-25 06:29:04 +00:00
|
|
|
.globl apic_imen
|
|
|
|
apic_imen:
|
1997-07-23 20:47:19 +00:00
|
|
|
.long HWI_MASK
|
1997-05-26 17:58:27 +00:00
|
|
|
|
|
|
|
.text
|
|
|
|
SUPERALIGN_TEXT
|
|
|
|
|
1997-07-22 20:12:32 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* XXX FIXME: figure out where these belong.
|
|
|
|
*/
|
|
|
|
|
1997-07-23 05:49:19 +00:00
|
|
|
/* this nonsense is to verify that masks ALWAYS have 1 and only 1 bit set */
|
1997-07-23 20:47:19 +00:00
|
|
|
#define QUALIFY_MASKS_NOT
|
1997-07-23 05:49:19 +00:00
|
|
|
|
|
|
|
#ifdef QUALIFY_MASKS
|
|
|
|
#define QUALIFY_MASK \
|
1997-07-23 20:47:19 +00:00
|
|
|
btrl %ecx, %eax ; \
|
|
|
|
andl %eax, %eax ; \
|
|
|
|
jz 1f ; \
|
|
|
|
pushl $bad_mask ; \
|
2001-02-25 06:29:04 +00:00
|
|
|
call panic ; \
|
1997-07-23 05:49:19 +00:00
|
|
|
1:
|
|
|
|
|
|
|
|
bad_mask: .asciz "bad mask"
|
|
|
|
#else
|
|
|
|
#define QUALIFY_MASK
|
|
|
|
#endif
|
|
|
|
|
1997-07-22 20:12:32 +00:00
|
|
|
/*
|
1997-07-23 05:49:19 +00:00
|
|
|
* (soon to be) MP-safe function to clear ONE INT mask bit.
|
1997-07-22 20:12:32 +00:00
|
|
|
* The passed arg is a 32bit u_int MASK.
|
1997-07-23 20:47:19 +00:00
|
|
|
* It sets the associated bit in _apic_imen.
|
1997-07-22 20:12:32 +00:00
|
|
|
* It sets the mask bit of the associated IO APIC register.
|
|
|
|
*/
|
1997-07-24 23:49:44 +00:00
|
|
|
ENTRY(INTREN)
|
1997-07-23 21:25:31 +00:00
|
|
|
pushfl /* save state of EI flag */
|
|
|
|
cli /* prevent recursion */
|
1997-07-23 20:47:19 +00:00
|
|
|
IMASK_LOCK /* enter critical reg */
|
|
|
|
|
1997-07-23 21:25:31 +00:00
|
|
|
movl 8(%esp), %eax /* mask into %eax */
|
1997-07-23 20:47:19 +00:00
|
|
|
bsfl %eax, %ecx /* get pin index */
|
2001-02-25 06:29:04 +00:00
|
|
|
btrl %ecx, apic_imen /* update apic_imen */
|
1997-07-22 20:12:32 +00:00
|
|
|
|
1997-07-23 05:49:19 +00:00
|
|
|
QUALIFY_MASK
|
|
|
|
|
1998-09-06 22:41:42 +00:00
|
|
|
shll $4, %ecx
|
|
|
|
movl CNAME(int_to_apicintpin) + 8(%ecx), %edx
|
|
|
|
movl CNAME(int_to_apicintpin) + 12(%ecx), %ecx
|
1999-04-10 19:22:17 +00:00
|
|
|
testl %edx, %edx
|
|
|
|
jz 1f
|
1997-07-23 05:49:19 +00:00
|
|
|
|
1997-07-23 20:47:19 +00:00
|
|
|
movl %ecx, (%edx) /* write the target register index */
|
|
|
|
movl 16(%edx), %eax /* read the target register data */
|
|
|
|
andl $~IOART_INTMASK, %eax /* clear mask bit */
|
|
|
|
movl %eax, 16(%edx) /* write the APIC register data */
|
1999-04-10 19:22:17 +00:00
|
|
|
1:
|
1997-07-23 20:47:19 +00:00
|
|
|
IMASK_UNLOCK /* exit critical reg */
|
1997-07-23 21:25:31 +00:00
|
|
|
popfl /* restore old state of EI flag */
|
1997-07-22 20:12:32 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
/*
|
1997-07-23 05:49:19 +00:00
|
|
|
* (soon to be) MP-safe function to set ONE INT mask bit.
|
1997-07-22 20:12:32 +00:00
|
|
|
* The passed arg is a 32bit u_int MASK.
|
1997-07-23 20:47:19 +00:00
|
|
|
* It clears the associated bit in _apic_imen.
|
1997-07-22 20:12:32 +00:00
|
|
|
* It clears the mask bit of the associated IO APIC register.
|
|
|
|
*/
|
1997-07-24 23:49:44 +00:00
|
|
|
ENTRY(INTRDIS)
|
1997-07-23 21:25:31 +00:00
|
|
|
pushfl /* save state of EI flag */
|
|
|
|
cli /* prevent recursion */
|
1997-07-23 20:47:19 +00:00
|
|
|
IMASK_LOCK /* enter critical reg */
|
|
|
|
|
1997-07-23 21:25:31 +00:00
|
|
|
movl 8(%esp), %eax /* mask into %eax */
|
1997-07-23 20:47:19 +00:00
|
|
|
bsfl %eax, %ecx /* get pin index */
|
2001-02-25 06:29:04 +00:00
|
|
|
btsl %ecx, apic_imen /* update apic_imen */
|
1997-07-22 20:12:32 +00:00
|
|
|
|
1997-07-23 05:49:19 +00:00
|
|
|
QUALIFY_MASK
|
|
|
|
|
1998-09-06 22:41:42 +00:00
|
|
|
shll $4, %ecx
|
|
|
|
movl CNAME(int_to_apicintpin) + 8(%ecx), %edx
|
|
|
|
movl CNAME(int_to_apicintpin) + 12(%ecx), %ecx
|
1999-04-10 19:22:17 +00:00
|
|
|
testl %edx, %edx
|
|
|
|
jz 1f
|
1997-07-23 05:49:19 +00:00
|
|
|
|
1997-07-23 20:47:19 +00:00
|
|
|
movl %ecx, (%edx) /* write the target register index */
|
|
|
|
movl 16(%edx), %eax /* read the target register data */
|
|
|
|
orl $IOART_INTMASK, %eax /* set mask bit */
|
|
|
|
movl %eax, 16(%edx) /* write the APIC register data */
|
1999-04-10 19:22:17 +00:00
|
|
|
1:
|
1997-07-23 20:47:19 +00:00
|
|
|
IMASK_UNLOCK /* exit critical reg */
|
1997-07-23 21:25:31 +00:00
|
|
|
popfl /* restore old state of EI flag */
|
1997-07-22 20:12:32 +00:00
|
|
|
ret
|