Subject: Re: config & endianness
To: Garrett D'Amore <garrett_damore@tadpole.com>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 03/07/2006 13:05:46
Hi Garrett,

"Garrett D'Amore" wrote:

> Hmm.... we now have some kernel configs in evbmips that do not make
> sense for either big or little endian.
> 
>     * OMSAL and MTX-1 are always little endian
>     * forthcoming ATHEROS AR531x based systems will always be big endian
>     * DBAU1XXX can be either endian (jumper selectable)
>     * Malta/PB1XXX?  probably also jumper selectable
> 
> Is there a way to establish stuff in config so that:
> 
>     1) an attempt to build a kernel with endianness that doesn't make
> sense fails in config(8), AND
> 
>     2) the master releng Makefiles/scripts only bother to build the
> kernels that make sense for a particular endianness

etc.evbarm/Makefile.inc uses $MACHINE_ARCH to build two different kernel
lists.  I can't think of a cleaner way of doing this off-hand.

> I also have another question relating to the atheros HAL and endianness
> in Makefiles.  Is there a way to detect in the kernel Makefiles what
> endianness is being used and use different dependencies based on that? 
> (I.e. pick either the big or the little endian HAL properly.)

You can use ${MACHINE_ARCH} and/or <bsd.endian.mk>.  For example,
if I put the following in sys/arch/mips/conf/Makefile.mips somewhere:

	.include <bsd.endian.mk>

	ls-ath:
		@ls $S/contrib/arch/mips/dev/athhal-mips-${MACHINE_ARCH:C/^mipse//}e-elf.hal.o.uue

	endian:
		@echo ${TARGET_ENDIANNESS}

I can then do:

	bigkev 58> nbmake-evbmips-eb ls-ath
	../../../../contrib/arch/mips/dev/athhal-mips-be-elf.hal.o.uue
	bigkev 59> nbmake-evbmips-eb endian
	4321
	bigkev 60> nbmake-evbmips-el ls-ath
	../../../../contrib/arch/mips/dev/athhal-mips-le-elf.hal.o.uue
	bigkev 61> nbmake-evbmips-el endian
	1234

Is this what you mean?  Note that for the ath example, $MACHINE_ARCH
ends in "eb" or "el", but the ath files want to use "be" or "le" so we
delete the 'e' as well and tack it on the end.

Cheers,
Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Support and Service:         http://www.wasabisystems.com/