cpu.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* $OpenBSD: cpu.h,v 1.35 2012/12/02 07:03:31 guenther Exp $ */
  2. /* $NetBSD: cpu.h,v 1.24 1997/03/15 22:25:15 pk Exp $ */
  3. /*
  4. * Copyright (c) 1992, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This software was developed by the Computer Systems Engineering group
  8. * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  9. * contributed to Berkeley.
  10. *
  11. * All advertising materials mentioning features or use of this software
  12. * must display the following acknowledgement:
  13. * This product includes software developed by the University of
  14. * California, Lawrence Berkeley Laboratory.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. * 1. Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * 3. Neither the name of the University nor the names of its contributors
  25. * may be used to endorse or promote products derived from this software
  26. * without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  29. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  32. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. * SUCH DAMAGE.
  39. *
  40. * @(#)cpu.h 8.4 (Berkeley) 1/5/94
  41. */
  42. #ifndef _MACHINE_CPU_H_
  43. #define _MACHINE_CPU_H_
  44. /*
  45. * CTL_MACHDEP definitions.
  46. */
  47. #define CPU_LED_BLINK 1 /* int: twiddle the power LED */
  48. /* 2 formerly int: vsyncblank */
  49. #define CPU_CPUTYPE 3 /* int: cpu type */
  50. #define CPU_V8MUL 4
  51. #define CPU_MAXID 5 /* 4 valid machdep IDs */
  52. #define CTL_MACHDEP_NAMES { \
  53. { 0, 0 }, \
  54. { "led_blink", CTLTYPE_INT }, \
  55. { 0, 0 }, \
  56. { "cputype", CTLTYPE_INT }, \
  57. { "v8mul", CTLTYPE_INT }, \
  58. }
  59. #ifdef _KERNEL
  60. /*
  61. * Exported definitions unique to SPARC cpu support.
  62. */
  63. #include <machine/psl.h>
  64. #include <machine/reg.h>
  65. #include <machine/intr.h>
  66. #include <sparc/sparc/intreg.h>
  67. #include <sparc/sparc/cpuvar.h>
  68. /*
  69. * Arguments to hardclock, softclock and gatherstats encapsulate the
  70. * previous machine state in an opaque clockframe. The ipl is here
  71. * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
  72. * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
  73. */
  74. struct clockframe {
  75. u_int psr; /* psr before interrupt, excluding PSR_ET */
  76. u_int pc; /* pc at interrupt */
  77. u_int npc; /* npc at interrupt */
  78. u_int ipl; /* actual interrupt priority level */
  79. u_int fp; /* %fp at interrupt */
  80. };
  81. typedef struct clockframe clockframe;
  82. extern int eintstack[];
  83. #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0)
  84. #define CLKF_PC(framep) ((framep)->pc)
  85. #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack)
  86. /*
  87. * Preempt the current process if in interrupt from user mode,
  88. * or after the current trap/syscall if in system mode.
  89. */
  90. extern int want_resched; /* resched() was called */
  91. #define need_resched(ci) (want_resched = 1, want_ast = 1)
  92. #define clear_resched(ci) want_resched = 0
  93. extern int want_ast;
  94. /*
  95. * This is used during profiling to integrate system time.
  96. */
  97. #define PROC_PC(p) ((p)->p_md.md_tf->tf_pc)
  98. #define PROC_STACK(p) ((p)->p_md.md_tf->tf_out[6])
  99. /*
  100. * Give a profiling tick to the current process when the user profiling
  101. * buffer pages are invalid. On the sparc, request an ast to send us
  102. * through trap(), marking the proc as needing a profiling tick.
  103. */
  104. #define need_proftick(p) do { want_ast = 1; } while (0)
  105. /*
  106. * Notify the current process (p) that it has a signal pending,
  107. * process as soon as possible.
  108. */
  109. #define signotify(p) (want_ast = 1)
  110. extern int foundfpu; /* true => we have an FPU */
  111. /* auxreg.c */
  112. void led_blink(void *);
  113. /* scf.c */
  114. void scfblink(void *);
  115. /* disksubr.c */
  116. struct dkbad;
  117. int isbad(struct dkbad *bt, int, int, int);
  118. /* machdep.c */
  119. int ldcontrolb(caddr_t);
  120. void dumpconf(void);
  121. caddr_t reserve_dumppages(caddr_t);
  122. /* clock.c */
  123. struct timeval;
  124. void lo_microtime(struct timeval *);
  125. int statintr(void *);
  126. int clockintr(void *);/* level 10 (clock) interrupt code */
  127. int statintr(void *); /* level 14 (statclock) interrupt code */
  128. /* locore.s */
  129. struct fpstate;
  130. void savefpstate(struct fpstate *);
  131. void loadfpstate(struct fpstate *);
  132. int probeget(caddr_t, int);
  133. void write_all_windows(void);
  134. void write_user_windows(void);
  135. void proc_trampoline(void);
  136. struct pcb;
  137. void snapshot(struct pcb *);
  138. struct frame *getfp(void);
  139. int xldcontrolb(caddr_t, struct pcb *);
  140. void copywords(const void *, void *, size_t);
  141. void qcopy(const void *, void *, size_t);
  142. void qzero(void *, size_t);
  143. /* locore2.c */
  144. void remrunqueue(struct proc *);
  145. /* trap.c */
  146. void pmap_unuse_final(struct proc *);
  147. int rwindow_save(struct proc *);
  148. /* amd7930intr.s */
  149. void amd7930_trap(void);
  150. #ifdef KGDB
  151. /* zs_kgdb.c */
  152. void zs_kgdb_init(void);
  153. #endif
  154. /* fb.c */
  155. void fb_unblank(void);
  156. /* cache.c */
  157. void cache_flush(caddr_t, u_int);
  158. /* kgdb_stub.c */
  159. #ifdef KGDB
  160. void kgdb_attach(int (*)(void *), void (*)(void *, int), void *);
  161. void kgdb_connect(int);
  162. void kgdb_panic(void);
  163. #endif
  164. /* iommu.c */
  165. void iommu_enter(u_int, u_int);
  166. void iommu_remove(u_int, u_int);
  167. /* emul.c */
  168. struct trapframe;
  169. int emulinstr(int, struct trapframe *);
  170. /*
  171. *
  172. * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
  173. * of the trap vector table. The next eight bits are supplied by the
  174. * hardware when the trap occurs, and the bottom four bits are always
  175. * zero (so that we can shove up to 16 bytes of executable code---exactly
  176. * four instructions---into each trap vector).
  177. *
  178. * The hardware allocates half the trap vectors to hardware and half to
  179. * software.
  180. *
  181. * Traps have priorities assigned (lower number => higher priority).
  182. */
  183. struct trapvec {
  184. int tv_instr[4]; /* the four instructions */
  185. };
  186. extern struct trapvec *trapbase; /* the 256 vectors */
  187. #endif /* _KERNEL */
  188. #endif /* _MACHINE_CPU_H_ */