2 * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both the copyright notice and this permission notice appear in
9 * supporting documentation.
11 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
15 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
18 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
19 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * Machine specific support for thread initialization
31 #include <architecture/ppc/cframe.h>
34 #include "pthread_internals.h"
37 * Set up the initial state of a MACH thread
40 _pthread_setup(pthread_t thread
,
41 void (*routine
)(pthread_t
),
47 struct ppc_thread_state state
;
48 struct ppc_thread_state
*ts
= &state
;
51 * Set up PowerPC registers.
53 count
= PPC_THREAD_STATE_COUNT
;
54 PTHREAD_MACH_CALL(thread_get_state(thread
->kernel_thread
,
56 (thread_state_t
) &state
,
60 ts
->srr0
= (int) routine
;
61 ts
->r1
= vsp
- C_ARGSAVE_LEN
- C_RED_ZONE
;
63 PTHREAD_MACH_CALL(thread_set_state(thread
->kernel_thread
,
65 (thread_state_t
) &state
,
66 PPC_THREAD_STATE_COUNT
),
68 #elif defined(__i386__)
69 i386_thread_state_t state
;
70 i386_thread_state_t
*ts
= &state
;
71 int *sp
= (int *) vsp
;
74 * Set up i386 registers & function call.
76 count
= i386_THREAD_STATE_COUNT
;
77 PTHREAD_MACH_CALL(thread_get_state(thread
->kernel_thread
,
79 (thread_state_t
) &state
,
82 ts
->eip
= (int) routine
;
83 *--sp
= (int) thread
; /* argument to function */
84 *--sp
= 0; /* fake return address */
85 ts
->esp
= (int) sp
; /* set stack pointer */
86 PTHREAD_MACH_CALL(thread_set_state(thread
->kernel_thread
,
88 (thread_state_t
) &state
,
89 i386_THREAD_STATE_COUNT
),
93 #error _pthread_setup not defined for this architecture