arm64: optimise for arm64_switchcontext
We can save execution time by inline arm64_fullcontextrestore and arm64_switchcontext test: We can use qemu for testing. compiling make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20 running qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
11dfc5809a
commit
6c1b900e82
@ -34,8 +34,7 @@ list(APPEND SRCS arm64_initialize.c arm64_initialstate.c arm64_boot.c)
|
||||
list(APPEND SRCS arm64_nputs.c arm64_idle.c arm64_copystate.c
|
||||
arm64_createstack.c)
|
||||
list(APPEND SRCS arm64_releasestack.c arm64_stackframe.c arm64_usestack.c)
|
||||
list(APPEND SRCS arm64_task_sched.c arm64_exit.c arm64_fork.c
|
||||
arm64_switchcontext.c)
|
||||
list(APPEND SRCS arm64_exit.c arm64_fork.c arm64_switchcontext.c)
|
||||
list(APPEND SRCS arm64_schedulesigaction.c arm64_sigdeliver.c)
|
||||
list(APPEND SRCS arm64_getintstack.c arm64_registerdump.c)
|
||||
list(APPEND SRCS arm64_perf.c arm64_tcbinfo.c)
|
||||
|
@ -45,7 +45,7 @@ endif
|
||||
CMN_CSRCS = arm64_initialize.c arm64_initialstate.c arm64_boot.c
|
||||
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c arm64_createstack.c
|
||||
CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
|
||||
CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_fork.c arm64_switchcontext.c
|
||||
CMN_CSRCS += arm64_exit.c arm64_fork.c arm64_switchcontext.c
|
||||
CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c
|
||||
CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c
|
||||
CMN_CSRCS += arm64_perf.c arm64_tcbinfo.c
|
||||
|
@ -32,6 +32,7 @@
|
||||
# include <nuttx/arch.h>
|
||||
# include <sys/types.h>
|
||||
# include <stdint.h>
|
||||
# include <syscall.h>
|
||||
#endif
|
||||
|
||||
#include "arm64_arch.h"
|
||||
@ -116,6 +117,18 @@
|
||||
# define SMP_STACK_WORDS (SMP_STACK_SIZE >> 2)
|
||||
#endif
|
||||
|
||||
/* Context switching */
|
||||
|
||||
#define arm64_fullcontextrestore(restoreregs) \
|
||||
do \
|
||||
{ \
|
||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs); \
|
||||
} \
|
||||
while (1)
|
||||
|
||||
#define arm64_switchcontext(saveregs, restoreregs) \
|
||||
sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -267,11 +280,6 @@ int arm64_psci_init(const char *method);
|
||||
void __start(void);
|
||||
void arm64_secondary_start(void);
|
||||
|
||||
/* Context switching */
|
||||
|
||||
void arm64_fullcontextrestore(uint64_t *restoreregs) noreturn_function;
|
||||
void arm64_switchcontext(uint64_t **saveregs, uint64_t *restoreregs);
|
||||
|
||||
/* Signal handling **********************************************************/
|
||||
|
||||
void arm64_sigdeliver(void);
|
||||
|
@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm64/src/common/arm64_task_sched.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "arm64_internal.h"
|
||||
#include "arm64_fatal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_FPU
|
||||
#include "arm64_fpu.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arm64_fullcontextrestore
|
||||
*
|
||||
* Description:
|
||||
* Restore the current thread context. Full prototype is:
|
||||
*
|
||||
* void arm64_fullcontextrestore(uint64_t *restoreregs) noreturn_function;
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void arm64_fullcontextrestore(uint64_t *restoreregs)
|
||||
{
|
||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arm64_switchcontext
|
||||
*
|
||||
* Description:
|
||||
* Save the current thread context and restore the specified context.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void arm64_switchcontext(uint64_t **saveregs, uint64_t *restoreregs)
|
||||
{
|
||||
sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
|
||||
}
|
Loading…
Reference in New Issue
Block a user