Changeset 106674 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Oct 24, 2024 9:31:30 PM (3 months ago)
- Location:
- trunk/src/VBox/Additions/3D/win/VBoxICD
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk
r106061 r106674 62 62 $(PATH_SUB_CURRENT)/icd_forwarders.py $(VBOX_GL_ICD_DEF_FILE) | $$(dir $$@) 63 63 $(call MSG_GENERATE,python,$@,$(VBOX_GL_ICD_DEF_FILE)) 64 $(QUIET)$(VBOX_BLD_PYTHON) $< $(VBOX_GL_ICD_DEF_FILE) $@ 64 $(QUIET)$(VBOX_BLD_PYTHON) $< $(VBOX_GL_ICD_DEF_FILE) $@ "$(KBUILD_TARGET_ARCH)" 65 65 $$(VBoxICD_0_OUTDIR)/pfns.c: \ 66 66 $(PATH_SUB_CURRENT)/icd_pfns.py $(VBOX_GL_ICD_DEF_FILE) | $$(dir $$@) -
trunk/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.c
r106658 r106674 46 46 ; 47 47 48 extern struct VBOXWDDMDLLPROC aIcdProcs[];48 extern struct VBOXWDDMDLLPROC g_aIcdProcs[]; 49 49 50 50 HMODULE volatile g_hmodICD = NULL; … … 104 104 if (g_hmodICD) 105 105 { 106 VBoxWddmLoadAdresses(g_hmodICD, aIcdProcs);106 VBoxWddmLoadAdresses(g_hmodICD, g_aIcdProcs); 107 107 } 108 108 } -
trunk/src/VBox/Additions/3D/win/VBoxICD/icd_forwarders.py
r106661 r106674 36 36 37 37 def GenerateForwarders(asArgs): 38 39 if len(asArgs) != 4: 40 raise Exception('Expected 3 arguments, not %u!' % (len(asArgs) - 1,)); 38 41 39 42 # Get list of functions. … … 58 61 # Assembler forwarders 59 62 # 60 asLines = [ 61 '; AUTOGENERATED - DO NOT EDIT!', 62 '%include "iprt/asmdefs.mac"', 63 '', 64 ';;;; Enable ICD_LAZY_LOAD to lazy load the ICD DLL - bird 2024-10-24: it should work again now', 65 '; %define ICD_LAZY_LOAD 1', 66 '', 67 '%ifdef ICD_LAZY_LOAD', 68 'extern NAME(g_hmodICD)', 69 'extern NAME(VBoxLoadICD)', 70 '', 71 'BEGINPROC VBoxLoadICDWrapper' 72 ' ; Check if loaded', 73 ' mov xAX, [NAME(g_hmodICD) xWrtRIP]', 74 ' test xAX, xAX', 75 ' jz .needs_loading', 76 ' ret', 77 ' ; Save parameter registers', 78 '.needs_loading:', 79 ' %ifdef RT_ARCH_AMD64', 80 ' push rcx', 81 ' push rdx', 82 ' push r8', 83 ' push r9', 84 ' %ifdef ASM_CALL64_GCC', 85 ' push rsi', 86 ' push rdi', 87 ' sub rsp, 8h', 88 ' %else', 89 ' sub rsp, 28h', 90 ' %endif', 91 ' %endif', 92 ' call NAME(VBoxLoadICD)', 93 ' ; Restore parameter registers', 94 ' %ifdef RT_ARCH_AMD64', 95 ' %ifdef ASM_CALL64_GCC', 96 ' add rsp, 8h', 97 ' pop rdi', 98 ' pop rsi', 99 ' %else', 100 ' add rsp, 28h', 101 ' %endif', 102 ' pop r9', 103 ' pop r8', 104 ' pop rdx', 105 ' pop rcx', 106 ' %endif', 107 ' ret', 108 'ENDPROC VBoxLoadICDWrapper', 109 '%endif ; ICD_LAZY_LOAD', 110 ]; 111 112 for index in range(len(asNames)): 113 sFnNm = asNames[index] 114 cbRet = asParamSizes[index] 115 asLines.extend([ 116 '', 117 'BEGINPROC_EXPORTED %s' % sFnNm, 118 ' extern NAME(pfn_%s)' % sFnNm, 119 '; int3', 63 if asArgs[3] in ('x86', 'amd64',): 64 asLines = [ 65 '; AUTOGENERATED - DO NOT EDIT!', 66 '%include "iprt/asmdefs.mac"', 67 '', 68 ';;;; Enable ICD_LAZY_LOAD to lazy load the ICD DLL - bird 2024-10-24: it should work again now', 69 '; %define ICD_LAZY_LOAD 1', 70 '', 120 71 '%ifdef ICD_LAZY_LOAD', 121 ' call VBoxLoadICDWrapper', 122 '%endif', 123 ' mov xAX, [NAME(pfn_%s) xWrtRIP]' % sFnNm, 124 ' test xAX, xAX', 125 ' jz .return', 126 ' jmp xAX', 127 '.return:', 128 '%ifdef RT_ARCH_AMD64', 129 ' ret', 130 '%else ; X86', 131 ' ret %s' % cbRet, 132 '%endif', 133 'ENDPROC %s' % sFnNm, 134 ]); 72 'extern NAME(g_hmodICD)', 73 'extern NAME(VBoxLoadICD)', 74 '', 75 'BEGINPROC VBoxLoadICDWrapper', 76 ' ; Check if loaded', 77 ' mov xAX, [NAME(g_hmodICD) xWrtRIP]', 78 ' test xAX, xAX', 79 ' jz .needs_loading', 80 ' ret', 81 ' ; Save parameter registers', 82 '.needs_loading:', 83 ' %ifdef RT_ARCH_AMD64', 84 ' push rcx', 85 ' push rdx', 86 ' push r8', 87 ' push r9', 88 ' %ifdef ASM_CALL64_GCC', 89 ' push rsi', 90 ' push rdi', 91 ' sub rsp, 8h', 92 ' %else', 93 ' sub rsp, 28h', 94 ' %endif', 95 ' %endif', 96 ' ; Make the call', 97 ' call NAME(VBoxLoadICD)', 98 ' ; Restore parameter registers', 99 ' %ifdef RT_ARCH_AMD64', 100 ' %ifdef ASM_CALL64_GCC', 101 ' add rsp, 8h', 102 ' pop rdi', 103 ' pop rsi', 104 ' %else', 105 ' add rsp, 28h', 106 ' %endif', 107 ' pop r9', 108 ' pop r8', 109 ' pop rdx', 110 ' pop rcx', 111 ' %endif', 112 ' ret', 113 'ENDPROC VBoxLoadICDWrapper', 114 '%endif ; ICD_LAZY_LOAD', 115 ]; 116 117 for iFn, sFnNm in enumerate(asNames): 118 cbRet = asParamSizes[iFn] 119 asLines.extend([ 120 '', 121 'BEGINPROC_EXPORTED %s' % sFnNm, 122 ' extern NAME(g_pfn_%s)' % sFnNm, 123 '; int3', 124 '%ifdef ICD_LAZY_LOAD', 125 ' call VBoxLoadICDWrapper', 126 '%endif', 127 ' mov xAX, [NAME(g_pfn_%s) xWrtRIP]' % sFnNm, 128 ' test xAX, xAX', 129 ' jz .return', 130 ' jmp xAX', 131 '.return:', 132 '%ifdef RT_ARCH_AMD64', 133 ' ret', 134 '%else ; X86', 135 ' ret %s' % cbRet, 136 '%endif', 137 'ENDPROC %s' % sFnNm, 138 ]); 139 140 elif asArgs[3] == 'arm64': 141 asLines = [ 142 '/* AUTOGENERATED - DO NOT EDIT!*/', 143 '#include "iprt/asmdefs-arm.h"', 144 '', 145 '/** Enable ICD_LAZY_LOAD to lazy load the ICD DLL */', 146 '/* #define ICD_LAZY_LOAD 1*/', 147 '', 148 '#ifdef ICD_LAZY_LOAD', 149 ' .p2align 4', 150 'BEGINPROC VBoxLoadICDWrapper', 151 ' ; Check if loaded', 152 ' adrp x8, PAGE(NAME(g_hmodICD))', 153 ' ldr x8, [x8, PAGEOFF(NAME(g_hmodICD))]', 154 ' cbz x8, Lneeds_loading', 155 ' ret', 156 'Lneeds_loading:', 157 ' /* Save parameter registers */', 158 ' stp x0, x1, [sp, #-0x50]!', 159 ' stp x2, x3, [sp, #0x10]', 160 ' stp x4, x5, [sp, #0x20]', 161 ' stp x6, x7, [sp, #0x30]', 162 ' stp x29, x30, [sp, #0x40]', 163 ' /* Make the call */', 164 ' bl NAME(VBoxLoadICD)', 165 ' /* Restore parameter registers */', 166 ' ldp x0, x1, [sp, #0x00]', 167 ' ldp x2, x3, [sp, #x10]', 168 ' ldp x4, x5, [sp, #x20]', 169 ' ldp x6, x7, [sp, #x30]', 170 ' ldp x29, x30, [sp, #x40]', 171 ' add sp, sp #0x50', 172 ' ret', 173 'ENDPROC VBoxLoadICDWrapper', 174 '#endif /* ICD_LAZY_LOAD */', 175 ]; 176 177 for sFnNm in asNames: 178 asLines.extend([ 179 '', 180 ' .p2align 3', 181 'BEGINPROC_EXPORTED %s' % (sFnNm,), 182 '; brk #0x8888', 183 '#ifdef ICD_LAZY_LOAD', 184 ' bl VBoxLoadICDWrapper', 185 '#endif', 186 ' adrp x8, PAGE(NAME(g_pfn_%s))' % (sFnNm,), 187 ' ldr x8, [x8, PAGEOFF(NAME(g_pfn_%s))]' % (sFnNm,), 188 ' cbz x8, Lreturn_%s' % (sFnNm,), 189 ' br x8', 190 'Lreturn_%s:' % (sFnNm,), 191 ' ret', 192 'ENDPROC %s' % (sFnNm,), 193 ]); 194 195 else: 196 raise Exception('Unsupported target architecture: %s' % (asArgs[3],)); 135 197 136 198 # -
trunk/src/VBox/Additions/3D/win/VBoxICD/icd_pfns.py
r106061 r106674 58 58 for index in range(len(names)): 59 59 fn = names[index] 60 c_file.write('FARPROC pfn_%s;\n' % fn)60 c_file.write('FARPROC g_pfn_%s;\n' % fn) # init this to a dummy that returns 0? 61 61 c_file.write('\n') 62 62 63 c_file.write("struct VBOXWDDMDLLPROC aIcdProcs[] =\n")63 c_file.write("struct VBOXWDDMDLLPROC g_aIcdProcs[] =\n") 64 64 c_file.write('{\n') 65 for index in range(len(names)): 66 fn = names[index] 67 c_file.write(' { "%s", &pfn_%s },\n' % (fn, fn) ) 65 for sFnNm in names: 66 c_file.write(' { "%s", &g_pfn_%s },\n' % (sFnNm, sFnNm) ) 68 67 c_file.write(' { NULL, NULL }\n') 69 68 c_file.write('};\n')
Note:
See TracChangeset
for help on using the changeset viewer.