intr.h revision 1.6
11.6Sad/*	$NetBSD: intr.h,v 1.6 2007/02/09 21:55:02 ad Exp $	*/
21.3Such
31.3Such/*-
41.3Such * Copyright (c) 2002 The NetBSD Foundation, Inc.
51.3Such * All rights reserved.
61.3Such *
71.3Such * Redistribution and use in source and binary forms, with or without
81.3Such * modification, are permitted provided that the following conditions
91.3Such * are met:
101.3Such * 1. Redistributions of source code must retain the above copyright
111.3Such *    notice, this list of conditions and the following disclaimer.
121.3Such * 2. Redistributions in binary form must reproduce the above copyright
131.3Such *    notice, this list of conditions and the following disclaimer in the
141.3Such *    documentation and/or other materials provided with the distribution.
151.3Such * 3. All advertising materials mentioning features or use of this software
161.3Such *    must display the following acknowledgement:
171.3Such *        This product includes software developed by the NetBSD
181.3Such *        Foundation, Inc. and its contributors.
191.3Such * 4. Neither the name of The NetBSD Foundation nor the names of its
201.3Such *    contributors may be used to endorse or promote products derived
211.3Such *    from this software without specific prior written permission.
221.3Such *
231.3Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
241.3Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
251.3Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
261.3Such * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
271.3Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
281.3Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
291.3Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
301.3Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
311.3Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
321.3Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
331.3Such * POSSIBILITY OF SUCH DAMAGE.
341.3Such */
351.3Such
361.1Smarcus#ifndef _DREAMCAST_INTR_H_
371.1Smarcus#define _DREAMCAST_INTR_H_
381.1Smarcus
391.3Such#include <sh3/intr.h>
401.1Smarcus
411.3Such/* Number of interrupt source */
421.4Sitohy#define _INTR_N		10	/* TMU0, TMU1, TMU2, SCIF * 4, IRL * 3 */
431.3Such
441.3Such/* Interrupt priority levels */
451.4Sitohy#define	IPL_BIO		9	/* block I/O	(IRL9) */
461.4Sitohy#define	IPL_NET		11	/* network	(IRL11) */
471.4Sitohy#define	IPL_TTY		12	/* terminal	(IRL13) */
481.5Syamt#define	IPL_VM		IPL_TTY
491.3Such#define	IPL_SERIAL	12	/* serial */
501.3Such#define	IPL_CLOCK	14	/* clock */
511.5Syamt#define	IPL_STATCLOCK	IPL_CLOCK
521.5Syamt#define	IPL_SCHED	IPL_CLOCK
531.3Such#define	IPL_HIGH	15	/* everything */
541.5Syamt#define	IPL_LOCK	IPL_HIGH
551.3Such
561.6Sadtypedef uint8_t ipl_t;
571.5Syamttypedef struct {
581.5Syamt	ipl_t _ipl;
591.5Syamt} ipl_cookie_t;
601.5Syamt
611.5Syamtstatic inline ipl_cookie_t
621.5Syamtmakeiplcookie(ipl_t ipl)
631.5Syamt{
641.5Syamt
651.5Syamt	return (ipl_cookie_t){._ipl = ipl << 4};
661.5Syamt}
671.5Syamt
681.5Syamtstatic inline int
691.5Syamtsplraiseipl(ipl_cookie_t icookie)
701.5Syamt{
711.5Syamt
721.5Syamt	return _cpu_intr_raise(icookie._ipl);
731.5Syamt}
741.5Syamt
751.5Syamt#include <sys/spl.h>
761.1Smarcus
771.3Such#define	spl0()			_cpu_intr_resume(0)
781.3Such#define	splx(x)			_cpu_intr_resume(x)
791.1Smarcus
801.3Such#define	spllowersoftclock()	_cpu_intr_resume(IPL_SOFTCLOCK << 4)
811.1Smarcus
821.3Such#endif /* !_DREAMCAST_INTR_H_ */
83