github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/vmm_stack_api.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 VMM_STACK_API_H 16 #define VMM_STACK_API_H 17 18 #include <vmm_defs.h> 19 #include <vmm_startup.h> 20 21 /* Function: vmm_stack_caclulate_stack_pointer 22 * Description: This function may be called at the first stages of the boot, when 23 * the vmm_stack object is not initialized at all. It calculates the stack 24 * pointer of requested cpu. 25 * Input: 26 * startup_struct - pointer to startup structure 27 * cpu_id - index of the cpu 28 * Output: 29 * stack_pointer - value (virtual address) that should be put into ESP/RSP 30 * Return Value: TRUE in case the calculation is successful. 31 */ 32 BOOLEAN vmm_stack_caclulate_stack_pointer(IN const VMM_STARTUP_STRUCT* startup_struct, 33 IN CPU_ID cpu_id, OUT HVA* stack_pointer); 34 35 36 /* Function: vmm_stack_initialize 37 * Description: This function is called in order to initialize internal data structures. 38 * Input: 39 * startup_struct - pointer to startup structure 40 * Return Value: TRUE in case the initialization is successful. 41 */ 42 BOOLEAN vmm_stack_initialize(IN const VMM_STARTUP_STRUCT* startup_struct); 43 44 45 /* Function: vmm_stack_is_initialized 46 * Description: Query whether the component is initialized. 47 * Return Value: TRUE in case the component was successfully initialized. 48 */ 49 BOOLEAN vmm_stack_is_initialized(void); 50 51 52 /* Function: vmm_stack_get_stack_pointer_for_cpu 53 * Description: This function is called in order to retrieve the initial value 54 * of stack pointer of specific cpu. 55 * Input: 56 * cpu_id - index of cpu 57 * Output: 58 * stack_pointer - value (virtual address) that should be put into ESP/RSP; 59 * Return Value: TRUE in case the query is successful. 60 * FALSE will be returned when the component wasn't initialized or 61 * cpu_id has invalid value. 62 */ 63 BOOLEAN vmm_stack_get_stack_pointer_for_cpu(IN CPU_ID cpu_id, OUT HVA* stack_pointer); 64 65 /* Function: vmm_stacks_get_details 66 * Description: This function return details of allocated memory for stacks. 67 * Output: 68 * lowest_addr_used - Host Virtual Address (pointer) of lowest used address 69 * size - size allocated for all stacks; 70 * Return Value: Host Virtual Address (pointer) of the address 71 */ 72 void vmm_stacks_get_details(OUT HVA* lowest_addr_used, OUT UINT32* size); 73 74 75 /* Function: vmm_stacks_get_exception_stack_for_cpu 76 * Description: This function return the initial page of the stack that must be unmapped 77 * in vmm page tables and re-mapped to higher addresses. 78 * Input: 79 * cpu_id - cpu number 80 * stack_num - number of exception stack 81 * Output: 82 * page_addr - HVA of the page to guard; 83 * Return Value: TRUE in case of success. 84 * FALSE will be returned in cpu_id has invalid value 85 */ 86 BOOLEAN vmm_stacks_get_exception_stack_for_cpu(IN CPU_ID cpu_id, 87 IN UINT32 stack_num, OUT HVA* page_addr); 88 89 #ifdef DEBUG 90 /* Function: vmm_stacks_print 91 * Description: Prints inner map of stacks area. 92 */ 93 void vmm_stacks_print(void); 94 #endif // DEBUG 95 96 #endif