Home | History | Annotate | Line # | Download | only in ppc
interrupts.h revision 1.5
      1  1.1  christos /*  This file is part of the program psim.
      2  1.1  christos 
      3  1.1  christos     Copyright (C) 1994-1995, Andrew Cagney <cagney (at) highland.com.au>
      4  1.1  christos 
      5  1.1  christos     This program is free software; you can redistribute it and/or modify
      6  1.1  christos     it under the terms of the GNU General Public License as published by
      7  1.1  christos     the Free Software Foundation; either version 3 of the License, or
      8  1.1  christos     (at your option) any later version.
      9  1.1  christos 
     10  1.1  christos     This program is distributed in the hope that it will be useful,
     11  1.1  christos     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos     GNU General Public License for more details.
     14  1.1  christos 
     15  1.1  christos     You should have received a copy of the GNU General Public License
     16  1.1  christos     along with this program; if not, see <http://www.gnu.org/licenses/>.
     17  1.1  christos 
     18  1.1  christos     */
     19  1.1  christos 
     20  1.1  christos 
     21  1.1  christos #ifndef _INTERRUPTS_H_
     22  1.1  christos #define _INTERRUPTS_H_
     23  1.1  christos 
     24  1.1  christos /* Interrupts:
     25  1.1  christos 
     26  1.1  christos    The code below handles two different types of interrupts.
     27  1.1  christos    Synchronous and Asynchronous.
     28  1.1  christos 
     29  1.1  christos    Synchronous:
     30  1.1  christos 
     31  1.1  christos    Interrupts that must immediately force either an abort or restart
     32  1.1  christos    of a current instruction are implemented by forcing an instruction
     33  1.1  christos    restart. (or to put it another way, long jump).  In looking at the
     34  1.1  christos    code it may occure to you that, for some interrupts, they could
     35  1.1  christos    return instead of restarting the cpu (eg system_call).  While true
     36  1.1  christos    (it once was like that) I've decided to make the behavour of all
     37  1.1  christos    interrupt routines roughly identical.
     38  1.1  christos 
     39  1.1  christos    Because, a cpu's recorded state (ie what is in the cpu structure)
     40  1.1  christos    is allowed to lag behind the cpu's true current state (eg PC not
     41  1.1  christos    updated) sycnronous interrupt handers are parameterized with the
     42  1.1  christos    the cpu being interrupted so that, as part of moddeling the
     43  1.1  christos    interrupt, the cpu's state can be updated.
     44  1.1  christos 
     45  1.1  christos    Asynchronous:
     46  1.1  christos 
     47  1.1  christos    Interrupts such as reset or external exception are delivered using
     48  1.1  christos    more normal (returning) functions.  It is assumed that these
     49  1.1  christos    functions are called out side of the normal processor execution
     50  1.1  christos    cycle. */
     51  1.1  christos 
     52  1.1  christos 
     53  1.1  christos /* Software generated interrupts.
     54  1.1  christos 
     55  1.1  christos    The below are generated by software driven events.  For instance,
     56  1.1  christos    an invalid instruction or access (virtual or physical) to an
     57  1.1  christos    invalid address */
     58  1.1  christos 
     59  1.1  christos typedef enum {
     60  1.1  christos   direct_store_storage_interrupt,
     61  1.1  christos   hash_table_miss_storage_interrupt,
     62  1.1  christos   protection_violation_storage_interrupt,
     63  1.1  christos   earwax_violation_storage_interrupt,
     64  1.1  christos   segment_table_miss_storage_interrupt,
     65  1.1  christos   earwax_disabled_storage_interrupt,
     66  1.1  christos   vea_storage_interrupt,
     67  1.1  christos } storage_interrupt_reasons;
     68  1.1  christos 
     69  1.1  christos 
     70  1.1  christos INLINE_INTERRUPTS\
     71  1.1  christos (void) data_storage_interrupt
     72  1.1  christos (cpu *processor,
     73  1.1  christos  unsigned_word cia,
     74  1.1  christos  unsigned_word ea,
     75  1.1  christos  storage_interrupt_reasons reason,
     76  1.1  christos  int is_store);
     77  1.1  christos 
     78  1.1  christos INLINE_INTERRUPTS\
     79  1.1  christos (void) instruction_storage_interrupt
     80  1.1  christos (cpu *processor,
     81  1.1  christos  unsigned_word cia,
     82  1.1  christos  storage_interrupt_reasons reason);
     83  1.1  christos 
     84  1.1  christos INLINE_INTERRUPTS\
     85  1.1  christos (void) alignment_interrupt
     86  1.1  christos (cpu *processor,
     87  1.1  christos  unsigned_word cia,
     88  1.1  christos  unsigned_word ra);
     89  1.1  christos 
     90  1.1  christos typedef enum {
     91  1.1  christos   floating_point_enabled_program_interrupt,
     92  1.1  christos   illegal_instruction_program_interrupt,
     93  1.1  christos   privileged_instruction_program_interrupt,
     94  1.1  christos   trap_program_interrupt,
     95  1.1  christos   optional_instruction_program_interrupt, /* subset of illegal instruction */
     96  1.1  christos   mpc860c0_instruction_program_interrupt, /* fwd br, taken but not predicted, near EO page */
     97  1.1  christos   nr_program_interrupt_reasons
     98  1.1  christos } program_interrupt_reasons;
     99  1.1  christos 
    100  1.1  christos INLINE_INTERRUPTS\
    101  1.1  christos (void) program_interrupt
    102  1.1  christos (cpu *processor,
    103  1.1  christos  unsigned_word cia,
    104  1.1  christos  program_interrupt_reasons reason);
    105  1.1  christos 
    106  1.1  christos INLINE_INTERRUPTS\
    107  1.1  christos (void) floating_point_unavailable_interrupt
    108  1.1  christos (cpu *processor,
    109  1.1  christos  unsigned_word cia);
    110  1.1  christos 
    111  1.1  christos INLINE_INTERRUPTS\
    112  1.1  christos (void) system_call_interrupt
    113  1.1  christos (cpu *processor,
    114  1.1  christos  unsigned_word cia);
    115  1.1  christos 
    116  1.1  christos INLINE_INTERRUPTS\
    117  1.1  christos (void) floating_point_assist_interrupt
    118  1.1  christos (cpu *processor,
    119  1.1  christos  unsigned_word cia);
    120  1.1  christos 
    121  1.1  christos INLINE_INTERRUPTS\
    122  1.1  christos (void) machine_check_interrupt
    123  1.1  christos (cpu *processor,
    124  1.1  christos  unsigned_word cia);
    125  1.1  christos 
    126  1.1  christos /* Hardware generated interrupts:
    127  1.1  christos 
    128  1.1  christos    These asynchronous hardware generated interrupts may be called at
    129  1.1  christos    any time.  It is the responsibility of this (the interrupts) module
    130  1.1  christos    to ensure that interrupts are delivered correctly (when possible).
    131  1.1  christos    The delivery of these interrupts is controlled by the MSR's
    132  1.1  christos    external interrupt enable bit.  When ever the MSR's value is
    133  1.1  christos    changed, the processor must call the check_masked_interrupts()
    134  1.1  christos    function in case delivery has been made possible.
    135  1.1  christos 
    136  1.1  christos    decrementer_interrupt is `edge' sensitive.  Multiple edges arriving
    137  1.1  christos    before the first edge has been delivered result in only one
    138  1.1  christos    interrupt.
    139  1.1  christos 
    140  1.1  christos    external_interrupt is `level' sensitive.  An external interrupt
    141  1.1  christos    will only be delivered when the external interrupt port is
    142  1.1  christos    `asserted'. While interrupts are disabled, the external interrupt
    143  1.1  christos    can be asserted and then de-asserted without an interrupt
    144  1.1  christos    eventually being delivered. */
    145  1.1  christos 
    146  1.1  christos enum {
    147  1.1  christos   external_interrupt_pending = 1,
    148  1.1  christos   decrementer_interrupt_pending = 2,
    149  1.1  christos };
    150  1.1  christos 
    151  1.1  christos typedef struct _interrupts {
    152  1.1  christos   event_entry_tag delivery_scheduled;
    153  1.1  christos   int pending_interrupts;
    154  1.1  christos } interrupts;
    155  1.1  christos 
    156  1.1  christos INLINE_INTERRUPTS\
    157  1.1  christos (void) check_masked_interrupts
    158  1.1  christos (cpu *processor);
    159  1.1  christos 
    160  1.1  christos INLINE_INTERRUPTS\
    161  1.1  christos (void) decrementer_interrupt
    162  1.1  christos (cpu *processor);
    163  1.1  christos 
    164  1.1  christos INLINE_INTERRUPTS\
    165  1.1  christos (void) external_interrupt
    166  1.1  christos (cpu *processor,
    167  1.1  christos  int is_asserted);
    168  1.1  christos 
    169  1.1  christos #endif /* _INTERRUPTS_H_ */
    170