powerpc: Add _CPU_Get_current_per_CPU_control()

Add _CPU_Get_current_per_CPU_control() on SMP configurations.  Use SPRG0
for the current per-CPU control.  This reduces the code size by three
instructions and is slightly faster.

Update #2805.
This commit is contained in:
Sebastian Huber
2016-11-09 14:59:33 +01:00
parent 58bced64b9
commit 38a1449fd4
5 changed files with 2641 additions and 2603 deletions

View File

@@ -182,6 +182,10 @@ _start:
/* Set small-data anchor */
LA r13, _SDA_BASE_
#ifdef RTEMS_SMP
SET_SELF_CPU_CONTROL r4
#endif
blr
.Linitmore:

View File

@@ -936,13 +936,20 @@ void ShowBATS(void);
mtmsr \level
.endm
.macro GET_SELF_CPU_CONTROL reg
#if defined(RTEMS_SMP)
.macro SET_SELF_CPU_CONTROL reg
/* Use Book E Processor ID Register (PIR) */
mfspr \reg, 286
slwi \reg, \reg, PER_CPU_CONTROL_SIZE_LOG2
addis \reg, \reg, _Per_CPU_Information@ha
addi \reg, \reg, _Per_CPU_Information@l
mtspr PPC_PER_CPU_CONTROL_REGISTER, \reg
.endm
#endif
.macro GET_SELF_CPU_CONTROL reg
#if defined(RTEMS_SMP)
mfspr \reg, PPC_PER_CPU_CONTROL_REGISTER
#else
lis \reg, _Per_CPU_Information@h
ori \reg, \reg, _Per_CPU_Information@l

View File

@@ -5,6 +5,8 @@
*/
/*
* Copyright (c) 2016 embedded brains GmbH
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
@@ -15,12 +17,37 @@
#include <rtems/score/cpu.h>
#ifdef RTEMS_SMP
/* Use SPRG0 for the per-CPU control of the current processor */
#define PPC_PER_CPU_CONTROL_REGISTER 272
#endif /* RTEMS_SMP */
#ifndef ASM
#ifdef __cplusplus
extern "C" {
#endif
#ifdef RTEMS_SMP
static inline struct Per_CPU_Control *_PPC_Get_current_per_CPU_control( void )
{
struct Per_CPU_Control *cpu_self;
__asm__ volatile (
"mfspr %0, " RTEMS_XSTRING( PPC_PER_CPU_CONTROL_REGISTER )
: "=r" ( cpu_self )
);
return cpu_self;
}
#define _CPU_Get_current_per_CPU_control() _PPC_Get_current_per_CPU_control()
#endif /* RTEMS_SMP */
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff