Commit f492efdb authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Reimplement thread initialization in assembler on ARM.

parent 8a07ee48
...@@ -1220,35 +1220,31 @@ static void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -1220,35 +1220,31 @@ static void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
abort(); /* should not be reached */ abort(); /* should not be reached */
} }
typedef void (WINAPI *thread_start_func)(LPTHREAD_START_ROUTINE,void *); extern void DECLSPEC_NORETURN start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend,
void *relay, TEB *teb );
struct startup_info __ASM_GLOBAL_FUNC( start_thread,
{ ".arm\n\t"
thread_start_func start; "push {r4-r12,lr}\n\t"
LPTHREAD_START_ROUTINE entry; /* build initial context on thread stack */
void *arg; "ldr r4, [sp, #40]\n\t" /* teb */
BOOL suspend; "ldr r4, [r4, #4]\n\t" /* teb->Tib.StackBase */
}; "sub r5, r4, #0x1a0\n\t" /* sizeof(CONTEXT) */
"mov ip, #0x0200000\n\t" /* CONTEXT_ARM */
/*********************************************************************** "add ip, #0x3\n\t" /* CONTEXT_FULL */
* thread_startup "str ip, [r5]\n\t" /* context->ContextFlags */
*/ "str r0, [r5, #0x4]\n\t" /* context->R0 = entry */
static void thread_startup( void *param ) "str r1, [r5, #0x8]\n\t" /* context->R1 = arg */
{ "str r4, [r5, #0x38]\n\t" /* context->Sp = stack */
CONTEXT context = { 0 }; "str r3, [r5, #0x40]\n\t" /* context->Pc = relay */
struct startup_info *info = param; /* switch to thread stack */
"mov sp, r5\n\t"
/* build the initial context */ /* attach dlls */
context.ContextFlags = CONTEXT_FULL; "mov r0, r5\n\t" /* context */
context.R0 = (DWORD)info->entry; "mov r1, r2\n\t" /* suspend */
context.R1 = (DWORD)info->arg; "bl " __ASM_NAME("attach_dlls") "\n\t"
context.Sp = (DWORD)NtCurrentTeb()->Tib.StackBase; /* switch to the initial context */
context.Pc = (DWORD)info->start; "mov r0, r5\n\t"
"b " __ASM_NAME("set_cpu_context") )
attach_dlls( &context, info->suspend );
set_cpu_context( &context );
}
/*********************************************************************** /***********************************************************************
* signal_start_thread * signal_start_thread
...@@ -1260,8 +1256,7 @@ static void thread_startup( void *param ) ...@@ -1260,8 +1256,7 @@ static void thread_startup( void *param )
*/ */
void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend ) void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend )
{ {
struct startup_info info = { call_thread_entry_point, entry, arg, suspend }; start_thread( entry, arg, suspend, call_thread_entry_point, NtCurrentTeb() );
wine_switch_to_stack( thread_startup, &info, NtCurrentTeb()->Tib.StackBase );
} }
/********************************************************************** /**********************************************************************
...@@ -1274,8 +1269,7 @@ void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend ...@@ -1274,8 +1269,7 @@ void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend
*/ */
void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend )
{ {
struct startup_info info = { kernel32_start_process, entry, NtCurrentTeb()->Peb, suspend }; start_thread( entry, NtCurrentTeb()->Peb, suspend, kernel32_start_process, NtCurrentTeb() );
wine_switch_to_stack( thread_startup, &info, NtCurrentTeb()->Tib.StackBase );
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment