[RTEMS Project] #2369: [PowerPC Book E] Invalid mftb instruction in _CPU_Counter_read()

RTEMS trac trac at rtems.org
Thu Jul 9 07:48:30 UTC 2015


#2369: [PowerPC Book E] Invalid mftb instruction in _CPU_Counter_read()
--------------------------+---------------------
 Reporter:  nick.withers  |       Owner:
     Type:  defect        |      Status:  new
 Priority:  normal        |   Milestone:  4.11.1
Component:  General       |     Version:  4.11
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+---------------------

Comment (by nick.withers):

 Replying to [comment:3 sebastian.huber]:
 > A BSP for the e500 should use the "-mcpu=8540 -meabi -msdata=sysv -fno-
 common" options.

 Cheers - I tried the following:
 {{{
 diff --git a/c/src/lib/libbsp/powerpc/mvme3100/make/custom/mvme3100.cfg
 b/c/src/lib/libbsp/powerpc/mvme3100/make/custom/mvme3100.cfg
 index ddd6d23..3872f18 100644
 --- a/c/src/lib/libbsp/powerpc/mvme3100/make/custom/mvme3100.cfg
 +++ b/c/src/lib/libbsp/powerpc/mvme3100/make/custom/mvme3100.cfg
 @@ -10,10 +10,10 @@ RTEMS_CPU_MODEL=e500

  #  This contains the compiler options necessary to select the CPU model
  #  and (hopefully) optimize for it.
 -CPU_CFLAGS = -mcpu=powerpc -msoft-float -D__ppc_generic
 +CPU_CFLAGS = -mcpu=8540 -meabi -msdata=sysv -fno-common -D__ppc_generic
 }}}

 ...and wasn't very successful ![1]:
 {{{
 powerpc-rtems4.11-gcc -B../../../../../mvme3100/lib/ -specs bsp_specs
 -qrtems -mcpu=8540 -meabi -msdata=sysv -fno-common -D__ppc_generic -O2 -g
 -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-
 prototypes -Wnested-externs    -mcpu=8540 -meabi -msdata=sysv -fno-common
 -D__ppc_generic   -o loopback.exe init.o
 /usr/home/nick/rtems/rtems-4.11/bin/../lib/gcc/powerpc-rtems4.11/4.9.3
 /../../../../powerpc-rtems4.11/bin/ld:
 ../../../../../mvme3100/lib/librtemsbsp.a(bspgetworkarea.o): the target
 (__rtems_end) of a R_PPC_SDAREL16 relocation is in the wrong output
 section (.bss)
 powerpc-rtems4.11-nm -g -n loopback.exe > loopback.num
 powerpc-rtems4.11-size loopback.exe
    text    data     bss     dec     hex filename
  390421    7124   19317  416862   65c5e loopback.exe
 powerpc-rtems4.11-objcopy -O binary loopback.exe loopback.ralf
 gmake[6]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/testsuites/samples/loopback'
 Making all in pppd
 gmake[6]: Entering directory '/usr/home/nick/rtems/git/build/rtems
 /powerpc-rtems4.11/c/mvme3100/testsuites/samples/pppd'
 powerpc-rtems4.11-gcc -B../../../../../mvme3100/lib/ -specs bsp_specs
 -qrtems -DHAVE_CONFIG_H -I.
 -I../../../../../../../../rtems/c/src/../../testsuites/samples/pppd -I..
 -mcpu=8540 -meabi -msdata=sysv -fno-common -D__ppc_generic -O2 -g -Wall
 -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes
 -Wnested-externs -MT init.o -MD -MP -MF .deps/init.Tpo -c -o init.o
 ../../../../../../../../rtems/c/src/../../testsuites/samples/pppd/init.c
 mv -f .deps/init.Tpo .deps/init.Po
 powerpc-rtems4.11-gcc -B../../../../../mvme3100/lib/ -specs bsp_specs
 -qrtems -DHAVE_CONFIG_H -I.
 -I../../../../../../../../rtems/c/src/../../testsuites/samples/pppd -I..
 -mcpu=8540 -meabi -msdata=sysv -fno-common -D__ppc_generic -O2 -g -Wall
 -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes
 -Wnested-externs -MT pppdapp.o -MD -MP -MF .deps/pppdapp.Tpo -c -o
 pppdapp.o
 ../../../../../../../../rtems/c/src/../../testsuites/samples/pppd/pppdapp.c
 mv -f .deps/pppdapp.Tpo .deps/pppdapp.Po
 powerpc-rtems4.11-gcc -B../../../../../mvme3100/lib/ -specs bsp_specs
 -qrtems -mcpu=8540 -meabi -msdata=sysv -fno-common -D__ppc_generic -O2 -g
 -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-
 prototypes -Wnested-externs    -mcpu=8540 -meabi -msdata=sysv -fno-common
 -D__ppc_generic   -o pppd.exe init.o pppdapp.o -lpppd
 /usr/home/nick/rtems/rtems-4.11/bin/../lib/gcc/powerpc-rtems4.11/4.9.3
 /../../../../powerpc-rtems4.11/bin/ld:
 ../../../../../mvme3100/lib/librtemsbsp.a(bspgetworkarea.o): the target
 (__rtems_end) of a R_PPC_SDAREL16 relocation is in the wrong output
 section (.bss)
 ../../../../../mvme3100/lib/librtemsbsp.a(bspgetworkarea.o): In function
 `bsp_work_area_initialize':
 /home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/lib/libbsp/powerpc/mvme3100/../../../../../../../../../rtems/c/src/lib/libbsp/powerpc/mvme3100/../../powerpc/shared/startup/bspgetworkarea.c:17:(.text+0x6):
 relocation truncated to fit: R_PPC_SDAREL16 against symbol `__rtems_end'
 defined in .bss section in pppd.exe
 collect2: error: ld returned 1 exit status
 Makefile:639: recipe for target 'pppd.exe' failed
 gmake[6]: *** [pppd.exe] Error 1
 gmake[6]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/testsuites/samples/pppd'
 Makefile:718: recipe for target 'all-local' failed
 gmake[5]: *** [all-local] Error 1
 gmake[5]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/testsuites/samples'
 Makefile:319: recipe for target 'all' failed
 gmake[4]: *** [all] Error 2
 gmake[4]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/testsuites/samples'
 Makefile:385: recipe for target 'all-recursive' failed
 gmake[3]: *** [all-recursive] Error 1
 gmake[3]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100/testsuites'
 Makefile:496: recipe for target 'all-recursive' failed
 gmake[2]: *** [all-recursive] Error 1
 gmake[2]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c/mvme3100'
 Makefile:359: recipe for target 'all-recursive' failed
 gmake[1]: *** [all-recursive] Error 1
 gmake[1]: Leaving directory '/usr/home/nick/rtems/git/build/rtems/powerpc-
 rtems4.11/c'
 Makefile:482: recipe for target 'all-recursive' failed
 gmake: *** [all-recursive] Error 1
 }}}

 > I am not sure if the SPR 268 exists really on all PowerPCs supported by
 RTEMS:
 >
 > static inline uint64_t PPC_Get_timebase_register( void )
 > {
 >   uint32_t tbr_low;
 >   uint32_t tbr_high;
 >   uint32_t tbr_high_old;
 >   uint64_t tbr;
 >
 >   do {
 > #if defined(mpx8xx) || defined(mpc860) || defined(mpc821)
 > /* See comment above (CPU_Get_timebase_low) */
 >     __asm__ volatile( "mftbu %0" : "=r" (tbr_high_old));
 >     __asm__ volatile( "mftb  %0" : "=r" (tbr_low));
 >     __asm__ volatile( "mftbu %0" : "=r" (tbr_high));
 > #else
 >     __asm__ volatile( "mfspr %0, 269" : "=r" (tbr_high_old));
 >     __asm__ volatile( "mfspr %0, 268" : "=r" (tbr_low));
 >     __asm__ volatile( "mfspr %0, 269" : "=r" (tbr_high));
 > #endif
 >   } while ( tbr_high_old != tbr_high );
 >
 >   tbr = tbr_high;
 >   tbr <<= 32;
 >   tbr |= tbr_low;
 >   return tbr;
 > }
 >
 > However these exceptions look more like museum hardware.

 Seems like they exist on the MPC860 at least (though they can't be used in
 place of ''mttb'' as they're user-level / read-only).

 ![1] ''-D!__ppc_generic'' was left in to shut powerpc.h up, but I'll
 investigate whether that's appropriate and/or explicitly whack an mpc8540
 check in there

--
Ticket URL: <http://devel.rtems.org/ticket/2369#comment:4>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list