summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch/sparc/uthread_machdep.c
blob: f7599ef46367eebb3286abb19fa2b8d8ec28a2c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*	$OpenBSD: uthread_machdep.c,v 1.3 2003/01/31 04:46:16 marc Exp $	*/

/*
 * Machine-dependent thread state functions for OpenBSD/sparc.
 */

#include <machine/frame.h>
#include <machine/param.h>
#include <pthread.h>
#include "pthread_private.h"

extern void _thread_machdep_fpsave(u_int32_t *, u_int64_t *);
extern void _thread_machdep_fprestore(u_int32_t *, u_int64_t *);

/*
 * Given a stack and an entry function, initialise a state
 * structure that can be later switched to.
 */
void
_thread_machdep_init(statep, base, len, entry)
	struct _machdep_state* statep;
	void *base;
	int len;
	void (*entry)(void);
{
	struct frame *f;

	/* Locate the initial frame, aligned at the top of the stack */
	f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES);
	
	f->fr_fp = (struct frame *)-1;		/* purposefully misaligned */
	f->fr_pc = -1;				/* for gdb */
	statep->fp = (int)f;
	statep->pc = -8 + (int)entry;
}

void
_thread_machdep_save_float_state(statep)
	struct _machdep_state* statep;
{
	_thread_machdep_fpsave(&statep->fs_csr, &statep->fs_regs[0]);
}

void
_thread_machdep_restore_float_state(statep)
	struct _machdep_state* statep;
{
	_thread_machdep_fprestore(&statep->fs_csr, &statep->fs_regs[0]);
}