github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/isr.h (about)

     1  /*
     2   * Copyright (c) 2013 Intel Corporation
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *     http://www.apache.org/licenses/LICENSE-2.0
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11   * See the License for the specific language governing permissions and
    12   * limitations under the License.
    13   */
    14  
    15  #ifndef _ISR_H_
    16  #define _ISR_H_
    17  
    18  #include "vmm_defs.h"
    19  
    20  #pragma PACK_ON
    21  
    22  typedef struct _EXCEPTION_STACK_WITH_ERRCODE_LAYOUT {
    23      ADDRESS errcode;
    24      ADDRESS ip;
    25      ADDRESS cs;
    26      ADDRESS flags;
    27      ADDRESS sp;
    28  } EXCEPTION_STACK_WITH_ERRCODE_LAYOUT;
    29  
    30  typedef struct _EXCEPTION_STACK_LAYOUT {
    31      ADDRESS ip;
    32      ADDRESS cs;
    33      ADDRESS flags;
    34      ADDRESS sp;
    35      ADDRESS dummy;
    36  } EXCEPTION_STACK_LAYOUT;
    37  
    38  typedef struct {
    39      union {
    40          ADDRESS vector_id;     // assembler code sets this as an input to
    41                                 // C handler
    42          ADDRESS except_ip_ptr; // C handler have to set this to point to the
    43                                 // ip member of the EXCEPTION_STACK before
    44                                 // return to assembler code
    45      } a;
    46      union {
    47          EXCEPTION_STACK_WITH_ERRCODE_LAYOUT errcode_exception;
    48          EXCEPTION_STACK_LAYOUT exception;
    49      } PACKED u;
    50  } PACKED ISR_PARAMETERS_ON_STACK;
    51  
    52  typedef void (*VMM_ISR_HANDLER)(ISR_PARAMETERS_ON_STACK *p_stack);
    53  
    54  #pragma PACK_OFF
    55  
    56  typedef enum {
    57      IA32_EXCEPTION_VECTOR_DIVIDE_ERROR,
    58      IA32_EXCEPTION_VECTOR_DEBUG_BREAKPOINT,
    59      IA32_EXCEPTION_VECTOR_NMI,
    60      IA32_EXCEPTION_VECTOR_BREAKPOINT,
    61      IA32_EXCEPTION_VECTOR_OVERFLOW,
    62      IA32_EXCEPTION_VECTOR_BOUND_RANGE_EXCEEDED,
    63      IA32_EXCEPTION_VECTOR_UNDEFINED_OPCODE,
    64      IA32_EXCEPTION_VECTOR_NO_MATH_COPROCESSOR,
    65      IA32_EXCEPTION_VECTOR_DOUBLE_FAULT,
    66      IA32_EXCEPTION_VECTOR_RESERVED_0X09,
    67      IA32_EXCEPTION_VECTOR_INVALID_TASK_SEGMENT_SELECTOR,
    68      IA32_EXCEPTION_VECTOR_SEGMENT_NOT_PRESENT,
    69      IA32_EXCEPTION_VECTOR_STACK_SEGMENT_FAULT,
    70      IA32_EXCEPTION_VECTOR_GENERAL_PROTECTION_FAULT,
    71      IA32_EXCEPTION_VECTOR_PAGE_FAULT,
    72      IA32_EXCEPTION_VECTOR_RESERVED_0X0F,
    73      IA32_EXCEPTION_VECTOR_MATH_FAULT,
    74      IA32_EXCEPTION_VECTOR_ALIGNMENT_CHECK,
    75      IA32_EXCEPTION_VECTOR_MACHINE_CHECK,
    76      IA32_EXCEPTION_VECTOR_SIMD_FLOATING_POINT_NUMERIC_ERROR,
    77      IA32_EXCEPTION_VECTOR_VIRTUAL_EXCEPTION,
    78      IA32_EXCEPTION_VECTOR_RESERVED_0X15,
    79      IA32_EXCEPTION_VECTOR_RESERVED_0X16,
    80      IA32_EXCEPTION_VECTOR_RESERVED_0X17,
    81      IA32_EXCEPTION_VECTOR_RESERVED_0X18,
    82      IA32_EXCEPTION_VECTOR_RESERVED_0X19,
    83      IA32_EXCEPTION_VECTOR_RESERVED_0X1A,
    84      IA32_EXCEPTION_VECTOR_RESERVED_0X1B,
    85      IA32_EXCEPTION_VECTOR_RESERVED_0X1C,
    86      IA32_EXCEPTION_VECTOR_RESERVED_0X1D,
    87      IA32_EXCEPTION_VECTOR_RESERVED_0X1E,
    88      IA32_EXCEPTION_VECTOR_RESERVED_0X1F
    89  } HW_APIC_EXCEPTION_VECTORS;
    90  
    91  
    92  // FUNCTION     : isr_c_handler()
    93  // PURPOSE      : Generic ISR handler which calls registered
    94  //              : vector specific handlers.
    95  //              : Clear FLAGS.IF
    96  // ARGUMENTS    : IN ISR_PARAMETERS_ON_STACK *p_stack - points
    97  //              : to the stack, where FLAGS register stored
    98  //              : as a part of return from interrupt cycle
    99  void isr_c_handler( IN OUT ISR_PARAMETERS_ON_STACK *p_stack);
   100  
   101  
   102  // FUNCTION     : isr_register_handler()
   103  // PURPOSE      : Registers ISR handler
   104  // ARGUMENTS    : VMM_ISR_HANDLER handler - is called
   105  //              : when vector interrupt/exception occurs
   106  //              : VECTOR_ID vector_id
   107  // RETURNS      : void
   108  void isr_register_handler( IN VMM_ISR_HANDLER  handler, IN VECTOR_ID vector_id);
   109  
   110  
   111  // FUNCTION     : isr_setup()
   112  // PURPOSE      : Builds ISR wrappers, IDT tables and
   113  //              : default high level ISR handlers for all CPUs.
   114  // ARGUMENTS    : IN UINT8 number_of_cpus
   115  void isr_setup(void);
   116  
   117  void isr_handling_start(void);
   118  
   119  // FUNCTION     : isr_error_code_required()
   120  // PURPOSE      : Check if CPU pushes error code onto stack for given vector ID
   121  // ARGUMENTS    : IN UINT8 number_of_cpus
   122  // RETURNS      : BOOLEAN if error code is pushed
   123  BOOLEAN isr_error_code_required( VECTOR_ID vector_id);
   124  #endif // _ISR_H_
   125  
   126