Subject: Re: cpufunc.h
To: Ben Harris <bjh21@netbsd.org>
From: John Fremlin <vii@users.sourceforge.net>
List: port-arm
Date: 05/29/2001 22:06:41
Ben Harris <bjh21@netbsd.org> writes:

[...]

> Most of the occurrances of SetCPSR seem to be being used to disable
> IRQs and restore their previous state, so we should probably have an
> API specifically to do that.

There already exists one in cpufunc.h

#define disable_interrupts(mask) \
	(SetCPSR((mask) & (I32_bit | F32_bit), (mask) & (I32_bit | F32_bit)))

#define enable_interrupts(mask) \
	(SetCPSR((mask) & (I32_bit | F32_bit), 0))

#define restore_interrupts(old_cpsr) \
	(SetCPSR((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))

Typical that people don't use it. Looking at the hpcarm port I see
people doing the set_cpsr stuff themselves in inline assembly :-(

> > > > Is the current assembly SetCPSR even valid? It can clobber a bunch of
> > > > registers on mode change. Are all these registers caller save in the
> > > > abi?
> > >
> > > r0-r3, r12 are all caller-saved.
> >
> > Then the current code setcpsr.S code is screwed because set_cpsr can
> > clobber "r8","r9","r10","r11","r12","r13","r14".
> 
> This is only true if it's ever used to change mode, which I'm fairly sure
> it isn't.

So the api should have a comment or two about that. My improved
version permits this.

-- 

	http://ape.n3.net