Module: wine Branch: master Commit: cbaa3d08041b7a0a465c852f09a3f620798d86f6 URL: https://gitlab.winehq.org/wine/wine/-/commit/cbaa3d08041b7a0a465c852f09a3f62...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Nov 14 17:28:05 2023 +0100
ntdll: Add a stub ARM64EC CPU backend.
---
dlls/ntdll/Makefile.in | 1 + dlls/ntdll/signal_arm64ec.c | 227 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/signal_x86_64.c | 7 +- 3 files changed, 230 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index 7aa1652507d..d3f2a0e5523 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -37,6 +37,7 @@ SOURCES = \ sec.c \ signal_arm.c \ signal_arm64.c \ + signal_arm64ec.c \ signal_i386.c \ signal_x86_64.c \ string.c \ diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c new file mode 100644 index 00000000000..4f39c24bfe1 --- /dev/null +++ b/dlls/ntdll/signal_arm64ec.c @@ -0,0 +1,227 @@ +/* + * ARM64EC signal handling routines + * + * Copyright 1999, 2005, 2023 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __arm64ec__ + +#include <stdlib.h> +#include <stdarg.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winternl.h" +#include "wine/exception.h" +#include "wine/list.h" +#include "ntdll_misc.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(unwind); +WINE_DECLARE_DEBUG_CHANNEL(relay); + + +/******************************************************************* + * KiUserExceptionDispatcher (NTDLL.@) + */ +NTSTATUS WINAPI KiUserExceptionDispatcher( EXCEPTION_RECORD *rec, CONTEXT *context ) +{ + FIXME( "not implemented\n" ); + return STATUS_INVALID_DISPOSITION; +} + + +/******************************************************************* + * KiUserApcDispatcher (NTDLL.@) + */ +void WINAPI KiUserApcDispatcher( CONTEXT *context, ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, + PNTAPCFUNC apc ) +{ + FIXME( "not implemented\n" ); +} + + +/******************************************************************* + * KiUserCallbackDispatcher (NTDLL.@) + */ +void WINAPI KiUserCallbackDispatcher( ULONG id, void *args, ULONG len ) +{ + FIXME( "not implemented\n" ); +} + + +/************************************************************************** + * RtlIsEcCode (NTDLL.@) + */ +BOOLEAN WINAPI RtlIsEcCode( const void *ptr ) +{ + const UINT64 *map = (const UINT64 *)NtCurrentTeb()->Peb->EcCodeBitMap; + ULONG_PTR page = (ULONG_PTR)ptr / page_size; + return (map[page / 64] >> (page & 63)) & 1; +} + + +/*********************************************************************** + * RtlCaptureContext (NTDLL.@) + */ +void WINAPI RtlCaptureContext( CONTEXT *context ) +{ + FIXME( "not implemented\n" ); +} + + +/******************************************************************* + * RtlRestoreContext (NTDLL.@) + */ +void CDECL RtlRestoreContext( CONTEXT *context, EXCEPTION_RECORD *rec ) +{ + FIXME( "not implemented\n" ); +} + + +/********************************************************************** + * RtlVirtualUnwind (NTDLL.@) + */ +PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc, + RUNTIME_FUNCTION *function, CONTEXT *context, + PVOID *data, ULONG64 *frame_ret, + KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr ) +{ + FIXME( "not implemented\n" ); + return NULL; +} + + +/******************************************************************* + * RtlUnwindEx (NTDLL.@) + */ +void WINAPI RtlUnwindEx( PVOID end_frame, PVOID target_ip, EXCEPTION_RECORD *rec, + PVOID retval, CONTEXT *context, UNWIND_HISTORY_TABLE *table ) +{ + FIXME( "not implemented\n" ); +} + + +/******************************************************************* + * RtlUnwind (NTDLL.@) + */ +void WINAPI RtlUnwind( void *frame, void *target_ip, EXCEPTION_RECORD *rec, void *retval ) +{ + FIXME( "not implemented\n" ); +} + + +/******************************************************************* + * _local_unwind (NTDLL.@) + */ +void WINAPI _local_unwind( void *frame, void *target_ip ) +{ + CONTEXT context; + RtlUnwindEx( frame, target_ip, NULL, NULL, &context, NULL ); +} + + +/******************************************************************* + * __C_specific_handler (NTDLL.@) + */ +EXCEPTION_DISPOSITION WINAPI __C_specific_handler( EXCEPTION_RECORD *rec, + void *frame, + CONTEXT *context, + struct _DISPATCHER_CONTEXT *dispatch ) +{ + FIXME( "not implemented\n" ); + return ExceptionContinueSearch; +} + + +/************************************************************************* + * RtlCaptureStackBackTrace (NTDLL.@) + */ +USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +{ + FIXME( "not implemented\n" ); + return 0; +} + + +/************************************************************************** + * __chkstk (NTDLL.@) + * + * Supposed to touch all the stack pages, but we shouldn't need that. + */ +void __attribute__((naked)) __chkstk(void) +{ + asm( "ret" ); +} + + +/*********************************************************************** + * RtlRaiseException (NTDLL.@) + */ +void WINAPI RtlRaiseException( struct _EXCEPTION_RECORD * rec) +{ + FIXME( "not implemented\n" ); +} + + +/*********************************************************************** + * RtlUserThreadStart (NTDLL.@) + */ +void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg ) +{ + __TRY + { + pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg ); + } + __EXCEPT(call_unhandled_exception_filter) + { + NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() ); + } + __ENDTRY +} + + +/****************************************************************** + * LdrInitializeThunk (NTDLL.@) + */ +void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unk2, ULONG_PTR unk3, ULONG_PTR unk4 ) +{ + loader_init( context, (void **)&context->Rcx ); + TRACE_(relay)( "\1Starting thread proc %p (arg=%p)\n", (void *)context->Rcx, (void *)context->Rdx ); + NtContinue( context, TRUE ); +} + + +/********************************************************************** + * DbgBreakPoint (NTDLL.@) + */ +void __attribute__((naked)) DbgBreakPoint(void) +{ + asm( "brk #0xf000; ret" ); +} + + +/********************************************************************** + * DbgUserBreakPoint (NTDLL.@) + */ +void __attribute__((naked)) DbgUserBreakPoint(void) +{ + asm( "brk #0xf000; ret" ); +} + +#endif /* __arm64ec__ */ diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index ae658910868..ff02cdc5fdc 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#ifdef __x86_64__ +#if defined(__x86_64__) && !defined(__arm64ec__)
#include <stdlib.h> #include <stdarg.h> @@ -711,10 +711,7 @@ void WINAPI KiUserCallbackDispatcher( ULONG id, void *args, ULONG len ) */ BOOLEAN WINAPI RtlIsEcCode( const void *ptr ) { - const UINT64 *map = (const UINT64 *)NtCurrentTeb()->Peb->EcCodeBitMap; - ULONG_PTR page = (ULONG_PTR)ptr / page_size; - if (!map) return FALSE; - return (map[page / 64] >> (page & 63)) & 1; + return FALSE; }