Subject: Re: how to detect at runtime which system you're running on...
To: Ben Harris <bjh21@netbsd.org>
From: Chris Gilbert <chris@paradox.demon.co.uk>
List: port-arm
Date: 06/19/2001 22:49:42
On Monday 18 June 2001 11:49 am, Ben Harris wrote:
> On Sun, 17 Jun 2001, Chris Gilbert wrote:
> > 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 :)
>
> What do you mean by "arch"?  Do you mean inside the kernel or outside?
> Inside, you can check MACHINE, and if that isn't fine-grained enough, you
> should probably check the actual feature you're interested in.

What I really meant the platform, IE CATS and EBSA are identical bar one 
section of code in footbridge_pci.c, so the arch is cats, but the platform is 
ebsa or cats.  However footbridge is shared with netwinder, so the variable 
either becomes footbridge specific, or I generalise it.  So that anyone 
looking at the code sees:

if (platform_type == pt_EBSA)
or
if (platform_type == pt_A7000)

they can clearly see what it means, for archs that are just one platform it's 
just a macro, and gets delt with at compile_time.

The problem that we could all do different things, to achieve a similiar end, 
eg the a7000/riscpc will have something like:
if (cpu_id != ARM7500)
cats/ebsa/netwinder will be some flag like
if (is_ebsa)

I suppose I'm just looking for consistency and that we don't end up with a 
pile of flags just to indicate which platform you're on.

> > 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)
>
> That seems like overkill for the job at hand.  The problem is that you'll
> probably end up putting the division between two "arch"es in the wrong
> place anyway, and end up needing to distinguish between machines in the
> same "arch", and you'll have to invent another mechanism to tell the
> difference between _them_.  I think a better approach is to have a
> variable to indicate the presence of the actual feature you're interested
> in.

Sorry what I really meant is to be able to distinguish the exact platform for 
those rare cases we need it.  I think I confused things by saying arch.

Cheers,
Chris