On Thu, 19 Aug 2004 01:28:34 +0200, Richard Zidlicky wrote:

> 
> On Thu, Aug 19, 2004 at 12:16:04AM +0200, Thierry Godefroy wrote:
> > 
> > Hello...
> > 
> > I tried to compile the v2.4.27 kernel for the Q60 today, but I came
> > across a strange assembler error.
> > 
> > I get:
> > 
> > gcc -D__KERNEL__ -I/usr/src/linux-2.4.27/include -Wall -Wstrict-prototypes
> > -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer
> > -pipe -fno-strength-reduce -ffixed-a2 -m68060   -nostdinc -iwithprefix
> > include -DKBUILD_BASENAME=setup  -DEXPORT_SYMTAB -c setup.c
> > {standard input}: Assembler messages:
> > {standard input}:291: Error: invalid instruction for this architecture;
> > needs fpu (68040, 68060 or 68881/68882) -- statement `frestore -4(%a6)'
> > ignored
> > make[1]: *** [setup.o] Error 1
> > 
> > The weird thing is that the -m68060 option is passed and 'as' complains
> > about no 68060 fpu...
> 
> looks like a ".chip" directive from some earlier asm statement
> did something strange, can you look at the assembler output?

Yep, that's it apparently... The assembler produced (line 273 onwards):
-----------
#APP
        .chip 68060; movec %pcr,%d2; .chip 68k
#NO_APP
        bfextu %d2{#16:#8},%d0
        moveq.l #5,%d1
        cmp.l %d0,%d1
        jbcc .L117
.L45:
        bftst m68k_fputype+3{#4:#4}
        jbeq .L47
        clr.l -4(%a6)
#APP
        frestore -4(%a6)
#NO_APP
-----------

And in setup.c, one can find:

-----------
        if (CPU_IS_060) {
                u32 pcr;

                asm (".chip 68060; movec %%pcr,%0; .chip 68k"
                     : "=d" (pcr));
                if (((pcr >> 8) & 0xff) <= 5) {
                        printk("Enabling workaround for errata I14\n");
                        asm (".chip 68060; movec %0,%%pcr; .chip 68k"
                             : : "d" (pcr | 0x20));
                }
        }

        /* FIXME: m68k_fputype is passed in by Penguin booter, which can
         * be confused by software FPU emulation. BEWARE.
         * We should really do our own FPU check at startup.
         * [what do we do with buggy 68LC040s? if we have problems
         *  with them, we should add a test to check_bugs() below] */
#ifndef CONFIG_M68KFPU_EMU_ONLY
        /* clear the fpu if we have one */
        if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
                volatile int zero = 0;
                asm __volatile__ ("frestore %0" : : "m" (zero));
        }
#endif  
------------

So, there's obviously a .chip directive missing in:
asm __volatile__ ("frestore %0" : : "m" (zero));

I changed it for:
asm __volatile__ (".chip 68060; frestore %0" : : "m" (zero));

and everything seems to compile fine (resulting kernel still to be tested
though)... Of course, there should be a different .chip directive for each
processor type, I think (though frestore is perhaps assembled into the same
opcode for all variations of CPU/FPU... I didn't check it either). It would
be interesting to see what was in setup.c for Linux v2.4.23 (or 2.4.26),
but I cruelly lack time and I no more got the sources handy.

Nevertheless, it still sounds strange to me that "as" seems to ignore the
-m68060 option passed to gcc (or is gcc not passing that option to "as" ?),
as the '.chip 68060' should be implicit with -m68060 on...

If the shebang compiles properly, new pre-compiled Q60-Linux kernels should
be available "soon" (the poor 68060/66MHz is so slooooow when compared to a
2GHz Athlon XP...) from my website.

Thierry Godefroy.

Reply via email to