home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / machsun3.tz / machsun3 / mk.kernel / sun3 / thread.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-15  |  5.9 KB  |  219 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  *    File:    sun3/thread.h
  28.  *    Author:    Avadis Tevanian, Jr.
  29.  *
  30.  *    This file defines machine specific, thread related structures,
  31.  *    variables and macros.
  32.  *
  33.  * HISTORY
  34.  * $Log:    thread.h,v $
  35.  * Revision 2.4  92/03/03  14:22:55  rpd
  36.  *     Added dummy definition of syscall_emulation_sync.
  37.  *     [92/03/03            rpd]
  38.  * 
  39.  * Revision 2.3  91/07/31  18:14:39  dbg
  40.  *     Support stack switching.
  41.  *     [91/03/25            dbg]
  42.  * 
  43.  * Revision 2.2  91/01/08  15:52:50  rpd
  44.  *     Added KEEP_STACKS support.
  45.  *     [91/01/06            rpd]
  46.  * 
  47.  * Revision 2.1  89/08/03  16:53:40  rwd
  48.  * Created.
  49.  * 
  50.  * 20-Jul-88  David Golub (dbg) at Carnegie-Mellon University
  51.  *    Move kernel state fields to this file.
  52.  *
  53.  * 25-Jan-88  Robert Baron (rvb) at Carnegie-Mellon University
  54.  *    Rather than have "u" expand to current_thread()->u_address, have
  55.  *    it expand to the constant U_ADDRESS which is updated by load_context
  56.  *    when the thread changes.  If "u" is defined then user.h won't define
  57.  *    it.  U_ADDRESS is extern because when we are included by sys/thread.h
  58.  *    u_address has not been defined yet.
  59.  *
  60.  *  2-Apr-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  61.  *    Created, no definitions here yet.
  62.  *
  63.  */
  64.  
  65. #ifndef    _SUN3_THREAD_
  66. #define    _SUN3_THREAD_
  67.  
  68. #include <mach/kern_return.h>
  69.  
  70. #include <sun3/buserr.h>
  71. #include <sun3/reg.h>
  72.  
  73. /*
  74.  * User registers are pushed on PCB stack.  Bus error frame
  75.  * follows this.  Variable length - the end address is fixed.
  76.  *
  77.  * Kernel registers are pushed on kernel stack.
  78.  */
  79. struct mc68020_saved_state {
  80.     int        d0;        /* data registers */
  81.     int        d1;
  82.     int        d2;
  83.     int        d3;
  84.     int        d4;
  85.     int        d5;
  86.     int        d6;
  87.     int        d7;
  88.     int        a0;        /* address registers */
  89.     int        a1;
  90.     int        a2;
  91.     int        a3;
  92.     int        a4;
  93.     int        a5;
  94.     int        a6;
  95.     int        sp;        /* stack pointer */
  96.     unsigned short    sr;        /* status register */
  97.     unsigned int    pc;        /* program counter - UNALIGNED!!! */
  98.     unsigned int    stkfmt    : 4;    /* rte stack frame format */
  99.     unsigned int    vector    : 12;    /* vector number */
  100. };
  101.  
  102.  
  103. /*
  104.  * Other user machine state, saved on context switch.
  105.  */
  106.  
  107. /*
  108.  * 68881 floating-point state.
  109.  */
  110. struct mc68881_state {
  111.     struct fp_status    fp_status;    /* user-visible 68881 state */
  112.     struct fp_istate    fp_istate;    /* internal 68881 state */
  113. };
  114.  
  115. /*
  116.  * Weitek floating-point accelerator.
  117.  */
  118. struct fpa_stack {
  119.     short        fpst_save_size;        /* size of saved frame */
  120.     short        fpst_alloc_size;    /* size of this structure */
  121.     long        fpst_ast_bits;        /* saved AST bits */
  122.     struct mc68020_saved_state
  123.             fpst_regs;        /* saved registers and fmt */
  124.     struct bei_longb fpst_longb;        /* and frame */
  125. };
  126.  
  127. struct fpa_state {
  128.     struct fpa_status    fpa_status;    /* fpa internal status */
  129.     struct fpa_exception {
  130.         struct fpa_stack *    fe_fmtptr;    /* points to saved
  131.                            bus error frame */
  132.         int            fe_pc;        /* user pc where
  133.                                bus error occurred */
  134.     } fpa_exception;
  135. #define    fpa_fmtptr        fpa_exception.fe_fmtptr
  136. #define    fpa_pc            fpa_exception.fe_pc
  137.     fpa_long        fpa_data[FPA_NDATA_REGS];
  138.                         /* fpa registers */
  139. };
  140.  
  141. /*
  142.  * User state is allocated lots of space, since it varies in
  143.  * size and moves.  Its TOP is fixed, not its bottom.
  144.  */
  145. #define    USER_STATE_EXTRA    64
  146.                     /* 16 words for stack switching */
  147. #define    USER_STATE_SIZE    (USER_STATE_EXTRA \
  148.             +sizeof(struct mc68020_saved_state) \
  149.             +sizeof(struct bei_longb))
  150.  
  151. struct pcb {
  152.     unsigned char        flag;        /* user - trace flags */
  153.     unsigned char        discard_frame;    /* user - discard bus-error
  154.                               info on exit */
  155.     unsigned short        fault_type;    /* user - fault type */
  156.     vm_offset_t        fault_addr;    /* user - faulting address */
  157.     struct mc68020_saved_state *
  158.                 user_regs;    /* pointer to user state */
  159.     char            user_state[USER_STATE_SIZE];
  160.                         /* user state pushed here */
  161.     struct mc68881_state    mc68881s;    /* 68881 state, if in use */
  162.     struct fpa_state *    fpas;        /* fpa state, if in use */
  163. };
  164. typedef struct pcb    *pcb_t;
  165.  
  166. /*
  167.  * Bits in flag byte.
  168.  */
  169. #define    AST_STEP    0x40        /* force a single step */
  170. #define    TRACE_USER    0x20        /* user has requested tracing */
  171. #define    TRACE_AST    0x10        /* AST has requested tracing */
  172. #define    TRACE_PENDING    0x08        /* user trace caught in supervisor
  173.                        mode */
  174. #define    TRACE_KDB    0x04        /* trace is for KDB (single step
  175.                        supervisor mode) */
  176. #define    AST_CLR        (AST_STEP|TRACE_USER|TRACE_AST|TRACE_PENDING)
  177.  
  178. #define    FPA_USED    0x02        /* FPA used by this thread */
  179. #define    FPA_SAVED    0x01        /* FPA context saved in PCB,
  180.                        if FPA_USED; otherwise,
  181.                        pcb_fpa_status.fpas_state
  182.                        gives the register set. */
  183.  
  184.  
  185. /*
  186.  * State saved on kernel context switch.
  187.  */
  188. struct mc68020_kernel_state {
  189.     int        d2;
  190.     int        d3;
  191.     int        d4;
  192.     int        d5;
  193.     int        d6;
  194.     int        d7;
  195.     int        a2;
  196.     int        a3;
  197.     int        a4;
  198.     int        a5;
  199.     int        a6;
  200.     int        sp;
  201.     int        pc;
  202. };
  203.  
  204. #define    STACK_MKS(stack) \
  205.     ((struct mc68020_kernel_state *)((stack) + KERNEL_STACK_SIZE) - 1)
  206.  
  207.  
  208. /*
  209.  *    Routine definitions
  210.  */
  211. extern void        pcb_init();
  212. extern void        pcb_terminate();
  213. extern kern_return_t    thread_setstatus();
  214. extern kern_return_t    thread_getstatus();
  215.  
  216. #define syscall_emulation_sync(task)    /* do nothing */
  217.  
  218. #endif  /* _SUN3_THREAD_H_ */
  219.