mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
arch: Move up_getsp from arch.h to irq.h
since all other special register operation in irq.h Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
caf92cdadf
commit
3d1ce144df
@@ -40,8 +40,6 @@
|
||||
* Pre-processor Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#define up_getsp() (uintptr_t)__builtin_frame_address(0)
|
||||
|
||||
#ifdef CONFIG_PIC
|
||||
|
||||
/* This identifies the register the is used by the processor as the PIC base
|
||||
|
||||
@@ -60,6 +60,12 @@
|
||||
# include <arch/arm/irq.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#define up_getsp() (uintptr_t)__builtin_frame_address(0)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -39,30 +39,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint8_t spl;
|
||||
uint8_t sph;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"in %0, __SP_L__\n\t"
|
||||
"in %1, __SP_H__\n"
|
||||
: "=r" (spl), "=r" (sph)
|
||||
:
|
||||
);
|
||||
|
||||
return (uint16_t)sph << 8 | spl;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
@@ -147,6 +147,24 @@ static inline void putsreg(irqstate_t sreg)
|
||||
asm volatile ("out __SREG__, %s" : : "r" (sreg) :);
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint8_t spl;
|
||||
uint8_t sph;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"in %0, __SP_L__\n\t"
|
||||
"in %1, __SP_H__\n"
|
||||
: "=r" (spl), "=r" (sph)
|
||||
:
|
||||
);
|
||||
|
||||
return (uint16_t)sph << 8 | spl;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
|
||||
static inline void up_irq_enable()
|
||||
|
||||
@@ -39,27 +39,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t retval;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov\t%0,sp\n\t"
|
||||
: "=r" (retval)
|
||||
:
|
||||
);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
@@ -156,6 +156,21 @@ static inline uint32_t avr32_evba(void)
|
||||
return evba;
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t retval;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov\t%0,sp\n\t"
|
||||
: "=r" (retval)
|
||||
:
|
||||
);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Return the current interrupt enable state and disable all interrupts */
|
||||
|
||||
static inline irqstate_t up_irq_save(void)
|
||||
|
||||
@@ -231,6 +231,15 @@ static inline void setmodp(uint32_t modp_v)
|
||||
);
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__("nop\nmov sp, %0" : "=r"(sp));
|
||||
return sp;
|
||||
}
|
||||
|
||||
static inline void up_irq_disable(void)
|
||||
{
|
||||
setmodp(REG_MODP_DISABLE);
|
||||
@@ -253,17 +262,6 @@ static inline void up_irq_restore(irqstate_t flags)
|
||||
setmodp(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__("nop\nmov sp, %0" : "=r"(sp));
|
||||
return sp;
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_CEVA_INCLUDE_XC5_IRQ_H */
|
||||
|
||||
@@ -221,6 +221,15 @@ static inline void setmoda(uint32_t moda)
|
||||
__asm__ __volatile__("nop #0x04\nnop\nmovp %0.ui, moda.ui" : : "r"(moda));
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__("mov sp.ui, %0.ui" : "=r"(sp));
|
||||
return sp;
|
||||
}
|
||||
|
||||
static inline void up_irq_disable(void)
|
||||
{
|
||||
setmoda(REG_MODA_DISABLE);
|
||||
@@ -243,17 +252,6 @@ static inline void up_irq_restore(irqstate_t flags)
|
||||
setmoda(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__("mov sp.ui, %0.ui" : "=r"(sp));
|
||||
return sp;
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_CEVA_INCLUDE_XM6_IRQ_H */
|
||||
|
||||
@@ -35,25 +35,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint16_t ret;
|
||||
__asm__
|
||||
(
|
||||
"\tsts %0\n"
|
||||
: "=m"(ret) :
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -69,6 +69,23 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return 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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -35,25 +35,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
__asm__
|
||||
(
|
||||
"\tadd %0, $0, $29\n"
|
||||
: "=r"(sp)
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -67,6 +67,23 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
__asm__
|
||||
(
|
||||
"\tadd %0, $0, $29\n"
|
||||
: "=r"(sp)
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -29,23 +29,8 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
|
||||
__asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
#endif /* __ARCH_MISOC_INCLUDE_ARCH_H */
|
||||
|
||||
@@ -57,6 +57,21 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
|
||||
__asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -66,27 +66,6 @@
|
||||
# endif
|
||||
#endif /* CONFIG_ARCH_ADDRENV */
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
|
||||
__asm__
|
||||
(
|
||||
"\tmov %0, sp\n\t"
|
||||
: "=r"(sp)
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -42,6 +42,25 @@
|
||||
|
||||
#include <arch/chip/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
|
||||
__asm__
|
||||
(
|
||||
"\tmov %0, sp\n\t"
|
||||
: "=r"(sp)
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -39,28 +39,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint16_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"\tstc sp, %0\n\t"
|
||||
: "=r" (sp)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* arch/renesas/include/m16c/irq.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@@ -16,7 +16,7 @@
|
||||
* 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/irq.h
|
||||
@@ -25,20 +25,20 @@
|
||||
#ifndef __ARCH_RENESAS_INCLUDE_M16C_IRQ_H
|
||||
#define __ARCH_RENESAS_INCLUDE_M16C_IRQ_H
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* IRQ numbers **********************************************************************/
|
||||
/* IRQ numbers **************************************************************/
|
||||
|
||||
/* Fixed vector table */
|
||||
|
||||
@@ -219,9 +219,9 @@
|
||||
|
||||
#define XCPTCONTEXT_SIZE 22
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* This struct defines the way the registers are stored. We need to save: */
|
||||
|
||||
@@ -251,9 +251,29 @@ struct xcptcontext
|
||||
};
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint16_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"\tstc sp, %0\n\t"
|
||||
: "=r" (sp)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
@@ -264,9 +284,9 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
@@ -323,9 +343,9 @@ static inline irqstate_t up_irq_enable(void)
|
||||
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -39,29 +39,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint16_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"\tmvfc usp, %0\n\t"
|
||||
: "=r" (sp)
|
||||
:
|
||||
:"memory"
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1031,6 +1031,23 @@ static inline void __setsr(irqstate_t psw)
|
||||
__asm__ __volatile__("mvtc %0, psw": :"r"(psw));
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint16_t up_getsp(void)
|
||||
{
|
||||
uint16_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"\tmvfc usp, %0\n\t"
|
||||
: "=r" (sp)
|
||||
:
|
||||
:"memory"
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/* Disable interrupts */
|
||||
|
||||
static inline void up_irq_disable(void)
|
||||
|
||||
@@ -39,28 +39,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov r15, %0\n\t"
|
||||
: "=&z" (sp)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
@@ -507,6 +507,22 @@ static inline void __setsr(irqstate_t sr)
|
||||
__asm__ __volatile__ ("ldc %0, sr" : : "r" (sr));
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov r15, %0\n\t"
|
||||
: "=&z" (sp)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/* Return the current interrupt enable state and disable interrupts */
|
||||
|
||||
static inline irqstate_t up_irq_save(void)
|
||||
|
||||
@@ -78,29 +78,6 @@
|
||||
# define ARCH_SPGTS (ARCH_PGT_MAX_LEVELS - 1)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
register uintptr_t sp;
|
||||
__asm__
|
||||
(
|
||||
"\tadd %0, x0, x2\n"
|
||||
: "=r"(sp)
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -568,6 +568,23 @@ struct xcptcontext
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
register uintptr_t sp;
|
||||
__asm__
|
||||
(
|
||||
"\tadd %0, x0, x2\n"
|
||||
: "=r"(sp)
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -25,17 +25,4 @@
|
||||
#ifndef __ARCH_SIM_INCLUDE_ARCH_H
|
||||
#define __ARCH_SIM_INCLUDE_ARCH_H
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
return (uintptr_t)__builtin_frame_address(0);
|
||||
}
|
||||
|
||||
#endif /* __ARCH_SIM_INCLUDE_ARCH_H */
|
||||
|
||||
@@ -69,6 +69,17 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
return (uintptr_t)__builtin_frame_address(0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_cpu_index
|
||||
*
|
||||
|
||||
@@ -35,28 +35,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t retval;
|
||||
|
||||
do
|
||||
{
|
||||
retval = 0;
|
||||
__asm__ volatile("mov %%sp, %0" : "=r" (retval) : "0" (retval));
|
||||
}
|
||||
while (0);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -68,6 +68,26 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t retval;
|
||||
|
||||
do
|
||||
{
|
||||
retval = 0;
|
||||
__asm__ volatile("mov %%sp, %0" : "=r" (retval) : "0" (retval));
|
||||
}
|
||||
while (0);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -349,64 +349,8 @@ begin_packed_struct struct idt_ptr_s
|
||||
uint32_t base; /* The address of the first GDT entry */
|
||||
} end_packed_struct;
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Return stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmovl %%esp, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Get segment registers */
|
||||
|
||||
static inline uint32_t up_getds(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ds, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getcs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%cs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getss(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ss, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -181,6 +181,58 @@ struct xcptcontext
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Return stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmovl %%esp, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Get segment registers */
|
||||
|
||||
static inline uint32_t up_getds(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ds, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getcs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%cs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getss(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ss, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Name: up_irq_save, up_irq_restore, and friends.
|
||||
*
|
||||
* NOTE: This function should never be called from application code and,
|
||||
|
||||
@@ -347,198 +347,6 @@ begin_packed_struct struct ist_s
|
||||
uint16_t IOPB_OFFSET; /* IOPB_offset */
|
||||
} end_packed_struct;
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline void setgdt(void *gdt, int size)
|
||||
{
|
||||
struct gdt_ptr_s gdt_ptr;
|
||||
gdt_ptr.limit = size;
|
||||
gdt_ptr.base = (uintptr_t)gdt;
|
||||
|
||||
asm volatile ("lgdt %0"::"m"(gdt_ptr):"memory");
|
||||
}
|
||||
|
||||
static inline void setidt(void *idt, int size)
|
||||
{
|
||||
struct idt_ptr_s idt_ptr;
|
||||
idt_ptr.limit = size;
|
||||
idt_ptr.base = (uintptr_t)idt;
|
||||
|
||||
asm volatile ("lidt %0"::"m"(idt_ptr):"memory");
|
||||
}
|
||||
|
||||
static inline uint64_t rdtsc(void)
|
||||
{
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
|
||||
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"memory");
|
||||
return (uint64_t)lo | (((uint64_t)hi) << 32);
|
||||
}
|
||||
|
||||
static inline uint64_t _rdtsc(void)
|
||||
{
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
|
||||
asm volatile("rdtsc" : "=a" (lo), "=d" (hi)::"memory");
|
||||
return (uint64_t)lo | (((uint64_t)hi) << 32);
|
||||
}
|
||||
|
||||
static inline void set_pcid(uint64_t pcid)
|
||||
{
|
||||
if (pcid < 4095)
|
||||
{
|
||||
asm volatile("mov %%cr3, %%rbx; andq $-4096, %%rbx; or %0, "
|
||||
"%%rbx; mov %%rbx, %%cr3;"
|
||||
::"g"(pcid):"memory", "rbx", "rax");
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long read_msr(unsigned int msr)
|
||||
{
|
||||
uint32_t low;
|
||||
uint32_t high;
|
||||
|
||||
asm volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
|
||||
return low | ((unsigned long)high << 32);
|
||||
}
|
||||
|
||||
static inline void write_msr(unsigned int msr, unsigned long val)
|
||||
{
|
||||
asm volatile("wrmsr"
|
||||
: /* no output */
|
||||
: "c" (msr), "a" (val), "d" (val >> 32)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static inline uint64_t read_fsbase(void)
|
||||
{
|
||||
uint64_t val;
|
||||
asm volatile("rdfsbase %0"
|
||||
: "=r" (val)
|
||||
: /* no output */
|
||||
: "memory");
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void write_fsbase(unsigned long val)
|
||||
{
|
||||
asm volatile("wrfsbase %0"
|
||||
: /* no output */
|
||||
: "r" (val)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static inline uint64_t read_gsbase(void)
|
||||
{
|
||||
uint64_t val;
|
||||
asm volatile("rdgsbase %0"
|
||||
: "=r" (val)
|
||||
: /* no output */
|
||||
: "memory");
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void write_gsbase(unsigned long val)
|
||||
{
|
||||
asm volatile("wrgsbase %0"
|
||||
: /* no output */
|
||||
: "r" (val)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/* Return stack pointer */
|
||||
|
||||
static inline uint64_t up_getsp(void)
|
||||
{
|
||||
uint64_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmovq %%rsp, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Get segment registers */
|
||||
|
||||
static inline uint32_t up_getds(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ds, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getcs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%cs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getss(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ss, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getes(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%es, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getfs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%fs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getgs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%gs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -193,6 +193,195 @@ struct xcptcontext
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
static inline void setgdt(void *gdt, int size)
|
||||
{
|
||||
struct gdt_ptr_s gdt_ptr;
|
||||
gdt_ptr.limit = size;
|
||||
gdt_ptr.base = (uintptr_t)gdt;
|
||||
|
||||
asm volatile ("lgdt %0"::"m"(gdt_ptr):"memory");
|
||||
}
|
||||
|
||||
static inline void setidt(void *idt, int size)
|
||||
{
|
||||
struct idt_ptr_s idt_ptr;
|
||||
idt_ptr.limit = size;
|
||||
idt_ptr.base = (uintptr_t)idt;
|
||||
|
||||
asm volatile ("lidt %0"::"m"(idt_ptr):"memory");
|
||||
}
|
||||
|
||||
static inline uint64_t rdtsc(void)
|
||||
{
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
|
||||
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"memory");
|
||||
return (uint64_t)lo | (((uint64_t)hi) << 32);
|
||||
}
|
||||
|
||||
static inline uint64_t _rdtsc(void)
|
||||
{
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
|
||||
asm volatile("rdtsc" : "=a" (lo), "=d" (hi)::"memory");
|
||||
return (uint64_t)lo | (((uint64_t)hi) << 32);
|
||||
}
|
||||
|
||||
static inline void set_pcid(uint64_t pcid)
|
||||
{
|
||||
if (pcid < 4095)
|
||||
{
|
||||
asm volatile("mov %%cr3, %%rbx; andq $-4096, %%rbx; or %0, "
|
||||
"%%rbx; mov %%rbx, %%cr3;"
|
||||
::"g"(pcid):"memory", "rbx", "rax");
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long read_msr(unsigned int msr)
|
||||
{
|
||||
uint32_t low;
|
||||
uint32_t high;
|
||||
|
||||
asm volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
|
||||
return low | ((unsigned long)high << 32);
|
||||
}
|
||||
|
||||
static inline void write_msr(unsigned int msr, unsigned long val)
|
||||
{
|
||||
asm volatile("wrmsr"
|
||||
: /* no output */
|
||||
: "c" (msr), "a" (val), "d" (val >> 32)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static inline uint64_t read_fsbase(void)
|
||||
{
|
||||
uint64_t val;
|
||||
asm volatile("rdfsbase %0"
|
||||
: "=r" (val)
|
||||
: /* no output */
|
||||
: "memory");
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void write_fsbase(unsigned long val)
|
||||
{
|
||||
asm volatile("wrfsbase %0"
|
||||
: /* no output */
|
||||
: "r" (val)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static inline uint64_t read_gsbase(void)
|
||||
{
|
||||
uint64_t val;
|
||||
asm volatile("rdgsbase %0"
|
||||
: "=r" (val)
|
||||
: /* no output */
|
||||
: "memory");
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void write_gsbase(unsigned long val)
|
||||
{
|
||||
asm volatile("wrgsbase %0"
|
||||
: /* no output */
|
||||
: "r" (val)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/* Return stack pointer */
|
||||
|
||||
static inline uint64_t up_getsp(void)
|
||||
{
|
||||
uint64_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmovq %%rsp, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Get segment registers */
|
||||
|
||||
static inline uint32_t up_getds(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ds, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getcs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%cs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getss(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%ss, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getes(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%es, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getfs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%fs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
static inline uint32_t up_getgs(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
asm volatile(
|
||||
"\tmov %%gs, %0\n"
|
||||
: "=rm" (regval)
|
||||
:
|
||||
: "memory");
|
||||
return regval;
|
||||
}
|
||||
|
||||
/* Name: up_irq_save, up_irq_restore, and friends.
|
||||
*
|
||||
* NOTE: This function should never be called from application code and,
|
||||
|
||||
@@ -39,28 +39,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getsp
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint32_t up_getsp(void) inline_function;
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov %0, sp\n"
|
||||
: "=r" (sp)
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -232,6 +232,21 @@ static inline void xtensa_setps(uint32_t ps)
|
||||
);
|
||||
}
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uint32_t up_getsp(void)
|
||||
{
|
||||
register uint32_t sp;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"mov %0, sp\n"
|
||||
: "=r" (sp)
|
||||
);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/* Restore the value of the PS register */
|
||||
|
||||
static inline void up_irq_restore(uint32_t ps)
|
||||
|
||||
@@ -59,10 +59,6 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
chipreg_t up_getsp(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
chipreg_t up_getsp(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
@@ -59,10 +59,6 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
uintptr_t up_getsp(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -32,4 +32,25 @@
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/chip/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
uintptr_t up_getsp(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_Z80_INCLUDE_IRQ_H */
|
||||
|
||||
Reference in New Issue
Block a user