Xtensa: Keep task state in TCB (unless you want to redesign signal handling). Lots of cosmetic clean-up.

This commit is contained in:
Gregory Nutt 2016-10-16 07:57:16 -06:00
parent 275120a6d1
commit a8662c70db
20 changed files with 87 additions and 232 deletions

View File

@ -159,9 +159,9 @@ struct xcptcontext
uint32_t saved_cpsr;
#endif
/* Pointer to the register save area on the stack*/
/* Register save area */
uint32_t *regs;
uint32_t regs[XCPTCONTEXT_REGS];
#ifdef CONFIG_LIB_SYSCALL
/* The following array holds the return address and the exc_return value

View File

@ -104,19 +104,28 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* In the XTENSA model, only a pointer to register state on the stack is
* saved in the TCB.
/* In the XTENSA model, the state is copied from the stack to the TCB, but
* only a referenced is passed to get the state from the TCB.
*/
#define up_savestate(regs) do { reg = g_current_regs; } while (0)
#define up_restorestate(regs) do { g_current_regs = regs; } while (0)
#define xtensa_savestate(regs) xtensa_copystate(regs, (uint32_t*)g_current_regs)
#define xtensa_restorestate(regs) do { g_current_regs = regs; } while (0)
/* Register access macros */
# define getreg8(a) (*(volatile uint8_t *)(a))
# define putreg8(v,a) (*(volatile uint8_t *)(a) = (v))
# define getreg16(a) (*(volatile uint16_t *)(a))
# define putreg16(v,a) (*(volatile uint16_t *)(a) = (v))
# define getreg32(a) (*(volatile uint32_t *)(a))
# define putreg32(v,a) (*(volatile uint32_t *)(a) = (v))
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
typedef void (*up_vector_t)(void);
typedef void (*xtensa_vector_t)(void);
#endif
/****************************************************************************
@ -130,7 +139,7 @@ typedef void (*up_vector_t)(void);
extern volatile uint32_t *g_current_regs;
/* This is the beginning of heap as provided from up_head.S. This is the
/* This is the beginning of heap as provided from *_head.S. This is the
* first address in DRAM after the loaded program+bss+idle stack. The end
* of the heap is CONFIG_RAM_END
*/
@ -183,14 +192,20 @@ extern uint32_t _bmxdupba_address; /* BMX register setting */
#ifndef __ASSEMBLY__
/* Common Functions *********************************************************/
/* Common functions define in arch/mips/src/common. These may be replaced
/* Common functions defined in arch/mips/src/common. These may be replaced
* with chip-specific functions of the same name if needed. See also
* functions prototyped in include/nuttx/arch.h.
*/
/* Atomic modification of registers */
void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits);
void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits);
void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits);
/* Context switching */
void up_copystate(uint32_t *dest, uint32_t *src);
void xtensa_copystate(uint32_t *dest, uint32_t *src);
/* Serial output */
@ -208,36 +223,36 @@ void lowconsole_init(void);
/* Debug */
#ifdef CONFIG_ARCH_STACKDUMP
void up_dumpstate(void);
void xtensa_dumpstate(void);
#else
# define up_dumpstate()
# define xtensa_dumpstate()
#endif
/* Common XTENSA functions */
/* IRQs */
uint32_t *up_doirq(int irq, uint32_t *regs);
uint32_t *xtensa_doirq(int irq, uint32_t *regs);
/* Software interrupt handler */
int up_swint(int irq, FAR void *context);
int xtensa_swint(int irq, FAR void *context);
/* Signals */
void up_sigdeliver(void);
void xtensa_sigdeliver(void);
/* Chip-specific functions **************************************************/
/* Chip specific functions defined in arch/mips/src/<chip> */
/* IRQs */
void up_irqinitialize(void);
bool up_pending_irq(int irq);
void up_clrpend_irq(int irq);
void xtensa_irq_initialize(void);
bool xtensa_pending_irq(int irq);
void xtensa_clrpend_irq(int irq);
/* DMA */
#ifdef CONFIG_ARCH_DMA
void weak_function up_dmainitialize(void);
void weak_function xtensa_dma_initialize(void);
#endif
/* Memory management */
@ -261,7 +276,7 @@ void up_serialinit(void);
/* System timer */
void up_timer_initialize(void);
void xtensa_timer_initialize(void);
/* Network */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_allocateheap.c
*
* Copyright (C) 2010, 2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -46,21 +46,8 @@
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_arch.h
* arch/xtensa/src/common/xtensa_copystate.c
*
* Copyright (C) 2010, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -33,58 +33,42 @@
*
****************************************************************************/
#ifndef ___ARCH_XTENSA_SRC_COMMON_XTENSA_ARCH_H
#define ___ARCH_XTENSA_SRC_COMMON_XTENSA_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
#include <stdint.h>
#include <arch/irq.h>
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
* Public Functions
****************************************************************************/
/****************************************************************************
* Inline Functions
* Name: up_copystate
****************************************************************************/
#ifndef __ASSEMBLY__
/* A little faster than most memcpy's */
# define getreg8(a) (*(volatile uint8_t *)(a))
# define putreg8(v,a) (*(volatile uint8_t *)(a) = (v))
# define getreg16(a) (*(volatile uint16_t *)(a))
# define putreg16(v,a) (*(volatile uint16_t *)(a) = (v))
# define getreg32(a) (*(volatile uint32_t *)(a))
# define putreg32(v,a) (*(volatile uint32_t *)(a) = (v))
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
void xtensa_copystate(uint32_t *dest, uint32_t *src)
{
#else
#define EXTERN extern
#endif
int i;
/* Atomic modification of registers */
/* In the XTENSA model, the state is copied from the stack to the TCB,
* but only a reference is passed to get the state from the TCB. So the
* following check avoids copying the TCB save area onto itself:
*/
void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits);
void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits);
void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits);
#undef EXTERN
#if defined(__cplusplus)
if (src != dest)
{
for (i = 0; i < XCPTCONTEXT_REGS; i++)
{
*dest++ = *src++;
}
}
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* ___ARCH_XTENSA_SRC_COMMON_XTENSA_ARCH_H */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_createstack.c
*
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -49,7 +49,6 @@
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "xtensa.h"
/****************************************************************************

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_etherstub.c
*
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,22 +41,6 @@
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_exit.c
*
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -67,7 +67,7 @@
****************************************************************************/
/****************************************************************************
* Name: _up_dumponexit
* Name: _xtensa_dumponexit
*
* Description:
* Dump the state of all tasks whenever on task exits. This is debug
@ -77,7 +77,7 @@
****************************************************************************/
#ifdef CONFIG_DUMP_ON_EXIT
static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
static void _xtensa_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
{
#if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct filelist *filelist;
@ -152,7 +152,7 @@ void _exit(int status)
#ifdef CONFIG_DUMP_ON_EXIT
sinfo("Other tasks:\n");
sched_foreach(_up_dumponexit, NULL);
sched_foreach(_xtensa_dumponexit, NULL);
#endif
/* Destroy the task at the head of the ready to run list. */
@ -185,4 +185,3 @@ void _exit(int status)
PANIC();
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_idle.c
*
* Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_initialize.c
*
* Copyright (C) 2011-2013, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -57,7 +57,6 @@
#include <arch/board/board.h>
#include "up_arch.h"
#include "xtensa.h"
/****************************************************************************
@ -128,7 +127,7 @@ void up_initialize(void)
/* Initialize the interrupt subsystem */
up_irqinitialize();
xtensa_irq_initialize();
#ifdef CONFIG_PM
/* Initialize the power management subsystem. This MCU-specific function
@ -141,22 +140,22 @@ void up_initialize(void)
#endif
#ifdef CONFIG_ARCH_DMA
/* Initialize the DMA subsystem if the weak function up_dmainitialize has been
* brought into the build
/* Initialize the DMA subsystem if the weak function xtensa_dma_initialize
* has been brought into the build
*/
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (up_dmainitialize)
if (xtensa_dma_initialize)
#endif
{
up_dmainitialize();
xtensa_dma_initialize();
}
#endif
/* Initialize the system timer interrupt */
#if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS)
up_timer_initialize();
xtensa_timer_initialize();
#endif
/* Register devices */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_interruptcontext.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,14 +45,6 @@
#include "xtensa.h"
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_lowputs.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,18 +41,6 @@
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_mdelay.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -40,26 +40,6 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_modifyreg16.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,19 +45,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "up_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "xtensa.h"
/****************************************************************************
* Public Functions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_modifyreg32.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,19 +45,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "up_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "xtensa.h"
/****************************************************************************
* Public Functions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_modifyreg8.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,19 +45,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "up_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "xtensa.h"
/****************************************************************************
* Public Functions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_puts.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -42,18 +42,6 @@
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_releasestack.c
*
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -47,14 +47,6 @@
#include "xtensa.h"
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_stackframe.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_udelay.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -49,22 +49,6 @@
#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_usestack.c
*
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without