#include <sun4/asm_linkage.h>
#include <sun4/psl.h>

	.global	_splhigh
	.global	_splx
	.global	_getspl
	.global	_atsplhigh

_splhigh:
	mov		%psr,%o0
	andn		%o0,PSR_PIL,%o1
	or		%o1,PSR_PIL,%o2
	mov		%o2,%psr
	nop
	nop
	nop
	retl
	nop

_splx:
	mov		%psr,%o1
	andn		%o1,PSR_PIL,%o2
	and		%o0,PSR_PIL,%o3
	or		%o2,%o3,%o4
	mov		%o4,%psr
	nop
	nop
	nop
	retl
	nop

_getspl:
	retl
	mov		%psr,%o0

_atsplhigh:
	mov		%psr,%o2
	and		%o2,PSR_PIL,%o1
	clr		%o0
	cmp		%o1,PSR_PIL
#if 0 /* I'm not sure I can get this tricky with delay slots */
	be		1f
	retl
	nop
1:	inc		%o0
#else
	be		1f
	nop
2:	retl
	nop
1:	inc		%o0
	b		2b
	nop
#endif
