github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/ipc/ipc_impl.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 _IPC_IMPL_H
    16  #define _IPC_IMPL_H
    17  
    18  #include "vmm_defs.h"
    19  #include "isr.h"
    20  #include "list.h"
    21  #include "ipc.h"
    22  #include "lock.h"
    23  
    24  
    25  #define IPC_ALIGNMENT                         ARCH_ADDRESS_WIDTH
    26  
    27  
    28  #define IPC_CPU_ID()                          hw_cpu_id()
    29  
    30  #define NMI_VECTOR                            2
    31  
    32  #define NMIS_WAITING_FOR_PROCESSING(ipc)      (ipc->num_received_nmi_interrupts - ipc->num_processed_nmi_interrupts)
    33  #define IPC_NMIS_WAITING_FOR_PROCESSING(ipc)  (ipc->num_of_sent_ipc_nmi_interrupts - ipc->num_of_processed_ipc_nmi_interrupts)
    34  
    35  // %VT% typedef struct _ARRAY_LIST      *ARRAY_LIST_HANDLE;
    36  // %VT% typedef struct _IPC_CPU_CONTEXT IPC_CPU_CONTEXT;
    37  // %VT% typedef struct _ARRAY_LIST ARRAY_LIST;
    38  // %VT% typedef struct _IPC_MESSAGE IPC_MESSAGE;
    39  
    40  typedef struct _IPC_MESSAGE
    41  {
    42      IPC_MESSAGE_TYPE  type;
    43      CPU_ID            from;
    44      char              padding[2];
    45      IPC_HANDLER_FN    handler;
    46      void              *arg;
    47      volatile UINT32   *before_handler_ack;
    48      volatile UINT32   *after_handler_ack;
    49  } IPC_MESSAGE;
    50  
    51  typedef enum
    52  {
    53      IPC_CPU_NOT_ACTIVE = 0,
    54      IPC_CPU_ACTIVE,
    55  	IPC_CPU_SIPI
    56  } IPC_CPU_ACTIVITY_STATE;
    57  
    58  typedef struct _IPC_CPU_CONTEXT
    59  {
    60      volatile UINT64    num_received_nmi_interrupts;
    61      UINT64             num_processed_nmi_interrupts;
    62      
    63      UINT64             num_of_sent_ipc_nmi_interrupts;
    64      UINT64             num_of_processed_ipc_nmi_interrupts;
    65      
    66      volatile UINT64    num_blocked_nmi_injections_to_guest;
    67      volatile UINT64    num_start_messages;
    68      volatile UINT64    num_stop_messages;
    69  
    70      ARRAY_LIST_HANDLE  message_queue;
    71      UINT64             num_of_sent_ipc_messages;
    72      UINT64             num_of_received_ipc_messages;
    73  
    74      VMM_LOCK           data_lock;
    75  } IPC_CPU_CONTEXT;
    76  
    77  BOOLEAN ipc_state_init(UINT16 number_of_host_processors);
    78  
    79  BOOLEAN ipc_guest_state_init(GUEST_ID guest_id);
    80  
    81  
    82  #endif