github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/vmexit/vmexit_dbg.c (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  #include <vmm_defs.h>
    16  #include <guest_cpu.h>
    17  #include <libc.h>
    18  #include <vmm_dbg.h>
    19  #include "file_codes.h"
    20  #define VMM_DEADLOOP()          VMM_DEADLOOP_LOG(VMEXIT_DBG_C)
    21  #define VMM_ASSERT(__condition) VMM_ASSERT_LOG(VMEXIT_DBG_C, __condition)
    22  #ifdef JLMDEBUG
    23  #include "jlmdebug.h"
    24  #endif
    25  
    26  #pragma warning (disable : 4100) // enable non referenced formal parameters
    27  
    28  // External declaration.
    29  //extern void gdb_check_halt(GUEST_CPU_HANDLE  gcpu);               // Checks GDB halt condition.
    30  
    31  const char* string = "bla bla";
    32  
    33  #define CTRL(__char)    (__char - 'a' + 1)
    34  
    35  #define REQUEST_COUNT    8
    36  static char monitor_requested[REQUEST_COUNT] = { 0,0,0,0,0,0,0,0};
    37  static char monitor_request_keys[REQUEST_COUNT] = {
    38      CTRL('q'),
    39      CTRL('w'),
    40      CTRL('e'),
    41      CTRL('r'),
    42      CTRL('t'),
    43      CTRL('y'),
    44      CTRL('u'),
    45      CTRL('i')
    46  };
    47  
    48  int monitor_was_requested(char key)
    49  {
    50      size_t i;
    51      for (i = 0; i < NELEMENTS(monitor_request_keys); ++i) {
    52          if (key == monitor_request_keys[i]) {
    53              return (int)i;
    54          }
    55      }
    56      return -1;
    57  }
    58  
    59  
    60  
    61  void vmexit_check_keystroke(GUEST_CPU_HANDLE gcpu UNUSED)
    62  {
    63      UINT8 key = vmm_getc();
    64      int monitor_cpu;
    65  
    66      switch (key) {
    67      case 0: // optimization
    68          //gdb_check_halt(gcpu);
    69          break;
    70  
    71      case 's':
    72      case 'S':
    73      	VMM_LOG(mask_anonymous, level_trace,"%s\n", string);
    74      	break;
    75  
    76      case CTRL('b'):
    77      case CTRL('d'):
    78          VMM_DEADLOOP();
    79          break;
    80  
    81  #ifdef ENABLE_VTLB
    82      case '`':
    83          IVtlbDoPerfCommand(0, VTLB_PERF_COMMAND_PRINT);
    84          IVtlbDoPerfCommand(0, VTLB_PERF_COMMAND_START);
    85          break;
    86  #endif
    87      default:
    88          monitor_cpu = monitor_was_requested(key);
    89          if (monitor_cpu != -1) {
    90              monitor_requested[monitor_cpu] = 1;
    91          }
    92          if (monitor_requested[hw_cpu_id()] != 0) {
    93              monitor_requested[hw_cpu_id()] = 0;
    94              VMM_DEADLOOP();
    95          }
    96          break;
    97      }
    98  }
    99