mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
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:
committed by
Abdelatif Guettouche
parent
5da9cb3ae6
commit
05f6445493
+20
-2
@@ -123,6 +123,24 @@ do { \
|
|||||||
* Inline functions
|
* 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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -134,8 +152,8 @@ do { \
|
|||||||
* nuttx/arch/<architecture>/include/arch.h.
|
* nuttx/arch/<architecture>/include/arch.h.
|
||||||
*
|
*
|
||||||
* These tables would hold the physical address of the level 2 page tables.
|
* 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
|
* All would be initially NULL and would not be backed up with physical
|
||||||
* until mappings in the level 2 page table are required.
|
* memory until mappings in the level 2 page table are required.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct group_addrenv_s
|
struct group_addrenv_s
|
||||||
|
|||||||
@@ -34,24 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -54,6 +54,21 @@
|
|||||||
* Inline functions
|
* 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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* CCR bit definitions */
|
/* CCR bit definitions */
|
||||||
|
|
||||||
#define HCS12_CCR_C (1 << 0) /* Bit 0: Carry/Borrow status bit */
|
#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 */
|
#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
|
* Low Address <-- SP after state save
|
||||||
* [PPAGE]
|
* [PPAGE]
|
||||||
* [soft regisers]
|
* [soft regisers]
|
||||||
@@ -88,6 +89,7 @@
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Byte offsets */
|
/* Byte offsets */
|
||||||
|
|
||||||
/* PPAGE register (only in banked mode) */
|
/* PPAGE register (only in banked mode) */
|
||||||
|
|
||||||
#ifndef CONFIG_HCS12_NONBANKED
|
#ifndef CONFIG_HCS12_NONBANKED
|
||||||
@@ -174,9 +176,9 @@ struct xcptcontext
|
|||||||
uint8_t regs[XCPTCONTEXT_REGS];
|
uint8_t regs[XCPTCONTEXT_REGS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/************************************************************************************
|
||||||
* Inline functions
|
* Inline functions
|
||||||
****************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Name: up_irq_save, up_irq_restore, and friends.
|
/* Name: up_irq_save, up_irq_restore, and friends.
|
||||||
*
|
*
|
||||||
@@ -194,19 +196,6 @@ struct xcptcontext
|
|||||||
#define xenable() __asm("andcc #0xbf")
|
#define xenable() __asm("andcc #0xbf")
|
||||||
#define xdisable() __asm("orcc #0x40")
|
#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 */
|
/* Get the current value of the CCR */
|
||||||
|
|
||||||
static inline irqstate_t up_getccr(void)
|
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)
|
uintptr_t parm2, uintptr_t parm3)
|
||||||
{
|
{
|
||||||
/* To be provided */
|
/* To be provided */
|
||||||
|
|
||||||
/* __asm("swi") */
|
/* __asm("swi") */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +262,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Functions
|
* Public Functions Prototypes
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|||||||
@@ -34,21 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -54,6 +54,21 @@
|
|||||||
* Inline functions
|
* 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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -34,21 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -34,19 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -87,6 +87,23 @@
|
|||||||
* Inline functions
|
* 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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -98,8 +115,8 @@
|
|||||||
* nuttx/arch/<architecture>/include/arch.h.
|
* nuttx/arch/<architecture>/include/arch.h.
|
||||||
*
|
*
|
||||||
* These tables would hold the physical address of the level 2 page tables.
|
* 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
|
* All would be initially NULL and would not be backed up with physical
|
||||||
* until mappings in the level 2 page table are required.
|
* memory until mappings in the level 2 page table are required.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct group_addrenv_s
|
struct group_addrenv_s
|
||||||
|
|||||||
@@ -34,23 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -54,6 +54,23 @@
|
|||||||
* Inline functions
|
* 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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -34,23 +34,6 @@
|
|||||||
* Inline Functions
|
* 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
|
* Name: up_tls_info
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -65,25 +65,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS];
|
|||||||
* Private Functions
|
* 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
|
* Name: up_taskdump
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user