cpu.h revision 1.3
11.3Sthorpej/* $NetBSD: cpu.h,v 1.3 2024/01/02 18:10:36 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/* 41.1Sthorpej * Copyright (c) 1988 University of Utah. 51.1Sthorpej * Copyright (c) 1982, 1990, 1993 61.1Sthorpej * The Regents of the University of California. All rights reserved. 71.1Sthorpej * 81.1Sthorpej * This code is derived from software contributed to Berkeley by 91.1Sthorpej * the Systems Programming Group of the University of Utah Computer 101.1Sthorpej * Science Department. 111.1Sthorpej * 121.1Sthorpej * Redistribution and use in source and binary forms, with or without 131.1Sthorpej * modification, are permitted provided that the following conditions 141.1Sthorpej * are met: 151.1Sthorpej * 1. Redistributions of source code must retain the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer. 171.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 181.1Sthorpej * notice, this list of conditions and the following disclaimer in the 191.1Sthorpej * documentation and/or other materials provided with the distribution. 201.1Sthorpej * 3. Neither the name of the University nor the names of its contributors 211.1Sthorpej * may be used to endorse or promote products derived from this software 221.1Sthorpej * without specific prior written permission. 231.1Sthorpej * 241.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271.1Sthorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341.1Sthorpej * SUCH DAMAGE. 351.1Sthorpej * 361.1Sthorpej * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 371.1Sthorpej * 381.1Sthorpej * @(#)cpu.h 8.4 (Berkeley) 1/5/94 391.1Sthorpej */ 401.1Sthorpej 411.1Sthorpej#ifndef _MACHINE_CPU_H_ 421.1Sthorpej#define _MACHINE_CPU_H_ 431.1Sthorpej 441.1Sthorpej#if defined(_KERNEL_OPT) 451.1Sthorpej#include "opt_lockdebug.h" 461.1Sthorpej#include "opt_m68k_arch.h" 471.1Sthorpej#endif 481.1Sthorpej 491.1Sthorpej/* 501.1Sthorpej * Get common m68k CPU definitions. 511.1Sthorpej */ 521.1Sthorpej#include <m68k/cpu.h> 531.1Sthorpej 541.1Sthorpej#if defined(_KERNEL) 551.1Sthorpej/* 561.1Sthorpej * Exported definitions unique to virt68k/68k cpu support. 571.1Sthorpej */ 581.1Sthorpej#define M68K_MMU_MOTOROLA 591.1Sthorpej 601.1Sthorpej/* 611.1Sthorpej * Arguments to hardclock and gatherstats encapsulate the previous 621.1Sthorpej * machine state in an opaque clockframe. On the virt68k, we use 631.1Sthorpej * what the hardware pushes on an interrupt (frame format 0). 641.1Sthorpej */ 651.1Sthorpejstruct clockframe { 661.1Sthorpej u_short sr; /* sr at time of interrupt */ 671.1Sthorpej u_long pc; /* pc at time of interrupt */ 681.1Sthorpej u_short fmt:4, 691.1Sthorpej vec:12; /* vector offset (4-word frame) */ 701.1Sthorpej} __attribute__((packed)); 711.1Sthorpej 721.1Sthorpej#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 731.1Sthorpej#define CLKF_PC(framep) ((framep)->pc) 741.1Sthorpej 751.1Sthorpej/* 761.1Sthorpej * The clock interrupt handler can determine if it's a nested 771.1Sthorpej * interrupt by checking for intr_depth > 1. 781.1Sthorpej * (Remember, the clock interrupt handler itself will cause the 791.1Sthorpej * depth counter to be incremented). 801.1Sthorpej */ 811.1Sthorpejextern volatile unsigned int intr_depth; 821.1Sthorpej#define CLKF_INTR(framep) (intr_depth > 1) 831.1Sthorpej 841.1Sthorpej/* 851.1Sthorpej * Preempt the current process if in interrupt from user mode, 861.1Sthorpej * or after the current trap/syscall if in system mode. 871.1Sthorpej */ 881.1Sthorpej#define cpu_need_resched(ci,l,flags) do { \ 891.1Sthorpej __USE(flags); \ 901.1Sthorpej aston(); \ 911.1Sthorpej} while (/*CONSTCOND*/0) 921.1Sthorpej 931.1Sthorpej/* 941.1Sthorpej * Give a profiling tick to the current process when the user profiling 951.1Sthorpej * buffer pages are invalid. On the virt68k, request an ast to send us 961.1Sthorpej * through trap, marking the proc as needing a profiling tick. 971.1Sthorpej */ 981.1Sthorpej#define cpu_need_proftick(l) \ 991.1Sthorpej do { (l)->l_pflag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */0) 1001.1Sthorpej 1011.1Sthorpej/* 1021.1Sthorpej * Notify the current process (p) that it has a signal pending, 1031.1Sthorpej * process as soon as possible. 1041.1Sthorpej */ 1051.1Sthorpej#define cpu_signotify(l) aston() 1061.1Sthorpej 1071.1Sthorpejextern int astpending; /* need to trap before returning to user mode */ 1081.1Sthorpej#define aston() (astpending++) 1091.1Sthorpej 1101.1Sthorpej#endif /* _KERNEL */ 1111.1Sthorpej 1121.1Sthorpej#ifdef _KERNEL 1131.3Sthorpejvoid cpu_set_reset_func(void (*)(void *, int), void *); 1141.1Sthorpejint nmihand(void *); 1151.1Sthorpejvoid loadustp(paddr_t); 1161.1Sthorpej 1171.1Sthorpej#endif /* _KERNEL */ 1181.1Sthorpej 1191.1Sthorpej#endif /* _MACHINE_CPU_H_ */ 120