github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/host/vmm_globals.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_globals.h" 16 #include "vmm_version_struct.h" 17 #include "vmm_dbg.h" 18 #include "libc.h" 19 #include "file_codes.h" 20 #define VMM_DEADLOOP() VMM_DEADLOOP_LOG(VMM_GLOBALS_C) 21 #define VMM_ASSERT(__condition) VMM_ASSERT_LOG(VMM_GLOBALS_C, __condition) 22 #ifdef JLMDEBUG 23 #include "jlmdebug.h" 24 #endif 25 26 27 // Just instaniation of global variables 28 29 30 VMM_STATE g_vmm_state = VMM_STATE_UNINITIALIZED; 31 32 #if defined DEBUG || defined ENABLE_RELEASE_VMM_LOG 33 // This is done to remove out the strings from the release build 34 #ifdef VMM_VERSION_STRING 35 const char* g_vmm_version_string = VMM_VERSION_START VMM_VERSION_STRING VMM_VERSION_END; 36 #else 37 const char* g_vmm_version_string = NULL; 38 #endif 39 #else 40 const char* g_vmm_version_string = NULL; 41 #endif 42 43 void vmm_version_print( void ) 44 { 45 #if 0 // version print disabled 46 UINT32 global_string_length = 0; 47 UINT32 header_len, trailer_len; 48 UINT32 cur; 49 50 // Version string is surrounded with VMM_VERSION_START and VMM_VERSION_END 51 // VMM_VERSION_END must be followed with NULL 52 if (NULL == g_vmm_version_string) { 53 return; 54 } 55 56 header_len = (UINT32)vmm_strlen(VMM_VERSION_START); 57 trailer_len = (UINT32)vmm_strlen(VMM_VERSION_END); 58 59 // BEFORE_VMLAUNCH. Non-fatal error, not removing ASSERT for now. 60 VMM_ASSERT((0 != header_len) && (0 != trailer_len)) 61 62 global_string_length = (UINT32)vmm_strlen(g_vmm_version_string); 63 64 if (global_string_length <= (header_len + trailer_len)) { 65 // nothing between header and trailer 66 return; 67 } 68 69 // check that header and trailer match 70 for (cur = 0; cur < header_len; ++cur) { 71 if (g_vmm_version_string[cur] != VMM_VERSION_START[cur]) { 72 // header does not match 73 return; 74 } 75 } 76 77 for (cur = 0; cur < trailer_len; ++cur) { 78 if (g_vmm_version_string[global_string_length-trailer_len+cur] != VMM_VERSION_END[cur]) { 79 // trailer does not match 80 return; 81 } 82 } 83 84 // if we are here - version string is ok. Print it. 85 VMM_LOG(mask_anonymous, level_trace, 86 "\n------------------------------------------------------------------------\n"); 87 88 VMM_LOG(mask_anonymous, level_trace, "%*s\n", 89 global_string_length - header_len - trailer_len, 90 g_vmm_version_string + header_len); 91 92 VMM_LOG(mask_anonymous, level_trace, 93 "------------------------------------------------------------------------\n\n"); 94 #endif 95 } 96 97