2018-04-20 00:50:06 +03:00
|
|
|
/* $NetBSD: intr.h,v 1.27 2018/04/19 21:50:07 christos Exp $ */
|
1999-12-09 17:53:00 +03:00
|
|
|
|
2008-04-30 12:13:24 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
1999-12-09 17:53:00 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Minoura Makoto and Jason R. Thorpe.
|
|
|
|
*
|
|
|
|
* 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. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2008-04-30 12:13:24 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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-12-09 17:53:00 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NEWS68K_INTR_H_
|
|
|
|
#define _NEWS68K_INTR_H_
|
|
|
|
|
2009-04-09 14:48:22 +04:00
|
|
|
#include <sys/evcnt.h>
|
2007-02-10 05:03:51 +03:00
|
|
|
#include <sys/queue.h>
|
1999-12-09 17:53:00 +03:00
|
|
|
#include <machine/psl.h>
|
2000-11-24 17:08:14 +03:00
|
|
|
#include <m68k/asm_single.h>
|
1999-12-09 17:53:00 +03:00
|
|
|
|
2006-12-21 18:55:21 +03:00
|
|
|
#define IPL_NONE 0
|
2007-02-10 05:03:51 +03:00
|
|
|
#define IPL_SOFTCLOCK 1
|
2007-12-03 18:33:00 +03:00
|
|
|
#define IPL_SOFTBIO 2
|
|
|
|
#define IPL_SOFTNET 3
|
|
|
|
#define IPL_SOFTSERIAL 4
|
|
|
|
#define IPL_VM 5
|
|
|
|
#define IPL_SCHED 6
|
2008-06-15 11:20:46 +04:00
|
|
|
#define IPL_HIGH 7
|
|
|
|
#define NIPL 8
|
2006-12-21 18:55:21 +03:00
|
|
|
|
2008-01-28 20:07:19 +03:00
|
|
|
extern int idepth;
|
2008-06-22 21:33:41 +04:00
|
|
|
|
2018-04-20 00:50:06 +03:00
|
|
|
static __inline bool
|
2008-06-22 21:33:41 +04:00
|
|
|
cpu_intr_p(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
return idepth != 0;
|
2011-03-06 17:54:46 +03:00
|
|
|
}
|
|
|
|
|
2008-06-15 11:20:46 +04:00
|
|
|
extern const uint16_t ipl2psl_table[NIPL];
|
2008-01-28 20:07:19 +03:00
|
|
|
|
2006-12-21 18:55:21 +03:00
|
|
|
typedef int ipl_t;
|
|
|
|
typedef struct {
|
2007-03-11 08:22:24 +03:00
|
|
|
uint16_t _psl;
|
2006-12-21 18:55:21 +03:00
|
|
|
} ipl_cookie_t;
|
|
|
|
|
2018-04-20 00:50:06 +03:00
|
|
|
static __inline ipl_cookie_t
|
2008-06-15 11:20:46 +04:00
|
|
|
makeiplcookie(ipl_t ipl)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
|
|
|
|
}
|
2006-12-21 18:55:21 +03:00
|
|
|
|
2018-04-20 00:50:06 +03:00
|
|
|
static __inline int
|
2006-12-21 18:55:21 +03:00
|
|
|
splraiseipl(ipl_cookie_t icookie)
|
|
|
|
{
|
|
|
|
|
2007-02-10 05:03:51 +03:00
|
|
|
return _splraise(icookie._psl);
|
2006-12-21 18:55:21 +03:00
|
|
|
}
|
|
|
|
|
2018-04-20 00:50:06 +03:00
|
|
|
static __inline void
|
2003-08-02 17:04:49 +04:00
|
|
|
splx(int sr)
|
|
|
|
{
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
__asm volatile("movw %0,%%sr" : : "di" (sr));
|
2003-08-02 17:04:49 +04:00
|
|
|
}
|
|
|
|
|
2007-02-10 05:03:51 +03:00
|
|
|
/*
|
|
|
|
* news68k can handle software interrupts by its own hardware
|
|
|
|
* so has no need to check for any simulated interrupts, etc.
|
|
|
|
*/
|
|
|
|
#define spl0() _spl0()
|
|
|
|
|
2007-12-03 18:33:00 +03:00
|
|
|
#define splsoftbio() splraise2()
|
|
|
|
#define splsoftclock() splraise2()
|
|
|
|
#define splsoftnet() splraise2()
|
|
|
|
#define splsoftserial() splraise2()
|
2007-02-10 05:03:51 +03:00
|
|
|
#define splvm() splraise5()
|
|
|
|
#define splhigh() spl7()
|
|
|
|
#define splsched() spl7()
|
|
|
|
|
1999-12-09 17:53:00 +03:00
|
|
|
#endif /* _NEWS68K_INTR_H_ */
|