cpu.h revision 1.7
11.7Sthorpej/* $NetBSD: cpu.h,v 1.7 2000/05/26 21:20:05 thorpej Exp $ */ 21.1Sws 31.1Sws/* 41.2Sthorpej * Copyright (C) 1995-1997 Wolfgang Solfrank. 51.2Sthorpej * Copyright (C) 1995-1997 TooLs GmbH. 61.1Sws * All rights reserved. 71.1Sws * 81.1Sws * Redistribution and use in source and binary forms, with or without 91.1Sws * modification, are permitted provided that the following conditions 101.1Sws * are met: 111.1Sws * 1. Redistributions of source code must retain the above copyright 121.1Sws * notice, this list of conditions and the following disclaimer. 131.1Sws * 2. Redistributions in binary form must reproduce the above copyright 141.1Sws * notice, this list of conditions and the following disclaimer in the 151.1Sws * documentation and/or other materials provided with the distribution. 161.1Sws * 3. All advertising materials mentioning features or use of this software 171.1Sws * must display the following acknowledgement: 181.1Sws * This product includes software developed by TooLs GmbH. 191.1Sws * 4. The name of TooLs GmbH may not be used to endorse or promote products 201.1Sws * derived from this software without specific prior written permission. 211.1Sws * 221.1Sws * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 231.1Sws * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.1Sws * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.1Sws * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 261.1Sws * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 271.1Sws * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 281.1Sws * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 291.1Sws * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 301.1Sws * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 311.1Sws * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 321.1Sws */ 331.1Sws#ifndef _MACHINE_CPU_H_ 341.1Sws#define _MACHINE_CPU_H_ 351.1Sws 361.7Sthorpej#if defined(_KERNEL) && !defined(_LKM) 371.7Sthorpej#include "opt_lockdebug.h" 381.7Sthorpej#endif 391.7Sthorpej 401.1Sws#include <machine/frame.h> 411.7Sthorpej 421.7Sthorpej#include <sys/sched.h> 431.7Sthorpejstruct cpu_info { 441.7Sthorpej struct schedstate_percpu ci_schedstate; /* scheduler state */ 451.7Sthorpej#if defined(DIAGNOSTIC) || defined(LOCKDEBUG) 461.7Sthorpej u_long ci_spin_locks; /* # of spin locks held */ 471.7Sthorpej u_long ci_simple_locks; /* # of simple locks held */ 481.7Sthorpej#endif 491.7Sthorpej}; 501.7Sthorpej 511.7Sthorpej#ifdef _KERNEL 521.7Sthorpejextern struct cpu_info cpu_info_store; 531.7Sthorpej 541.7Sthorpej#define curcpu() (&cpu_info_store) 551.7Sthorpej#endif 561.1Sws 571.1Swsstruct machvec { 581.2Sthorpej int (*splhigh) __P((void)); 591.2Sthorpej int (*spl0) __P((void)); 601.2Sthorpej int (*splbio) __P((void)); 611.2Sthorpej int (*splnet) __P((void)); 621.2Sthorpej int (*spltty) __P((void)); 631.2Sthorpej int (*splimp) __P((void)); 641.2Sthorpej int (*splclock) __P((void)); 651.5Sthorpej int (*spllowersoftclock) __P((void)); 661.2Sthorpej int (*splsoftclock) __P((void)); 671.2Sthorpej int (*splsoftnet) __P((void)); 681.2Sthorpej int (*splx) __P((int)); 691.2Sthorpej void (*setsoftclock) __P((void)); 701.2Sthorpej void (*setsoftnet) __P((void)); 711.2Sthorpej void (*clock_return) __P((struct clockframe *, int)); 721.1Sws void (*irq_establish) __P((int, int, void (*)(void *), void *)); 731.1Sws}; 741.1Swsextern struct machvec machine_interface; 751.1Sws 761.1Sws#include <machine/psl.h> 771.1Sws 781.2Sthorpej#define splhigh() ((*machine_interface.splhigh)()) 791.2Sthorpej#define spl0() ((*machine_interface.spl0)()) 801.2Sthorpej#define splbio() ((*machine_interface.splbio)()) 811.2Sthorpej#define splnet() ((*machine_interface.splnet)()) 821.2Sthorpej#define spltty() ((*machine_interface.spltty)()) 831.2Sthorpej#define splimp() ((*machine_interface.splimp)()) 841.2Sthorpej#define splclock() ((*machine_interface.splclock)()) 851.5Sthorpej#define spllowersoftclock() ((*machine_interface.spllowersoftclock)()) 861.2Sthorpej#define splsoftclock() ((*machine_interface.splsoftclock)()) 871.2Sthorpej#define splstatclock() splclock() 881.2Sthorpej#define splsoftnet() ((*machine_interface.splsoftnet)()) 891.2Sthorpej#define splx(new) ((*machine_interface.splx)(new)) 901.2Sthorpej#define setsoftclock() ((*machine_interface.setsoftclock)()) 911.2Sthorpej#define setsoftnet() ((*machine_interface.setsoftnet)()) 921.2Sthorpej#define clock_return(frame, level) \ 931.2Sthorpej ((*machine_interface.clock_return)((frame), (level))) 941.1Sws#define irq_establish(irq, level, handler, arg) \ 951.1Sws ((*machine_interface.irq_establish)((irq), (level), (handler), (arg))) 961.1Sws 971.1Sws#define CLKF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 981.1Sws#define CLKF_BASEPRI(frame) ((frame)->pri == 0) 991.1Sws#define CLKF_PC(frame) ((frame)->srr0) 1001.2Sthorpej#define CLKF_INTR(frame) ((frame)->depth >= 0) 1011.1Sws 1021.1Sws#define cpu_swapout(p) 1031.1Sws#define cpu_wait(p) 1041.6Sthorpej#define cpu_number() 0 1051.1Sws 1061.1Swsextern void delay __P((unsigned)); 1071.1Sws#define DELAY(n) delay(n) 1081.1Sws 1091.3Sthorpejextern __volatile int want_resched; 1101.3Sthorpejextern __volatile int astpending; 1111.1Sws 1121.1Sws#define need_resched() (want_resched = 1, astpending = 1) 1131.1Sws#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, astpending = 1) 1141.1Sws#define signotify(p) (astpending = 1) 1151.1Sws 1161.4Swsextern char *bootpath; 1171.1Sws 1181.4Sws#ifdef _KERNEL 1191.4Sws#define CACHELINESIZE 32 1201.4Sws#endif 1211.1Sws 1221.4Sws#include <powerpc/cpu.h> 1231.1Sws 1241.1Sws#endif /* _MACHINE_CPU_H_ */ 125