Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.1
      1  1.1  sakamoto /*	$NetBSD: cpu.h,v 1.1 1997/10/14 06:48:11 sakamoto Exp $	*/
      2  1.1  sakamoto 
      3  1.1  sakamoto /*
      4  1.1  sakamoto  * Copyright (C) 1995-1997 Wolfgang Solfrank.
      5  1.1  sakamoto  * Copyright (C) 1995-1997 TooLs GmbH.
      6  1.1  sakamoto  * All rights reserved.
      7  1.1  sakamoto  *
      8  1.1  sakamoto  * Redistribution and use in source and binary forms, with or without
      9  1.1  sakamoto  * modification, are permitted provided that the following conditions
     10  1.1  sakamoto  * are met:
     11  1.1  sakamoto  * 1. Redistributions of source code must retain the above copyright
     12  1.1  sakamoto  *    notice, this list of conditions and the following disclaimer.
     13  1.1  sakamoto  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  sakamoto  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  sakamoto  *    documentation and/or other materials provided with the distribution.
     16  1.1  sakamoto  * 3. All advertising materials mentioning features or use of this software
     17  1.1  sakamoto  *    must display the following acknowledgement:
     18  1.1  sakamoto  *	This product includes software developed by TooLs GmbH.
     19  1.1  sakamoto  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20  1.1  sakamoto  *    derived from this software without specific prior written permission.
     21  1.1  sakamoto  *
     22  1.1  sakamoto  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23  1.1  sakamoto  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.1  sakamoto  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.1  sakamoto  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  1.1  sakamoto  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27  1.1  sakamoto  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28  1.1  sakamoto  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29  1.1  sakamoto  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30  1.1  sakamoto  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31  1.1  sakamoto  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  1.1  sakamoto  */
     33  1.1  sakamoto #ifndef	_MACHINE_CPU_H_
     34  1.1  sakamoto #define	_MACHINE_CPU_H_
     35  1.1  sakamoto 
     36  1.1  sakamoto #include <machine/frame.h>
     37  1.1  sakamoto 
     38  1.1  sakamoto struct machvec {
     39  1.1  sakamoto 	int (*splhigh) __P((void));
     40  1.1  sakamoto 	int (*spl0) __P((void));
     41  1.1  sakamoto 	int (*splbio) __P((void));
     42  1.1  sakamoto 	int (*splnet) __P((void));
     43  1.1  sakamoto 	int (*spltty) __P((void));
     44  1.1  sakamoto 	int (*splimp) __P((void));
     45  1.1  sakamoto 	int (*splclock) __P((void));
     46  1.1  sakamoto 	int (*splsoftclock) __P((void));
     47  1.1  sakamoto 	int (*splsoftnet) __P((void));
     48  1.1  sakamoto 	int (*splx) __P((int));
     49  1.1  sakamoto 	void (*setsoftclock) __P((void));
     50  1.1  sakamoto 	void (*setsoftnet) __P((void));
     51  1.1  sakamoto 	void (*clock_return) __P((struct clockframe *, int));
     52  1.1  sakamoto 	void (*irq_establish) __P((int, int, void (*)(void *), void *));
     53  1.1  sakamoto };
     54  1.1  sakamoto extern struct machvec machine_interface;
     55  1.1  sakamoto 
     56  1.1  sakamoto #include <machine/psl.h>
     57  1.1  sakamoto 
     58  1.1  sakamoto #define	splhigh()	((*machine_interface.splhigh)())
     59  1.1  sakamoto #define	spl0()		((*machine_interface.spl0)())
     60  1.1  sakamoto #define	splbio()	((*machine_interface.splbio)())
     61  1.1  sakamoto #define	splnet()	((*machine_interface.splnet)())
     62  1.1  sakamoto #define	spltty()	((*machine_interface.spltty)())
     63  1.1  sakamoto #define	splimp()	((*machine_interface.splimp)())
     64  1.1  sakamoto #define	splclock()	((*machine_interface.splclock)())
     65  1.1  sakamoto #define	splsoftclock()	((*machine_interface.splsoftclock)())
     66  1.1  sakamoto #define	splstatclock()	splclock()
     67  1.1  sakamoto #define	splsoftnet()	((*machine_interface.splsoftnet)())
     68  1.1  sakamoto #define	splx(new)	((*machine_interface.splx)(new))
     69  1.1  sakamoto #define	setsoftclock()	((*machine_interface.setsoftclock)())
     70  1.1  sakamoto #define	setsoftnet()	((*machine_interface.setsoftnet)())
     71  1.1  sakamoto #define	clock_return(frame, level)		\
     72  1.1  sakamoto 	((*machine_interface.clock_return)((frame), (level)))
     73  1.1  sakamoto #define	irq_establish(irq, level, handler, arg)	\
     74  1.1  sakamoto 	((*machine_interface.irq_establish)((irq), (level), (handler), (arg)))
     75  1.1  sakamoto 
     76  1.1  sakamoto #define	CLKF_USERMODE(frame)	(((frame)->srr1 & PSL_PR) != 0)
     77  1.1  sakamoto #define	CLKF_BASEPRI(frame)	((frame)->pri == 0)
     78  1.1  sakamoto #define	CLKF_PC(frame)		((frame)->srr0)
     79  1.1  sakamoto #define	CLKF_INTR(frame)	((frame)->depth > 0)
     80  1.1  sakamoto 
     81  1.1  sakamoto #define	cpu_swapout(p)
     82  1.1  sakamoto #define cpu_wait(p)
     83  1.1  sakamoto 
     84  1.1  sakamoto extern void delay __P((int));
     85  1.1  sakamoto #define	DELAY(n)		delay(n)
     86  1.1  sakamoto 
     87  1.1  sakamoto extern volatile int want_resched;
     88  1.1  sakamoto extern volatile int astpending;
     89  1.1  sakamoto 
     90  1.1  sakamoto #define	need_resched()		(want_resched = 1, astpending = 1)
     91  1.1  sakamoto #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, astpending = 1)
     92  1.1  sakamoto #define	signotify(p)		(astpending = 1)
     93  1.1  sakamoto 
     94  1.1  sakamoto #define	CACHELINESIZE	32			/* For now		XXX */
     95  1.1  sakamoto 
     96  1.1  sakamoto extern __inline void
     97  1.1  sakamoto syncicache(from, len)
     98  1.1  sakamoto 	void *from;
     99  1.1  sakamoto 	int len;
    100  1.1  sakamoto {
    101  1.1  sakamoto 	int l = len;
    102  1.1  sakamoto 	void *p = from;
    103  1.1  sakamoto 
    104  1.1  sakamoto 	do {
    105  1.1  sakamoto 		asm volatile ("dcbst 0,%0" :: "r"(p));
    106  1.1  sakamoto 		p += CACHELINESIZE;
    107  1.1  sakamoto 	} while ((l -= CACHELINESIZE) > 0);
    108  1.1  sakamoto 	asm volatile ("sync");
    109  1.1  sakamoto 	do {
    110  1.1  sakamoto 		asm volatile ("icbi 0,%0" :: "r"(from));
    111  1.1  sakamoto 		from += CACHELINESIZE;
    112  1.1  sakamoto 	} while ((len -= CACHELINESIZE) > 0);
    113  1.1  sakamoto 	asm volatile ("isync");
    114  1.1  sakamoto }
    115  1.1  sakamoto 
    116  1.1  sakamoto extern char *bootpath;
    117  1.1  sakamoto 
    118  1.1  sakamoto #endif	/* _MACHINE_CPU_H_ */
    119