Subject: how to detect at runtime which system you're running on...
To: None <port-arm@netbsd.org>
From: Chris Gilbert <chris@paradox.demon.co.uk>
List: port-arm
Date: 06/17/2001 23:31:26
Hi,

With the move towards different arch dirs, it's been suggested that archs 
that can merge do, eg EBSA285 and CATS, A7000 and RISCPC.  However I'm 
currently unaware of an easy way to do runtime detection of arch.  If someone 
knows of one I'm just being ignorant of, please shout up :)

To make the merge for some ports is easier as other information differs, eg 
iomd version/cpu id can be used.  However in the CATS and EBSA case the two 
machines are near identical, but not quite (eg footbridge/footbridge_pci.c 
has a #ifdef EBSA285 in it)

To deal with this in a generic manner, I'd like to suggest we have an 
arm/arch_type.h header file, into which we have an enum of all the 
arch/platforms.  We then have a variable for checking what arch the kernel is 
on.  The variable being in arm/arm/cpufunc.c (or some other file decided on)

Then in the bootup code the variable is set as appropriate (or even at 
compile time for some archs where they're not shared, eg netwinder) and 
runtime checks can be used in a generic way, and compile away to nothing for 
fixed platforms.

Is this the right thing to do?  do we already have a mechanism that I'm 
ignorant of?  Is there a better way to do this?

Cheers,
Chris