arch: Move *_getsp to the common place arch/arch.h

so other place can get the stack pointer easily

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-07-09 02:39:29 +08:00 committed by Abdelatif Guettouche
parent 5da9cb3ae6
commit 05f6445493
14 changed files with 143 additions and 135 deletions

View file

@ -123,6 +123,24 @@ do { \
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: arm_getsp
****************************************************************************/
/* I don't know if the builtin to get SP is enabled */
static inline uint32_t arm_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Types
****************************************************************************/
@ -134,8 +152,8 @@ do { \
* nuttx/arch/<architecture>/include/arch.h.
*
* These tables would hold the physical address of the level 2 page tables.
* All would be initially NULL and would not be backed up with physical memory
* until mappings in the level 2 page table are required.
* All would be initially NULL and would not be backed up with physical
* memory until mappings in the level 2 page table are required.
*/
struct group_addrenv_s

View file

@ -34,24 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: arm_getsp
****************************************************************************/
/* I don't know if the builtin to get SP is enabled */
static inline uint32_t arm_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -54,6 +54,21 @@
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: hc_getsp
****************************************************************************/
static inline uint16_t hc_getsp(void)
{
uint16_t ret;
__asm__
(
"\tsts %0\n"
: "=m"(ret) :
);
return ret;
}
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -50,6 +50,7 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* CCR bit definitions */
#define HCS12_CCR_C (1 << 0) /* Bit 0: Carry/Borrow status bit */
@ -62,7 +63,7 @@
#define HCS12_CCR_S (1 << 7) /* Bit 7: STOP instruction control bit */
/************************************************************************************
* Register state save strucure
* Register state save strucure
* Low Address <-- SP after state save
* [PPAGE]
* [soft regisers]
@ -88,6 +89,7 @@
************************************************************************************/
/* Byte offsets */
/* PPAGE register (only in banked mode) */
#ifndef CONFIG_HCS12_NONBANKED
@ -174,9 +176,9 @@ struct xcptcontext
uint8_t regs[XCPTCONTEXT_REGS];
};
/****************************************************************************
/************************************************************************************
* Inline functions
****************************************************************************/
************************************************************************************/
/* Name: up_irq_save, up_irq_restore, and friends.
*
@ -194,19 +196,6 @@ struct xcptcontext
#define xenable() __asm("andcc #0xbf")
#define xdisable() __asm("orcc #0x40")
/* Get the current value of the stack pointer */
static inline uint16_t up_getsp(void)
{
uint16_t ret;
__asm__
(
"\tsts %0\n"
: "=m"(ret) :
);
return ret;
}
/* Get the current value of the CCR */
static inline irqstate_t up_getccr(void)
@ -256,6 +245,7 @@ static inline void system_call3(unsigned int nbr, uintptr_t parm1,
uintptr_t parm2, uintptr_t parm3)
{
/* To be provided */
/* __asm("swi") */
}
@ -272,7 +262,7 @@ extern "C"
#endif
/************************************************************************************
* Public Functions
* Public Functions Prototypes
************************************************************************************/
#undef EXTERN

View file

@ -34,21 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: hc_getsp
****************************************************************************/
static inline uint16_t hc_getsp(void)
{
uint16_t ret;
__asm__
(
"\tsts %0\n"
: "=m"(ret) :
);
return ret;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -54,6 +54,21 @@
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: mips_getsp
****************************************************************************/
static inline uint32_t mips_getsp(void)
{
register uint32_t sp;
__asm__
(
"\tadd %0, $0, $29\n"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -34,21 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: mips_getsp
****************************************************************************/
static inline uint32_t mips_getsp(void)
{
register uint32_t sp;
__asm__
(
"\tadd %0, $0, $29\n"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -1 +1,51 @@
/****************************************************************************
* arch/misoc/include/arch.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_MISOC_INCLUDE_ARCH_H
#define __ARCH_MISOC_INCLUDE_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: misoc_getsp
****************************************************************************/
static inline uint32_t misoc_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
return sp;
}
#endif /* __ARCH_MISOC_INCLUDE_ARCH_H */

View file

@ -34,19 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: misoc_getsp
****************************************************************************/
static inline uint32_t misoc_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
return sp;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -87,6 +87,23 @@
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: or1k_getsp
****************************************************************************/
static inline uint32_t or1k_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Types
****************************************************************************/
@ -98,8 +115,8 @@
* nuttx/arch/<architecture>/include/arch.h.
*
* These tables would hold the physical address of the level 2 page tables.
* All would be initially NULL and would not be backed up with physical memory
* until mappings in the level 2 page table are required.
* All would be initially NULL and would not be backed up with physical
* memory until mappings in the level 2 page table are required.
*/
struct group_addrenv_s

View file

@ -34,23 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: or1k_getsp
****************************************************************************/
static inline uint32_t or1k_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -54,6 +54,23 @@
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: xtensa_getsp
****************************************************************************/
static inline uint32_t xtensa_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__
(
"mov %0, sp\n"
: "=r" (sp)
);
return sp;
}
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -34,23 +34,6 @@
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: xtensa_getsp
****************************************************************************/
static inline uint32_t xtensa_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__
(
"mov %0, sp\n"
: "=r" (sp)
);
return sp;
}
/****************************************************************************
* Name: up_tls_info
*

View file

@ -65,25 +65,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS];
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: xtensa_getsp
****************************************************************************/
/* I don't know if the builtin to get SP is enabled */
static inline uint32_t xtensa_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__
(
"mov %0, sp\n"
: "=r" (sp)
);
return sp;
}
/****************************************************************************
* Name: up_taskdump
****************************************************************************/