Changeset 22988 in vbox
- Timestamp:
- Sep 14, 2009 6:57:38 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VM.cpp
r22986 r22988 143 143 static void vmR3AtDtor(PVM pVM); 144 144 static DECLCALLBACK(int) vmR3Reset(PVM pVM); 145 static DECLCALLBACK(int) vmR3AtStateDeregisterU(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);146 static DECLCALLBACK(int) vmR3AtErrorRegisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);147 static DECLCALLBACK(int) vmR3AtErrorDeregisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);148 145 static int vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...); 149 static DECLCALLBACK(int) vmR3AtRuntimeErrorRegisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);150 static DECLCALLBACK(int) vmR3AtRuntimeErrorDeregisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);151 146 152 147 … … 425 420 * Create and initialize the UVM. 426 421 */ 427 PUVM pUVM = (PUVM)RTMem AllocZ(RT_OFFSETOF(UVM, aCpus[cCpus]));422 PUVM pUVM = (PUVM)RTMemPageAllocZ(RT_OFFSETOF(UVM, aCpus[cCpus])); 428 423 AssertReturn(pUVM, VERR_NO_MEMORY); 429 424 pUVM->u32Magic = UVM_MAGIC; … … 2783 2778 { 2784 2779 LogFlow(("VMR3AtErrorRegister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser)); 2780 2781 /* 2782 * Validate input. 2783 */ 2785 2784 AssertPtrReturn(pfnAtError, VERR_INVALID_PARAMETER); 2786 2787 /* 2788 * Make sure we're in EMT (to avoid the logging). 2789 */ 2790 PVMREQ pReq; 2791 int rc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)vmR3AtErrorRegisterU, 3, pUVM, pfnAtError, pvUser); 2792 if (RT_FAILURE(rc)) 2793 return rc; 2794 rc = pReq->iStatus; 2795 VMR3ReqFree(pReq); 2796 2797 LogFlow(("VMR3AtErrorRegister: returns %Rrc\n", rc)); 2798 return rc; 2799 } 2800 2801 2802 /** 2803 * Registers a VM error callback. 2804 * 2805 * @returns VBox status code. 2806 * @param pUVM Pointer to the user mode VM structure. 2807 * @param pfnAtError Pointer to callback. 2808 * @param pvUser User argument. 2809 * @thread EMT 2810 */ 2811 static DECLCALLBACK(int) vmR3AtErrorRegisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser) 2812 { 2785 UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); 2786 2813 2787 /* 2814 2788 * Allocate a new record. 2815 2789 */ 2816 2817 2790 PVMATERROR pNew = (PVMATERROR)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew)); 2818 2791 if (!pNew) … … 2843 2816 * @thread Any. 2844 2817 */ 2845 VMMR3DECL(int) 2818 VMMR3DECL(int) VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser) 2846 2819 { 2847 2820 LogFlow(("VMR3AtErrorDeregister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser)); … … 2850 2823 * Validate input. 2851 2824 */ 2852 if (!pfnAtError) 2853 { 2854 AssertMsgFailed(("callback is required\n")); 2855 return VERR_INVALID_PARAMETER; 2856 } 2857 2858 /* 2859 * Make sure we're in EMT (to avoid the logging). 2860 */ 2861 PVMREQ pReq; 2862 int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtErrorDeregisterU, 3, pVM->pUVM, pfnAtError, pvUser); 2863 if (RT_FAILURE(rc)) 2864 return rc; 2865 rc = pReq->iStatus; 2866 VMR3ReqFree(pReq); 2867 2868 LogFlow(("VMR3AtErrorDeregister: returns %Rrc\n", rc)); 2869 return rc; 2870 } 2871 2872 2873 /** 2874 * Deregisters a VM error callback. 2875 * 2876 * @returns VBox status code. 2877 * @param pUVM Pointer to the user mode VM structure. 2878 * @param pfnAtError Pointer to callback. 2879 * @param pvUser User argument. 2880 * @thread EMT 2881 */ 2882 static DECLCALLBACK(int) vmR3AtErrorDeregisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser) 2883 { 2884 LogFlow(("vmR3AtErrorDeregisterU: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser)); 2825 AssertPtrReturn(pfnAtError, VERR_INVALID_PARAMETER); 2826 VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); 2827 2828 PUVM pUVM = pVM->pUVM; 2885 2829 RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect); 2886 2830 … … 3075 3019 * Validate input. 3076 3020 */ 3077 if (!pfnAtRuntimeError) 3078 { 3079 AssertMsgFailed(("callback is required\n")); 3080 return VERR_INVALID_PARAMETER; 3081 } 3082 3083 /* 3084 * Make sure we're in EMT (to avoid the logging). 3085 */ 3086 PVMREQ pReq; 3087 int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtRuntimeErrorRegisterU, 3, pVM->pUVM, pfnAtRuntimeError, pvUser); 3088 if (RT_FAILURE(rc)) 3089 return rc; 3090 rc = pReq->iStatus; 3091 VMR3ReqFree(pReq); 3092 3093 LogFlow(("VMR3AtRuntimeErrorRegister: returns %Rrc\n", rc)); 3094 return rc; 3095 } 3096 3097 3098 /** 3099 * Registers a VM runtime error callback. 3100 * 3101 * @returns VBox status code. 3102 * @param pUVM Pointer to the user mode VM structure. 3103 * @param pfnAtRuntimeError Pointer to callback. 3104 * @param pvUser User argument. 3105 * @thread EMT 3106 */ 3107 static DECLCALLBACK(int) vmR3AtRuntimeErrorRegisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser) 3108 { 3021 AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER); 3022 VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); 3023 3109 3024 /* 3110 3025 * Allocate a new record. 3111 3026 */ 3112 3027 PUVM pUVM = pVM->pUVM; 3113 3028 PVMATRUNTIMEERROR pNew = (PVMATRUNTIMEERROR)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew)); 3114 3029 if (!pNew) … … 3146 3061 * Validate input. 3147 3062 */ 3148 if (!pfnAtRuntimeError) 3149 { 3150 AssertMsgFailed(("callback is required\n")); 3151 return VERR_INVALID_PARAMETER; 3152 } 3153 3154 /* 3155 * Make sure we're in EMT (to avoid the logging). 3156 */ 3157 PVMREQ pReq; 3158 int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtRuntimeErrorDeregisterU, 3, pVM->pUVM, pfnAtRuntimeError, pvUser); 3159 if (RT_FAILURE(rc)) 3160 return rc; 3161 rc = pReq->iStatus; 3162 VMR3ReqFree(pReq); 3163 3164 LogFlow(("VMR3AtRuntimeErrorDeregister: returns %Rrc\n", rc)); 3165 return rc; 3166 } 3167 3168 3169 /** 3170 * Deregisters a VM runtime error callback. 3171 * 3172 * @returns VBox status code. 3173 * @param pUVM Pointer to the user mode VM structure. 3174 * @param pfnAtRuntimeError Pointer to callback. 3175 * @param pvUser User argument. 3176 * @thread EMT 3177 */ 3178 static DECLCALLBACK(int) vmR3AtRuntimeErrorDeregisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser) 3179 { 3180 LogFlow(("vmR3AtRuntimeErrorDeregisterU: pfnAtRuntimeError=%p pvUser=%p\n", pfnAtRuntimeError, pvUser)); 3063 AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER); 3064 VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); 3065 3066 PUVM pUVM = pVM->pUVM; 3181 3067 RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect); 3182 3068
Note:
See TracChangeset
for help on using the changeset viewer.